@spscommerce/utils 5.5.0-ie → 5.7.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/out-tsc → lib}/array/flatten.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/flatten.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/is-subset.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/is-subset.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/range.d.ts +0 -0
- package/{dist/out-tsc → lib}/array/range.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/classes/custom-event.d.ts +0 -0
- package/{dist/out-tsc → lib}/classes/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/data/doctypes.d.ts +0 -0
- package/{dist/out-tsc → lib}/data/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/cast-to-number.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/debounced.broken_spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/debounced.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/locked-to-animation-frames.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/locked-to-animation-frames.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/simple-metadata-decorator-applicator.d.ts +0 -0
- package/{dist/out-tsc → lib}/decorators/tick-delay.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/debounce.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/debounce.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/debounced-function.interface.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/delayed-function.interface.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/lock-to-animation-frames.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/lock-to-animation-frames.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/on-next-tick.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/on-next-tick.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/op.d.ts +0 -0
- package/{dist/out-tsc → lib}/function/op.spec.d.ts +0 -0
- package/lib/index.cjs.js +1 -0
- package/{dist/out-tsc → lib}/index.d.ts +0 -0
- package/lib/index.es.js +1024 -0
- package/{dist/out-tsc → lib}/number/constrain.d.ts +0 -0
- package/{dist/out-tsc → lib}/number/decimal-round.d.ts +0 -0
- package/{dist/out-tsc → lib}/number/decimal-round.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/number/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/number/to-file-size-string.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/copy-property.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/copy-property.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/crumble-path.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/crumble-path.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/deep-freeze.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/deep-freeze.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/diff.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/diff.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/for-each-entry-deep.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/for-each-entry-deep.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/for-each-nested-object.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/for-each-nested-object.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/get-path.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/get-path.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/merge-deep.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/merge-deep.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/merge-properties-deep.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/merge-properties-deep.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/omit.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/omit.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/set-path.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/set-path.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/traverse-path.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/values.d.ts +0 -0
- package/{dist/out-tsc → lib}/object/values.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/string/code.template-tag.d.ts +0 -0
- package/{dist/out-tsc → lib}/string/index.d.ts +0 -0
- package/{dist/out-tsc → lib}/string/parse-file-size.d.ts +0 -0
- package/{dist/out-tsc → lib}/string/template.d.ts +0 -0
- package/{dist/out-tsc → lib}/string/template.spec.d.ts +0 -0
- package/{dist/out-tsc → lib}/typings.d.ts +0 -0
- package/package.json +5 -5
- package/vite.config.js +1 -1
- package/.pnpm-debug.log +0 -20
- package/dist/out-tsc/array/flatten.js +0 -7
- package/dist/out-tsc/array/flatten.js.map +0 -1
- package/dist/out-tsc/array/flatten.spec.js +0 -10
- package/dist/out-tsc/array/flatten.spec.js.map +0 -1
- package/dist/out-tsc/array/index.js +0 -4
- package/dist/out-tsc/array/index.js.map +0 -1
- package/dist/out-tsc/array/is-subset.js +0 -41
- package/dist/out-tsc/array/is-subset.js.map +0 -1
- package/dist/out-tsc/array/is-subset.spec.js +0 -41
- package/dist/out-tsc/array/is-subset.spec.js.map +0 -1
- package/dist/out-tsc/array/range.js +0 -16
- package/dist/out-tsc/array/range.js.map +0 -1
- package/dist/out-tsc/array/range.spec.js +0 -26
- package/dist/out-tsc/array/range.spec.js.map +0 -1
- package/dist/out-tsc/classes/custom-event.js +0 -87
- package/dist/out-tsc/classes/custom-event.js.map +0 -1
- package/dist/out-tsc/classes/index.js +0 -2
- package/dist/out-tsc/classes/index.js.map +0 -1
- package/dist/out-tsc/data/doctypes.js +0 -302
- package/dist/out-tsc/data/doctypes.js.map +0 -1
- package/dist/out-tsc/data/index.js +0 -2
- package/dist/out-tsc/data/index.js.map +0 -1
- package/dist/out-tsc/decorators/cast-to-number.js +0 -29
- package/dist/out-tsc/decorators/cast-to-number.js.map +0 -1
- package/dist/out-tsc/decorators/debounced.broken_spec.js +0 -38
- package/dist/out-tsc/decorators/debounced.broken_spec.js.map +0 -1
- package/dist/out-tsc/decorators/debounced.js +0 -35
- package/dist/out-tsc/decorators/debounced.js.map +0 -1
- package/dist/out-tsc/decorators/index.js +0 -6
- package/dist/out-tsc/decorators/index.js.map +0 -1
- package/dist/out-tsc/decorators/locked-to-animation-frames.js +0 -34
- package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +0 -1
- package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +0 -63
- package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +0 -1
- package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +0 -80
- package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +0 -1
- package/dist/out-tsc/decorators/tick-delay.js +0 -31
- package/dist/out-tsc/decorators/tick-delay.js.map +0 -1
- package/dist/out-tsc/function/debounce.js +0 -102
- package/dist/out-tsc/function/debounce.js.map +0 -1
- package/dist/out-tsc/function/debounce.spec.js +0 -150
- package/dist/out-tsc/function/debounce.spec.js.map +0 -1
- package/dist/out-tsc/function/debounced-function.interface.js +0 -2
- package/dist/out-tsc/function/debounced-function.interface.js.map +0 -1
- package/dist/out-tsc/function/delayed-function.interface.js +0 -2
- package/dist/out-tsc/function/delayed-function.interface.js.map +0 -1
- package/dist/out-tsc/function/index.js +0 -7
- package/dist/out-tsc/function/index.js.map +0 -1
- package/dist/out-tsc/function/lock-to-animation-frames.js +0 -43
- package/dist/out-tsc/function/lock-to-animation-frames.js.map +0 -1
- package/dist/out-tsc/function/lock-to-animation-frames.spec.js +0 -53
- package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +0 -1
- package/dist/out-tsc/function/on-next-tick.js +0 -12
- package/dist/out-tsc/function/on-next-tick.js.map +0 -1
- package/dist/out-tsc/function/on-next-tick.spec.js +0 -13
- package/dist/out-tsc/function/on-next-tick.spec.js.map +0 -1
- package/dist/out-tsc/function/op.js +0 -34
- package/dist/out-tsc/function/op.js.map +0 -1
- package/dist/out-tsc/function/op.spec.js +0 -94
- package/dist/out-tsc/function/op.spec.js.map +0 -1
- package/dist/out-tsc/index.js +0 -10
- package/dist/out-tsc/index.js.map +0 -1
- package/dist/out-tsc/number/constrain.js +0 -16
- package/dist/out-tsc/number/constrain.js.map +0 -1
- package/dist/out-tsc/number/decimal-round.js +0 -19
- package/dist/out-tsc/number/decimal-round.js.map +0 -1
- package/dist/out-tsc/number/decimal-round.spec.js +0 -10
- package/dist/out-tsc/number/decimal-round.spec.js.map +0 -1
- package/dist/out-tsc/number/index.js +0 -4
- package/dist/out-tsc/number/index.js.map +0 -1
- package/dist/out-tsc/number/to-file-size-string.js +0 -24
- package/dist/out-tsc/number/to-file-size-string.js.map +0 -1
- package/dist/out-tsc/object/copy-property.js +0 -9
- package/dist/out-tsc/object/copy-property.js.map +0 -1
- package/dist/out-tsc/object/copy-property.spec.js +0 -16
- package/dist/out-tsc/object/copy-property.spec.js.map +0 -1
- package/dist/out-tsc/object/crumble-path.js +0 -9
- package/dist/out-tsc/object/crumble-path.js.map +0 -1
- package/dist/out-tsc/object/crumble-path.spec.js +0 -24
- package/dist/out-tsc/object/crumble-path.spec.js.map +0 -1
- package/dist/out-tsc/object/deep-freeze.js +0 -36
- package/dist/out-tsc/object/deep-freeze.js.map +0 -1
- package/dist/out-tsc/object/deep-freeze.spec.js +0 -14
- package/dist/out-tsc/object/deep-freeze.spec.js.map +0 -1
- package/dist/out-tsc/object/diff.js +0 -92
- package/dist/out-tsc/object/diff.js.map +0 -1
- package/dist/out-tsc/object/diff.spec.js +0 -40
- package/dist/out-tsc/object/diff.spec.js.map +0 -1
- package/dist/out-tsc/object/for-each-entry-deep.js +0 -38
- package/dist/out-tsc/object/for-each-entry-deep.js.map +0 -1
- package/dist/out-tsc/object/for-each-entry-deep.spec.js +0 -24
- package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +0 -1
- package/dist/out-tsc/object/for-each-nested-object.js +0 -38
- package/dist/out-tsc/object/for-each-nested-object.js.map +0 -1
- package/dist/out-tsc/object/for-each-nested-object.spec.js +0 -46
- package/dist/out-tsc/object/for-each-nested-object.spec.js.map +0 -1
- package/dist/out-tsc/object/get-path.js +0 -67
- package/dist/out-tsc/object/get-path.js.map +0 -1
- package/dist/out-tsc/object/get-path.spec.js +0 -44
- package/dist/out-tsc/object/get-path.spec.js.map +0 -1
- package/dist/out-tsc/object/index.js +0 -14
- package/dist/out-tsc/object/index.js.map +0 -1
- package/dist/out-tsc/object/merge-deep.js +0 -60
- package/dist/out-tsc/object/merge-deep.js.map +0 -1
- package/dist/out-tsc/object/merge-deep.spec.js +0 -16
- package/dist/out-tsc/object/merge-deep.spec.js.map +0 -1
- package/dist/out-tsc/object/merge-properties-deep.js +0 -61
- package/dist/out-tsc/object/merge-properties-deep.js.map +0 -1
- package/dist/out-tsc/object/merge-properties-deep.spec.js +0 -24
- package/dist/out-tsc/object/merge-properties-deep.spec.js.map +0 -1
- package/dist/out-tsc/object/omit.js +0 -40
- package/dist/out-tsc/object/omit.js.map +0 -1
- package/dist/out-tsc/object/omit.spec.js +0 -10
- package/dist/out-tsc/object/omit.spec.js.map +0 -1
- package/dist/out-tsc/object/set-path.js +0 -45
- package/dist/out-tsc/object/set-path.js.map +0 -1
- package/dist/out-tsc/object/set-path.spec.js +0 -36
- package/dist/out-tsc/object/set-path.spec.js.map +0 -1
- package/dist/out-tsc/object/traverse-path.js +0 -81
- package/dist/out-tsc/object/traverse-path.js.map +0 -1
- package/dist/out-tsc/object/values.js +0 -31
- package/dist/out-tsc/object/values.js.map +0 -1
- package/dist/out-tsc/object/values.spec.js +0 -7
- package/dist/out-tsc/object/values.spec.js.map +0 -1
- package/dist/out-tsc/string/code.template-tag.js +0 -38
- package/dist/out-tsc/string/code.template-tag.js.map +0 -1
- package/dist/out-tsc/string/index.js +0 -4
- package/dist/out-tsc/string/index.js.map +0 -1
- package/dist/out-tsc/string/parse-file-size.js +0 -43
- package/dist/out-tsc/string/parse-file-size.js.map +0 -1
- package/dist/out-tsc/string/template.js +0 -28
- package/dist/out-tsc/string/template.js.map +0 -1
- package/dist/out-tsc/string/template.spec.js +0 -39
- package/dist/out-tsc/string/template.spec.js.map +0 -1
- package/dist/out-tsc/typings.js +0 -2
- package/dist/out-tsc/typings.js.map +0 -1
- package/rollup.config.js +0 -22
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __values = (this && this.__values) || function(o) {
|
|
13
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
14
|
-
if (m) return m.call(o);
|
|
15
|
-
if (o && typeof o.length === "number") return {
|
|
16
|
-
next: function () {
|
|
17
|
-
if (o && i >= o.length) o = void 0;
|
|
18
|
-
return { value: o && o[i++], done: !o };
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* This would be simpler to understand as a factory that returns a decorator function,
|
|
25
|
-
* but TypeScript AoT compliation doesn't allow that. This lets you create a decorator
|
|
26
|
-
* that takes in a metadata object as an argument and assigns its values along with
|
|
27
|
-
* default values to the decorated method. The decorator will look like a standard
|
|
28
|
-
* decorator but calling this method and returning the result is the only thing it
|
|
29
|
-
* needs to do.
|
|
30
|
-
*/
|
|
31
|
-
export function simpleMetadataDecoratorApplicator(metadata, defaults, target, key, descriptor) {
|
|
32
|
-
var updatedDescriptor = descriptor || Object.getOwnPropertyDescriptor(target, key);
|
|
33
|
-
var getter = updatedDescriptor.get;
|
|
34
|
-
var value = updatedDescriptor.value;
|
|
35
|
-
updatedDescriptor.get = function get() {
|
|
36
|
-
var e_1, _a;
|
|
37
|
-
// I don't remember why I did this "this" alias & want to ensure we don't break anything...
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
39
|
-
var self = this;
|
|
40
|
-
var fn = value || getter.call(this);
|
|
41
|
-
var boundFn = fn.bind(this);
|
|
42
|
-
var updatedMetadata = __assign(__assign({}, defaults), metadata);
|
|
43
|
-
var _loop_1 = function (prop) {
|
|
44
|
-
if (typeof metadata[prop] === "function") {
|
|
45
|
-
Object.defineProperty(boundFn, prop, {
|
|
46
|
-
get: function () {
|
|
47
|
-
return updatedMetadata[prop](self);
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
boundFn[prop] = updatedMetadata[prop];
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
for (var _b = __values(Object.keys(defaults)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
57
|
-
var prop = _c.value;
|
|
58
|
-
_loop_1(prop);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
62
|
-
finally {
|
|
63
|
-
try {
|
|
64
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
65
|
-
}
|
|
66
|
-
finally { if (e_1) throw e_1.error; }
|
|
67
|
-
}
|
|
68
|
-
Object.defineProperty(this, key, {
|
|
69
|
-
writable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
enumerable: updatedDescriptor.enumerable,
|
|
72
|
-
value: boundFn,
|
|
73
|
-
});
|
|
74
|
-
return boundFn;
|
|
75
|
-
};
|
|
76
|
-
delete updatedDescriptor.value;
|
|
77
|
-
delete updatedDescriptor.writable;
|
|
78
|
-
return updatedDescriptor;
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=simple-metadata-decorator-applicator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"simple-metadata-decorator-applicator.js","sourceRoot":"","sources":["../../../src/decorators/simple-metadata-decorator-applicator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;;;GAOG;AACH,MAAM,UAAU,iCAAiC,CAC/C,QAAoB,EACpB,QAAW,EACX,MAAW,EACX,GAAgB,EAChB,UAAsC;IAEtC,IAAM,iBAAiB,GAAG,UAAU,IAAI,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrF,IAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,CAAC;IAC7B,IAAA,KAAK,GAAK,iBAAiB,MAAtB,CAAuB;IAEpC,iBAAiB,CAAC,GAAG,GAAG,SAAS,GAAG;;QAClC,2FAA2F;QAC3F,4DAA4D;QAC5D,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAM,EAAE,GAAG,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,IAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9B,IAAM,eAAe,yBAAQ,QAAQ,GAAK,QAAQ,CAAE,CAAC;gCAE1C,IAAI;YACb,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,UAAU,EAAE;gBACxC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE;oBACnC,GAAG;wBACD,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;oBACrC,CAAC;iBACF,CAAC,CAAC;aACJ;iBAAM;gBACL,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;aACvC;;;YATH,KAAmB,IAAA,KAAA,SAAA,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA,gBAAA;gBAAnC,IAAM,IAAI,WAAA;wBAAJ,IAAI;aAUd;;;;;;;;;QAED,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE;YAC/B,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,iBAAiB,CAAC,UAAU;YACxC,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,iBAAiB,CAAC,KAAK,CAAC;IAC/B,OAAO,iBAAiB,CAAC,QAAQ,CAAC;IAElC,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
/** Method decorator that configures the method to always run the tick after it's invoked */
|
|
13
|
-
export function tickDelay(target, propertyKey, descriptor) {
|
|
14
|
-
var originalDescriptorCopy = __assign({}, descriptor);
|
|
15
|
-
originalDescriptorCopy.get = function get() {
|
|
16
|
-
/*
|
|
17
|
-
* Make a new copy each time; if you don't then every instance after the first
|
|
18
|
-
* one of the class containing the decorated method will break.
|
|
19
|
-
*/
|
|
20
|
-
var newDescriptor = __assign({}, originalDescriptorCopy);
|
|
21
|
-
var boundFn = originalDescriptorCopy.value.bind(this);
|
|
22
|
-
newDescriptor.value = function () { return setTimeout(boundFn, 0); };
|
|
23
|
-
Object.defineProperty(this, propertyKey, newDescriptor);
|
|
24
|
-
return newDescriptor.value;
|
|
25
|
-
};
|
|
26
|
-
originalDescriptorCopy.configurable = true;
|
|
27
|
-
delete originalDescriptorCopy.writable;
|
|
28
|
-
delete originalDescriptorCopy.value;
|
|
29
|
-
return originalDescriptorCopy;
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=tick-delay.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tick-delay.js","sourceRoot":"","sources":["../../../src/decorators/tick-delay.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,4FAA4F;AAC5F,MAAM,UAAU,SAAS,CACvB,MAAW,EACX,WAAmB,EACnB,UAAsC;IAEtC,IAAM,sBAAsB,gBAAoC,UAAU,CAAE,CAAC;IAC7E,sBAAsB,CAAC,GAAG,GAAG,SAAS,GAAG;QACvC;;;WAGG;QACH,IAAM,aAAa,gBAAQ,sBAAsB,CAAE,CAAC;QACpD,IAAM,OAAO,GAAoC,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzF,aAAa,CAAC,KAAK,GAAG,cAAM,OAAA,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAtB,CAAsB,CAAC;QACnD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;QACxD,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC,CAAC;IACF,sBAAsB,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3C,OAAO,sBAAsB,CAAC,QAAQ,CAAC;IACvC,OAAO,sBAAsB,CAAC,KAAK,CAAC;IACpC,OAAO,sBAAsB,CAAC;AAChC,CAAC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* If the function is set to be called, cancel the
|
|
39
|
-
* timeout that would call it. Reset id & pending to defaults.
|
|
40
|
-
*
|
|
41
|
-
* @returns - Whether an invocation was actually canceled or not.
|
|
42
|
-
*/
|
|
43
|
-
function resetDebouncedFn() {
|
|
44
|
-
this.pending = false;
|
|
45
|
-
if (typeof this.id === "number") {
|
|
46
|
-
clearTimeout(this.id);
|
|
47
|
-
delete this.id;
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Takes in a function and returns a new function that debounces it.
|
|
54
|
-
* The returned function returns an observable that can be subscribed to
|
|
55
|
-
* if you need to have something happen when the debounced function
|
|
56
|
-
* finally gets called and returns a value.
|
|
57
|
-
*/
|
|
58
|
-
export function debounce(functionToDebounce, milliseconds, thisArg) {
|
|
59
|
-
var debFn = function debouncedFn() {
|
|
60
|
-
var args = [];
|
|
61
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
62
|
-
args[_i] = arguments[_i];
|
|
63
|
-
}
|
|
64
|
-
return new Promise(function (resolve, reject) {
|
|
65
|
-
debFn.reset();
|
|
66
|
-
debFn.pending = true;
|
|
67
|
-
function executor() {
|
|
68
|
-
var _this = this;
|
|
69
|
-
void (function () { return __awaiter(_this, void 0, void 0, function () {
|
|
70
|
-
var output, err_1;
|
|
71
|
-
return __generator(this, function (_a) {
|
|
72
|
-
switch (_a.label) {
|
|
73
|
-
case 0:
|
|
74
|
-
_a.trys.push([0, 3, 4, 5]);
|
|
75
|
-
output = functionToDebounce.apply(thisArg || this, args);
|
|
76
|
-
if (!(output instanceof Promise)) return [3 /*break*/, 2];
|
|
77
|
-
return [4 /*yield*/, output];
|
|
78
|
-
case 1:
|
|
79
|
-
output = _a.sent();
|
|
80
|
-
_a.label = 2;
|
|
81
|
-
case 2:
|
|
82
|
-
resolve(output);
|
|
83
|
-
return [3 /*break*/, 5];
|
|
84
|
-
case 3:
|
|
85
|
-
err_1 = _a.sent();
|
|
86
|
-
reject(err_1);
|
|
87
|
-
return [3 /*break*/, 5];
|
|
88
|
-
case 4:
|
|
89
|
-
debFn.reset();
|
|
90
|
-
return [7 /*endfinally*/];
|
|
91
|
-
case 5: return [2 /*return*/];
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}); })();
|
|
95
|
-
}
|
|
96
|
-
debFn.id = window.setTimeout(executor, milliseconds);
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
debFn.reset = resetDebouncedFn.bind(debFn);
|
|
100
|
-
return debFn;
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","sourceRoot":"","sources":["../../../src/function/debounce.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA;;;;;GAKG;AACH,SAAS,gBAAgB;IACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACrB,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,EAAE;QAC/B,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,kBAAqD,EACrD,YAAoB,EACpB,OAAa;IAEb,IAAM,KAAK,GAAyB,SAAS,WAAW;QAAC,cAAc;aAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;YAAd,yBAAc;;QACrE,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YACjC,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;YAErB,SAAS,QAAQ;gBAAjB,iBAcC;gBAbC,KAAK,CAAC;;;;;;gCAEE,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,EAAE,IAAI,CAAC,CAAC;qCACzD,CAAA,MAAM,YAAY,OAAO,CAAA,EAAzB,wBAAyB;gCAClB,qBAAM,MAAM,EAAA;;gCAArB,MAAM,GAAG,SAAY,CAAC;;;gCAExB,OAAO,CAAC,MAAM,CAAC,CAAC;;;;gCAEhB,MAAM,CAAC,KAAG,CAAC,CAAC;;;gCAEZ,KAAK,CAAC,KAAK,EAAE,CAAC;;;;;qBAEjB,CAAC,EAAE,CAAC;YACP,CAAC;YAED,KAAK,CAAC,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,KAAK,CAAC,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE3C,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
-
if (!m) return o;
|
|
40
|
-
var i = m.call(o), r, ar = [], e;
|
|
41
|
-
try {
|
|
42
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
-
}
|
|
44
|
-
catch (error) { e = { error: error }; }
|
|
45
|
-
finally {
|
|
46
|
-
try {
|
|
47
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
-
}
|
|
49
|
-
finally { if (e) throw e.error; }
|
|
50
|
-
}
|
|
51
|
-
return ar;
|
|
52
|
-
};
|
|
53
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
-
if (ar || !(i in from)) {
|
|
56
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
-
ar[i] = from[i];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
-
};
|
|
62
|
-
import { debounce } from "./debounce";
|
|
63
|
-
function flushPromises() {
|
|
64
|
-
return new Promise(function (resolve) {
|
|
65
|
-
// eslint-disable-next-line no-undef
|
|
66
|
-
setImmediate(resolve);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function testDebounce(fn, callback, args, result) {
|
|
70
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
function fnAndCallbackHaveNotBeenCalled() {
|
|
72
|
-
expect(fn).not.toHaveBeenCalled();
|
|
73
|
-
expect(callback).not.toHaveBeenCalled();
|
|
74
|
-
}
|
|
75
|
-
var debounced;
|
|
76
|
-
var _a;
|
|
77
|
-
return __generator(this, function (_b) {
|
|
78
|
-
switch (_b.label) {
|
|
79
|
-
case 0:
|
|
80
|
-
debounced = debounce(fn, 1000);
|
|
81
|
-
void debounced.apply(void 0, __spreadArray([], __read(args), false)).then(callback);
|
|
82
|
-
fnAndCallbackHaveNotBeenCalled();
|
|
83
|
-
jest.advanceTimersByTime(999);
|
|
84
|
-
fnAndCallbackHaveNotBeenCalled();
|
|
85
|
-
void debounced.apply(void 0, __spreadArray([], __read(args), false)).then(callback);
|
|
86
|
-
jest.advanceTimersByTime(1);
|
|
87
|
-
fnAndCallbackHaveNotBeenCalled();
|
|
88
|
-
jest.advanceTimersByTime(998);
|
|
89
|
-
fnAndCallbackHaveNotBeenCalled();
|
|
90
|
-
jest.advanceTimersByTime(1);
|
|
91
|
-
return [4 /*yield*/, flushPromises()];
|
|
92
|
-
case 1:
|
|
93
|
-
_b.sent();
|
|
94
|
-
(_a = expect(fn)).toHaveBeenCalledWith.apply(_a, __spreadArray([], __read(args), false));
|
|
95
|
-
expect(callback).toHaveBeenCalledWith(result);
|
|
96
|
-
return [2 /*return*/];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
describe("debounce", function () {
|
|
102
|
-
beforeEach(function () {
|
|
103
|
-
jest.useFakeTimers();
|
|
104
|
-
});
|
|
105
|
-
afterAll(function () {
|
|
106
|
-
jest.useRealTimers();
|
|
107
|
-
});
|
|
108
|
-
test("returns a new, debounced version of the function", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
-
var expectedArguments, fn, callback;
|
|
110
|
-
return __generator(this, function (_a) {
|
|
111
|
-
switch (_a.label) {
|
|
112
|
-
case 0:
|
|
113
|
-
expectedArguments = 2;
|
|
114
|
-
fn = jest.fn(function () { return expectedArguments; });
|
|
115
|
-
callback = jest.fn(function (arg) { return arg; });
|
|
116
|
-
return [4 /*yield*/, testDebounce(fn, callback, [1, "foo"], expectedArguments)];
|
|
117
|
-
case 1:
|
|
118
|
-
_a.sent();
|
|
119
|
-
return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}); });
|
|
123
|
-
test("works with a function that returns a Promise", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
124
|
-
var result, fn, callback;
|
|
125
|
-
return __generator(this, function (_a) {
|
|
126
|
-
switch (_a.label) {
|
|
127
|
-
case 0:
|
|
128
|
-
result = 2;
|
|
129
|
-
fn = jest.fn(function () { return Promise.resolve(result); });
|
|
130
|
-
callback = jest.fn(function (arg) { return arg; });
|
|
131
|
-
return [4 /*yield*/, testDebounce(fn, callback, [], 2)];
|
|
132
|
-
case 1:
|
|
133
|
-
_a.sent();
|
|
134
|
-
return [2 /*return*/];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); });
|
|
138
|
-
test("is cancelable with reset()", function () {
|
|
139
|
-
var fn = jest.fn(function () { return 2; });
|
|
140
|
-
var callback = jest.fn();
|
|
141
|
-
var debounced = debounce(fn, 1000);
|
|
142
|
-
void debounced().then(callback);
|
|
143
|
-
jest.advanceTimersByTime(999);
|
|
144
|
-
debounced.reset();
|
|
145
|
-
jest.advanceTimersByTime(1);
|
|
146
|
-
expect(fn).not.toHaveBeenCalled();
|
|
147
|
-
expect(callback).not.toHaveBeenCalled();
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
//# sourceMappingURL=debounce.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.spec.js","sourceRoot":"","sources":["../../../src/function/debounce.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,SAAS,aAAa;IACpB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;QACzB,oCAAoC;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,EAAE,CAAC;QAClB,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debounced-function.interface.js","sourceRoot":"","sources":["../../../src/function/debounced-function.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delayed-function.interface.js","sourceRoot":"","sources":["../../../src/function/delayed-function.interface.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/function/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,MAAM,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If the function is set to be called, cancel the
|
|
3
|
-
* timeout that would call it. Reset id & pending to defaults.
|
|
4
|
-
*
|
|
5
|
-
* @returns - Whether an invocation was actually canceled or not.
|
|
6
|
-
*/
|
|
7
|
-
function resetLockedFn() {
|
|
8
|
-
this.pending = false;
|
|
9
|
-
if (typeof this.id === "number") {
|
|
10
|
-
window.cancelAnimationFrame(this.id);
|
|
11
|
-
delete this.id;
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Return a new function to replace the passed in one which ensures that
|
|
18
|
-
* the given function will run only in `requestAnimationFrame()` and at
|
|
19
|
-
* most once per frame.
|
|
20
|
-
*/
|
|
21
|
-
export function lockToAnimationFrames(functionToLock, thisArg) {
|
|
22
|
-
var lockFn = function lockedFn() {
|
|
23
|
-
var _this = this;
|
|
24
|
-
var args = [];
|
|
25
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
26
|
-
args[_i] = arguments[_i];
|
|
27
|
-
}
|
|
28
|
-
if (lockFn.pending) {
|
|
29
|
-
lockFn.reset();
|
|
30
|
-
}
|
|
31
|
-
lockFn.id = window.requestAnimationFrame(function () {
|
|
32
|
-
if (functionToLock) {
|
|
33
|
-
functionToLock.apply(thisArg || _this, args);
|
|
34
|
-
}
|
|
35
|
-
lockFn.reset();
|
|
36
|
-
});
|
|
37
|
-
lockFn.pending = true;
|
|
38
|
-
};
|
|
39
|
-
lockFn.pending = false;
|
|
40
|
-
lockFn.reset = resetLockedFn.bind(lockFn);
|
|
41
|
-
return lockFn;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=lock-to-animation-frames.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lock-to-animation-frames.js","sourceRoot":"","sources":["../../../src/function/lock-to-animation-frames.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,SAAS,aAAa;IACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACrB,IAAI,OAAO,IAAI,CAAC,EAAE,KAAK,QAAQ,EAAE;QAC/B,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAyB,EACzB,OAAa;IAEb,IAAM,MAAM,GAAyB,SAAS,QAAQ;QAAjB,iBAYpC;QAZsD,cAAO;aAAP,UAAO,EAAP,qBAAO,EAAP,IAAO;YAAP,yBAAO;;QAC5D,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,MAAM,CAAC,KAAK,EAAE,CAAC;SAChB;QACD,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,qBAAqB,CAAC;YACvC,IAAI,cAAc,EAAE;gBAClB,cAAc,CAAC,KAAK,CAAC,OAAO,IAAI,KAAI,EAAE,IAAI,CAAC,CAAC;aAC7C;YAED,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC,CAAC;IAEF,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// TODO: This was written for Jasmine, needs to be updated for Jest
|
|
2
|
-
/*
|
|
3
|
-
* import createRAFStub from "raf-stub";
|
|
4
|
-
* import { lockToAnimationFrames } from "./lock-to-animation-frames";
|
|
5
|
-
*/
|
|
6
|
-
describe("lockToAnimationFrames", function () {
|
|
7
|
-
/*
|
|
8
|
-
* let rAFStub; let f; let
|
|
9
|
-
* locked;
|
|
10
|
-
*/
|
|
11
|
-
beforeEach(function () {
|
|
12
|
-
/*
|
|
13
|
-
* rAFStub = createRAFStub();
|
|
14
|
-
* spyOn(window, "requestAnimationFrame").and.callFake(rAFStub.add);
|
|
15
|
-
* spyOn(window, "cancelAnimationFrame").and.callFake(rAFStub.remove);
|
|
16
|
-
* f = jasmine.createSpy();
|
|
17
|
-
* locked = lockToAnimationFrames(f);
|
|
18
|
-
*/
|
|
19
|
-
});
|
|
20
|
-
test("returns a function that runs the passed in function only in RAF", function () {
|
|
21
|
-
/*
|
|
22
|
-
* locked();
|
|
23
|
-
* expect(f).not.toHaveBeenCalled();
|
|
24
|
-
* rAFStub.step();
|
|
25
|
-
* expect(f).toHaveBeenCalled();
|
|
26
|
-
*/
|
|
27
|
-
});
|
|
28
|
-
test("allows the function to run at most once per frame", function () {
|
|
29
|
-
/*
|
|
30
|
-
* locked();
|
|
31
|
-
* locked();
|
|
32
|
-
* locked();
|
|
33
|
-
* locked();
|
|
34
|
-
* locked();
|
|
35
|
-
* locked();
|
|
36
|
-
* locked();
|
|
37
|
-
* locked();
|
|
38
|
-
*/
|
|
39
|
-
/*
|
|
40
|
-
* rAFStub.step();
|
|
41
|
-
* expect(f).toHaveBeenCalledTimes(1);
|
|
42
|
-
*/
|
|
43
|
-
});
|
|
44
|
-
test("is cancelable with reset()", function () {
|
|
45
|
-
/*
|
|
46
|
-
* locked();
|
|
47
|
-
* locked.reset();
|
|
48
|
-
* rAFStub.step();
|
|
49
|
-
* expect(f).not.toHaveBeenCalled();
|
|
50
|
-
*/
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
//# sourceMappingURL=lock-to-animation-frames.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lock-to-animation-frames.spec.js","sourceRoot":"","sources":["../../../src/function/lock-to-animation-frames.spec.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAEnE;;;GAGG;AAEH,QAAQ,CAAC,uBAAuB,EAAE;IAChC;;;OAGG;IAEH,UAAU,CAAC;QACT;;;;;;WAMG;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iEAAiE,EAAE;QACtE;;;;;WAKG;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,mDAAmD,EAAE;QACxD;;;;;;;;;WASG;QAEH;;;WAGG;IACL,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,4BAA4B,EAAE;QACjC;;;;;WAKG;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Enqueues the given function to run on the next "tick" of the JS event
|
|
3
|
-
* loop cycle. If you ever encounter the "value changed after it was
|
|
4
|
-
* checked" error in Angular when trying to assign a value of a
|
|
5
|
-
* component class, performing that assignment on the next tick, i.e. when
|
|
6
|
-
* all of Angular's current cycle is finished, will resolve that error.
|
|
7
|
-
*/
|
|
8
|
-
export function onNextTick(fn, thisArg) {
|
|
9
|
-
var boundFn = thisArg ? fn.bind(thisArg) : fn;
|
|
10
|
-
setTimeout(boundFn, 0);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=on-next-tick.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"on-next-tick.js","sourceRoot":"","sources":["../../../src/function/on-next-tick.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,EAAmC,EAAE,OAAa;IAC3E,IAAM,OAAO,GAAoC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjF,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { onNextTick } from "./on-next-tick";
|
|
2
|
-
describe("onNextTick", function () {
|
|
3
|
-
test("does a thing?", function (done) {
|
|
4
|
-
var fn = jest.fn();
|
|
5
|
-
onNextTick(fn);
|
|
6
|
-
expect(fn).not.toHaveBeenCalled();
|
|
7
|
-
onNextTick(function () {
|
|
8
|
-
expect(fn).toHaveBeenCalled();
|
|
9
|
-
done();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=on-next-tick.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"on-next-tick.spec.js","sourceRoot":"","sources":["../../../src/function/on-next-tick.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,QAAQ,CAAC,YAAY,EAAE;IACrB,IAAI,CAAC,eAAe,EAAE,UAAC,IAAI;QACzB,IAAM,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QACrB,UAAU,CAAC,EAAE,CAAC,CAAC;QACf,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAClC,UAAU,CAAC;YACT,MAAM,CAAC,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC;YAC9B,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Functions for various operators, most useful in combination
|
|
3
|
-
* with functional programming tools like map, filter, and reduce.
|
|
4
|
-
*/
|
|
5
|
-
export var Op = {
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
7
|
-
add: function (a, b) { return a + b; },
|
|
8
|
-
and: function (a, b) { return a && b; },
|
|
9
|
-
band: function (a, b) { return a & b; },
|
|
10
|
-
bor: function (a, b) { return a | b; },
|
|
11
|
-
bxor: function (a, b) { return a ^ b; },
|
|
12
|
-
bnot: function (a) { return ~a; },
|
|
13
|
-
decr: function (a) { return a - 1; },
|
|
14
|
-
div: function (a, b) { return a / b; },
|
|
15
|
-
eq: function (a, b) { return a === b; },
|
|
16
|
-
exp: function (a, b) { return Math.pow(a, b); },
|
|
17
|
-
gt: function (a, b) { return a > b; },
|
|
18
|
-
gte: function (a, b) { return a >= b; },
|
|
19
|
-
incr: function (a) { return a + 1; },
|
|
20
|
-
lshift: function (a, b) { return a << b; },
|
|
21
|
-
lt: function (a, b) { return a < b; },
|
|
22
|
-
lte: function (a, b) { return a <= b; },
|
|
23
|
-
mul: function (a, b) { return a * b; },
|
|
24
|
-
neg: function (a) { return -a; },
|
|
25
|
-
neq: function (a, b) { return a !== b; },
|
|
26
|
-
not: function (a) { return !a; },
|
|
27
|
-
or: function (a, b) { return a || b; },
|
|
28
|
-
rem: function (a, b) { return a % b; },
|
|
29
|
-
rshift: function (a, b) { return a >> b; },
|
|
30
|
-
rshift_zf: function (a, b) { return a >>> b; },
|
|
31
|
-
sub: function (a, b) { return a - b; },
|
|
32
|
-
xor: function (a, b) { return (a || b) && !(a && b); },
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=op.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"op.js","sourceRoot":"","sources":["../../../src/function/op.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,IAAM,EAAE,GAAG;IAChB,qEAAqE;IACrE,GAAG,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAEpB,GAAG,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,IAAI,CAAC,EAAN,CAAM;IAErB,IAAI,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAErB,GAAG,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAEpB,IAAI,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAErB,IAAI,EAAE,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,EAAF,CAAE;IAEf,IAAI,EAAE,UAAC,CAAS,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAE1B,GAAG,EAAE,UAAC,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAEpC,EAAE,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,KAAK,CAAC,EAAP,CAAO;IAErB,GAAG,EAAE,UAAC,CAAS,EAAE,CAAS,IAAK,OAAA,SAAA,CAAC,EAAI,CAAC,CAAA,EAAN,CAAM;IAErC,EAAE,EAAE,UAAC,CAAC,EAAE,C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