@loopback/context
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [2.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@2.1.0...@loopback/context@2.1.1) (2020-02-06) | ||
### Bug Fixes | ||
* **context:** relax checking on instances of BindingKey class ([8668eb6](https://github.com/strongloop/loopback-next/commit/8668eb64b267e2644be87db92aeb86188d7e86f7)) | ||
# [2.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@2.0.0...@loopback/context@2.1.0) (2020-02-05) | ||
@@ -8,0 +19,0 @@ |
@@ -7,4 +7,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const binding_key_1 = require("./binding-key"); | ||
/** | ||
* Check if an object is a `BindingKey` by duck typing | ||
* @param selector Binding selector | ||
*/ | ||
function isBindingKey(selector) { | ||
if (selector == null || typeof selector !== 'object') | ||
return false; | ||
return (typeof selector.key === 'string' && | ||
typeof selector.deepProperty === 'function'); | ||
} | ||
/** | ||
* Type guard for binding address | ||
@@ -14,3 +23,9 @@ * @param bindingSelector - Binding key or filter function | ||
function isBindingAddress(bindingSelector) { | ||
return (typeof bindingSelector === 'string' || bindingSelector instanceof binding_key_1.BindingKey); | ||
return (typeof bindingSelector !== 'function' && | ||
(typeof bindingSelector === 'string' || | ||
// See https://github.com/strongloop/loopback-next/issues/4570 | ||
// `bindingSelector instanceof BindingKey` is not always reliable as the | ||
// `@loopback/context` module might be loaded from multiple locations if | ||
// `npm install` does not dedupe or there are mixed versions in the tree | ||
isBindingKey(bindingSelector))); | ||
} | ||
@@ -17,0 +32,0 @@ exports.isBindingAddress = isBindingAddress; |
{ | ||
"name": "@loopback/context", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "LoopBack's container for Inversion of Control", | ||
@@ -58,3 +58,3 @@ "engines": { | ||
}, | ||
"gitHead": "b5e53892d327c6cf4c6023055d2b38f13fe4729e" | ||
"gitHead": "6eea5e428b145cafb84a998bd53979da8c8fba07" | ||
} |
@@ -7,3 +7,3 @@ // Copyright IBM Corp. 2019. All Rights Reserved. | ||
import {Binding, BindingTag} from './binding'; | ||
import {BindingAddress, BindingKey} from './binding-key'; | ||
import {BindingAddress} from './binding-key'; | ||
import {MapObject} from './value-promise'; | ||
@@ -55,2 +55,14 @@ | ||
/** | ||
* Check if an object is a `BindingKey` by duck typing | ||
* @param selector Binding selector | ||
*/ | ||
function isBindingKey(selector: BindingSelector) { | ||
if (selector == null || typeof selector !== 'object') return false; | ||
return ( | ||
typeof selector.key === 'string' && | ||
typeof selector.deepProperty === 'function' | ||
); | ||
} | ||
/** | ||
* Type guard for binding address | ||
@@ -63,3 +75,9 @@ * @param bindingSelector - Binding key or filter function | ||
return ( | ||
typeof bindingSelector === 'string' || bindingSelector instanceof BindingKey | ||
typeof bindingSelector !== 'function' && | ||
(typeof bindingSelector === 'string' || | ||
// See https://github.com/strongloop/loopback-next/issues/4570 | ||
// `bindingSelector instanceof BindingKey` is not always reliable as the | ||
// `@loopback/context` module might be loaded from multiple locations if | ||
// `npm install` does not dedupe or there are mixed versions in the tree | ||
isBindingKey(bindingSelector)) | ||
); | ||
@@ -66,0 +84,0 @@ } |
Sorry, the diff of this file is not supported yet
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
597157
13190