@loopback/context 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/binding-filter.js +17 -2
- package/dist/binding-filter.js.map +1 -1
- package/package.json +2 -2
- package/src/binding-filter.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.1.1](https://github.com/strongloop/loopback-next/compare/@loopback/context@2.1.0...@loopback/context@2.1.1) (2020-02-06)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **context:** relax checking on instances of BindingKey class ([8668eb6](https://github.com/strongloop/loopback-next/commit/8668eb64b267e2644be87db92aeb86188d7e86f7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.1.0](https://github.com/strongloop/loopback-next/compare/@loopback/context@2.0.0...@loopback/context@2.1.0) (2020-02-05)
|
|
7
18
|
|
|
8
19
|
|
package/dist/binding-filter.js
CHANGED
|
@@ -4,13 +4,28 @@
|
|
|
4
4
|
// This file is licensed under the MIT License.
|
|
5
5
|
// License text available at https://opensource.org/licenses/MIT
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Check if an object is a `BindingKey` by duck typing
|
|
9
|
+
* @param selector Binding selector
|
|
10
|
+
*/
|
|
11
|
+
function isBindingKey(selector) {
|
|
12
|
+
if (selector == null || typeof selector !== 'object')
|
|
13
|
+
return false;
|
|
14
|
+
return (typeof selector.key === 'string' &&
|
|
15
|
+
typeof selector.deepProperty === 'function');
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* Type guard for binding address
|
|
10
19
|
* @param bindingSelector - Binding key or filter function
|
|
11
20
|
*/
|
|
12
21
|
function isBindingAddress(bindingSelector) {
|
|
13
|
-
return (typeof bindingSelector
|
|
22
|
+
return (typeof bindingSelector !== 'function' &&
|
|
23
|
+
(typeof bindingSelector === 'string' ||
|
|
24
|
+
// See https://github.com/strongloop/loopback-next/issues/4570
|
|
25
|
+
// `bindingSelector instanceof BindingKey` is not always reliable as the
|
|
26
|
+
// `@loopback/context` module might be loaded from multiple locations if
|
|
27
|
+
// `npm install` does not dedupe or there are mixed versions in the tree
|
|
28
|
+
isBindingKey(bindingSelector)));
|
|
14
29
|
}
|
|
15
30
|
exports.isBindingAddress = isBindingAddress;
|
|
16
31
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding-filter.js","sourceRoot":"","sources":["../src/binding-filter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;
|
|
1
|
+
{"version":3,"file":"binding-filter.js","sourceRoot":"","sources":["../src/binding-filter.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,iCAAiC;AACjC,+CAA+C;AAC/C,gEAAgE;;AAiDhE;;;GAGG;AACH,SAAS,YAAY,CAAC,QAAyB;IAC7C,IAAI,QAAQ,IAAI,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACnE,OAAO,CACL,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ;QAChC,OAAO,QAAQ,CAAC,YAAY,KAAK,UAAU,CAC5C,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,eAAgC;IAEhC,OAAO,CACL,OAAO,eAAe,KAAK,UAAU;QACrC,CAAC,OAAO,eAAe,KAAK,QAAQ;YAClC,8DAA8D;YAC9D,wEAAwE;YACxE,wEAAwE;YACxE,wEAAwE;YACxE,YAAY,CAAC,eAAe,CAAC,CAAC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AC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,IAAI,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loopback/context",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "LoopBack's container for Inversion of Control",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=8.9"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"url": "https://github.com/strongloop/loopback-next.git",
|
|
56
56
|
"directory": "packages/context"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6eea5e428b145cafb84a998bd53979da8c8fba07"
|
|
59
59
|
}
|
package/src/binding-filter.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// License text available at https://opensource.org/licenses/MIT
|
|
5
5
|
|
|
6
6
|
import {Binding, BindingTag} from './binding';
|
|
7
|
-
import {BindingAddress
|
|
7
|
+
import {BindingAddress} from './binding-key';
|
|
8
8
|
import {MapObject} from './value-promise';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -50,6 +50,18 @@ export type BindingSelector<ValueType = unknown> =
|
|
|
50
50
|
| BindingAddress<ValueType>
|
|
51
51
|
| BindingFilter<ValueType>;
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Check if an object is a `BindingKey` by duck typing
|
|
55
|
+
* @param selector Binding selector
|
|
56
|
+
*/
|
|
57
|
+
function isBindingKey(selector: BindingSelector) {
|
|
58
|
+
if (selector == null || typeof selector !== 'object') return false;
|
|
59
|
+
return (
|
|
60
|
+
typeof selector.key === 'string' &&
|
|
61
|
+
typeof selector.deepProperty === 'function'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
53
65
|
/**
|
|
54
66
|
* Type guard for binding address
|
|
55
67
|
* @param bindingSelector - Binding key or filter function
|
|
@@ -58,7 +70,13 @@ export function isBindingAddress(
|
|
|
58
70
|
bindingSelector: BindingSelector,
|
|
59
71
|
): bindingSelector is BindingAddress {
|
|
60
72
|
return (
|
|
61
|
-
typeof bindingSelector
|
|
73
|
+
typeof bindingSelector !== 'function' &&
|
|
74
|
+
(typeof bindingSelector === 'string' ||
|
|
75
|
+
// See https://github.com/strongloop/loopback-next/issues/4570
|
|
76
|
+
// `bindingSelector instanceof BindingKey` is not always reliable as the
|
|
77
|
+
// `@loopback/context` module might be loaded from multiple locations if
|
|
78
|
+
// `npm install` does not dedupe or there are mixed versions in the tree
|
|
79
|
+
isBindingKey(bindingSelector))
|
|
62
80
|
);
|
|
63
81
|
}
|
|
64
82
|
|