@tsed/core 6.107.4 → 6.109.0
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/cjs/domain/AnyToPromise.js +10 -10
- package/lib/cjs/domain/AnyToPromise.js.map +1 -1
- package/lib/cjs/index.js +79 -79
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/utils/imports/importPackage.js +5 -1
- package/lib/cjs/utils/imports/importPackage.js.map +1 -1
- package/lib/cjs/utils/objects/getValue.js +1 -1
- package/lib/cjs/utils/objects/getValue.js.map +1 -1
- package/lib/esm/utils/objects/getValue.js +1 -1
- package/lib/esm/utils/objects/getValue.js.map +1 -1
- package/package.json +2 -2
|
@@ -35,17 +35,17 @@ class AnyToPromise {
|
|
|
35
35
|
_AnyToPromise_rejects.set(this, void 0);
|
|
36
36
|
_AnyToPromise_hasNextFunction.set(this, false);
|
|
37
37
|
_AnyToPromise_promise.set(this, void 0);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
tslib_1.__classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, hasNextFunction, "f");
|
|
39
|
+
tslib_1.__classPrivateFieldSet(this, _AnyToPromise_promise, new Promise((resolve, reject) => {
|
|
40
|
+
tslib_1.__classPrivateFieldSet(this, _AnyToPromise_resolves, resolve, "f");
|
|
41
|
+
tslib_1.__classPrivateFieldSet(this, _AnyToPromise_rejects, reject, "f");
|
|
42
42
|
}), "f");
|
|
43
43
|
}
|
|
44
44
|
isDone() {
|
|
45
45
|
return this.status !== AnyToPromiseStatus.PENDING;
|
|
46
46
|
}
|
|
47
47
|
get next() {
|
|
48
|
-
|
|
48
|
+
tslib_1.__classPrivateFieldSet(this, _AnyToPromise_hasNextFunction, true, "f");
|
|
49
49
|
return (error) => {
|
|
50
50
|
if (this.isDone()) {
|
|
51
51
|
return;
|
|
@@ -66,21 +66,21 @@ class AnyToPromise {
|
|
|
66
66
|
catch (er) {
|
|
67
67
|
this.reject(er);
|
|
68
68
|
}
|
|
69
|
-
return
|
|
69
|
+
return tslib_1.__classPrivateFieldGet(this, _AnyToPromise_promise, "f");
|
|
70
70
|
}
|
|
71
71
|
reject(er) {
|
|
72
72
|
if (this.isDone()) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
this.done(AnyToPromiseStatus.REJECTED);
|
|
76
|
-
|
|
76
|
+
tslib_1.__classPrivateFieldGet(this, _AnyToPromise_rejects, "f").call(this, er);
|
|
77
77
|
}
|
|
78
78
|
resolve(response = {}) {
|
|
79
79
|
if (this.isDone()) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
this.done(AnyToPromiseStatus.RESOLVED);
|
|
83
|
-
|
|
83
|
+
tslib_1.__classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { ...response, state: AnyToPromiseStatus.RESOLVED });
|
|
84
84
|
}
|
|
85
85
|
destroy() { }
|
|
86
86
|
cancel() {
|
|
@@ -88,7 +88,7 @@ class AnyToPromise {
|
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
90
|
this.done(AnyToPromiseStatus.CANCELED);
|
|
91
|
-
return
|
|
91
|
+
return tslib_1.__classPrivateFieldGet(this, _AnyToPromise_resolves, "f").call(this, { state: AnyToPromiseStatus.CANCELED });
|
|
92
92
|
}
|
|
93
93
|
done(status) {
|
|
94
94
|
this.destroy();
|
|
@@ -130,7 +130,7 @@ class AnyToPromise {
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
if (!
|
|
133
|
+
if (!tslib_1.__classPrivateFieldGet(this, _AnyToPromise_hasNextFunction, "f")) {
|
|
134
134
|
// no next function and empty response
|
|
135
135
|
return this.resolve({
|
|
136
136
|
...additionalProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnyToPromise.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromise.ts"],"names":[],"mappings":";;;;;AAAA,gEAA2D;AA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gBAC5B,CAAC,CAAC,CAAC;aACN;SACF;QAED,IAAI,CAAC,+BAAA,IAAI,qCAAiB,EAAE;YAC1B,sCAAsC;YACtC,OAAO,IAAI,CAAC,OAAO,CAAC;gBAClB,GAAG,eAAe;gBAClB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,yBAAyB,CAAC,IAAI;aACrC,CAAC,CAAC;SACJ;IACH,CAAC;IAES,kBAAkB,CAAC,OAAY;QACvC,OAAO,OAAO,KAAK,kBAAkB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACF;AAhJD,oCAgJC","sourcesContent":["import {isObservable} from \"../utils/objects/isObservable\";\nimport {isPromise} from \"../utils/objects/isPromise\";\nimport {isStream} from \"../utils/objects/isStream\";\n\n/**\n * @ignore\n */\nfunction isResponse(obj: any) {\n return obj.data && obj.headers && obj.status && obj.statusText;\n}\n\n/**\n * @ignore\n */\nexport enum AnyToPromiseStatus {\n PENDING = \"PENDING\",\n CANCELED = \"CANCELED\",\n RESOLVED = \"RESOLVED\",\n REJECTED = \"REJECTED\"\n}\n\nexport enum AnyToPromiseResponseTypes {\n STREAM = \"STREAM\",\n BUFFER = \"BUFFER\",\n DATA = \"DATA\"\n}\n\nexport interface AnyPromiseResult<T = any> {\n state: AnyToPromiseStatus;\n type: AnyToPromiseResponseTypes;\n status?: number;\n headers?: Record<string, any>;\n data: T;\n}\n\nexport class AnyToPromise<T = any> {\n public status = AnyToPromiseStatus.PENDING;\n public args: any[];\n\n #resolves: any;\n #rejects: any;\n #hasNextFunction = false;\n\n readonly #promise: Promise<AnyPromiseResult<T>>;\n\n constructor({hasNextFunction = false}: {hasNextFunction?: boolean} = {}) {\n this.#hasNextFunction = hasNextFunction;\n\n this.#promise = new Promise((resolve: any, reject: any) => {\n this.#resolves = resolve;\n this.#rejects = reject;\n });\n }\n\n isDone(): boolean {\n return this.status !== AnyToPromiseStatus.PENDING;\n }\n\n get next() {\n this.#hasNextFunction = true;\n\n return (error?: any) => {\n if (this.isDone()) {\n return;\n }\n\n return error ? this.reject(error) : this.resolve({type: AnyToPromiseResponseTypes.DATA});\n };\n }\n\n /**\n *\n */\n async call(cb: Function): Promise<AnyPromiseResult<T>> {\n if (this.isDone()) {\n return this as any;\n }\n\n try {\n this.handle(cb());\n } catch (er) {\n this.reject(er);\n }\n\n return this.#promise;\n }\n\n reject(er: any) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.REJECTED);\n\n this.#rejects(er);\n }\n\n resolve(response: any = {}) {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.RESOLVED);\n\n this.#resolves({...response, state: AnyToPromiseStatus.RESOLVED});\n }\n\n destroy() {}\n\n cancel() {\n if (this.isDone()) {\n return;\n }\n\n this.done(AnyToPromiseStatus.CANCELED);\n\n return this.#resolves({state: AnyToPromiseStatus.CANCELED});\n }\n\n done(status: AnyToPromiseStatus) {\n this.destroy();\n this.status = status;\n }\n\n handle(process: any, additionalProps = {}): any {\n if (this.isDone()) {\n return;\n }\n\n if (process) {\n if (this.isCanceledResponse(process)) {\n // ABANDON\n return this.cancel();\n }\n\n if (isObservable(process)) {\n process = process.toPromise();\n }\n\n if (isResponse(process)) {\n return this.handle(process.data, {\n ...additionalProps,\n status: process.status,\n headers: process.headers\n });\n }\n\n if (isStream(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.STREAM, data: process});\n }\n if (isStream(process) || Buffer.isBuffer(process)) {\n return this.resolve({...additionalProps, type: AnyToPromiseResponseTypes.BUFFER, data: process});\n }\n\n if (isPromise(process)) {\n return process\n .then((result: any) => this.handle(result, additionalProps))\n .catch((error: any) => {\n if (error.response && isResponse(error.response)) {\n return this.handle(error.response);\n }\n return this.reject(error);\n });\n }\n }\n\n if (!this.#hasNextFunction) {\n // no next function and empty response\n return this.resolve({\n ...additionalProps,\n data: process,\n type: AnyToPromiseResponseTypes.DATA\n });\n }\n }\n\n protected isCanceledResponse(process: any) {\n return process === AnyToPromiseStatus.CANCELED;\n }\n}\n"]}
|
package/lib/cjs/index.js
CHANGED
|
@@ -4,83 +4,83 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./decorators/configurable"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./decorators/deprecated"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./decorators/enumerable"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./decorators/notConfigurable"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./decorators/notEnumerable"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./decorators/readOnly"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./decorators/storeFn"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./decorators/storeMerge"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./decorators/storeSet"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./decorators/writable"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./domain/AnyToPromise"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./domain/DecoratorTypes"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./domain/Env"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./domain/Hooks"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./domain/Metadata"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./domain/Store"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./domain/Type"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./errors/UnsupportedDecoratorType"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./interfaces/AnyDecorator"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./interfaces/DecoratorParameters"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./interfaces/HashOf"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./interfaces/MetadataTypes"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./interfaces/ValueOf"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./utils/catchError"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./utils/proxyDelegation"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./utils/uniq"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./utils/decorators/decorateMethodsOf"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./utils/decorators/decoratorArgs"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./utils/decorators/decoratorTypeOf"), exports);
|
|
36
|
+
tslib_1.__exportStar(require("./utils/decorators/inheritedDescriptorOf"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./utils/decorators/useDecorators"), exports);
|
|
38
|
+
tslib_1.__exportStar(require("./utils/decorators/useMethodDecorators"), exports);
|
|
39
|
+
tslib_1.__exportStar(require("./utils/http/getHostInfoFromPort"), exports);
|
|
40
|
+
tslib_1.__exportStar(require("./utils/imports/importPackage"), exports);
|
|
41
|
+
tslib_1.__exportStar(require("./utils/objects/ancestorOf"), exports);
|
|
42
|
+
tslib_1.__exportStar(require("./utils/objects/ancestorsOf"), exports);
|
|
43
|
+
tslib_1.__exportStar(require("./utils/objects/classOf"), exports);
|
|
44
|
+
tslib_1.__exportStar(require("./utils/objects/cleanObject"), exports);
|
|
45
|
+
tslib_1.__exportStar(require("./utils/objects/constructorOf"), exports);
|
|
46
|
+
tslib_1.__exportStar(require("./utils/objects/createInstance"), exports);
|
|
47
|
+
tslib_1.__exportStar(require("./utils/objects/deepClone"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./utils/objects/deepExtends"), exports);
|
|
49
|
+
tslib_1.__exportStar(require("./utils/objects/deepMerge"), exports);
|
|
50
|
+
tslib_1.__exportStar(require("./utils/objects/descriptorOf"), exports);
|
|
51
|
+
tslib_1.__exportStar(require("./utils/objects/getClassOrSymbol"), exports);
|
|
52
|
+
tslib_1.__exportStar(require("./utils/objects/getConstructorArgNames"), exports);
|
|
53
|
+
tslib_1.__exportStar(require("./utils/objects/getEnumerableKeys"), exports);
|
|
54
|
+
tslib_1.__exportStar(require("./utils/objects/getValue"), exports);
|
|
55
|
+
tslib_1.__exportStar(require("./utils/objects/isArray"), exports);
|
|
56
|
+
tslib_1.__exportStar(require("./utils/objects/isArrowFn"), exports);
|
|
57
|
+
tslib_1.__exportStar(require("./utils/objects/isBoolean"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./utils/objects/isBuffer"), exports);
|
|
59
|
+
tslib_1.__exportStar(require("./utils/objects/isClass"), exports);
|
|
60
|
+
tslib_1.__exportStar(require("./utils/objects/isCollection"), exports);
|
|
61
|
+
tslib_1.__exportStar(require("./utils/objects/isDate"), exports);
|
|
62
|
+
tslib_1.__exportStar(require("./utils/objects/isEmpty"), exports);
|
|
63
|
+
tslib_1.__exportStar(require("./utils/objects/isEnumerable"), exports);
|
|
64
|
+
tslib_1.__exportStar(require("./utils/objects/isFunction"), exports);
|
|
65
|
+
tslib_1.__exportStar(require("./utils/objects/isInheritedFrom"), exports);
|
|
66
|
+
tslib_1.__exportStar(require("./utils/objects/isNil"), exports);
|
|
67
|
+
tslib_1.__exportStar(require("./utils/objects/isNumber"), exports);
|
|
68
|
+
tslib_1.__exportStar(require("./utils/objects/isObject"), exports);
|
|
69
|
+
tslib_1.__exportStar(require("./utils/objects/isObservable"), exports);
|
|
70
|
+
tslib_1.__exportStar(require("./utils/objects/isPlainObject"), exports);
|
|
71
|
+
tslib_1.__exportStar(require("./utils/objects/isPrimitive"), exports);
|
|
72
|
+
tslib_1.__exportStar(require("./utils/objects/isPromise"), exports);
|
|
73
|
+
tslib_1.__exportStar(require("./utils/objects/isProtectedKey"), exports);
|
|
74
|
+
tslib_1.__exportStar(require("./utils/objects/isSerializable"), exports);
|
|
75
|
+
tslib_1.__exportStar(require("./utils/objects/isStream"), exports);
|
|
76
|
+
tslib_1.__exportStar(require("./utils/objects/isString"), exports);
|
|
77
|
+
tslib_1.__exportStar(require("./utils/objects/isSymbol"), exports);
|
|
78
|
+
tslib_1.__exportStar(require("./utils/objects/methodsOf"), exports);
|
|
79
|
+
tslib_1.__exportStar(require("./utils/objects/nameOf"), exports);
|
|
80
|
+
tslib_1.__exportStar(require("./utils/objects/objectKeys"), exports);
|
|
81
|
+
tslib_1.__exportStar(require("./utils/objects/primitiveOf"), exports);
|
|
82
|
+
tslib_1.__exportStar(require("./utils/objects/prototypeOf"), exports);
|
|
83
|
+
tslib_1.__exportStar(require("./utils/objects/setValue"), exports);
|
|
84
|
+
tslib_1.__exportStar(require("./utils/objects/toMap"), exports);
|
|
85
|
+
tslib_1.__exportStar(require("./utils/objects/toStringConstructor"), exports);
|
|
86
86
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oEAA0C;AAC1C,kEAAwC;AACxC,kEAAwC;AACxC,uEAA6C;AAC7C,qEAA2C;AAC3C,gEAAsC;AACtC,+DAAqC;AACrC,kEAAwC;AACxC,gEAAsC;AACtC,gEAAsC;AACtC,gEAAsC;AACtC,kEAAwC;AACxC,uDAA6B;AAC7B,yDAA+B;AAC/B,4DAAkC;AAClC,yDAA+B;AAC/B,wDAA8B;AAC9B,4EAAkD;AAClD,oEAA0C;AAC1C,2EAAiD;AACjD,8DAAoC;AACpC,qEAA2C;AAC3C,+DAAqC;AACrC,6DAAmC;AACnC,kEAAwC;AACxC,uDAA6B;AAC7B,+EAAqD;AACrD,2EAAiD;AACjD,6EAAmD;AACnD,mFAAyD;AACzD,2EAAiD;AACjD,iFAAuD;AACvD,2EAAiD;AACjD,wEAA8C;AAC9C,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,sEAA4C;AAC5C,wEAA8C;AAC9C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,oEAA0C;AAC1C,uEAA6C;AAC7C,2EAAiD;AACjD,iFAAuD;AACvD,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,oEAA0C;AAC1C,oEAA0C;AAC1C,mEAAyC;AACzC,kEAAwC;AACxC,uEAA6C;AAC7C,iEAAuC;AACvC,kEAAwC;AACxC,uEAA6C;AAC7C,qEAA2C;AAC3C,0EAAgD;AAChD,gEAAsC;AACtC,mEAAyC;AACzC,mEAAyC;AACzC,uEAA6C;AAC7C,wEAA8C;AAC9C,sEAA4C;AAC5C,oEAA0C;AAC1C,yEAA+C;AAC/C,yEAA+C;AAC/C,mEAAyC;AACzC,mEAAyC;AACzC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,qEAA2C;AAC3C,sEAA4C;AAC5C,sEAA4C;AAC5C,mEAAyC;AACzC,gEAAsC;AACtC,8EAAoD","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./decorators/configurable\";\nexport * from \"./decorators/deprecated\";\nexport * from \"./decorators/enumerable\";\nexport * from \"./decorators/notConfigurable\";\nexport * from \"./decorators/notEnumerable\";\nexport * from \"./decorators/readOnly\";\nexport * from \"./decorators/storeFn\";\nexport * from \"./decorators/storeMerge\";\nexport * from \"./decorators/storeSet\";\nexport * from \"./decorators/writable\";\nexport * from \"./domain/AnyToPromise\";\nexport * from \"./domain/DecoratorTypes\";\nexport * from \"./domain/Env\";\nexport * from \"./domain/Hooks\";\nexport * from \"./domain/Metadata\";\nexport * from \"./domain/Store\";\nexport * from \"./domain/Type\";\nexport * from \"./errors/UnsupportedDecoratorType\";\nexport * from \"./interfaces/AnyDecorator\";\nexport * from \"./interfaces/DecoratorParameters\";\nexport * from \"./interfaces/HashOf\";\nexport * from \"./interfaces/MetadataTypes\";\nexport * from \"./interfaces/ValueOf\";\nexport * from \"./utils/catchError\";\nexport * from \"./utils/proxyDelegation\";\nexport * from \"./utils/uniq\";\nexport * from \"./utils/decorators/decorateMethodsOf\";\nexport * from \"./utils/decorators/decoratorArgs\";\nexport * from \"./utils/decorators/decoratorTypeOf\";\nexport * from \"./utils/decorators/inheritedDescriptorOf\";\nexport * from \"./utils/decorators/useDecorators\";\nexport * from \"./utils/decorators/useMethodDecorators\";\nexport * from \"./utils/http/getHostInfoFromPort\";\nexport * from \"./utils/imports/importPackage\";\nexport * from \"./utils/objects/ancestorOf\";\nexport * from \"./utils/objects/ancestorsOf\";\nexport * from \"./utils/objects/classOf\";\nexport * from \"./utils/objects/cleanObject\";\nexport * from \"./utils/objects/constructorOf\";\nexport * from \"./utils/objects/createInstance\";\nexport * from \"./utils/objects/deepClone\";\nexport * from \"./utils/objects/deepExtends\";\nexport * from \"./utils/objects/deepMerge\";\nexport * from \"./utils/objects/descriptorOf\";\nexport * from \"./utils/objects/getClassOrSymbol\";\nexport * from \"./utils/objects/getConstructorArgNames\";\nexport * from \"./utils/objects/getEnumerableKeys\";\nexport * from \"./utils/objects/getValue\";\nexport * from \"./utils/objects/isArray\";\nexport * from \"./utils/objects/isArrowFn\";\nexport * from \"./utils/objects/isBoolean\";\nexport * from \"./utils/objects/isBuffer\";\nexport * from \"./utils/objects/isClass\";\nexport * from \"./utils/objects/isCollection\";\nexport * from \"./utils/objects/isDate\";\nexport * from \"./utils/objects/isEmpty\";\nexport * from \"./utils/objects/isEnumerable\";\nexport * from \"./utils/objects/isFunction\";\nexport * from \"./utils/objects/isInheritedFrom\";\nexport * from \"./utils/objects/isNil\";\nexport * from \"./utils/objects/isNumber\";\nexport * from \"./utils/objects/isObject\";\nexport * from \"./utils/objects/isObservable\";\nexport * from \"./utils/objects/isPlainObject\";\nexport * from \"./utils/objects/isPrimitive\";\nexport * from \"./utils/objects/isPromise\";\nexport * from \"./utils/objects/isProtectedKey\";\nexport * from \"./utils/objects/isSerializable\";\nexport * from \"./utils/objects/isStream\";\nexport * from \"./utils/objects/isString\";\nexport * from \"./utils/objects/isSymbol\";\nexport * from \"./utils/objects/methodsOf\";\nexport * from \"./utils/objects/nameOf\";\nexport * from \"./utils/objects/objectKeys\";\nexport * from \"./utils/objects/primitiveOf\";\nexport * from \"./utils/objects/prototypeOf\";\nexport * from \"./utils/objects/setValue\";\nexport * from \"./utils/objects/toMap\";\nexport * from \"./utils/objects/toStringConstructor\";\n"]}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"importPackage.js","sourceRoot":"","sources":["../../../../src/utils/imports/importPackage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"importPackage.js","sourceRoot":"","sources":["../../../../src/utils/imports/importPackage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,KAAK,UAAU,aAAa,CAAC,WAAmB,EAAE,WAAqB,GAAG,EAAE,mDAAQ,WAAW,GAAC,EAAE,QAAQ,GAAG,KAAK;IACvH,IAAI;QACF,OAAO,MAAM,QAAQ,EAAE,CAAC;KACzB;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,CAAC,CAAC;SACT;QAED,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAVD,sCAUC","sourcesContent":["export async function importPackage(packageName: string, loaderFn: Function = () => import(packageName), optional = false) {\n try {\n return await loaderFn();\n } catch (e) {\n if (!optional) {\n throw e;\n }\n\n return {};\n }\n}\n"]}
|
|
@@ -34,7 +34,7 @@ function getValue(...args) {
|
|
|
34
34
|
const keys = expression.split(separator);
|
|
35
35
|
const getValue = (key) => {
|
|
36
36
|
if (scope) {
|
|
37
|
-
if (scope[key] !== undefined || key in scope) {
|
|
37
|
+
if (scope[key] !== undefined || ((0, isObject_1.isObject)(scope) && key in scope)) {
|
|
38
38
|
return scope[key];
|
|
39
39
|
}
|
|
40
40
|
if ((0, isFunction_1.isFunction)(scope.get)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValue.js","sourceRoot":"","sources":["../../../../src/utils/objects/getValue.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AACxC,yCAAoC;AACpC,yCAAoC;AAEpC,MAAM,UAAU,GAAG,CAAC,IAAW,EAAE,EAAE;IACjC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IAEhE,IAAI,IAAA,mBAAQ,EAAC,KAAK,CAAC,IAAI,IAAA,mBAAQ,EAAC,UAAU,CAAC,EAAE;QAC3C,OAAO;YACL,UAAU;YACV,KAAK;YACL,YAAY;YACZ,SAAS;SACV,CAAC;KACH;IAED,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,UAAU;QACjB,YAAY;QACZ,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAkCF,SAAgB,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,MAAM,EAAC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAC,GAAG,OAAO,CAAC;IAEtD,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,IAAI,GAAa,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;QAC/B,IAAI,KAAK,EAAE;YACT,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,KAAK,EAAE;
|
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,CAAC,GAAG,CAAC,EAAE;gBACzB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aACvB;SACF;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAG,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,GAAE;IAE3D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC;AA9BD,4BA8BC","sourcesContent":["import {isFunction} from \"./isFunction\";\nimport {isObject} from \"./isObject\";\nimport {isString} from \"./isString\";\n\nconst mapOptions = (args: any[]) => {\n const [expression, scope, defaultValue, separator = \".\"] = args;\n\n if (isObject(scope) || isString(expression)) {\n return {\n expression,\n scope,\n defaultValue,\n separator\n };\n }\n\n return {\n expression: scope,\n scope: expression,\n defaultValue,\n separator\n };\n};\n\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @returns {any}\n */\nexport function getValue<T = any>(scope: any, expression: string | undefined): T | undefined;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @param defaultValue\n * @param separator\n * @returns {any}\n */\nexport function getValue<T = any>(scope: any, expression: string | undefined, defaultValue: T, separator?: string): T;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @returns {any}\n */\nexport function getValue<T = any>(expression: string | undefined, scope: any): T | undefined;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @param defaultValue\n * @param separator\n * @returns {any}\n */\nexport function getValue<T = any>(expression: string | undefined, scope: any, defaultValue: T, separator?: string): T;\nexport function getValue(...args: any[]) {\n const options = mapOptions(args);\n let scope = options.scope;\n const {expression, defaultValue, separator} = options;\n\n if (!expression) {\n return scope;\n }\n\n if (!scope) {\n return defaultValue;\n }\n\n const keys: string[] = expression.split(separator);\n\n const getValue = (key: string) => {\n if (scope) {\n if (scope[key] !== undefined || (isObject(scope) && key in scope)) {\n return scope[key];\n }\n\n if (isFunction(scope.get)) {\n return scope.get(key);\n }\n }\n };\n\n while ((scope = getValue(keys.shift()!)) && keys.length) {}\n\n return scope === undefined ? defaultValue : scope;\n}\n"]}
|
|
@@ -31,7 +31,7 @@ export function getValue(...args) {
|
|
|
31
31
|
const keys = expression.split(separator);
|
|
32
32
|
const getValue = (key) => {
|
|
33
33
|
if (scope) {
|
|
34
|
-
if (scope[key] !== undefined || key in scope) {
|
|
34
|
+
if (scope[key] !== undefined || (isObject(scope) && key in scope)) {
|
|
35
35
|
return scope[key];
|
|
36
36
|
}
|
|
37
37
|
if (isFunction(scope.get)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getValue.js","sourceRoot":"","sources":["../../../../src/utils/objects/getValue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,MAAM,UAAU,GAAG,CAAC,IAAW,EAAE,EAAE;IACjC,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;IAEhE,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE;QAC3C,OAAO;YACL,UAAU;YACV,KAAK;YACL,YAAY;YACZ,SAAS;SACV,CAAC;KACH;IAED,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,KAAK,EAAE,UAAU;QACjB,YAAY;QACZ,SAAS;KACV,CAAC;AACJ,CAAC,CAAC;AAkCF,MAAM,UAAU,QAAQ,CAAC,GAAG,IAAW;IACrC,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,MAAM,EAAC,UAAU,EAAE,YAAY,E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D,IAAI,CAAC,UAAU,EAAE;QACf,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,YAAY,CAAC;KACrB;IAED,MAAM,IAAI,GAAa,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAEnD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,EAAE;QAC/B,IAAI,KAAK,EAAE;YACT,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,KAAK,CAAC,EAAE;gBACjE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC;aACnB;YAED,IAAI,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACzB,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aACvB;SACF;IACH,CAAC,CAAC;IAEF,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAG,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,GAAE;IAE3D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC","sourcesContent":["import {isFunction} from \"./isFunction\";\nimport {isObject} from \"./isObject\";\nimport {isString} from \"./isString\";\n\nconst mapOptions = (args: any[]) => {\n const [expression, scope, defaultValue, separator = \".\"] = args;\n\n if (isObject(scope) || isString(expression)) {\n return {\n expression,\n scope,\n defaultValue,\n separator\n };\n }\n\n return {\n expression: scope,\n scope: expression,\n defaultValue,\n separator\n };\n};\n\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @returns {any}\n */\nexport function getValue<T = any>(scope: any, expression: string | undefined): T | undefined;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @param defaultValue\n * @param separator\n * @returns {any}\n */\nexport function getValue<T = any>(scope: any, expression: string | undefined, defaultValue: T, separator?: string): T;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @returns {any}\n */\nexport function getValue<T = any>(expression: string | undefined, scope: any): T | undefined;\n/**\n * Get value from scope\n * @param {string} expression\n * @param scope\n * @param defaultValue\n * @param separator\n * @returns {any}\n */\nexport function getValue<T = any>(expression: string | undefined, scope: any, defaultValue: T, separator?: string): T;\nexport function getValue(...args: any[]) {\n const options = mapOptions(args);\n let scope = options.scope;\n const {expression, defaultValue, separator} = options;\n\n if (!expression) {\n return scope;\n }\n\n if (!scope) {\n return defaultValue;\n }\n\n const keys: string[] = expression.split(separator);\n\n const getValue = (key: string) => {\n if (scope) {\n if (scope[key] !== undefined || (isObject(scope) && key in scope)) {\n return scope[key];\n }\n\n if (isFunction(scope.get)) {\n return scope.get(key);\n }\n }\n };\n\n while ((scope = getValue(keys.shift()!)) && keys.length) {}\n\n return scope === undefined ? defaultValue : scope;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/core",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.109.0",
|
|
4
4
|
"description": "Core module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"reflect-metadata": "^0.1.13",
|
|
25
|
-
"tslib": "2.
|
|
25
|
+
"tslib": "2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {},
|
|
28
28
|
"peerDependencies": {},
|