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 0cb2b14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
22 changes: 3 additions & 19 deletions lib/registry/injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,18 @@ const { parseDependencyQuery } = require('./query');

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

/**
* @param {Injector} injector
*/
function inspectProvider(injector) {
// @ts-ignore
return `Provider { ${injector[INSPECT]()} }`;
}

const PROVIDER_HANDLER = {
/**
* @param {Injector} injector
* @param {string | symbol} key
* @param {string} key
*/
get(injector, key) {
switch (key) {
case 'constructor':
return injector.constructor;

case 'get':
return injector.get;

case 'keys':
return injector.keys;

case INSPECT: {
return inspectProvider.bind(null, injector);
}

case 'scope':
return injector[key];
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 0cb2b14

Please sign in to comment.