@jscrpt/common 1.2.0 → 2.0.0-beta.20211108120022
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 +24 -0
- package/dist/es2015/decorators/bindThis.decorator.js +24 -24
- package/dist/es2015/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es2015/decorators/callOnce.decorator.js +29 -28
- package/dist/es2015/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es2015/decorators/debounceCall.decorator.js +25 -26
- package/dist/es2015/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es2015/decorators/index.js +4 -4
- package/dist/es2015/decorators/index.js.map +1 -0
- package/dist/es2015/encoder/encoder.js +220 -231
- package/dist/es2015/encoder/encoder.js.map +1 -0
- package/dist/es2015/enums/index.js +2 -2
- package/dist/es2015/enums/index.js.map +1 -0
- package/dist/es2015/enums/orderByDirection.js +15 -15
- package/dist/es2015/enums/orderByDirection.js.map +1 -0
- package/dist/es2015/index.js +10 -24
- package/dist/es2015/index.js.map +1 -0
- package/dist/es2015/indexNode.js +2 -2
- package/dist/es2015/indexNode.js.map +1 -0
- package/dist/es2015/initJsDevMode.js +8 -0
- package/dist/es2015/initJsDevMode.js.map +1 -0
- package/dist/es2015/jsDevMode.js +8 -8
- package/dist/es2015/jsDevMode.js.map +1 -0
- package/dist/es2015/normalizer/charMaps.js +20 -27
- package/dist/es2015/normalizer/charMaps.js.map +1 -0
- package/dist/es2015/normalizer/index.js +3 -3
- package/dist/es2015/normalizer/index.js.map +1 -0
- package/dist/es2015/normalizer/normalizer.js +14 -14
- package/dist/es2015/normalizer/normalizer.js.map +1 -0
- package/dist/es2015/paginator/paginator.js +230 -224
- package/dist/es2015/paginator/paginator.js.map +1 -0
- package/dist/es2015/types/dictionaries.js +2 -1
- package/dist/es2015/types/dictionaries.js.map +1 -0
- package/dist/es2015/types/enums.js +2 -0
- package/dist/es2015/types/enums.js.map +1 -0
- package/dist/es2015/types/functions.js +2 -0
- package/dist/es2015/types/functions.js.map +1 -0
- package/dist/es2015/types/index.js +5 -3
- package/dist/es2015/types/index.js.map +1 -0
- package/dist/es2015/types/valueNamePair.js +2 -1
- package/dist/es2015/types/valueNamePair.js.map +1 -0
- package/dist/es2015/utils/common.js +209 -215
- package/dist/es2015/utils/common.js.map +1 -0
- package/dist/es2015/utils/index.js +4 -4
- package/dist/es2015/utils/index.js.map +1 -0
- package/dist/es2015/utils/lang.js +79 -79
- package/dist/es2015/utils/lang.js.map +1 -0
- package/dist/es2015/utils/nameof.js +6 -6
- package/dist/es2015/utils/nameof.js.map +1 -0
- package/dist/es2020/decorators/bindThis.decorator.js +23 -0
- package/dist/es2020/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es2020/decorators/callOnce.decorator.js +28 -0
- package/dist/es2020/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es2020/decorators/debounceCall.decorator.js +24 -0
- package/dist/es2020/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es2020/decorators/index.js +4 -0
- package/dist/es2020/decorators/index.js.map +1 -0
- package/dist/es2020/encoder/encoder.js +220 -0
- package/dist/es2020/encoder/encoder.js.map +1 -0
- package/dist/es2020/enums/index.js +2 -0
- package/dist/es2020/enums/index.js.map +1 -0
- package/dist/es2020/enums/orderByDirection.js +15 -0
- package/dist/es2020/enums/orderByDirection.js.map +1 -0
- package/dist/es2020/index.js +10 -0
- package/dist/es2020/index.js.map +1 -0
- package/dist/es2020/indexNode.js +2 -0
- package/dist/es2020/indexNode.js.map +1 -0
- package/dist/es2020/initJsDevMode.js +8 -0
- package/dist/es2020/initJsDevMode.js.map +1 -0
- package/dist/es2020/jsDevMode.js +8 -0
- package/dist/es2020/jsDevMode.js.map +1 -0
- package/dist/es2020/normalizer/charMaps.js +20 -0
- package/dist/es2020/normalizer/charMaps.js.map +1 -0
- package/dist/es2020/normalizer/index.js +3 -0
- package/dist/es2020/normalizer/index.js.map +1 -0
- package/dist/es2020/normalizer/normalizer.js +14 -0
- package/dist/es2020/normalizer/normalizer.js.map +1 -0
- package/dist/es2020/paginator/paginator.js +230 -0
- package/dist/es2020/paginator/paginator.js.map +1 -0
- package/dist/es2020/types/dictionaries.js +2 -0
- package/dist/es2020/types/dictionaries.js.map +1 -0
- package/dist/es2020/types/enums.js +2 -0
- package/dist/es2020/types/enums.js.map +1 -0
- package/dist/es2020/types/functions.js +2 -0
- package/dist/es2020/types/functions.js.map +1 -0
- package/dist/es2020/types/index.js +5 -0
- package/dist/es2020/types/index.js.map +1 -0
- package/dist/es2020/types/valueNamePair.js +2 -0
- package/dist/es2020/types/valueNamePair.js.map +1 -0
- package/dist/es2020/utils/common.js +208 -0
- package/dist/es2020/utils/common.js.map +1 -0
- package/dist/es2020/utils/index.js +4 -0
- package/dist/es2020/utils/index.js.map +1 -0
- package/dist/es2020/utils/lang.js +79 -0
- package/dist/es2020/utils/lang.js.map +1 -0
- package/dist/es2020/utils/nameof.js +6 -0
- package/dist/es2020/utils/nameof.js.map +1 -0
- package/dist/es5/decorators/bindThis.decorator.js +24 -24
- package/dist/es5/decorators/bindThis.decorator.js.map +1 -0
- package/dist/es5/decorators/callOnce.decorator.js +33 -28
- package/dist/es5/decorators/callOnce.decorator.js.map +1 -0
- package/dist/es5/decorators/debounceCall.decorator.js +30 -27
- package/dist/es5/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/es5/decorators/index.js +4 -4
- package/dist/es5/decorators/index.js.map +1 -0
- package/dist/es5/encoder/encoder.js +222 -233
- package/dist/es5/encoder/encoder.js.map +1 -0
- package/dist/es5/enums/index.js +2 -2
- package/dist/es5/enums/index.js.map +1 -0
- package/dist/es5/enums/orderByDirection.js +15 -15
- package/dist/es5/enums/orderByDirection.js.map +1 -0
- package/dist/es5/index.js +10 -24
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/indexNode.js +2 -2
- package/dist/es5/indexNode.js.map +1 -0
- package/dist/es5/initJsDevMode.js +8 -0
- package/dist/es5/initJsDevMode.js.map +1 -0
- package/dist/es5/jsDevMode.js +8 -8
- package/dist/es5/jsDevMode.js.map +1 -0
- package/dist/es5/normalizer/charMaps.js +20 -35
- package/dist/es5/normalizer/charMaps.js.map +1 -0
- package/dist/es5/normalizer/index.js +3 -3
- package/dist/es5/normalizer/index.js.map +1 -0
- package/dist/es5/normalizer/normalizer.js +14 -14
- package/dist/es5/normalizer/normalizer.js.map +1 -0
- package/dist/es5/paginator/paginator.js +232 -226
- package/dist/es5/paginator/paginator.js.map +1 -0
- package/dist/es5/types/dictionaries.js +2 -1
- package/dist/es5/types/dictionaries.js.map +1 -0
- package/dist/es5/types/enums.js +2 -0
- package/dist/es5/types/enums.js.map +1 -0
- package/dist/es5/types/functions.js +2 -0
- package/dist/es5/types/functions.js.map +1 -0
- package/dist/es5/types/index.js +5 -3
- package/dist/es5/types/index.js.map +1 -0
- package/dist/es5/types/valueNamePair.js +2 -1
- package/dist/es5/types/valueNamePair.js.map +1 -0
- package/dist/es5/utils/common.js +220 -232
- package/dist/es5/utils/common.js.map +1 -0
- package/dist/es5/utils/index.js +4 -4
- package/dist/es5/utils/index.js.map +1 -0
- package/dist/es5/utils/lang.js +79 -79
- package/dist/es5/utils/lang.js.map +1 -0
- package/dist/es5/utils/nameof.js +6 -6
- package/dist/es5/utils/nameof.js.map +1 -0
- package/dist/module/decorators/bindThis.decorator.js +28 -28
- package/dist/module/decorators/bindThis.decorator.js.map +1 -0
- package/dist/module/decorators/callOnce.decorator.js +33 -32
- package/dist/module/decorators/callOnce.decorator.js.map +1 -0
- package/dist/module/decorators/debounceCall.decorator.js +29 -30
- package/dist/module/decorators/debounceCall.decorator.js.map +1 -0
- package/dist/module/decorators/index.js +7 -16
- package/dist/module/decorators/index.js.map +1 -0
- package/dist/module/encoder/encoder.js +224 -235
- package/dist/module/encoder/encoder.js.map +1 -0
- package/dist/module/enums/index.js +5 -14
- package/dist/module/enums/index.js.map +1 -0
- package/dist/module/enums/orderByDirection.js +18 -18
- package/dist/module/enums/orderByDirection.js.map +1 -0
- package/dist/module/index.js +13 -37
- package/dist/module/index.js.map +1 -0
- package/dist/module/indexNode.js +5 -14
- package/dist/module/indexNode.js.map +1 -0
- package/dist/module/initJsDevMode.js +10 -0
- package/dist/module/initJsDevMode.js.map +1 -0
- package/dist/module/jsDevMode.js +12 -12
- package/dist/module/jsDevMode.js.map +1 -0
- package/dist/module/normalizer/charMaps.js +23 -31
- package/dist/module/normalizer/charMaps.js.map +1 -0
- package/dist/module/normalizer/index.js +6 -15
- package/dist/module/normalizer/index.js.map +1 -0
- package/dist/module/normalizer/normalizer.js +18 -18
- package/dist/module/normalizer/normalizer.js.map +1 -0
- package/dist/module/paginator/paginator.js +234 -228
- package/dist/module/paginator/paginator.js.map +1 -0
- package/dist/module/types/dictionaries.js +3 -3
- package/dist/module/types/dictionaries.js.map +1 -0
- package/dist/module/types/enums.js +3 -0
- package/dist/module/types/enums.js.map +1 -0
- package/dist/module/types/functions.js +3 -0
- package/dist/module/types/functions.js.map +1 -0
- package/dist/module/types/index.js +8 -15
- package/dist/module/types/index.js.map +1 -0
- package/dist/module/types/valueNamePair.js +3 -3
- package/dist/module/types/valueNamePair.js.map +1 -0
- package/dist/module/utils/common.js +232 -240
- package/dist/module/utils/common.js.map +1 -0
- package/dist/module/utils/index.js +7 -16
- package/dist/module/utils/index.js.map +1 -0
- package/dist/module/utils/lang.js +99 -99
- package/dist/module/utils/lang.js.map +1 -0
- package/dist/module/utils/nameof.js +10 -9
- package/dist/module/utils/nameof.js.map +1 -0
- package/package.json +45 -16
- package/src/decorators/bindThis.decorator.d.ts +5 -7
- package/src/decorators/bindThis.decorator.d.ts.map +1 -1
- package/src/decorators/callOnce.decorator.d.ts +5 -5
- package/src/decorators/callOnce.decorator.d.ts.map +1 -1
- package/src/decorators/debounceCall.decorator.d.ts +5 -5
- package/src/decorators/debounceCall.decorator.d.ts.map +1 -1
- package/src/decorators/index.d.ts +3 -3
- package/src/encoder/encoder.d.ts +45 -45
- package/src/encoder/encoder.d.ts.map +1 -1
- package/src/enums/index.d.ts +1 -1
- package/src/enums/orderByDirection.d.ts +13 -13
- package/src/index.d.ts +9 -17
- package/src/index.d.ts.map +1 -1
- package/src/indexNode.d.ts +1 -1
- package/src/initJsDevMode.d.ts +2 -0
- package/src/initJsDevMode.d.ts.map +1 -0
- package/src/jsDevMode.d.ts +8 -8
- package/src/jsDevMode.d.ts.map +1 -1
- package/src/normalizer/charMaps.d.ts +5 -9
- package/src/normalizer/charMaps.d.ts.map +1 -1
- package/src/normalizer/index.d.ts +2 -2
- package/src/normalizer/normalizer.d.ts +7 -6
- package/src/normalizer/normalizer.d.ts.map +1 -1
- package/src/paginator/paginator.d.ts +129 -129
- package/src/paginator/paginator.d.ts.map +1 -1
- package/src/types/dictionaries.d.ts +15 -6
- package/src/types/dictionaries.d.ts.map +1 -1
- package/src/types/enums.d.ts +7 -0
- package/src/types/enums.d.ts.map +1 -0
- package/src/types/functions.d.ts +14 -0
- package/src/types/functions.d.ts.map +1 -0
- package/src/types/index.d.ts +4 -2
- package/src/types/index.d.ts.map +1 -1
- package/src/types/valueNamePair.d.ts +13 -13
- package/src/utils/common.d.ts +181 -122
- package/src/utils/common.d.ts.map +1 -1
- package/src/utils/index.d.ts +3 -3
- package/src/utils/lang.d.ts +41 -41
- package/src/utils/lang.d.ts.map +1 -1
- package/src/utils/nameof.d.ts +5 -5
- package/src/utils/nameof.d.ts.map +1 -1
- package/version.bak +1 -1
- package/.jsbeautifyrc +0 -7
- package/appveyor.yml +0 -67
package/dist/es5/utils/lang.js
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests whether is object not `null` and not `undefined` at the same time
|
|
3
|
-
* @param obj - Object to be tested
|
|
4
|
-
*/
|
|
5
|
-
export function isPresent(obj) {
|
|
6
|
-
return obj !== undefined && obj !== null;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Tests whether is object `null` or `undefined`
|
|
10
|
-
* @param obj - Object to be tested
|
|
11
|
-
*/
|
|
12
|
-
export function isBlank(obj) {
|
|
13
|
-
return obj === undefined || obj === null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Tests whether is object instance of `boolean`
|
|
17
|
-
* @param obj - Object to be tested
|
|
18
|
-
*/
|
|
19
|
-
export function isBoolean(obj) {
|
|
20
|
-
return typeof obj === 'boolean';
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Tests whether is object instance of number
|
|
24
|
-
* @param obj - Object to be tested
|
|
25
|
-
*/
|
|
26
|
-
export function isNumber(obj) {
|
|
27
|
-
return typeof obj === 'number';
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Tests whether is object instance of string
|
|
31
|
-
* @param obj - Object to be tested
|
|
32
|
-
*/
|
|
33
|
-
export function isString(obj) {
|
|
34
|
-
return typeof obj === 'string';
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Tests whether is object instance of function
|
|
38
|
-
* @param obj - Object to be tested
|
|
39
|
-
*/
|
|
40
|
-
export function isFunction(obj) {
|
|
41
|
-
return typeof obj === 'function';
|
|
42
|
-
}
|
|
43
|
-
export function isType(obj) {
|
|
44
|
-
return isFunction(obj);
|
|
45
|
-
}
|
|
46
|
-
export function isStringMap(obj) {
|
|
47
|
-
return typeof obj === 'object' && obj !== null;
|
|
48
|
-
}
|
|
49
|
-
var STRING_MAP_PROTO = Object.getPrototypeOf({});
|
|
50
|
-
export function isStrictStringMap(obj) {
|
|
51
|
-
return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
|
|
52
|
-
}
|
|
53
|
-
export function isArray(obj) {
|
|
54
|
-
return Array.isArray(obj);
|
|
55
|
-
}
|
|
56
|
-
export function isDate(obj) {
|
|
57
|
-
return obj instanceof Date && !isNaN(obj.valueOf());
|
|
58
|
-
}
|
|
59
|
-
export function noop() {
|
|
60
|
-
}
|
|
61
|
-
export function normalizeBlank(obj) {
|
|
62
|
-
return isBlank(obj) ? null : obj;
|
|
63
|
-
}
|
|
64
|
-
export function isJsObject(o) {
|
|
65
|
-
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
|
66
|
-
}
|
|
67
|
-
export function isPrimitive(obj) {
|
|
68
|
-
return !isJsObject(obj);
|
|
69
|
-
}
|
|
70
|
-
export function hasConstructor(value, type) {
|
|
71
|
-
return value.constructor === type;
|
|
72
|
-
}
|
|
73
|
-
export function isEmptyObject(obj) {
|
|
74
|
-
for (var _name in obj) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=
|
|
1
|
+
/**
|
|
2
|
+
* Tests whether is object not `null` and not `undefined` at the same time
|
|
3
|
+
* @param obj - Object to be tested
|
|
4
|
+
*/
|
|
5
|
+
export function isPresent(obj) {
|
|
6
|
+
return obj !== undefined && obj !== null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tests whether is object `null` or `undefined`
|
|
10
|
+
* @param obj - Object to be tested
|
|
11
|
+
*/
|
|
12
|
+
export function isBlank(obj) {
|
|
13
|
+
return obj === undefined || obj === null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Tests whether is object instance of `boolean`
|
|
17
|
+
* @param obj - Object to be tested
|
|
18
|
+
*/
|
|
19
|
+
export function isBoolean(obj) {
|
|
20
|
+
return typeof obj === 'boolean';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Tests whether is object instance of number
|
|
24
|
+
* @param obj - Object to be tested
|
|
25
|
+
*/
|
|
26
|
+
export function isNumber(obj) {
|
|
27
|
+
return typeof obj === 'number';
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tests whether is object instance of string
|
|
31
|
+
* @param obj - Object to be tested
|
|
32
|
+
*/
|
|
33
|
+
export function isString(obj) {
|
|
34
|
+
return typeof obj === 'string';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Tests whether is object instance of function
|
|
38
|
+
* @param obj - Object to be tested
|
|
39
|
+
*/
|
|
40
|
+
export function isFunction(obj) {
|
|
41
|
+
return typeof obj === 'function';
|
|
42
|
+
}
|
|
43
|
+
export function isType(obj) {
|
|
44
|
+
return isFunction(obj);
|
|
45
|
+
}
|
|
46
|
+
export function isStringMap(obj) {
|
|
47
|
+
return typeof obj === 'object' && obj !== null;
|
|
48
|
+
}
|
|
49
|
+
var STRING_MAP_PROTO = Object.getPrototypeOf({});
|
|
50
|
+
export function isStrictStringMap(obj) {
|
|
51
|
+
return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;
|
|
52
|
+
}
|
|
53
|
+
export function isArray(obj) {
|
|
54
|
+
return Array.isArray(obj);
|
|
55
|
+
}
|
|
56
|
+
export function isDate(obj) {
|
|
57
|
+
return obj instanceof Date && !isNaN(obj.valueOf());
|
|
58
|
+
}
|
|
59
|
+
export function noop() {
|
|
60
|
+
}
|
|
61
|
+
export function normalizeBlank(obj) {
|
|
62
|
+
return isBlank(obj) ? null : obj;
|
|
63
|
+
}
|
|
64
|
+
export function isJsObject(o) {
|
|
65
|
+
return o !== null && (typeof o === 'function' || typeof o === 'object');
|
|
66
|
+
}
|
|
67
|
+
export function isPrimitive(obj) {
|
|
68
|
+
return !isJsObject(obj);
|
|
69
|
+
}
|
|
70
|
+
export function hasConstructor(value, type) {
|
|
71
|
+
return value.constructor === type;
|
|
72
|
+
}
|
|
73
|
+
export function isEmptyObject(obj) {
|
|
74
|
+
for (var _name in obj) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=lang.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lang.js","sourceRoot":"","sources":["../../../src/utils/lang.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAO,GAAS;IAErC,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG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AAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,IAAI;AAGpB,CAAC;AAED,MAAM,UAAU,cAAc,CAAsB,GAAwB;IAExE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAM;IAE7B,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAQ;IAEhC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa,EAAE,IAAS;IAEnD,OAAO,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC;AACtC,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,GAAQ;IAElC,KAAK,IAAM,KAAK,IAAI,GAAG,EACvB;QACI,OAAO,KAAK,CAAC;KAChB;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["/**\r\n * Tests whether is object not `null` and not `undefined` at the same time\r\n * @param obj - Object to be tested\r\n */\r\nexport function isPresent<TObj>(obj: TObj): obj is NonNullable<TObj>\r\n{\r\n return obj !== undefined && obj !== null;\r\n}\r\n\r\n/**\r\n * Tests whether is object `null` or `undefined`\r\n * @param obj - Object to be tested\r\n */\r\nexport function isBlank(obj: any): obj is null|undefined\r\n{\r\n return obj === undefined || obj === null;\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of `boolean`\r\n * @param obj - Object to be tested\r\n */\r\nexport function isBoolean(obj: any): obj is boolean\r\n{\r\n return typeof obj === 'boolean';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of number\r\n * @param obj - Object to be tested\r\n */\r\nexport function isNumber(obj: any): obj is number\r\n{\r\n return typeof obj === 'number';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of string\r\n * @param obj - Object to be tested\r\n */\r\nexport function isString(obj: any): obj is string\r\n{\r\n return typeof obj === 'string';\r\n}\r\n\r\n/**\r\n * Tests whether is object instance of function\r\n * @param obj - Object to be tested\r\n */\r\nexport function isFunction(obj: any): obj is Function\r\n{\r\n return typeof obj === 'function';\r\n}\r\n\r\nexport function isType(obj: any): obj is Function\r\n{\r\n return isFunction(obj);\r\n}\r\n\r\nexport function isStringMap(obj: any): obj is Object\r\n{\r\n return typeof obj === 'object' && obj !== null;\r\n}\r\n\r\nconst STRING_MAP_PROTO = Object.getPrototypeOf({});\r\n\r\nexport function isStrictStringMap(obj: any): boolean\r\n{\r\n return isStringMap(obj) && Object.getPrototypeOf(obj) === STRING_MAP_PROTO;\r\n}\r\n\r\nexport function isArray(obj: any): obj is Array<any>\r\n{\r\n return Array.isArray(obj);\r\n}\r\n\r\nexport function isDate(obj: any): obj is Date\r\n{\r\n return obj instanceof Date && !isNaN(obj.valueOf());\r\n}\r\n\r\nexport function noop(): void\r\n// eslint-disable-next-line @typescript-eslint/no-empty-function\r\n{\r\n}\r\n\r\nexport function normalizeBlank<TObj extends Object>(obj: TObj|undefined|null): TObj|null\r\n{\r\n return isBlank(obj) ? null : obj;\r\n}\r\n\r\nexport function isJsObject(o: any): o is Function|Object\r\n{\r\n return o !== null && (typeof o === 'function' || typeof o === 'object');\r\n}\r\n\r\nexport function isPrimitive(obj: any): boolean\r\n{\r\n return !isJsObject(obj);\r\n}\r\n\r\nexport function hasConstructor(value: Object, type: any): boolean\r\n{\r\n return value.constructor === type;\r\n}\r\n\r\nexport function isEmptyObject(obj: any): boolean\r\n{\r\n for (const _name in obj)\r\n {\r\n return false;\r\n }\r\n\r\n return true;\r\n}"]}
|
package/dist/es5/utils/nameof.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns name of property, checked by typescript
|
|
3
|
-
* @param name - Name of property that should be returned
|
|
4
|
-
*/
|
|
5
|
-
export var nameof = function (name) { return name; };
|
|
6
|
-
//# sourceMappingURL=
|
|
1
|
+
/**
|
|
2
|
+
* Returns name of property, checked by typescript
|
|
3
|
+
* @param name - Name of property that should be returned
|
|
4
|
+
*/
|
|
5
|
+
export var nameof = function (name) { return name; };
|
|
6
|
+
//# sourceMappingURL=nameof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nameof.js","sourceRoot":"","sources":["../../../src/utils/nameof.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,IAAM,MAAM,GAAG,UAAI,IAA8B,IAAa,OAAA,IAAI,EAAJ,CAAI,CAAC","sourcesContent":["/**\r\n * Returns name of property, checked by typescript\r\n * @param name - Name of property that should be returned\r\n */\r\nexport const nameof = <T>(name: Extract<keyof T, string>): string => name;"]}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BindThis = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Binds function to this, object instance where is defined, it is importat to place it in correct order with other decorators, usually should be first
|
|
7
|
-
*/
|
|
8
|
-
function BindThis(_target, propertyKey, descriptor) {
|
|
9
|
-
var _a;
|
|
10
|
-
|
|
11
|
-
if (!utils_1.isFunction(originalValue)) {
|
|
12
|
-
throw new Error(`Unable to apply @BindThis decorator to '${propertyKey}', it is not a method.`);
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
configurable: true,
|
|
16
|
-
get() {
|
|
17
|
-
const bound = originalValue.bind(this);
|
|
18
|
-
Object.defineProperty(this, propertyKey, {
|
|
19
|
-
value: bound,
|
|
20
|
-
configurable: true,
|
|
21
|
-
writable: true
|
|
22
|
-
});
|
|
23
|
-
return bound;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.BindThis = BindThis;
|
|
28
|
-
//# sourceMappingURL=
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BindThis = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Binds function to this, object instance where is defined, it is importat to place it in correct order with other decorators, usually should be first
|
|
7
|
+
*/
|
|
8
|
+
function BindThis(_target, propertyKey, descriptor) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
|
|
11
|
+
if (!(0, utils_1.isFunction)(originalValue)) {
|
|
12
|
+
throw new Error(`Unable to apply @BindThis decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
configurable: true,
|
|
16
|
+
get() {
|
|
17
|
+
const bound = originalValue.bind(this);
|
|
18
|
+
Object.defineProperty(this, propertyKey, {
|
|
19
|
+
value: bound,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true
|
|
22
|
+
});
|
|
23
|
+
return bound;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.BindThis = BindThis;
|
|
28
|
+
//# sourceMappingURL=bindThis.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindThis.decorator.js","sourceRoot":"","sources":["../../../src/decorators/bindThis.decorator.ts"],"names":[],"mappings":";;;AACA,oCAAoC;AAEpC;;GAEG;AACH,SAAgB,QAAQ,CAAC,OAAe,EAAE,WAA0B,EAAE,UAA8B;;IAEhG,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,CAAC;IAEnE,IAAG,CAAC,IAAA,kBAAU,EAAC,aAAa,CAAC,EAC7B;QACI,MAAM,IAAI,KAAK,CAAC,2CAA2C,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;KAC9G;IAED,OAAO;QACH,YAAY,EAAE,IAAI;QAClB,GAAG;YAEC,MAAM,KAAK,GAAS,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAE7C,MAAM,CAAC,cAAc,CAAC,IAAI,EACJ,WAAW,EACX;gBACI,KAAK,EAAE,KAAK;gBACZ,YAAY,EAAE,IAAI;gBAClB,QAAQ,EAAE,IAAI;aACjB,CAAC,CAAC;YAEzB,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC;AA1BD,4BA0BC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction} from '../utils';\r\n\r\n/**\r\n * Binds function to this, object instance where is defined, it is importat to place it in correct order with other decorators, usually should be first\r\n */\r\nexport function BindThis(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor): TypedPropertyDescriptor<Func>\r\n{\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @BindThis decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n return {\r\n configurable: true,\r\n get(this: unknown): Func\r\n {\r\n const bound: Func = originalValue.bind(this);\r\n\r\n Object.defineProperty(this,\r\n propertyKey,\r\n {\r\n value: bound,\r\n configurable: true,\r\n writable: true\r\n });\r\n\r\n return bound;\r\n }\r\n };\r\n}"]}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CallOnce = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null
|
|
7
|
-
* @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call
|
|
8
|
-
*/
|
|
9
|
-
function CallOnce(time) {
|
|
10
|
-
return function (_target, propertyKey, descriptor) {
|
|
11
|
-
var _a;
|
|
12
|
-
let timeout;
|
|
13
|
-
|
|
14
|
-
if (!utils_1.isFunction(originalValue)) {
|
|
15
|
-
throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey}', it is not a method.`);
|
|
16
|
-
}
|
|
17
|
-
descriptor.value = function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CallOnce = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null
|
|
7
|
+
* @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call
|
|
8
|
+
*/
|
|
9
|
+
function CallOnce(time) {
|
|
10
|
+
return function (_target, propertyKey, descriptor) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
let timeout;
|
|
13
|
+
const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
|
|
14
|
+
if (!(0, utils_1.isFunction)(originalValue)) {
|
|
15
|
+
throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
16
|
+
}
|
|
17
|
+
descriptor.value = function (...args) {
|
|
18
|
+
if ((0, utils_1.isPresent)(timeout)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
originalValue.apply(this, args);
|
|
22
|
+
timeout = setTimeout(() => {
|
|
23
|
+
if ((0, utils_1.isPresent)(timeout)) {
|
|
24
|
+
clearTimeout(timeout);
|
|
25
|
+
}
|
|
26
|
+
timeout = null;
|
|
27
|
+
}, time);
|
|
28
|
+
};
|
|
29
|
+
return descriptor;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.CallOnce = CallOnce;
|
|
33
|
+
//# sourceMappingURL=callOnce.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callOnce.decorator.js","sourceRoot":"","sources":["../../../src/decorators/callOnce.decorator.ts"],"names":[],"mappings":";;;AACA,oCAA+C;AAE/C;;;GAGG;AACH,SAAgB,QAAQ,CAAC,IAAY;IAEjC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,IAAI,OAAoB,CAAC;QACzB,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,CAAC;QAEnE,IAAG,CAAC,IAAA,kBAAU,EAAC,aAAa,CAAC,EAC7B;YACI,MAAM,IAAI,KAAK,CAAC,6CAA6C,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;SAChH;QAED,UAAU,CAAC,KAAK,GAAG,UAAS,GAAG,IAAe;YAE1C,IAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,EACrB;gBACI,OAAO;aACV;YAED,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAEtB,IAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,EACrB;oBACI,YAAY,CAAC,OAAO,CAAC,CAAC;iBACzB;gBAED,OAAO,GAAG,IAAI,CAAC;YACnB,CAAC,EAAE,IAAI,CAAQ,CAAC;QACpB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC;AAlCD,4BAkCC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction, isPresent} from '../utils';\r\n\r\n/**\r\n * Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null\r\n * @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call\r\n */\r\nexport function CallOnce(time: number): MethodDecorator\r\n{\r\n return function(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor)\r\n {\r\n let timeout: number|null;\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n descriptor.value = function(...args: unknown[]): void\r\n {\r\n if(isPresent(timeout))\r\n {\r\n return;\r\n }\r\n\r\n originalValue.apply(this, args);\r\n\r\n timeout = setTimeout(() =>\r\n {\r\n if(isPresent(timeout))\r\n {\r\n clearTimeout(timeout);\r\n }\r\n \r\n timeout = null;\r\n }, time) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DebounceCall = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Adds special functionality to method call, that debounce method call for specified time
|
|
7
|
-
* @param delay - Number of miliseconds that delays function call
|
|
8
|
-
*/
|
|
9
|
-
function DebounceCall(delay) {
|
|
10
|
-
return function (_target, propertyKey, descriptor) {
|
|
11
|
-
var _a;
|
|
12
|
-
let timeout;
|
|
13
|
-
|
|
14
|
-
if (!utils_1.isFunction(originalValue)) {
|
|
15
|
-
throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey}', it is not a method.`);
|
|
16
|
-
}
|
|
17
|
-
descriptor.value = function () {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZG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AgICAgIHtcclxuICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGltZW91dCA9IHNldFRpbWVvdXQoKCkgPT5cclxuICAgICAgICAgICAge1xyXG4gICAgICAgICAgICAgICAgb3JpZ2luYWxWYWx1ZS5hcHBseSh0aGlzLCBhcmdzKTtcclxuICAgICAgICAgICAgfSwgZGVsYXkpIGFzIGFueTtcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICByZXR1cm4gZGVzY3JpcHRvcjtcclxuICAgIH07XHJcbn0iXX0=
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DebounceCall = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Adds special functionality to method call, that debounce method call for specified time
|
|
7
|
+
* @param delay - Number of miliseconds that delays function call
|
|
8
|
+
*/
|
|
9
|
+
function DebounceCall(delay) {
|
|
10
|
+
return function (_target, propertyKey, descriptor) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
let timeout;
|
|
13
|
+
const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
|
|
14
|
+
if (!(0, utils_1.isFunction)(originalValue)) {
|
|
15
|
+
throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
16
|
+
}
|
|
17
|
+
descriptor.value = function (...args) {
|
|
18
|
+
if ((0, utils_1.isPresent)(timeout)) {
|
|
19
|
+
clearTimeout(timeout);
|
|
20
|
+
}
|
|
21
|
+
timeout = setTimeout(() => {
|
|
22
|
+
originalValue.apply(this, args);
|
|
23
|
+
}, delay);
|
|
24
|
+
};
|
|
25
|
+
return descriptor;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.DebounceCall = DebounceCall;
|
|
29
|
+
//# sourceMappingURL=debounceCall.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debounceCall.decorator.js","sourceRoot":"","sources":["../../../src/decorators/debounceCall.decorator.ts"],"names":[],"mappings":";;;AACA,oCAA+C;AAE/C;;;GAGG;AACH,SAAgB,YAAY,CAAC,KAAa;IAEtC,OAAO,UAAS,OAAe,EAAE,WAA0B,EAAE,UAA8B;;QAEvF,IAAI,OAAe,CAAC;QACpB,MAAM,aAAa,GAAS,MAAA,UAAU,CAAC,KAAK,mCAAI,MAAA,UAAU,CAAC,GAAG,+CAAd,UAAU,CAAQ,CAAC;QAEnE,IAAG,CAAC,IAAA,kBAAU,EAAC,aAAa,CAAC,EAC7B;YACI,MAAM,IAAI,KAAK,CAAC,iDAAiD,WAAW,CAAC,QAAQ,EAAE,wBAAwB,CAAC,CAAC;SACpH;QAED,UAAU,CAAC,KAAK,GAAG,UAAS,GAAG,IAAe;YAE1C,IAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,EACrB;gBACI,YAAY,CAAC,OAAO,CAAC,CAAC;aACzB;YAED,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;gBAEtB,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC,EAAE,KAAK,CAAQ,CAAC;QACrB,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC;AA3BD,oCA2BC","sourcesContent":["import {Func} from '../types';\r\nimport {isFunction, isPresent} from '../utils';\r\n\r\n/**\r\n * Adds special functionality to method call, that debounce method call for specified time\r\n * @param delay - Number of miliseconds that delays function call\r\n */\r\nexport function DebounceCall(delay: number): MethodDecorator\r\n{\r\n return function(_target: Object, propertyKey: string|symbol, descriptor: PropertyDescriptor)\r\n {\r\n let timeout: number;\r\n const originalValue: Func = descriptor.value ?? descriptor.get?.();\r\n\r\n if(!isFunction(originalValue))\r\n {\r\n throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);\r\n }\r\n\r\n descriptor.value = function(...args: unknown[]): void\r\n {\r\n if(isPresent(timeout))\r\n {\r\n clearTimeout(timeout);\r\n }\r\n\r\n timeout = setTimeout(() =>\r\n {\r\n originalValue.apply(this, args);\r\n }, delay) as any;\r\n };\r\n\r\n return descriptor;\r\n };\r\n}"]}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./bindThis.decorator"), exports);
|
|
14
|
-
__exportStar(require("./callOnce.decorator"), exports);
|
|
15
|
-
__exportStar(require("./debounceCall.decorator"), exports);
|
|
16
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvZGVjb3JhdG9ycy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSx1REFBcUM7QUFDckMsdURBQXFDO0FBQ3JDLDJEQUF5QyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vYmluZFRoaXMuZGVjb3JhdG9yJztcclxuZXhwb3J0ICogZnJvbSAnLi9jYWxsT25jZS5kZWNvcmF0b3InO1xyXG5leHBvcnQgKiBmcm9tICcuL2RlYm91bmNlQ2FsbC5kZWNvcmF0b3InOyJdfQ==
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./bindThis.decorator"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./callOnce.decorator"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./debounceCall.decorator"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":";;;AAAA,oEAAqC;AACrC,oEAAqC;AACrC,wEAAyC","sourcesContent":["export * from './bindThis.decorator';\r\nexport * from './callOnce.decorator';\r\nexport * from './debounceCall.decorator';"]}
|