@spinajs/di 1.1.7 → 1.2.20

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/lib/root.d.ts CHANGED
@@ -1,90 +1,86 @@
1
- import { IBind, IContainer, AsyncModule } from './interfaces';
1
+ import { IBind, IContainer, AsyncModule, ResolvableObject } from './interfaces';
2
2
  import { Class, Factory } from './types';
3
- export declare namespace DI {
4
- /**
5
- * App main DI container
6
- */
7
- const RootContainer: IContainer;
8
- /***
9
- * EVENT LISTENER STUFF
10
- *
11
- * Allows to use event listener stuff on root container
12
- */
13
- function on(event: string, listener: (...args: any) => void): IContainer;
14
- function addListener(event: string | symbol, listener: (...args: any[]) => void): IContainer;
15
- function once(event: string | symbol, listener: (...args: any[]) => void): IContainer;
16
- function removeListener(event: string | symbol, listener: (...args: any[]) => void): IContainer;
17
- function off(event: string | symbol, listener: (...args: any[]) => void): IContainer;
18
- function removeAllListeners(event?: string | symbol): IContainer;
19
- function setMaxListeners(n: number): IContainer;
20
- function getMaxListeners(): number;
21
- function listeners(event: string | symbol): Function[];
22
- function rawListeners(event: string | symbol): Function[];
23
- function emit(event: string | symbol, ...args: any[]): boolean;
24
- function listenerCount(type: string | symbol): number;
25
- function prependListener(event: string | symbol, listener: (...args: any[]) => void): IContainer;
26
- function prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): IContainer;
27
- function eventNames(): (string | symbol)[];
28
- /**
29
- * ===========================================================================
30
- */
31
- /**
32
- * Clears root container registry and cache.
33
- */
34
- function clear(): void;
35
- /**
36
- * Clears out root registry ( registered types in root container )
37
- */
38
- function clearRegistry(): void;
39
- /**
40
- * Cleart ous root cache ( all resolved types )
41
- */
42
- function clearCache(): void;
43
- /**
44
- * Register class/interface to DI root container. If
45
- * @param type - interface object to register
46
- * @throws { InvalidArgument } if type is null or undefined
47
- */
48
- function register<T>(type: Class<T> | Factory<T>): IBind;
49
- /**
50
- * Resolves specified type from root container.
51
- *
52
- * @param type - class to resolve
53
- * @param options - optional parameters passed to class constructor
54
- * @return - class instance
55
- * @throws { InvalidArgument } if type is null or undefined
56
- */
57
- function resolve<T>(type: string, options?: any[], check?: boolean): T;
58
- function resolve<T>(type: string, check?: boolean): T;
59
- function resolve<T>(type: Class<T>, check?: boolean): T extends AsyncModule ? Promise<T> : T;
60
- function resolve<T>(type: TypedArray<T>, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
61
- function resolve<T>(type: Class<T>, options?: any[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T> : T;
62
- function resolve<T>(type: TypedArray<T>, options?: any[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
63
- /**
64
- * Gets already resolved service from root container.
65
- *
66
- * @param serviceName - name of service to get
67
- * @returns { null | T} - null if no service has been resolved at given name
68
- */
69
- function get<T>(serviceName: TypedArray<T>): T[];
70
- function get<T>(serviceName: string | Class<T>): T;
71
- /**
72
- * Checks if service is already resolved and exists in container cache.
73
- * NOTE: check is only valid for classes that are singletons.
74
- *
75
- * @param service - service name or class to check
76
- * @returns { boolean } - true if service instance already exists, otherwise false.
77
- */
78
- function has<T>(service: string | Class<T>): boolean;
79
- /**
80
- * Checks if service is registered in container.
81
- *
82
- * @param service service class object to check
83
- */
84
- function check<T>(service: Class<T> | string): boolean;
85
- /**
86
- * Creates child DI container.
87
- *
88
- */
89
- function child(): IContainer;
90
- }
3
+ import { TypedArray } from './array';
4
+ /**
5
+ * App main DI container
6
+ */
7
+ export declare const RootContainer: IContainer;
8
+ /***
9
+ * EVENT LISTENER STUFF
10
+ *
11
+ * Allows to use event listener stuff on root container
12
+ */
13
+ export declare function on(event: string, listener: (...args: unknown[]) => void): IContainer;
14
+ export declare function addListener(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
15
+ export declare function once(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
16
+ export declare function removeListener(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
17
+ export declare function off(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
18
+ export declare function removeAllListeners(event?: string | symbol): IContainer;
19
+ export declare function setMaxListeners(n: number): IContainer;
20
+ export declare function getMaxListeners(): number;
21
+ export declare function listeners(event: string | symbol): Function[];
22
+ export declare function rawListeners(event: string | symbol): Function[];
23
+ export declare function emit(event: string | symbol, ...args: unknown[]): boolean;
24
+ export declare function listenerCount(type: string | symbol): number;
25
+ export declare function prependListener(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
26
+ export declare function prependOnceListener(event: string | symbol, listener: (...args: unknown[]) => void): IContainer;
27
+ export declare function eventNames(): (string | symbol)[];
28
+ /**
29
+ * ===========================================================================
30
+ */
31
+ /**
32
+ * Clears root container registry and cache.
33
+ */
34
+ export declare function clear(): void;
35
+ /**
36
+ * Clears out root registry ( registered types in root container )
37
+ */
38
+ export declare function clearRegistry(): void;
39
+ /**
40
+ * Cleart ous root cache ( all resolved types )
41
+ */
42
+ export declare function clearCache(): void;
43
+ /**
44
+ * Register class/interface to DI root container. If
45
+ * @param type - interface object to register
46
+ * @throws {@link InvalidArgument} if type is null or undefined
47
+ */
48
+ export declare function register<T>(type: Class<T> | Factory<T> | ResolvableObject): IBind;
49
+ /**
50
+ * Resolves specified type from root container.
51
+ *
52
+ * @param type - class to resolve
53
+ * @param options - optional parameters passed to class constructor
54
+ * @throws {@link InvalidArgument} if type is null or undefined
55
+ */
56
+ export declare function resolve<T>(type: string, options?: unknown[], check?: boolean): T;
57
+ export declare function resolve<T>(type: string, check?: boolean): T;
58
+ export declare function resolve<T>(type: Class<T>, check?: boolean): T extends AsyncModule ? Promise<T> : T;
59
+ export declare function resolve<T>(type: TypedArray<T>, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
60
+ export declare function resolve<T>(type: Class<T>, options?: unknown[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T> : T;
61
+ export declare function resolve<T>(type: TypedArray<T>, options?: unknown[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
62
+ /**
63
+ * Gets already resolved service from root container.
64
+ *
65
+ * @param serviceName - name of service to get
66
+ */
67
+ export declare function get<T>(serviceName: TypedArray<T>): T[] | null;
68
+ export declare function get<T>(serviceName: string | Class<T>): T | null;
69
+ /**
70
+ * Checks if service is already resolved and exists in container cache.
71
+ * NOTE: check is only valid for classes that are singletons.
72
+ *
73
+ * @param service - service name or class to check
74
+ */
75
+ export declare function has<T>(service: string | Class<T>): boolean;
76
+ /**
77
+ * Checks if service is registered in container.
78
+ *
79
+ * @param service - service class object to check
80
+ */
81
+ export declare function check<T>(service: Class<T> | string): boolean;
82
+ /**
83
+ * Creates child DI container.
84
+ *
85
+ */
86
+ export declare function child(): IContainer;
package/lib/root.js CHANGED
@@ -1,148 +1,143 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DI = void 0;
3
+ exports.child = exports.check = exports.has = exports.get = exports.resolve = exports.register = exports.clearCache = exports.clearRegistry = exports.clear = exports.eventNames = exports.prependOnceListener = exports.prependListener = exports.listenerCount = exports.emit = exports.rawListeners = exports.listeners = exports.getMaxListeners = exports.setMaxListeners = exports.removeAllListeners = exports.off = exports.removeListener = exports.once = exports.addListener = exports.on = exports.RootContainer = void 0;
4
4
  const container_1 = require("./container");
5
- // tslint:disable-next-line: no-namespace
6
- var DI;
7
- (function (DI) {
8
- /**
9
- * App main DI container
10
- */
11
- DI.RootContainer = new container_1.Container();
12
- /***
13
- * EVENT LISTENER STUFF
14
- *
15
- * Allows to use event listener stuff on root container
16
- */
17
- function on(event, listener) {
18
- return DI.RootContainer.on(event, listener);
19
- }
20
- DI.on = on;
21
- function addListener(event, listener) {
22
- return DI.RootContainer.addListener(event, listener);
23
- }
24
- DI.addListener = addListener;
25
- function once(event, listener) {
26
- return DI.RootContainer.once(event, listener);
27
- }
28
- DI.once = once;
29
- function removeListener(event, listener) {
30
- return DI.RootContainer.removeListener(event, listener);
31
- }
32
- DI.removeListener = removeListener;
33
- function off(event, listener) {
34
- return DI.RootContainer.off(event, listener);
35
- }
36
- DI.off = off;
37
- function removeAllListeners(event) {
38
- return DI.RootContainer.removeAllListeners(event);
39
- }
40
- DI.removeAllListeners = removeAllListeners;
41
- function setMaxListeners(n) {
42
- return DI.RootContainer.setMaxListeners(n);
43
- }
44
- DI.setMaxListeners = setMaxListeners;
45
- function getMaxListeners() {
46
- return DI.RootContainer.getMaxListeners();
47
- }
48
- DI.getMaxListeners = getMaxListeners;
49
- function listeners(event) {
50
- return DI.RootContainer.listeners(event);
51
- }
52
- DI.listeners = listeners;
53
- function rawListeners(event) {
54
- return DI.RootContainer.rawListeners(event);
55
- }
56
- DI.rawListeners = rawListeners;
57
- function emit(event, ...args) {
58
- return DI.RootContainer.emit(event, ...args);
59
- }
60
- DI.emit = emit;
61
- function listenerCount(type) {
62
- return DI.RootContainer.listenerCount(type);
63
- }
64
- DI.listenerCount = listenerCount;
65
- function prependListener(event, listener) {
66
- return DI.RootContainer.prependListener(event, listener);
67
- }
68
- DI.prependListener = prependListener;
69
- function prependOnceListener(event, listener) {
70
- return DI.RootContainer.prependOnceListener(event, listener);
71
- }
72
- DI.prependOnceListener = prependOnceListener;
73
- function eventNames() {
74
- return DI.RootContainer.eventNames();
75
- }
76
- DI.eventNames = eventNames;
77
- /**
78
- * ===========================================================================
79
- */
80
- /**
81
- * Clears root container registry and cache.
82
- */
83
- function clear() {
84
- DI.RootContainer.clearCache();
85
- DI.RootContainer.clearRegistry();
86
- }
87
- DI.clear = clear;
88
- /**
89
- * Clears out root registry ( registered types in root container )
90
- */
91
- function clearRegistry() {
92
- DI.RootContainer.clearRegistry();
93
- }
94
- DI.clearRegistry = clearRegistry;
95
- /**
96
- * Cleart ous root cache ( all resolved types )
97
- */
98
- function clearCache() {
99
- DI.RootContainer.clearCache();
100
- }
101
- DI.clearCache = clearCache;
102
- /**
103
- * Register class/interface to DI root container. If
104
- * @param type - interface object to register
105
- * @throws { InvalidArgument } if type is null or undefined
106
- */
107
- function register(type) {
108
- return DI.RootContainer.register(type);
109
- }
110
- DI.register = register;
111
- function resolve(type, options, check) {
112
- return DI.RootContainer.resolve(type, options, check);
113
- }
114
- DI.resolve = resolve;
115
- function get(serviceName) {
116
- return DI.RootContainer.get(serviceName);
117
- }
118
- DI.get = get;
119
- /**
120
- * Checks if service is already resolved and exists in container cache.
121
- * NOTE: check is only valid for classes that are singletons.
122
- *
123
- * @param service - service name or class to check
124
- * @returns { boolean } - true if service instance already exists, otherwise false.
125
- */
126
- function has(service) {
127
- return DI.RootContainer.has(service);
128
- }
129
- DI.has = has;
130
- /**
131
- * Checks if service is registered in container.
132
- *
133
- * @param service service class object to check
134
- */
135
- function check(service) {
136
- return DI.RootContainer.hasRegistered(service);
137
- }
138
- DI.check = check;
139
- /**
140
- * Creates child DI container.
141
- *
142
- */
143
- function child() {
144
- return DI.RootContainer.child();
145
- }
146
- DI.child = child;
147
- })(DI = exports.DI || (exports.DI = {}));
5
+ /**
6
+ * App main DI container
7
+ */
8
+ exports.RootContainer = new container_1.Container();
9
+ /***
10
+ * EVENT LISTENER STUFF
11
+ *
12
+ * Allows to use event listener stuff on root container
13
+ */
14
+ function on(event, listener) {
15
+ return exports.RootContainer.on(event, listener);
16
+ }
17
+ exports.on = on;
18
+ function addListener(event, listener) {
19
+ return exports.RootContainer.addListener(event, listener);
20
+ }
21
+ exports.addListener = addListener;
22
+ function once(event, listener) {
23
+ return exports.RootContainer.once(event, listener);
24
+ }
25
+ exports.once = once;
26
+ function removeListener(event, listener) {
27
+ return exports.RootContainer.removeListener(event, listener);
28
+ }
29
+ exports.removeListener = removeListener;
30
+ function off(event, listener) {
31
+ return exports.RootContainer.off(event, listener);
32
+ }
33
+ exports.off = off;
34
+ function removeAllListeners(event) {
35
+ return exports.RootContainer.removeAllListeners(event);
36
+ }
37
+ exports.removeAllListeners = removeAllListeners;
38
+ function setMaxListeners(n) {
39
+ return exports.RootContainer.setMaxListeners(n);
40
+ }
41
+ exports.setMaxListeners = setMaxListeners;
42
+ function getMaxListeners() {
43
+ return exports.RootContainer.getMaxListeners();
44
+ }
45
+ exports.getMaxListeners = getMaxListeners;
46
+ function listeners(event) {
47
+ return exports.RootContainer.listeners(event);
48
+ }
49
+ exports.listeners = listeners;
50
+ function rawListeners(event) {
51
+ return exports.RootContainer.rawListeners(event);
52
+ }
53
+ exports.rawListeners = rawListeners;
54
+ function emit(event, ...args) {
55
+ return exports.RootContainer.emit(event, ...args);
56
+ }
57
+ exports.emit = emit;
58
+ function listenerCount(type) {
59
+ return exports.RootContainer.listenerCount(type);
60
+ }
61
+ exports.listenerCount = listenerCount;
62
+ function prependListener(event, listener) {
63
+ return exports.RootContainer.prependListener(event, listener);
64
+ }
65
+ exports.prependListener = prependListener;
66
+ function prependOnceListener(event, listener) {
67
+ return exports.RootContainer.prependOnceListener(event, listener);
68
+ }
69
+ exports.prependOnceListener = prependOnceListener;
70
+ function eventNames() {
71
+ return exports.RootContainer.eventNames();
72
+ }
73
+ exports.eventNames = eventNames;
74
+ /**
75
+ * ===========================================================================
76
+ */
77
+ /**
78
+ * Clears root container registry and cache.
79
+ */
80
+ function clear() {
81
+ exports.RootContainer.clearCache();
82
+ exports.RootContainer.clearRegistry();
83
+ }
84
+ exports.clear = clear;
85
+ /**
86
+ * Clears out root registry ( registered types in root container )
87
+ */
88
+ function clearRegistry() {
89
+ exports.RootContainer.clearRegistry();
90
+ }
91
+ exports.clearRegistry = clearRegistry;
92
+ /**
93
+ * Cleart ous root cache ( all resolved types )
94
+ */
95
+ function clearCache() {
96
+ exports.RootContainer.clearCache();
97
+ }
98
+ exports.clearCache = clearCache;
99
+ /**
100
+ * Register class/interface to DI root container. If
101
+ * @param type - interface object to register
102
+ * @throws {@link InvalidArgument} if type is null or undefined
103
+ */
104
+ function register(type) {
105
+ return exports.RootContainer.register(type);
106
+ }
107
+ exports.register = register;
108
+ function resolve(type, options, check) {
109
+ return exports.RootContainer.resolve(type, options, check);
110
+ }
111
+ exports.resolve = resolve;
112
+ function get(serviceName) {
113
+ return exports.RootContainer.get(serviceName);
114
+ }
115
+ exports.get = get;
116
+ /**
117
+ * Checks if service is already resolved and exists in container cache.
118
+ * NOTE: check is only valid for classes that are singletons.
119
+ *
120
+ * @param service - service name or class to check
121
+ */
122
+ function has(service) {
123
+ return exports.RootContainer.isResolved(service);
124
+ }
125
+ exports.has = has;
126
+ /**
127
+ * Checks if service is registered in container.
128
+ *
129
+ * @param service - service class object to check
130
+ */
131
+ function check(service) {
132
+ return exports.RootContainer.hasRegistered(service);
133
+ }
134
+ exports.check = check;
135
+ /**
136
+ * Creates child DI container.
137
+ *
138
+ */
139
+ function child() {
140
+ return exports.RootContainer.child();
141
+ }
142
+ exports.child = child;
148
143
  //# sourceMappingURL=root.js.map
package/lib/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAIxC,yCAAyC;AACzC,IAAiB,EAAE,CAkKlB;AAlKD,WAAiB,EAAE;IACjB;;OAEG;IACU,gBAAa,GAAe,IAAI,qBAAS,EAAE,CAAC;IAEzD;;;;OAIG;IAGH,SAAgB,EAAE,CAAC,KAAa,EAAE,QAAgC;QAChE,OAAO,GAAA,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAFe,KAAE,KAEjB,CAAA;IACD,SAAgB,WAAW,CAAC,KAAsB,EAAE,QAAkC;QACpF,OAAO,GAAA,aAAa,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC;IAFe,cAAW,cAE1B,CAAA;IACD,SAAgB,IAAI,CAAC,KAAsB,EAAE,QAAkC;QAC7E,OAAO,GAAA,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAC7C,CAAC;IAFe,OAAI,OAEnB,CAAA;IACD,SAAgB,cAAc,CAAC,KAAsB,EAAE,QAAkC;QACvF,OAAO,GAAA,aAA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ACpC,CAAC;AAFD,gCAEC;AAED;;GAEG;AAEH;;GAEG;AACH,SAAgB,KAAK;IACnB,qBAAa,CAAC,UAAU,EAAE,CAAC;IAC3B,qBAAa,CAAC,aAAa,EAAE,CAAC;AAChC,CAAC;AAHD,sBAGC;AAED;;GAEG;AACH,SAAgB,aAAa;IAC3B,qBAAa,CAAC,aAAa,EAAE,CAAC;AAChC,CAAC;AAFD,sCAEC;AAED;;GAEG;AACH,SAAgB,UAAU;IACxB,qBAAa,CAAC,UAAU,EAAE,CAAC;AAC7B,CAAC;AAFD,gCAEC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAI,IAA8C;IACxE,OAAO,qBAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAFD,4BAEC;AAeD,SAAgB,OAAO,CAAI,IAAuC,EAAE,OAA6B,EAAE,KAAe;IAChH,OAAO,qBAAa,CAAC,OAAO,CAAI,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AAFD,0BAEC;AASD,SAAgB,GAAG,CAAI,WAA8C;IACnE,OAAO,qBAAa,CAAC,GAAG,CAAC,WAAW,CAAM,CAAC;AAC7C,CAAC;AAFD,kBAEC;AAED;;;;;GAKG;AACH,SAAgB,GAAG,CAAI,OAA0B;IAC/C,OAAO,qBAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC3C,CAAC;AAFD,kBAEC;AAED;;;;GAIG;AACH,SAAgB,KAAK,CAAI,OAA0B;IACjD,OAAO,qBAAa,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,sBAEC;AACD;;;GAGG;AACH,SAAgB,KAAK;IACnB,OAAO,qBAAa,CAAC,KAAK,EAAE,CAAC;AAC/B,CAAC;AAFD,sBAEC"}
package/lib/types.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { IContainer } from './interfaces';
2
- /**
3
- * Abstract class type
4
- */
5
- export declare type Abstract<T = any> = Function & {
2
+ export declare type Abstract<T> = Function & {
6
3
  prototype: T;
7
4
  };
8
- export declare type Constructor<T = any> = new (...args: any[]) => T;
9
- export declare type Class<T = any> = Abstract<T> | Constructor<T>;
5
+ export declare type Constructor<T> = new (...args: any[]) => T;
6
+ export declare type Class<T> = Abstract<T> | Constructor<T>;
7
+ /**
8
+ * Factory functions should not be normal functions,
9
+ * but arrow functions. Its is by js limitation
10
+ * to detect if object is constructable
11
+ */
10
12
  export declare type Factory<T> = (container: IContainer, ...args: any[]) => T;
11
13
  export declare type ClassArray<T> = Class<T>[];
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@spinajs/di",
3
- "version": "1.1.7",
3
+ "version": "1.2.20",
4
4
  "description": "lightweight di container ",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
7
+ "build": "npm run clean && npm run compile",
8
+ "compile": "tsc -p tsconfig.build.json",
9
+ "clean": "",
7
10
  "test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
8
11
  "coverage": "nyc npm run test",
9
12
  "build-docs": "rimraf docs && typedoc --options typedoc.json src/",
10
- "build": "tsc",
11
- "build-watch": "tsc -w",
12
13
  "prepare": "npm run build",
13
- "format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
14
- "lint": "tslint -p tsconfig.json",
14
+ "format": "prettier --write \"src/**/*.ts\"",
15
+ "lint": "eslint -c .eslintrc.js --ext .ts src --fix",
15
16
  "prepublishOnly": "npm test && npm run lint",
16
17
  "preversion": "npm run lint",
17
18
  "version": "npm run format && git add -A src",
@@ -38,31 +39,9 @@
38
39
  },
39
40
  "homepage": "https://github.com/spinajs/di#readme",
40
41
  "dependencies": {
41
- "@spinajs/exceptions": "^1.0.5",
42
- "lodash": "^4.17.14",
42
+ "@spinajs/exceptions": "^1.2.7",
43
+ "lodash": "^4.17.21",
43
44
  "reflect-metadata": "^0.1.13"
44
45
  },
45
- "devDependencies": {
46
- "@types/bunyan": "^1.8.6",
47
- "@types/chai": "^4.1.7",
48
- "@types/chai-as-promised": "^7.1.0",
49
- "@types/lodash": "^4.14.136",
50
- "@types/mocha": "^9.1.0",
51
- "@types/sinon": "^10.0.8",
52
- "chai": "^4.2.0",
53
- "chai-as-promised": "^7.1.1",
54
- "mocha": "^9.2.0",
55
- "nyc": "^15.1.0",
56
- "prettier": "^2.5.1",
57
- "sinon": "^12.0.1",
58
- "ts-mocha": "^9.0.2",
59
- "ts-node": "^10.4.0",
60
- "tslint": "^6.1.3",
61
- "tslint-circular-dependencies": "^0.1.0",
62
- "tslint-config-prettier": "^1.18.0",
63
- "tslint-config-standard": "^9.0.0",
64
- "tslint-no-unused-expression-chai": "^0.1.4",
65
- "typedoc": "^0.22.11",
66
- "typescript": "^4.2.3"
67
- }
46
+ "gitHead": "bbed041879adfd9d6a502aa27891a3682e68c20c"
68
47
  }
File without changes
package/lib/resolvers.js DELETED
@@ -1 +0,0 @@
1
- //# sourceMappingURL=resolvers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../src/resolvers.ts"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- type Abstract<T = any> = Function & { prototype: T };
2
- type Constructor<T = any> = new (...args: any[]) => T;
3
- type Class<T = any> = Abstract<T> | Constructor<T>;
4
-
5
- declare class TypedArray<T> extends Array<T>{
6
- Type : Class<T>;
7
- }
8
-
9
- interface ArrayConstructor {
10
- ofType<T>(type: Class<T>): TypedArray<T>;
11
- }
12
-