@spscommerce/utils 5.18.2 → 5.18.3-ie

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.
Files changed (209) hide show
  1. package/dist/out-tsc/array/flatten.d.ts +1 -0
  2. package/dist/out-tsc/array/flatten.js +7 -0
  3. package/dist/out-tsc/array/flatten.js.map +1 -0
  4. package/dist/out-tsc/array/flatten.spec.d.ts +1 -0
  5. package/dist/out-tsc/array/flatten.spec.js +10 -0
  6. package/dist/out-tsc/array/flatten.spec.js.map +1 -0
  7. package/dist/out-tsc/array/index.d.ts +3 -0
  8. package/dist/out-tsc/array/index.js +4 -0
  9. package/dist/out-tsc/array/index.js.map +1 -0
  10. package/dist/out-tsc/array/is-subset.d.ts +4 -0
  11. package/dist/out-tsc/array/is-subset.js +41 -0
  12. package/dist/out-tsc/array/is-subset.js.map +1 -0
  13. package/dist/out-tsc/array/is-subset.spec.d.ts +1 -0
  14. package/dist/out-tsc/array/is-subset.spec.js +41 -0
  15. package/dist/out-tsc/array/is-subset.spec.js.map +1 -0
  16. package/dist/out-tsc/array/range.d.ts +5 -0
  17. package/dist/out-tsc/array/range.js +16 -0
  18. package/dist/out-tsc/array/range.js.map +1 -0
  19. package/dist/out-tsc/array/range.spec.d.ts +1 -0
  20. package/dist/out-tsc/array/range.spec.js +26 -0
  21. package/dist/out-tsc/array/range.spec.js.map +1 -0
  22. package/dist/out-tsc/classes/custom-event.d.ts +4 -0
  23. package/dist/out-tsc/classes/custom-event.js +87 -0
  24. package/dist/out-tsc/classes/custom-event.js.map +1 -0
  25. package/dist/out-tsc/classes/index.d.ts +1 -0
  26. package/dist/out-tsc/classes/index.js +2 -0
  27. package/dist/out-tsc/classes/index.js.map +1 -0
  28. package/dist/out-tsc/data/doctypes.d.ts +4 -0
  29. package/dist/out-tsc/data/doctypes.js +302 -0
  30. package/dist/out-tsc/data/doctypes.js.map +1 -0
  31. package/dist/out-tsc/data/index.d.ts +1 -0
  32. package/dist/out-tsc/data/index.js +2 -0
  33. package/dist/out-tsc/data/index.js.map +1 -0
  34. package/dist/out-tsc/decorators/cast-to-number.d.ts +5 -0
  35. package/dist/out-tsc/decorators/cast-to-number.js +29 -0
  36. package/dist/out-tsc/decorators/cast-to-number.js.map +1 -0
  37. package/dist/out-tsc/decorators/debounced.broken_spec.d.ts +0 -0
  38. package/dist/out-tsc/decorators/debounced.broken_spec.js +38 -0
  39. package/dist/out-tsc/decorators/debounced.broken_spec.js.map +1 -0
  40. package/dist/out-tsc/decorators/debounced.d.ts +11 -0
  41. package/dist/out-tsc/decorators/debounced.js +35 -0
  42. package/dist/out-tsc/decorators/debounced.js.map +1 -0
  43. package/dist/out-tsc/decorators/index.d.ts +5 -0
  44. package/dist/out-tsc/decorators/index.js +6 -0
  45. package/dist/out-tsc/decorators/index.js.map +1 -0
  46. package/dist/out-tsc/decorators/locked-to-animation-frames.d.ts +4 -0
  47. package/dist/out-tsc/decorators/locked-to-animation-frames.js +34 -0
  48. package/dist/out-tsc/decorators/locked-to-animation-frames.js.map +1 -0
  49. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.d.ts +0 -0
  50. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js +63 -0
  51. package/dist/out-tsc/decorators/locked-to-animation-frames.spec.js.map +1 -0
  52. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.d.ts +11 -0
  53. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js +80 -0
  54. package/dist/out-tsc/decorators/simple-metadata-decorator-applicator.js.map +1 -0
  55. package/dist/out-tsc/decorators/tick-delay.d.ts +6 -0
  56. package/dist/out-tsc/decorators/tick-delay.js +31 -0
  57. package/dist/out-tsc/decorators/tick-delay.js.map +1 -0
  58. package/dist/out-tsc/function/debounce.d.ts +9 -0
  59. package/dist/out-tsc/function/debounce.js +102 -0
  60. package/dist/out-tsc/function/debounce.js.map +1 -0
  61. package/dist/out-tsc/function/debounce.spec.d.ts +1 -0
  62. package/dist/out-tsc/function/debounce.spec.js +150 -0
  63. package/dist/out-tsc/function/debounce.spec.js.map +1 -0
  64. package/dist/out-tsc/function/debounced-function.interface.d.ts +10 -0
  65. package/dist/out-tsc/function/debounced-function.interface.js +2 -0
  66. package/dist/out-tsc/function/debounced-function.interface.js.map +1 -0
  67. package/dist/out-tsc/function/delayed-function.interface.d.ts +10 -0
  68. package/dist/out-tsc/function/delayed-function.interface.js +2 -0
  69. package/dist/out-tsc/function/delayed-function.interface.js.map +1 -0
  70. package/dist/out-tsc/function/index.d.ts +6 -0
  71. package/dist/out-tsc/function/index.js +7 -0
  72. package/dist/out-tsc/function/index.js.map +1 -0
  73. package/dist/out-tsc/function/lock-to-animation-frames.d.ts +7 -0
  74. package/dist/out-tsc/function/lock-to-animation-frames.js +43 -0
  75. package/dist/out-tsc/function/lock-to-animation-frames.js.map +1 -0
  76. package/dist/out-tsc/function/lock-to-animation-frames.spec.d.ts +0 -0
  77. package/dist/out-tsc/function/lock-to-animation-frames.spec.js +53 -0
  78. package/dist/out-tsc/function/lock-to-animation-frames.spec.js.map +1 -0
  79. package/dist/out-tsc/function/on-next-tick.d.ts +8 -0
  80. package/dist/out-tsc/function/on-next-tick.js +12 -0
  81. package/dist/out-tsc/function/on-next-tick.js.map +1 -0
  82. package/dist/out-tsc/function/on-next-tick.spec.d.ts +1 -0
  83. package/dist/out-tsc/function/on-next-tick.spec.js +13 -0
  84. package/dist/out-tsc/function/on-next-tick.spec.js.map +1 -0
  85. package/dist/out-tsc/function/op.d.ts +32 -0
  86. package/dist/out-tsc/function/op.js +34 -0
  87. package/dist/out-tsc/function/op.js.map +1 -0
  88. package/dist/out-tsc/function/op.spec.d.ts +1 -0
  89. package/dist/out-tsc/function/op.spec.js +94 -0
  90. package/dist/out-tsc/function/op.spec.js.map +1 -0
  91. package/dist/out-tsc/index.d.ts +9 -0
  92. package/dist/out-tsc/index.js +10 -0
  93. package/dist/out-tsc/index.js.map +1 -0
  94. package/dist/out-tsc/number/constrain.d.ts +7 -0
  95. package/dist/out-tsc/number/constrain.js +16 -0
  96. package/dist/out-tsc/number/constrain.js.map +1 -0
  97. package/dist/out-tsc/number/decimal-round.d.ts +7 -0
  98. package/dist/out-tsc/number/decimal-round.js +19 -0
  99. package/dist/out-tsc/number/decimal-round.js.map +1 -0
  100. package/dist/out-tsc/number/decimal-round.spec.d.ts +1 -0
  101. package/dist/out-tsc/number/decimal-round.spec.js +10 -0
  102. package/dist/out-tsc/number/decimal-round.spec.js.map +1 -0
  103. package/dist/out-tsc/number/index.d.ts +3 -0
  104. package/dist/out-tsc/number/index.js +4 -0
  105. package/dist/out-tsc/number/index.js.map +1 -0
  106. package/dist/out-tsc/number/to-file-size-string.d.ts +5 -0
  107. package/dist/out-tsc/number/to-file-size-string.js +24 -0
  108. package/dist/out-tsc/number/to-file-size-string.js.map +1 -0
  109. package/dist/out-tsc/object/copy-property.d.ts +6 -0
  110. package/dist/out-tsc/object/copy-property.js +9 -0
  111. package/dist/out-tsc/object/copy-property.js.map +1 -0
  112. package/dist/out-tsc/object/copy-property.spec.d.ts +1 -0
  113. package/dist/out-tsc/object/copy-property.spec.js +16 -0
  114. package/dist/out-tsc/object/copy-property.spec.js.map +1 -0
  115. package/dist/out-tsc/object/crumble-path.d.ts +6 -0
  116. package/dist/out-tsc/object/crumble-path.js +9 -0
  117. package/dist/out-tsc/object/crumble-path.js.map +1 -0
  118. package/dist/out-tsc/object/crumble-path.spec.d.ts +1 -0
  119. package/dist/out-tsc/object/crumble-path.spec.js +24 -0
  120. package/dist/out-tsc/object/crumble-path.spec.js.map +1 -0
  121. package/dist/out-tsc/object/deep-freeze.d.ts +1 -0
  122. package/dist/out-tsc/object/deep-freeze.js +36 -0
  123. package/dist/out-tsc/object/deep-freeze.js.map +1 -0
  124. package/dist/out-tsc/object/deep-freeze.spec.d.ts +1 -0
  125. package/dist/out-tsc/object/deep-freeze.spec.js +14 -0
  126. package/dist/out-tsc/object/deep-freeze.spec.js.map +1 -0
  127. package/dist/out-tsc/object/diff.d.ts +12 -0
  128. package/dist/out-tsc/object/diff.js +92 -0
  129. package/dist/out-tsc/object/diff.js.map +1 -0
  130. package/dist/out-tsc/object/diff.spec.d.ts +1 -0
  131. package/dist/out-tsc/object/diff.spec.js +40 -0
  132. package/dist/out-tsc/object/diff.spec.js.map +1 -0
  133. package/dist/out-tsc/object/for-each-entry-deep.d.ts +4 -0
  134. package/dist/out-tsc/object/for-each-entry-deep.js +38 -0
  135. package/dist/out-tsc/object/for-each-entry-deep.js.map +1 -0
  136. package/dist/out-tsc/object/for-each-entry-deep.spec.d.ts +1 -0
  137. package/dist/out-tsc/object/for-each-entry-deep.spec.js +24 -0
  138. package/dist/out-tsc/object/for-each-entry-deep.spec.js.map +1 -0
  139. package/dist/out-tsc/object/for-each-nested-object.d.ts +4 -0
  140. package/dist/out-tsc/object/for-each-nested-object.js +38 -0
  141. package/dist/out-tsc/object/for-each-nested-object.js.map +1 -0
  142. package/dist/out-tsc/object/for-each-nested-object.spec.d.ts +1 -0
  143. package/dist/out-tsc/object/for-each-nested-object.spec.js +46 -0
  144. package/dist/out-tsc/object/for-each-nested-object.spec.js.map +1 -0
  145. package/dist/out-tsc/object/get-path.d.ts +5 -0
  146. package/dist/out-tsc/object/get-path.js +67 -0
  147. package/dist/out-tsc/object/get-path.js.map +1 -0
  148. package/dist/out-tsc/object/get-path.spec.d.ts +1 -0
  149. package/dist/out-tsc/object/get-path.spec.js +44 -0
  150. package/dist/out-tsc/object/get-path.spec.js.map +1 -0
  151. package/dist/out-tsc/object/index.d.ts +13 -0
  152. package/dist/out-tsc/object/index.js +14 -0
  153. package/dist/out-tsc/object/index.js.map +1 -0
  154. package/dist/out-tsc/object/merge-deep.d.ts +4 -0
  155. package/dist/out-tsc/object/merge-deep.js +60 -0
  156. package/dist/out-tsc/object/merge-deep.js.map +1 -0
  157. package/dist/out-tsc/object/merge-deep.spec.d.ts +1 -0
  158. package/dist/out-tsc/object/merge-deep.spec.js +16 -0
  159. package/dist/out-tsc/object/merge-deep.spec.js.map +1 -0
  160. package/dist/out-tsc/object/merge-properties-deep.d.ts +4 -0
  161. package/dist/out-tsc/object/merge-properties-deep.js +61 -0
  162. package/dist/out-tsc/object/merge-properties-deep.js.map +1 -0
  163. package/dist/out-tsc/object/merge-properties-deep.spec.d.ts +1 -0
  164. package/dist/out-tsc/object/merge-properties-deep.spec.js +24 -0
  165. package/dist/out-tsc/object/merge-properties-deep.spec.js.map +1 -0
  166. package/dist/out-tsc/object/omit.d.ts +1 -0
  167. package/dist/out-tsc/object/omit.js +40 -0
  168. package/dist/out-tsc/object/omit.js.map +1 -0
  169. package/dist/out-tsc/object/omit.spec.d.ts +1 -0
  170. package/dist/out-tsc/object/omit.spec.js +10 -0
  171. package/dist/out-tsc/object/omit.spec.js.map +1 -0
  172. package/dist/out-tsc/object/set-path.d.ts +2 -0
  173. package/dist/out-tsc/object/set-path.js +45 -0
  174. package/dist/out-tsc/object/set-path.js.map +1 -0
  175. package/dist/out-tsc/object/set-path.spec.d.ts +1 -0
  176. package/dist/out-tsc/object/set-path.spec.js +36 -0
  177. package/dist/out-tsc/object/set-path.spec.js.map +1 -0
  178. package/dist/out-tsc/object/traverse-path.d.ts +2 -0
  179. package/dist/out-tsc/object/traverse-path.js +81 -0
  180. package/dist/out-tsc/object/traverse-path.js.map +1 -0
  181. package/dist/out-tsc/object/values.d.ts +2 -0
  182. package/dist/out-tsc/object/values.js +31 -0
  183. package/dist/out-tsc/object/values.js.map +1 -0
  184. package/dist/out-tsc/object/values.spec.d.ts +1 -0
  185. package/dist/out-tsc/object/values.spec.js +7 -0
  186. package/dist/out-tsc/object/values.spec.js.map +1 -0
  187. package/dist/out-tsc/string/code.template-tag.d.ts +2 -0
  188. package/dist/out-tsc/string/code.template-tag.js +38 -0
  189. package/dist/out-tsc/string/code.template-tag.js.map +1 -0
  190. package/dist/out-tsc/string/index.d.ts +3 -0
  191. package/dist/out-tsc/string/index.js +4 -0
  192. package/dist/out-tsc/string/index.js.map +1 -0
  193. package/dist/out-tsc/string/parse-file-size.d.ts +5 -0
  194. package/dist/out-tsc/string/parse-file-size.js +43 -0
  195. package/dist/out-tsc/string/parse-file-size.js.map +1 -0
  196. package/dist/out-tsc/string/template.d.ts +15 -0
  197. package/dist/out-tsc/string/template.js +28 -0
  198. package/dist/out-tsc/string/template.js.map +1 -0
  199. package/dist/out-tsc/string/template.spec.d.ts +1 -0
  200. package/dist/out-tsc/string/template.spec.js +39 -0
  201. package/dist/out-tsc/string/template.spec.js.map +1 -0
  202. package/dist/out-tsc/typings.d.ts +1 -0
  203. package/dist/out-tsc/typings.js +2 -0
  204. package/dist/out-tsc/typings.js.map +1 -0
  205. package/lib/index.cjs.js +2437 -1
  206. package/lib/index.es.js +2268 -893
  207. package/package.json +5 -5
  208. package/rollup.config.js +22 -0
  209. package/vite.config.js +1 -1
@@ -0,0 +1,150 @@
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
@@ -0,0 +1 @@
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;QACpC,YAAY,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAe,YAAY,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM;;QACpD,SAAS,8BAA8B;YACrC,MAAM,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;YAClC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAC1C,CAAC;;;;;;oBAE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*/
3
+ export interface DebouncedFunction<T> extends DelayedFunction<Promise<T>> {
4
+ (...args: any[]): Promise<T>;
5
+ _promise?: Promise<T>;
6
+ _promiseCallbacks?: {
7
+ resolve: any;
8
+ reject: any;
9
+ };
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=debounced-function.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debounced-function.interface.js","sourceRoot":"","sources":["../../../src/function/debounced-function.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A function or method that has been passed to `debounce` or
3
+ * `lockToAnimationFrames`.
4
+ */
5
+ export interface DelayedFunction<T> {
6
+ (...args: any[]): T;
7
+ pending?: boolean;
8
+ reset?: () => boolean;
9
+ id?: number;
10
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=delayed-function.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delayed-function.interface.js","sourceRoot":"","sources":["../../../src/function/delayed-function.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from "./debounce";
2
+ export * from "./debounced-function.interface";
3
+ export * from "./delayed-function.interface";
4
+ export * from "./lock-to-animation-frames";
5
+ export * from "./on-next-tick";
6
+ export * from "./op";
@@ -0,0 +1,7 @@
1
+ export * from "./debounce";
2
+ export * from "./debounced-function.interface";
3
+ export * from "./delayed-function.interface";
4
+ export * from "./lock-to-animation-frames";
5
+ export * from "./on-next-tick";
6
+ export * from "./op";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,7 @@
1
+ import type { DelayedFunction } from "./delayed-function.interface";
2
+ /**
3
+ * Return a new function to replace the passed in one which ensures that
4
+ * the given function will run only in `requestAnimationFrame()` and at
5
+ * most once per frame.
6
+ */
7
+ export declare function lockToAnimationFrames(functionToLock: () => any, thisArg?: any): DelayedFunction<any>;
@@ -0,0 +1,43 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,53 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
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 declare function onNextTick(fn: (...args: unknown[]) => unknown, thisArg?: any): void;
@@ -0,0 +1,12 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Functions for various operators, most useful in combination
3
+ * with functional programming tools like map, filter, and reduce.
4
+ */
5
+ export declare const Op: {
6
+ add: (a: any, b: any) => any;
7
+ and: (a: any, b: any) => any;
8
+ band: (a: any, b: any) => number;
9
+ bor: (a: any, b: any) => number;
10
+ bxor: (a: any, b: any) => number;
11
+ bnot: (a: any) => number;
12
+ decr: (a: number) => number;
13
+ div: (a: number, b: number) => number;
14
+ eq: (a: any, b: any) => boolean;
15
+ exp: (a: number, b: number) => number;
16
+ gt: (a: any, b: any) => boolean;
17
+ gte: (a: any, b: any) => boolean;
18
+ incr: (a: number) => number;
19
+ lshift: (a: any, b: any) => number;
20
+ lt: (a: any, b: any) => boolean;
21
+ lte: (a: any, b: any) => boolean;
22
+ mul: (a: number, b: number) => number;
23
+ neg: (a: number) => number;
24
+ neq: (a: any, b: any) => boolean;
25
+ not: (a: any) => boolean;
26
+ or: (a: any, b: any) => any;
27
+ rem: (a: number, b: number) => number;
28
+ rshift: (a: any, b: any) => number;
29
+ rshift_zf: (a: any, b: any) => number;
30
+ sub: (a: number, b: number) => number;
31
+ xor: (a: any, b: any) => boolean;
32
+ };
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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,I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AE,CAAC,IAAK,OAAA,CAAC,IAAI,CAAC,EAAN,CAAM;IAEpB,GAAG,EAAE,UAAC,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAEpC,MAAM,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,IAAI,CAAC,EAAN,CAAM;IAExB,SAAS,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,KAAK,CAAC,EAAP,CAAO;IAE5B,GAAG,EAAE,UAAC,CAAS,EAAE,CAAS,IAAK,OAAA,CAAC,GAAG,CAAC,EAAL,CAAK;IAEpC,GAAG,EAAE,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAArB,CAAqB;CACrC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
1
+ import { Op } from "./op";
2
+ describe("Op", function () {
3
+ test("provides addition as a function", function () {
4
+ expect(Op.add(1, 3)).toBe(4);
5
+ });
6
+ test("provides Boolean AND as a function", function () {
7
+ expect(Op.and(true, true)).toBe(true);
8
+ expect(Op.and(true, false)).toBe(false);
9
+ expect(Op.and(false, true)).toBe(false);
10
+ expect(Op.and(false, false)).toBe(false);
11
+ });
12
+ test("provides bitwise AND as a function", function () {
13
+ expect(Op.band(5, 12)).toBe(4);
14
+ });
15
+ test("provides bitwise OR as a function", function () {
16
+ expect(Op.bor(5, 12)).toBe(13);
17
+ });
18
+ test("provides bitwise XOR as a function", function () {
19
+ expect(Op.bxor(5, 12)).toBe(9);
20
+ });
21
+ test("provides bitwise NOT as a function", function () {
22
+ expect(Op.bnot(5)).toBe(-6);
23
+ });
24
+ test("provides decrement as a function", function () {
25
+ expect(Op.decr(6)).toBe(5);
26
+ });
27
+ test("provides division as a function", function () {
28
+ expect(Op.div(5, 2)).toBe(2.5);
29
+ });
30
+ test("provides equality (triple equals) as a function", function () {
31
+ var a = 5;
32
+ var b = 5;
33
+ var c = "5";
34
+ expect(Op.eq(a, b)).toBe(true);
35
+ expect(Op.eq(b, c)).toBe(false);
36
+ });
37
+ test("provides exponentiation as a function", function () {
38
+ expect(Op.exp(2, 5)).toBe(32);
39
+ });
40
+ test("provides greater-than as a function", function () {
41
+ expect(Op.gt(7, 6)).toBe(true);
42
+ });
43
+ test("provides greater-than-or-equals as a function", function () {
44
+ expect(Op.gte(7, 6)).toBe(true);
45
+ expect(Op.gte(6, 6)).toBe(true);
46
+ });
47
+ test("provides increment as a function", function () {
48
+ expect(Op.incr(4)).toBe(5);
49
+ });
50
+ test("provides left shift as a function", function () {
51
+ expect(Op.lshift(10, 1)).toBe(20);
52
+ expect(Op.lshift(-10, 1)).toBe(-20);
53
+ });
54
+ test("provides less-than as a function", function () {
55
+ expect(Op.lt(6, 7)).toBe(true);
56
+ });
57
+ test("provides less-than-or-equals as a function", function () {
58
+ expect(Op.lte(6, 7)).toBe(true);
59
+ expect(Op.lte(6, 6)).toBe(true);
60
+ });
61
+ test("provides multiplication as a function", function () {
62
+ expect(Op.mul(12, 12)).toBe(144);
63
+ });
64
+ test("provides negation as a function", function () {
65
+ expect(Op.neg(3)).toBe(-3);
66
+ });
67
+ test("provides Boolean OR as a function", function () {
68
+ expect(Op.or(true, true)).toBe(true);
69
+ expect(Op.or(true, false)).toBe(true);
70
+ expect(Op.or(false, true)).toBe(true);
71
+ expect(Op.or(false, false)).toBe(false);
72
+ });
73
+ test("provides remainder as a function", function () {
74
+ expect(Op.rem(17, 7)).toBe(3);
75
+ });
76
+ test("provides right shift as a function", function () {
77
+ expect(Op.rshift(10, 1)).toBe(5);
78
+ expect(Op.rshift(-10, 1)).toBe(-5);
79
+ });
80
+ test("provides unsigned zero-fill right shift as a function", function () {
81
+ expect(Op.rshift_zf(10, 1)).toBe(5);
82
+ expect(Op.rshift_zf(-10, 1)).toBe(2147483643);
83
+ });
84
+ test("provides subtraction as a function", function () {
85
+ expect(Op.sub(9, 4)).toBe(5);
86
+ });
87
+ test("provides Boolean XOR as a function", function () {
88
+ expect(Op.xor(true, true)).toBe(false);
89
+ expect(Op.xor(true, false)).toBe(true);
90
+ expect(Op.xor(false, true)).toBe(true);
91
+ expect(Op.xor(false, false)).toBe(false);
92
+ });
93
+ });
94
+ //# sourceMappingURL=op.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op.spec.js","sourceRoot":"","sources":["../../../src/function/op.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAE1B,QAAQ,CAAC,IAAI,EAAE;IACb,IAAI,CAAC,iCAAiC,EAAE;QACtC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,oCAAoC,EAAE;QACzC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,oCAAoC,EAAE;QACzC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAM,EAAE,EAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAM,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IACH,IAAI,CAA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 export * from "./data/index";
4
+ export * from "./decorators/index";
5
+ export * from "./function/index";
6
+ export * from "./number/index";
7
+ export * from "./object/index";
8
+ export * from "./string/index";
9
+ export * from "./typings";
@@ -0,0 +1,10 @@
1
+ export * from "./array/index";
2
+ export * from "./classes/index";
3
+ export * from "./data/index";
4
+ export * from "./decorators/index";
5
+ export * from "./function/index";
6
+ export * from "./number/index";
7
+ export * from "./object/index";
8
+ export * from "./string/index";
9
+ export * from "./typings";
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Constrains a number to the given range. If the number is below the
3
+ * low end of the range, the low end will be returned. If the number is
4
+ * above the top end of the range, the top end will be returned. Otherwise
5
+ * the number itself will be returned.
6
+ */
7
+ export declare function constrain(n: number, range: [number, number]): number;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Constrains a number to the given range. If the number is below the
3
+ * low end of the range, the low end will be returned. If the number is
4
+ * above the top end of the range, the top end will be returned. Otherwise
5
+ * the number itself will be returned.
6
+ */
7
+ export function constrain(n, range) {
8
+ if (!n || n < range[0]) {
9
+ return range[0];
10
+ }
11
+ if (n > range[1]) {
12
+ return range[1];
13
+ }
14
+ return n;
15
+ }
16
+ //# sourceMappingURL=constrain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constrain.js","sourceRoot":"","sources":["../../../src/number/constrain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,CAAS,EAAE,KAAuB;IAC1D,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;QACtB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB;IACD,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;KACjB;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Progressively rounds `num` to `decimalPlaces` places. This differs from other
3
+ * rounding methods out there such as lodash's, which are not progressive. For example,
4
+ * `(0.149).toFixed(1)` and lodash `_.round(0.149, 1)` both return `0.1`, but this
5
+ * function rounds `0.149` to `0.15` and then `0.15` to `0.2` and returns `0.2`.
6
+ */
7
+ export declare function decimalRound(num: number, decimalPlaces?: number): number;