Skip to content

Commit

Permalink
fix: node12 inspection of provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dbushong committed Dec 9, 2019
1 parent d50a30b commit 9b5b703
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
23 changes: 6 additions & 17 deletions lib/registry/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,7 @@ const { parseDependencyQuery } = require('./query');
/** @typedef {import('../typedefs').DependencyDescriptor} DependencyDescriptor */
/** @typedef {import('../typedefs').DependencyQuery} DependencyQuery */

const INSPECT = util.inspect.custom || Symbol.for('nodejs.util.inspect.custom');

/**
* @param {Injector} injector
*/
function inspectProvider(injector) {
// @ts-ignore
return `Provider { ${injector[INSPECT]()} }`;
}
const INSPECT = util.inspect.custom;

const PROVIDER_HANDLER = {
/**
Expand All @@ -59,17 +51,14 @@ const PROVIDER_HANDLER = {
get(injector, key) {
switch (key) {
case 'constructor':
return injector.constructor;

case 'get':
return injector.get;

case 'keys':
return injector.keys;
case 'scope':
return injector[key];

case INSPECT: {
return inspectProvider.bind(null, injector);
}
case INSPECT:
// @ts-ignore
return injector[INSPECT];

default:
return injector.get(key);
Expand Down
2 changes: 1 addition & 1 deletion test/registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('Registry', () => {
const provider = injector.getProvider();
assert.equal(
inspect(provider),
'Provider { Injector<action> { action, byAction, request, response, byReq, Symbol(byReq), constValue } }'
'Injector<action> { action, byAction, request, response, byReq, Symbol(byReq), constValue }'
);
});
});
Expand Down

0 comments on commit 9b5b703

Please sign in to comment.