@triviality/core
Version:
Purely typed service container
26 lines • 1.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
var ramda_1 = require("ramda");
exports.assetServiceFactory = function (sf) {
if (typeof sf !== 'function') {
throw new Error('ServiceFactory is not a function');
}
if (sf.length > 0) {
throw new Error("ServiceFactory '" + sf.name + "' cannot have any arguments");
}
return true;
};
exports.isServiceFactory = function (target) {
return typeof target === 'function' && target.length === 0;
};
exports.serviceOfServiceFactory = function (sf) { return sf(); };
exports.serviceOfServiceFactories = function (factories) { return ramda_1.map(exports.serviceOfServiceFactory, factories); };
exports.assertServiceTag = function (tag) {
if (typeof tag !== 'string' || tag === '') {
throw new Error('Tag should be a one empty string');
}
return true;
};
exports.isServiceTag = function (target) { return typeof target === 'string'; };
exports.AllAsServiceFactory = function (instances) { return instances.map(ramda_1.always); };
//# sourceMappingURL=ServiceFactory.js.map
;