@cashfarm/tractor
Version:
A Hapi server with superpowers
39 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lang_1 = require("@cashfarm/lang");
function listContainerBindings(container) {
let replacerCache = [];
const replacer = (key, value) => {
if (typeof value === 'object' && value !== null) {
if (replacerCache.indexOf(value) !== -1) {
// Circular reference found, discard key
return;
}
// Store value in our collection
replacerCache.push(value);
}
return value;
};
const bindings = [];
for (const bdgnArr of container._bindingDictionary._map.values()) {
bdgnArr.map((bdgn) => {
let value = '';
if (lang_1.isFunction(bdgn.implementationType))
value = bdgn.implementationType.name;
else if (bdgn.type === 'ConstantValue') {
if (lang_1.isJsobject(bdgn.cache) && lang_1.isFunction(bdgn.cache.constructor) && bdgn.constructor !== Object) {
value = bdgn.constructor.name;
}
else
value = JSON.stringify(bdgn.cache, replacer).substr(0, 100);
}
replacerCache = [];
const identifier = typeof bdgn.serviceIdentifier === 'function' ? bdgn.serviceIdentifier.name : bdgn.serviceIdentifier;
if (identifier !== '')
bindings.push(`${identifier.toString()} => ${bdgn.scope} ${bdgn.type} ${value}`);
});
}
return bindings;
}
exports.listContainerBindings = listContainerBindings;
//# sourceMappingURL=util.js.map