Skip to content

Commit 0cb2b14

Browse files
committed
fix: node12 inspection of provider
See: nodejs/node#26241
1 parent d50a30b commit 0cb2b14

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

lib/registry/injector.js

+3-19
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,18 @@ const { parseDependencyQuery } = require('./query');
4343

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

46-
/**
47-
* @param {Injector} injector
48-
*/
49-
function inspectProvider(injector) {
50-
// @ts-ignore
51-
return `Provider { ${injector[INSPECT]()} }`;
52-
}
53-
5446
const PROVIDER_HANDLER = {
5547
/**
5648
* @param {Injector} injector
57-
* @param {string | symbol} key
49+
* @param {string} key
5850
*/
5951
get(injector, key) {
6052
switch (key) {
6153
case 'constructor':
62-
return injector.constructor;
63-
6454
case 'get':
65-
return injector.get;
66-
6755
case 'keys':
68-
return injector.keys;
69-
70-
case INSPECT: {
71-
return inspectProvider.bind(null, injector);
72-
}
73-
56+
case 'scope':
57+
return injector[key];
7458
default:
7559
return injector.get(key);
7660
}

test/registry.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('Registry', () => {
125125
const provider = injector.getProvider();
126126
assert.equal(
127127
inspect(provider),
128-
'Provider { Injector<action> { action, byAction, request, response, byReq, Symbol(byReq), constValue } }'
128+
'Injector<action> { action, byAction, request, response, byReq, Symbol(byReq), constValue }'
129129
);
130130
});
131131
});

0 commit comments

Comments
 (0)