power-di
Version:
A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.
32 lines • 1.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRefMap = void 0;
var getGlobalType_1 = require("./getGlobalType");
var metadata_1 = require("../class/metadata");
function getRefMap(clsType, initMaps) {
if (initMaps === void 0) { initMaps = {}; }
var maps = initMaps;
function scan(clsType) {
var type = (0, getGlobalType_1.symbolString)((0, getGlobalType_1.getGlobalType)(clsType));
if (maps[type]) {
return;
}
var refs = (maps[type] = {
count: 0,
deps: [],
});
(0, metadata_1.getMetadataField)(clsType, 'injects').forEach(function (inj) {
var globalType = (0, getGlobalType_1.symbolString)(inj.globalType);
scan(inj.typeCls);
maps[globalType].count++;
refs.deps.push({
prop: inj.key,
type: globalType,
});
});
}
scan(clsType);
return maps;
}
exports.getRefMap = getRefMap;
//# sourceMappingURL=getRefMap.js.map