@beecode/msh-util 1.2.1 → 2.0.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/dist/array-util.d.ts +23 -0
- package/dist/array-util.d.ts.map +1 -0
- package/dist/array-util.js +27 -0
- package/{src/class-factory-pattern.ts → dist/class-factory-pattern.d.ts} +5 -9
- package/dist/class-factory-pattern.d.ts.map +1 -0
- package/dist/class-factory-pattern.js +26 -0
- package/{src/express/error-handler.ts → dist/express/error-handler.d.ts} +2 -10
- package/dist/express/error-handler.d.ts.map +1 -0
- package/dist/express/error-handler.js +26 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/joi-util.d.ts +47 -0
- package/dist/joi-util.d.ts.map +1 -0
- package/dist/joi-util.js +62 -0
- package/{src/memoize-factory.ts → dist/memoize-factory.d.ts} +3 -14
- package/dist/memoize-factory.d.ts.map +1 -0
- package/dist/memoize-factory.js +24 -0
- package/dist/object-util.d.ts +72 -0
- package/dist/object-util.d.ts.map +1 -0
- package/dist/object-util.js +115 -0
- package/dist/regex-util.d.ts +12 -0
- package/dist/regex-util.d.ts.map +1 -0
- package/dist/regex-util.js +12 -0
- package/dist/single-threshold-promise.d.ts +31 -0
- package/dist/single-threshold-promise.d.ts.map +1 -0
- package/dist/single-threshold-promise.js +46 -0
- package/dist/singleton/async.d.ts +50 -0
- package/dist/singleton/async.d.ts.map +1 -0
- package/dist/singleton/async.js +75 -0
- package/{src/singleton/pattern.ts → dist/singleton/pattern.d.ts} +3 -13
- package/dist/singleton/pattern.d.ts.map +1 -0
- package/dist/singleton/pattern.js +41 -0
- package/dist/string-util.d.ts +10 -0
- package/dist/string-util.d.ts.map +1 -0
- package/dist/string-util.js +18 -0
- package/dist/time-util.d.ts +74 -0
- package/dist/time-util.d.ts.map +1 -0
- package/dist/time-util.js +90 -0
- package/dist/time-zone.d.ts +467 -0
- package/dist/time-zone.d.ts.map +1 -0
- package/dist/time-zone.js +468 -0
- package/{src/timeout.ts → dist/timeout.d.ts} +2 -3
- package/dist/timeout.d.ts.map +1 -0
- package/dist/timeout.js +17 -0
- package/dist/type-util.d.ts +50 -0
- package/dist/type-util.d.ts.map +1 -0
- package/dist/type-util.js +54 -0
- package/lib/array-util.d.ts.map +1 -1
- package/lib/array-util.js +30 -28
- package/lib/class-factory-pattern.d.ts.map +1 -1
- package/lib/class-factory-pattern.js +17 -8
- package/lib/express/error-handler.d.ts.map +1 -1
- package/lib/express/error-handler.js +15 -11
- package/lib/index.d.ts +16 -13
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +107 -29
- package/lib/joi-util.d.ts.map +1 -1
- package/lib/joi-util.js +66 -22
- package/lib/memoize-factory.d.ts +1 -1
- package/lib/memoize-factory.d.ts.map +1 -1
- package/lib/memoize-factory.js +19 -13
- package/lib/object-util.d.ts.map +1 -1
- package/lib/object-util.js +110 -55
- package/lib/package.json +1 -0
- package/lib/regex-util.js +15 -13
- package/lib/single-threshold-promise.d.ts +1 -1
- package/lib/single-threshold-promise.d.ts.map +1 -1
- package/lib/single-threshold-promise.js +74 -28
- package/lib/singleton/async.d.ts +1 -1
- package/lib/singleton/async.d.ts.map +1 -1
- package/lib/singleton/async.js +105 -45
- package/lib/singleton/pattern.d.ts +1 -1
- package/lib/singleton/pattern.d.ts.map +1 -1
- package/lib/singleton/pattern.js +13 -12
- package/lib/string-util.js +21 -19
- package/lib/time-util.js +69 -39
- package/lib/time-zone.d.ts +467 -0
- package/lib/time-zone.d.ts.map +1 -0
- package/lib/time-zone.js +473 -0
- package/lib/timeout.js +9 -6
- package/lib/type-util.js +57 -55
- package/lib/types/global.d.js +5 -0
- package/lib/types/types.d.js +3 -0
- package/package.json +188 -134
- package/lib/array-util.js.map +0 -1
- package/lib/class-factory-pattern.js.map +0 -1
- package/lib/express/error-handler.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/joi-util.js.map +0 -1
- package/lib/memoize-factory.js.map +0 -1
- package/lib/object-util.js.map +0 -1
- package/lib/regex-util.js.map +0 -1
- package/lib/single-threshold-promise.js.map +0 -1
- package/lib/singleton/async.js.map +0 -1
- package/lib/singleton/pattern.js.map +0 -1
- package/lib/string-util.js.map +0 -1
- package/lib/time-util.js.map +0 -1
- package/lib/timeout.js.map +0 -1
- package/lib/type-util.js.map +0 -1
- package/lib/types/any-function/index.d.ts +0 -2
- package/lib/types/any-function/index.d.ts.map +0 -1
- package/lib/types/any-function/index.js +0 -3
- package/lib/types/any-function/index.js.map +0 -1
- package/lib/types/any-function/no-params.d.ts +0 -2
- package/lib/types/any-function/no-params.d.ts.map +0 -1
- package/lib/types/any-function/no-params.js +0 -3
- package/lib/types/any-function/no-params.js.map +0 -1
- package/lib/types/any-function/promise-no-params.d.ts +0 -2
- package/lib/types/any-function/promise-no-params.d.ts.map +0 -1
- package/lib/types/any-function/promise-no-params.js +0 -3
- package/lib/types/any-function/promise-no-params.js.map +0 -1
- package/lib/types/any-function/promise.d.ts +0 -2
- package/lib/types/any-function/promise.d.ts.map +0 -1
- package/lib/types/any-function/promise.js +0 -3
- package/lib/types/any-function/promise.js.map +0 -1
- package/src/array-util.test.ts +0 -50
- package/src/array-util.ts +0 -26
- package/src/class-factory-pattern.test.ts +0 -39
- package/src/express/error-handler.test.ts +0 -44
- package/src/index.ts +0 -25
- package/src/joi-util.test.ts +0 -192
- package/src/joi-util.ts +0 -65
- package/src/memoize-factory.test.ts +0 -40
- package/src/object-util.test.ts +0 -360
- package/src/object-util.ts +0 -127
- package/src/regex-util.test.ts +0 -25
- package/src/regex-util.ts +0 -11
- package/src/single-threshold-promise.test.ts +0 -91
- package/src/single-threshold-promise.ts +0 -56
- package/src/singleton/async.test.ts +0 -122
- package/src/singleton/async.ts +0 -90
- package/src/singleton/pattern.test.ts +0 -16
- package/src/string-util.test.ts +0 -18
- package/src/string-util.ts +0 -18
- package/src/time-util.test.ts +0 -89
- package/src/time-util.ts +0 -98
- package/src/timeout.test.ts +0 -65
- package/src/type-util.test.ts +0 -20
- package/src/type-util.ts +0 -54
- package/src/types/any-function/index.ts +0 -1
- package/src/types/any-function/no-params.ts +0 -1
- package/src/types/any-function/promise-no-params.ts +0 -1
- package/src/types/any-function/promise.ts +0 -1
- package/src/types/types.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-util.d.ts","sourceRoot":"","sources":["../src/type-util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;IACpB;;;;;;;;;;;;;;;;;;;;OAoBG;+BACwB,MAAM,KAAK,KAAK,KAAG,KAAK;IAInD;;;;;;;;;;;;;;;;;;;;;;;OAuBG;iCAC0B,MAAM,KAAK,KAAK,KAAG,MAAM;CAGtD,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export const typeUtil = {
|
|
2
|
+
/**
|
|
3
|
+
* This is the similar to exhaustiveMessage, but instead of message we are returning error so we can throw it
|
|
4
|
+
* @param {string} message
|
|
5
|
+
* @param {never} _
|
|
6
|
+
* @return {Error}
|
|
7
|
+
* @example
|
|
8
|
+
* export type Animal = 'cat' | 'dog' | 'bird';
|
|
9
|
+
*
|
|
10
|
+
* export const makeSound = (animal: Animal): string => {
|
|
11
|
+
* switch (animal) {
|
|
12
|
+
* case 'cat':
|
|
13
|
+
* return 'Meow'
|
|
14
|
+
* case 'dog':
|
|
15
|
+
* return 'Woof'
|
|
16
|
+
* case 'bird':
|
|
17
|
+
* return 'Tweet'
|
|
18
|
+
* default:
|
|
19
|
+
* throw typeUtil.exhaustiveError('Unknown animal [animal]', animal)
|
|
20
|
+
* }
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
exhaustiveError: (message, _) => {
|
|
24
|
+
return new Error(message);
|
|
25
|
+
},
|
|
26
|
+
/**
|
|
27
|
+
* In TypeScript, exhaustiveMessage is a technique that can be used with switch statements to ensure that all possible cases are handled.
|
|
28
|
+
*
|
|
29
|
+
* When using switch statements, it is common to have a default case that handles any unanticipated cases. However, sometimes it is important to ensure that all cases are explicitly handled to avoid potential errors or bugs in the code.
|
|
30
|
+
* @param {string} message
|
|
31
|
+
* @param {never} _
|
|
32
|
+
* @return {string}
|
|
33
|
+
* @example
|
|
34
|
+
* export type Animal = 'cat' | 'dog' | 'bird';
|
|
35
|
+
*
|
|
36
|
+
* export const makeSound = (animal: Animal): string => {
|
|
37
|
+
* switch (animal) {
|
|
38
|
+
* case 'cat':
|
|
39
|
+
* return 'Meow'
|
|
40
|
+
* case 'dog':
|
|
41
|
+
* return 'Woof'
|
|
42
|
+
* case 'bird':
|
|
43
|
+
* return 'Tweet'
|
|
44
|
+
* default:
|
|
45
|
+
* console.error(new TypeUtil().exhaustiveMessage('Unknown animal [animal]', animal))
|
|
46
|
+
* return 'unknown sound'
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
*/
|
|
50
|
+
exhaustiveMessage: (message, _) => {
|
|
51
|
+
return message;
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZS11dGlsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3R5cGUtdXRpbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxNQUFNLENBQUMsTUFBTSxRQUFRLEdBQUc7SUFDdkI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O09Bb0JHO0lBQ0gsZUFBZSxFQUFFLENBQUMsT0FBZSxFQUFFLENBQVEsRUFBUyxFQUFFO1FBQ3JELE9BQU8sSUFBSSxLQUFLLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDMUIsQ0FBQztJQUVEOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztPQXVCRztJQUNILGlCQUFpQixFQUFFLENBQUMsT0FBZSxFQUFFLENBQVEsRUFBVSxFQUFFO1FBQ3hELE9BQU8sT0F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IFR5cGVVdGlsKCkuZXhoYXVzdGl2ZU1lc3NhZ2UoJ1Vua25vd24gYW5pbWFsIFthbmltYWxdJywgYW5pbWFsKSlcblx0ICogICAgICAgcmV0dXJuICd1bmtub3duIHNvdW5kJ1xuXHQgKiAgIH1cblx0ICogfVxuXHQgKi9cblx0ZXhoYXVzdGl2ZU1lc3NhZ2U6IChtZXNzYWdlOiBzdHJpbmcsIF86IG5ldmVyKTogc3RyaW5nID0+IHtcblx0XHRyZXR1cm4gbWVzc2FnZVxuXHR9LFxufVxuIl19
|
package/lib/array-util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-util.d.ts","sourceRoot":"","sources":["../src/array-util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACrB;;;;;;;;OAQG
|
|
1
|
+
{"version":3,"file":"array-util.d.ts","sourceRoot":"","sources":["../src/array-util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;IACrB;;;;;;;;OAQG;yBACkB,CAAC,GAAG,IAAI,GAAG,SAAS;IAGzC;;;;;;;;OAQG;;CAIH,CAAA"}
|
package/lib/array-util.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.arrayUtil = void 0;
|
|
4
|
-
exports.arrayUtil = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=array-util.js.map
|
|
7
|
+
var arrayUtil = exports.arrayUtil = {
|
|
8
|
+
/**
|
|
9
|
+
* Check if array element is not empty
|
|
10
|
+
* @template T
|
|
11
|
+
* @param {T | null | undefined} value
|
|
12
|
+
* @return {value is T}
|
|
13
|
+
* @example
|
|
14
|
+
* const notEmptyArray = [0, 1, 2, null, undefined, ''].filter(arrayUtil.notEmpty)
|
|
15
|
+
* console.log(notEmptyArray)// [0, 1, 2, '']
|
|
16
|
+
*/
|
|
17
|
+
notEmpty: function notEmpty(value) {
|
|
18
|
+
return value !== null && value !== undefined;
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* Check if array element is not falsy
|
|
22
|
+
* @template T
|
|
23
|
+
* @param {T | null | undefined} value
|
|
24
|
+
* @return {value is T}
|
|
25
|
+
* @example
|
|
26
|
+
* const notFalsyArray = [0, 1, 2, null, undefined, ''].filter(arrayUtil.notFalsy)
|
|
27
|
+
* console.log(notFalsyArray)// [1, 2]
|
|
28
|
+
*/
|
|
29
|
+
notFalsy: function notFalsy(value) {
|
|
30
|
+
return !!value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-factory-pattern.d.ts","sourceRoot":"","sources":["../src/class-factory-pattern.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"class-factory-pattern.d.ts","sourceRoot":"","sources":["../src/class-factory-pattern.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,MAAM,IAAI,KAAK,GAAG,IAAI,EAAE,CAAC,SAAS;IAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,GAAG,GAAG,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,CAAA;AAE/G;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,mBAAmB,2CACpB,CAAC,eACC,sBAAsB,CAAC,CAAC,KAAK,aAAa,CAAC,CAIxD,CAAA"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.classFactoryPattern = void 0;
|
|
7
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
8
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
|
|
4
12
|
/**
|
|
5
13
|
* This is a wrapper that easily converts class constructor call (`new className(..constructorParams)`) into function call (`classNameFactory(..constructorParams)`)
|
|
6
14
|
* @param {C} classType
|
|
@@ -21,10 +29,11 @@ exports.classFactoryPattern = void 0;
|
|
|
21
29
|
* // using
|
|
22
30
|
* const someClassInstance = someClassFactory({ a: 'test' })
|
|
23
31
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
var classFactoryPattern = exports.classFactoryPattern = function classFactoryPattern(classType) {
|
|
33
|
+
return function () {
|
|
34
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
35
|
+
args[_key] = arguments[_key];
|
|
36
|
+
}
|
|
37
|
+
return _construct(classType, args);
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/express/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/express/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAO,MAAM,mBAAmB,YAAa,GAAG,QAAQ,MAAM,cAAc,wBAAwB,GAAG,CAAC,KAAG,GAU1G,CAAA"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.expressErrorHandler = void 0;
|
|
4
7
|
/**
|
|
5
8
|
* Wrap async express http request end return promise or call next on catch
|
|
@@ -16,13 +19,14 @@ exports.expressErrorHandler = void 0;
|
|
|
16
19
|
* }
|
|
17
20
|
* }
|
|
18
21
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
var expressErrorHandler = exports.expressErrorHandler = function expressErrorHandler(_target, _key, descriptor) {
|
|
24
|
+
var originalMethod = descriptor.value;
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
descriptor.value = function () {
|
|
27
|
+
var next = arguments[2]; // eslint-disable-line prefer-rest-params
|
|
28
|
+
|
|
29
|
+
return Promise.resolve(originalMethod.apply(this, arguments))["catch"](next); // eslint-disable-line prefer-rest-params
|
|
30
|
+
};
|
|
31
|
+
return descriptor;
|
|
32
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
1
|
+
export { expressErrorHandler } from './express/error-handler';
|
|
2
|
+
export { SingletonAsync } from './singleton/async';
|
|
3
|
+
export { singletonPattern } from './singleton/pattern';
|
|
4
|
+
export { classFactoryPattern } from './class-factory-pattern';
|
|
5
|
+
export type { ClassType } from './class-factory-pattern';
|
|
6
|
+
export { ErrorWithPayload, JoiUtil } from './joi-util';
|
|
7
|
+
export { memoizeFactory } from './memoize-factory';
|
|
8
|
+
export { ObjectUtil } from './object-util';
|
|
9
|
+
export type { ObjectType } from './object-util';
|
|
10
|
+
export { regexUtil } from './regex-util';
|
|
11
|
+
export { SingleThresholdPromise } from './single-threshold-promise';
|
|
12
|
+
export { stringUtil } from './string-util';
|
|
13
|
+
export { DurationUnit, TimeUtil } from './time-util';
|
|
14
|
+
export type { DurationUnitType } from './time-util';
|
|
15
|
+
export { timeout } from './timeout';
|
|
16
|
+
export { typeUtil } from './type-util';
|
|
14
17
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3D,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEzD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEvD,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA"}
|
package/lib/index.js
CHANGED
|
@@ -1,30 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DurationUnit", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _timeUtil.DurationUnit;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ErrorWithPayload", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _joiUtil.ErrorWithPayload;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "JoiUtil", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _joiUtil.JoiUtil;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "ObjectUtil", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _objectUtil.ObjectUtil;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "SingleThresholdPromise", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _singleThresholdPromise.SingleThresholdPromise;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "SingletonAsync", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _async.SingletonAsync;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "TimeUtil", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function get() {
|
|
45
|
+
return _timeUtil.TimeUtil;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(exports, "classFactoryPattern", {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get: function get() {
|
|
51
|
+
return _classFactoryPattern.classFactoryPattern;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
Object.defineProperty(exports, "expressErrorHandler", {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function get() {
|
|
57
|
+
return _errorHandler.expressErrorHandler;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
Object.defineProperty(exports, "memoizeFactory", {
|
|
61
|
+
enumerable: true,
|
|
62
|
+
get: function get() {
|
|
63
|
+
return _memoizeFactory.memoizeFactory;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(exports, "regexUtil", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
get: function get() {
|
|
69
|
+
return _regexUtil.regexUtil;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(exports, "singletonPattern", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _pattern.singletonPattern;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "stringUtil", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _stringUtil.stringUtil;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "timeout", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _timeout.timeout;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "typeUtil", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _typeUtil.typeUtil;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
var _errorHandler = require("./express/error-handler");
|
|
97
|
+
var _async = require("./singleton/async");
|
|
98
|
+
var _pattern = require("./singleton/pattern");
|
|
99
|
+
var _classFactoryPattern = require("./class-factory-pattern");
|
|
100
|
+
var _joiUtil = require("./joi-util");
|
|
101
|
+
var _memoizeFactory = require("./memoize-factory");
|
|
102
|
+
var _objectUtil = require("./object-util");
|
|
103
|
+
var _regexUtil = require("./regex-util");
|
|
104
|
+
var _singleThresholdPromise = require("./single-threshold-promise");
|
|
105
|
+
var _stringUtil = require("./string-util");
|
|
106
|
+
var _timeUtil = require("./time-util");
|
|
107
|
+
var _timeout = require("./timeout");
|
|
108
|
+
var _typeUtil = require("./type-util");
|
package/lib/joi-util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joi-util.d.ts","sourceRoot":"","sources":["../src/joi-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE7D,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,KAAK;IAC7C,OAAO,EAAE,CAAC,CAAA;gBAEE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;CAIvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAO;IACnB;;;;;;;;OAQG;
|
|
1
|
+
{"version":3,"file":"joi-util.d.ts","sourceRoot":"","sources":["../src/joi-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,KAAK,CAAA;AAE7D,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,KAAK;IAC7C,OAAO,EAAE,CAAC,CAAA;gBAEE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;CAIvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,OAAO;IACnB;;;;;;;;OAQG;IAEH,QAAQ,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAI9G;;;;;;;;OAQG;IAEH,QAAQ,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,CAAC;IAK9G,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,EAAE,iBAAiB,GAAG,CAAC;CAQzH"}
|
package/lib/joi-util.js
CHANGED
|
@@ -1,13 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
3
7
|
exports.JoiUtil = exports.ErrorWithPayload = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
12
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
17
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
18
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
19
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
20
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
21
|
+
function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; }
|
|
22
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
23
|
+
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } }
|
|
24
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
25
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
|
+
var ErrorWithPayload = exports.ErrorWithPayload = /*#__PURE__*/function (_Error) {
|
|
27
|
+
function ErrorWithPayload(message, payload) {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, ErrorWithPayload);
|
|
30
|
+
_this = _callSuper(this, ErrorWithPayload, [message]);
|
|
31
|
+
_this.payload = payload;
|
|
32
|
+
return _this;
|
|
33
|
+
}
|
|
34
|
+
_inherits(ErrorWithPayload, _Error);
|
|
35
|
+
return _createClass(ErrorWithPayload);
|
|
36
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
11
37
|
/**
|
|
12
38
|
* This is a simple wrapper around Joi validation with two functions exposed validate and sanitize. If object is not valid function throws an error.
|
|
13
39
|
* @example
|
|
@@ -26,7 +52,13 @@ exports.ErrorWithPayload = ErrorWithPayload;
|
|
|
26
52
|
* const invalidObject = joiUtil.validate({}, someSchema) // validate throws an error
|
|
27
53
|
* const validObject = joiUtil.validate({ a: 'a', b: 1 }, someSchema)
|
|
28
54
|
*/
|
|
29
|
-
|
|
55
|
+
var JoiUtil = exports.JoiUtil = /*#__PURE__*/function () {
|
|
56
|
+
function JoiUtil() {
|
|
57
|
+
_classCallCheck(this, JoiUtil);
|
|
58
|
+
}
|
|
59
|
+
return _createClass(JoiUtil, [{
|
|
60
|
+
key: "sanitize",
|
|
61
|
+
value:
|
|
30
62
|
/**
|
|
31
63
|
* Validate and clean object
|
|
32
64
|
* @template T
|
|
@@ -36,9 +68,13 @@ class JoiUtil {
|
|
|
36
68
|
* @param {validationOptions} [validationOptions]
|
|
37
69
|
* @returns {T} expected object after validation
|
|
38
70
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
function sanitize(objectToValidate, schema, validationOptions) {
|
|
73
|
+
return this._validate(objectToValidate, schema, _objectSpread(_objectSpread({}, validationOptions), {}, {
|
|
74
|
+
stripUnknown: true
|
|
75
|
+
}));
|
|
41
76
|
}
|
|
77
|
+
|
|
42
78
|
/**
|
|
43
79
|
* Only validate properties specified in validation schema
|
|
44
80
|
* @template T
|
|
@@ -48,16 +84,24 @@ class JoiUtil {
|
|
|
48
84
|
* @param {validationOptions} [validationOptions]
|
|
49
85
|
* @returns {T} expected object after validation
|
|
50
86
|
*/
|
|
51
|
-
|
|
52
|
-
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
}, {
|
|
89
|
+
key: "validate",
|
|
90
|
+
value: function validate(objectToValidate, schema, validationOptions) {
|
|
91
|
+
return this._validate(objectToValidate, schema, validationOptions);
|
|
53
92
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
}, {
|
|
96
|
+
key: "_validate",
|
|
97
|
+
value: function _validate(objectToValidate, schema, validationOptions) {
|
|
98
|
+
var _schema$validate = schema.validate(objectToValidate, validationOptions),
|
|
99
|
+
validationError = _schema$validate.error,
|
|
100
|
+
value = _schema$validate.value;
|
|
101
|
+
if (validationError) {
|
|
102
|
+
throw new ErrorWithPayload(validationError.message.split('"').join("'"), validationError);
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
60
105
|
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
//# sourceMappingURL=joi-util.js.map
|
|
106
|
+
}]);
|
|
107
|
+
}();
|
package/lib/memoize-factory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export type AnyFunction<T> = (...args: any[]) => T;
|
|
2
2
|
/**
|
|
3
3
|
* This is a simple implementation of memoize function that caches result against the parameter passed that are passed to the
|
|
4
4
|
* function so it never runs the same calculation twice.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memoize-factory.d.ts","sourceRoot":"","sources":["../src/memoize-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memoize-factory.d.ts","sourceRoot":"","sources":["../src/memoize-factory.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAElD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,2CAA4C,CAAC,KAAG,CAW1E,CAAA"}
|
package/lib/memoize-factory.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
3
6
|
exports.memoizeFactory = void 0;
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* This is a simple implementation of memoize function that caches result against the parameter passed that are passed to the
|
|
6
11
|
* function so it never runs the same calculation twice.
|
|
@@ -14,15 +19,16 @@ exports.memoizeFactory = void 0;
|
|
|
14
19
|
* // using
|
|
15
20
|
* sumTwoNumbersMemoize(5 + 10) // 15
|
|
16
21
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
var memoizeFactory = exports.memoizeFactory = function memoizeFactory(factoryFn) {
|
|
23
|
+
var cache = {};
|
|
24
|
+
return function () {
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
var key = JSON.stringify(args);
|
|
29
|
+
if (key in cache) {
|
|
30
|
+
return cache[key];
|
|
31
|
+
}
|
|
32
|
+
return cache[key] = factoryFn.apply(void 0, args);
|
|
33
|
+
};
|
|
34
|
+
};
|
package/lib/object-util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-util.d.ts","sourceRoot":"","sources":["../src/object-util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"object-util.d.ts","sourceRoot":"","sources":["../src/object-util.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE5C,qBAAa,UAAU;IACtB;;;;;OAKG;IACH,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,aAAa,EAAE,CAAC,GAAG,CAAC;IAIpD;;;;;;;OAOG;IACH,UAAU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