dependency-injection-cat
Version:
DI Cat is a truly clean DI-container, which allows you not to pollute your business logic with decorators from DI/IOC libraries!
35 lines (34 loc) • 1.57 kB
JavaScript
;
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getGlobalContextIdentifierFromArrayOrCreateNewAndPush = void 0;
var typescript_1 = require("typescript");
var getGlobalContextVariableNameByContextId_1 = require("./getGlobalContextVariableNameByContextId");
function getGlobalContextIdentifierFromArrayOrCreateNewAndPush(contextDescriptor, globalContextDescriptorToIdentifiers) {
var oldIdentifier = globalContextDescriptorToIdentifiers.find(function (_a) {
var _b = __read(_a, 1), descriptor = _b[0];
return descriptor.id === contextDescriptor.id;
});
if (oldIdentifier) {
return oldIdentifier[1];
}
var newIdentifier = typescript_1.factory.createIdentifier((0, getGlobalContextVariableNameByContextId_1.getGlobalContextVariableNameByContextId)(contextDescriptor.id));
globalContextDescriptorToIdentifiers.push([contextDescriptor, newIdentifier]);
return newIdentifier;
}
exports.getGlobalContextIdentifierFromArrayOrCreateNewAndPush = getGlobalContextIdentifierFromArrayOrCreateNewAndPush;