@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/changelog.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 2.0.0 (2021-11-08)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- added `NoopAction` type that represents function definition with no variables and no return type
|
|
8
|
+
- added `Action` type that represents function definition with variable arguments and no return type
|
|
9
|
+
- added `Func<TResult>` type that represents function definition with variable arguments and return type
|
|
10
|
+
- added `Enum<E>` type that represents enum type
|
|
11
|
+
- added `AsDictionary<TType>` represents type that extracts class as type Record with property keys as index and unknown property values
|
|
12
|
+
- added `asDictionary` function that converts instance of Class to equivalent Record type
|
|
13
|
+
- added better typings for `extend`
|
|
14
|
+
|
|
15
|
+
### BREAKING CHANGES
|
|
16
|
+
|
|
17
|
+
- dropped support of `Node.js <= 12.20`
|
|
18
|
+
- added strict compilation
|
|
19
|
+
- using latest package.json features
|
|
20
|
+
- removed `initializeJsDevMode` and marked index.js as `sideEffect`
|
|
21
|
+
- renamed `Ascendant` to `Ascending` in `OrderByDirection`
|
|
22
|
+
- renamed `Descendant` to `Descending` in `OrderByDirection`
|
|
23
|
+
- removed `merge` util method, use native `Object.assign`
|
|
24
|
+
- removed `NormalizationCharMaps` and moved static properties to separate exports
|
|
25
|
+
- new `SlovakCharmap` const for better tree shaking
|
|
26
|
+
|
|
3
27
|
## Version 1.2.0 (2021-10-29)
|
|
4
28
|
|
|
5
29
|
### Features
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { isFunction } from '../utils';
|
|
2
|
-
/**
|
|
3
|
-
* 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
|
|
4
|
-
*/
|
|
5
|
-
export function BindThis(_target, propertyKey, descriptor) {
|
|
6
|
-
var _a;
|
|
7
|
-
|
|
8
|
-
if (!isFunction(originalValue)) {
|
|
9
|
-
throw new Error(`Unable to apply @BindThis decorator to '${propertyKey}', it is not a method.`);
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
configurable: true,
|
|
13
|
-
get() {
|
|
14
|
-
const bound = originalValue.bind(this);
|
|
15
|
-
Object.defineProperty(this, propertyKey, {
|
|
16
|
-
value: bound,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true
|
|
19
|
-
});
|
|
20
|
-
return bound;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=
|
|
1
|
+
import { isFunction } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* 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
|
|
4
|
+
*/
|
|
5
|
+
export function BindThis(_target, propertyKey, descriptor) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const originalValue = (_a = descriptor.value) !== null && _a !== void 0 ? _a : (_b = descriptor.get) === null || _b === void 0 ? void 0 : _b.call(descriptor);
|
|
8
|
+
if (!isFunction(originalValue)) {
|
|
9
|
+
throw new Error(`Unable to apply @BindThis decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
configurable: true,
|
|
13
|
+
get() {
|
|
14
|
+
const bound = originalValue.bind(this);
|
|
15
|
+
Object.defineProperty(this, propertyKey, {
|
|
16
|
+
value: bound,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
return bound;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
//# 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,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,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,UAAU,CAAC,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","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,28 +1,29 @@
|
|
|
1
|
-
import { isFunction, isPresent } from '../utils';
|
|
2
|
-
/**
|
|
3
|
-
* Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null
|
|
4
|
-
* @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call
|
|
5
|
-
*/
|
|
6
|
-
export function CallOnce(time) {
|
|
7
|
-
return function (_target, propertyKey, descriptor) {
|
|
8
|
-
var _a;
|
|
9
|
-
let timeout;
|
|
10
|
-
|
|
11
|
-
if (!isFunction(originalValue)) {
|
|
12
|
-
throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey}', it is not a method.`);
|
|
13
|
-
}
|
|
14
|
-
descriptor.value = function () {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
1
|
+
import { isFunction, isPresent } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Method is called only once for specified time, other calls during this time are blocked and it does nothing and returns null
|
|
4
|
+
* @param time - Number of miliseconds which specifies period while are calls to this method blocked after first call
|
|
5
|
+
*/
|
|
6
|
+
export function CallOnce(time) {
|
|
7
|
+
return function (_target, propertyKey, descriptor) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
let timeout;
|
|
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 (!isFunction(originalValue)) {
|
|
12
|
+
throw new Error(`Unable to apply @CallOnce() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
13
|
+
}
|
|
14
|
+
descriptor.value = function (...args) {
|
|
15
|
+
if (isPresent(timeout)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
originalValue.apply(this, args);
|
|
19
|
+
timeout = setTimeout(() => {
|
|
20
|
+
if (isPresent(timeout)) {
|
|
21
|
+
clearTimeout(timeout);
|
|
22
|
+
}
|
|
23
|
+
timeout = null;
|
|
24
|
+
}, time);
|
|
25
|
+
};
|
|
26
|
+
return descriptor;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# 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,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,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,UAAU,CAAC,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,SAAS,CAAC,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,SAAS,CAAC,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","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,26 +1,25 @@
|
|
|
1
|
-
import { isFunction, isPresent } from '../utils';
|
|
2
|
-
/**
|
|
3
|
-
* Adds special functionality to method call, that debounce method call for specified time
|
|
4
|
-
* @param delay - Number of miliseconds that delays function call
|
|
5
|
-
*/
|
|
6
|
-
export function DebounceCall(delay) {
|
|
7
|
-
return function (_target, propertyKey, descriptor) {
|
|
8
|
-
var _a;
|
|
9
|
-
let timeout;
|
|
10
|
-
|
|
11
|
-
if (!isFunction(originalValue)) {
|
|
12
|
-
throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey}', it is not a method.`);
|
|
13
|
-
}
|
|
14
|
-
descriptor.value = function () {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVib3VuY2VDYWxsLmRlY29yYXRvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9kZWNvcmF0b3JzL2RlYm91bmNlQ2FsbC5kZWNvcmF0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLFVBQVUsRUFBRSxTQUFTLEVBQUMsTUFBTSxVQUFVLENBQUM7QUFFL0M7OztHQUdHO0FBQ0gsTUFBTSxVQUFVLFlBQVksQ0FBQyxLQUFhO0lBRXRDLE9BQU8sVUFBUyxPQUFlLEVBQUUsV0FBbUIsRUFBRSxVQUE4Qjs7UUFFaEYsSUFBSSxPQUFlLENBQUM7UUFDcEIsSUFBSSxhQUFhLFNBQWEsVUFBVSxDQUFDLEtBQUssbUNBQUksVUFBVSxDQUFDLEdBQUcsRUFBRSxDQUFDO1FBRW5FLElBQUcsQ0FBQyxVQUFVLENBQUMsYUFBYSxDQUFDLEVBQzdCO1lBQ0ksTUFBTSxJQUFJLEtBQUssQ0FBQyxpREFBaUQsV0FBVyx3QkFBd0IsQ0FBQyxDQUFDO1NBQ3pHO1FBRUQsVUFBVSxDQUFDLEtBQUssR0FBRztZQUVmLElBQUksSUFBSSxHQUFHLFNBQVMsQ0FBQztZQUVyQixJQUFHLFNBQVMsQ0FBQyxPQUFPLENBQUMsRUFDckI7Z0JBQ0ksWUFBWSxDQUFDLE9BQU8sQ0FBQyxDQUFDO2FBQ3pCO1lBRUQsT0FBTyxHQUFHLFVBQVUsQ0FBQyxHQUFHLEVBQUU7Z0JBRXRCLGFBQWEsQ0FBQyxLQUFLLENBQUMsSUFBSSxFQUFFLElBQUksQ0FBQyxDQUFDO1lBQ3BDLENBQUMsRUFBRSxLQUFLLENBQVEsQ0FBQztRQUNyQixDQUFDLENBQUM7UUFFRixPQUFPLFVBQVUsQ0FBQztJQUN0QixDQUFDLENBQUM7QUFDTixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtpc0Z1bmN0aW9uLCBpc1ByZXNlbnR9IGZyb20gJy4uL3V0aWxzJztcclxuXHJcbi8qKlxyXG4gKiBBZGRzIHNwZWNpYWwgZnVuY3Rpb25hbGl0eSB0byBtZXRob2QgY2FsbCwgdGhhdCBkZWJvdW5jZSBtZXRob2QgY2FsbCBmb3Igc3BlY2lmaWVkIHRpbWVcclxuICogQHBhcmFtIGRlbGF5IC0gTnVtYmVyIG9mIG1pbGlzZWNvbmRzIHRoYXQgZGVsYXlzIGZ1bmN0aW9uIGNhbGxcclxuICovXHJcbmV4cG9ydCBmdW5jdGlvbiBEZWJvdW5jZUNhbGwoZGVsYXk6IG51bWJlcik6IE1ldGhvZERlY29yYXRvclxyXG57XHJcbiAgICByZXR1cm4gZnVuY3Rpb24oX3RhcmdldDogb2JqZWN0LCBwcm9wZXJ0eUtleTogc3RyaW5nLCBkZXNjcmlwdG9yOiBQcm9wZXJ0eURlc2NyaXB0b3IpXHJcbiAgICB7XHJcbiAgICAgICAgbGV0IHRpbWVvdXQ6IG51bWJlcjtcclxuICAgICAgICBsZXQgb3JpZ2luYWxWYWx1ZTogRnVuY3Rpb24gPSBkZXNjcmlwdG9yLnZhbHVlID8/IGRlc2NyaXB0b3IuZ2V0KCk7XHJcblxyXG4gICAgICAgIGlmKCFpc0Z1bmN0aW9uKG9yaWdpbmFsVmFsdWUpKVxyXG4gICAgICAgIHtcclxuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKGBVbmFibGUgdG8gYXBwbHkgQERlYm91bmNlQ2FsbCgpIGRlY29yYXRvciB0byAnJHtwcm9wZXJ0eUtleX0nLCBpdCBpcyBub3QgYSBtZXRob2QuYCk7XHJcbiAgICAgICAgfVxyXG5cclxuICAgICAgICBkZXNjcmlwdG9yLnZhbHVlID0gZnVuY3Rpb24oKVxyXG4gICAgICAgIHtcclxuICAgICAgICAgICAgbGV0IGFyZ3MgPSBhcmd1bWVudHM7XHJcblxyXG4gICAgICAgICAgICBpZihpc1ByZXNlbnQodGltZW91dCkpXHJcbiAgICAgICAgICAgIHtcclxuICAgICAgICAgICAgICAgIGNsZWFyVGltZW91dCh0aW1lb3V0KTtcclxuICAgICAgICAgICAgfVxyXG5cclxuICAgICAgICAgICAgdGltZW91dCA9IHNldFRpbWVvdXQoKCkgPT5cclxuICAgICAgICAgICAge1xyXG4gICAgICAgICAgICAgICAgb3JpZ2luYWxWYWx1ZS5hcHBseSh0aGlzLCBhcmdzKTtcclxuICAgICAgICAgICAgfSwgZGVsYXkpIGFzIGFueTtcclxuICAgICAgICB9O1xyXG5cclxuICAgICAgICByZXR1cm4gZGVzY3JpcHRvcjtcclxuICAgIH07XHJcbn0iXX0=
|
|
1
|
+
import { isFunction, isPresent } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Adds special functionality to method call, that debounce method call for specified time
|
|
4
|
+
* @param delay - Number of miliseconds that delays function call
|
|
5
|
+
*/
|
|
6
|
+
export function DebounceCall(delay) {
|
|
7
|
+
return function (_target, propertyKey, descriptor) {
|
|
8
|
+
var _a, _b;
|
|
9
|
+
let timeout;
|
|
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 (!isFunction(originalValue)) {
|
|
12
|
+
throw new Error(`Unable to apply @DebounceCall() decorator to '${propertyKey.toString()}', it is not a method.`);
|
|
13
|
+
}
|
|
14
|
+
descriptor.value = function (...args) {
|
|
15
|
+
if (isPresent(timeout)) {
|
|
16
|
+
clearTimeout(timeout);
|
|
17
|
+
}
|
|
18
|
+
timeout = setTimeout(() => {
|
|
19
|
+
originalValue.apply(this, args);
|
|
20
|
+
}, delay);
|
|
21
|
+
};
|
|
22
|
+
return descriptor;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
//# 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,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,UAAU,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,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,UAAU,CAAC,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,SAAS,CAAC,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","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,4 +1,4 @@
|
|
|
1
|
-
export * from './bindThis.decorator';
|
|
2
|
-
export * from './callOnce.decorator';
|
|
3
|
-
export * from './debounceCall.decorator';
|
|
4
|
-
//# sourceMappingURL=
|
|
1
|
+
export * from './bindThis.decorator';
|
|
2
|
+
export * from './callOnce.decorator';
|
|
3
|
+
export * from './debounceCall.decorator';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './bindThis.decorator';\r\nexport * from './callOnce.decorator';\r\nexport * from './debounceCall.decorator';"]}
|