1
1
import { DecoratorParameters } from "../interfaces" ;
2
- import { deepClone , deepExtends , descriptorOf , getDecoratorType , nameOf } from "../utils" ;
2
+ import { deepClone , deepExtends , descriptorOf , getDecoratorType , isSymbol , nameOf } from "../utils" ;
3
3
4
4
import { Metadata } from "./Metadata" ;
5
5
@@ -10,6 +10,8 @@ export const PARAM_STORE = "tsed:param:store";
10
10
11
11
export type StoreMap = Map < string , any > ;
12
12
13
+ const stores = new Map < symbol , any > ( ) ;
14
+
13
15
/**
14
16
*
15
17
*/
@@ -71,6 +73,7 @@ export class Store {
71
73
* @deprecated Use StoreFn
72
74
* @returns {Function }
73
75
*/
76
+
74
77
/* istanbul ignore next */
75
78
static decorate ( fn : ( store : Store , parameters : DecoratorParameters ) => void ) : Function {
76
79
return ( ...parameters : any [ ] ) : any => {
@@ -214,12 +217,20 @@ export class Store {
214
217
* @private
215
218
*/
216
219
private _storeGet ( key : string , ...args : any [ ] ) : StoreMap {
217
- const registry = Metadata as any ;
220
+ if ( isSymbol ( args [ 0 ] ) ) {
221
+ if ( ! stores . has ( args [ 0 ] ) ) {
222
+ stores . set ( args [ 0 ] , new Map < string , any > ( ) ) ;
223
+ }
218
224
219
- if ( ! registry . hasOwn ( key , ... args ) ) {
220
- registry . set ( key , new Map < string , any > ( ) , ... args ) ;
221
- }
225
+ return stores . get ( args [ 0 ] ) ;
226
+ } else {
227
+ const registry = Metadata as any ;
222
228
223
- return registry . getOwn ( key , ...args ) ;
229
+ if ( ! registry . hasOwn ( key , ...args ) ) {
230
+ registry . set ( key , new Map < string , any > ( ) , ...args ) ;
231
+ }
232
+
233
+ return registry . getOwn ( key , ...args ) ;
234
+ }
224
235
}
225
236
}
0 commit comments