From 0cb2b144e4d9d572620c0ac0eefab0c885d2e450 Mon Sep 17 00:00:00 2001 From: David Bushong Date: Mon, 9 Dec 2019 14:53:37 -0800 Subject: [PATCH] fix: node12 inspection of provider See: https://github.com/nodejs/node/pull/26241 --- lib/registry/injector.js | 22 +++------------------- test/registry.test.js | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/registry/injector.js b/lib/registry/injector.js index c936a4c..5b32585 100644 --- a/lib/registry/injector.js +++ b/lib/registry/injector.js @@ -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); } diff --git a/test/registry.test.js b/test/registry.test.js index 7d38421..e529808 100644 --- a/test/registry.test.js +++ b/test/registry.test.js @@ -125,7 +125,7 @@ describe('Registry', () => { const provider = injector.getProvider(); assert.equal( inspect(provider), - 'Provider { Injector { action, byAction, request, response, byReq, Symbol(byReq), constValue } }' + 'Injector { action, byAction, request, response, byReq, Symbol(byReq), constValue }' ); }); });