@lillallol/dic
Version:
My own dependency injection container.
29 lines (28 loc) • 934 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwIfFactoryHasNoName = void 0;
const errorMessages_1 = require("../errorMessages");
/**
* @description
* It throws if the provided factory has name property that is a string of zero length.
*/
function throwIfFactoryHasNoName(factory) {
// This case will never happen, look below for the reason.
//if (factory.name === "") throw Error(errorMessages.factoryHasToHaveName);
/**
* The following error is a result of the following:
*
* ```ts
* const registration = {
* factory: function () { }
* }
* const { factory } = registration;
*
* expect(factory.name).toBe("factory");// yes the test passes
* ```
*
*/
if (factory.name === "factory")
throw Error(errorMessages_1.errorMessages.badFactoryName);
}
exports.throwIfFactoryHasNoName = throwIfFactoryHasNoName;