@naturalcycles/js-lib 14.240.0 → 14.241.1
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/abort.js +1 -2
- package/dist/array/array.util.d.ts +12 -0
- package/dist/array/array.util.js +55 -38
- package/dist/array/range.js +3 -4
- package/dist/datetime/localDate.js +2 -2
- package/dist/datetime/localTime.js +2 -2
- package/dist/decorators/asyncMemo.decorator.js +2 -2
- package/dist/decorators/createPromiseDecorator.js +1 -2
- package/dist/decorators/debounce.decorator.js +2 -3
- package/dist/decorators/debounce.js +2 -3
- package/dist/decorators/decorator.util.js +3 -4
- package/dist/decorators/logMethod.decorator.js +1 -2
- package/dist/decorators/memo.decorator.js +2 -2
- package/dist/decorators/memoFn.js +1 -2
- package/dist/decorators/memoFnAsync.js +1 -2
- package/dist/decorators/retry.decorator.js +1 -2
- package/dist/decorators/timeout.decorator.js +1 -2
- package/dist/define.js +6 -7
- package/dist/enum.util.js +20 -21
- package/dist/env/buildInfo.js +1 -2
- package/dist/env.js +2 -3
- package/dist/error/assert.js +9 -10
- package/dist/error/error.util.js +11 -11
- package/dist/error/try.js +6 -7
- package/dist/error/tryCatch.js +2 -2
- package/dist/form.util.js +2 -3
- package/dist/http/fetcher.d.ts +0 -3
- package/dist/http/fetcher.js +2 -2
- package/dist/http/fetcher.model.d.ts +0 -2
- package/dist/is.util.js +7 -7
- package/dist/json-schema/from-data/generateJsonSchemaFromData.js +1 -2
- package/dist/json-schema/jsonSchema.util.js +1 -2
- package/dist/json-schema/jsonSchemaBuilder.d.ts +8 -9
- package/dist/log/commonLogger.js +5 -5
- package/dist/math/math.util.js +6 -7
- package/dist/number/createDeterministicRandom.js +1 -2
- package/dist/number/number.util.js +9 -10
- package/dist/object/deepEquals.js +3 -4
- package/dist/object/object.util.js +26 -27
- package/dist/object/sortObject.js +1 -2
- package/dist/object/sortObjectDeep.js +1 -2
- package/dist/polyfill.js +1 -2
- package/dist/promise/abortable.js +2 -2
- package/dist/promise/pDefer.js +1 -2
- package/dist/promise/pDelay.js +2 -3
- package/dist/promise/pFilter.js +1 -2
- package/dist/promise/pHang.js +1 -2
- package/dist/promise/pMap.js +1 -2
- package/dist/promise/pProps.js +1 -2
- package/dist/promise/pRetry.js +2 -3
- package/dist/promise/pState.js +1 -2
- package/dist/promise/pTimeout.js +2 -3
- package/dist/semver.js +2 -2
- package/dist/string/case.js +3 -4
- package/dist/string/escape.js +2 -3
- package/dist/string/hash.util.js +4 -5
- package/dist/string/json.util.js +3 -4
- package/dist/string/leven.js +1 -2
- package/dist/string/lodash/unicodeWords.js +1 -2
- package/dist/string/lodash/words.js +1 -2
- package/dist/string/pupa.js +2 -2
- package/dist/string/readingTime.js +1 -2
- package/dist/string/safeJsonStringify.js +1 -2
- package/dist/string/string.util.js +13 -14
- package/dist/string/stringify.js +2 -3
- package/dist/string/url.util.js +1 -2
- package/dist/time/time.util.js +3 -4
- package/dist/types.d.ts +0 -1
- package/dist/types.js +2 -2
- package/dist/unit/size.util.js +5 -6
- package/dist/web.d.ts +0 -2
- package/dist/zod/zod.util.js +4 -4
- package/dist-esm/array/array.util.js +16 -0
- package/package.json +1 -1
- package/src/array/array.util.ts +26 -0
- package/src/enum.util.ts +1 -1
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +1 -1
package/dist/abort.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createAbortableSignal =
|
|
3
|
+
exports.createAbortableSignal = createAbortableSignal;
|
|
4
4
|
/**
|
|
5
5
|
* Creates AbortableSignal,
|
|
6
6
|
* which is like AbortSignal, but can "abort itself" with `.abort()` method.
|
|
@@ -13,4 +13,3 @@ function createAbortableSignal() {
|
|
|
13
13
|
abort: ac.abort.bind(ac),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
exports.createAbortableSignal = createAbortableSignal;
|
|
@@ -120,6 +120,18 @@ export declare function _takeWhile<T>(items: readonly T[], predicate: Predicate<
|
|
|
120
120
|
export declare function _takeRightWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
|
|
121
121
|
export declare function _dropWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
|
|
122
122
|
export declare function _dropRightWhile<T>(items: readonly T[], predicate: Predicate<T>): T[];
|
|
123
|
+
/**
|
|
124
|
+
* Returns true if the _count >= limit.
|
|
125
|
+
* _count counts how many times the Predicate returns true, and stops
|
|
126
|
+
* when it reaches the limit.
|
|
127
|
+
*/
|
|
128
|
+
export declare function _countAtLeast<T>(items: Iterable<T>, predicate: AbortablePredicate<T>, limit: number): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Returns true if the _count <> limit.
|
|
131
|
+
* _count counts how many times the Predicate returns true, and stops
|
|
132
|
+
* when it reaches the limit.
|
|
133
|
+
*/
|
|
134
|
+
export declare function _countLessThan<T>(items: Iterable<T>, predicate: AbortablePredicate<T>, limit: number): boolean;
|
|
123
135
|
/**
|
|
124
136
|
* Counts how many items match the predicate.
|
|
125
137
|
*
|
package/dist/array/array.util.js
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._chunk = _chunk;
|
|
4
|
+
exports._uniq = _uniq;
|
|
5
|
+
exports._pushUniq = _pushUniq;
|
|
6
|
+
exports._pushUniqBy = _pushUniqBy;
|
|
7
|
+
exports._uniqBy = _uniqBy;
|
|
8
|
+
exports._by = _by;
|
|
9
|
+
exports._mapBy = _mapBy;
|
|
10
|
+
exports._groupBy = _groupBy;
|
|
11
|
+
exports._sortBy = _sortBy;
|
|
12
|
+
exports._sortDescBy = _sortDescBy;
|
|
13
|
+
exports._find = _find;
|
|
14
|
+
exports._findLast = _findLast;
|
|
15
|
+
exports._takeWhile = _takeWhile;
|
|
16
|
+
exports._takeRightWhile = _takeRightWhile;
|
|
17
|
+
exports._dropWhile = _dropWhile;
|
|
18
|
+
exports._dropRightWhile = _dropRightWhile;
|
|
19
|
+
exports._countAtLeast = _countAtLeast;
|
|
20
|
+
exports._countLessThan = _countLessThan;
|
|
21
|
+
exports._count = _count;
|
|
22
|
+
exports._countBy = _countBy;
|
|
23
|
+
exports._intersection = _intersection;
|
|
24
|
+
exports._intersectsWith = _intersectsWith;
|
|
25
|
+
exports._difference = _difference;
|
|
26
|
+
exports._sum = _sum;
|
|
27
|
+
exports._sumBy = _sumBy;
|
|
28
|
+
exports._mapToObject = _mapToObject;
|
|
29
|
+
exports._shuffle = _shuffle;
|
|
30
|
+
exports._last = _last;
|
|
31
|
+
exports._lastOrUndefined = _lastOrUndefined;
|
|
32
|
+
exports._first = _first;
|
|
33
|
+
exports._minOrUndefined = _minOrUndefined;
|
|
34
|
+
exports._min = _min;
|
|
35
|
+
exports._maxOrUndefined = _maxOrUndefined;
|
|
36
|
+
exports._max = _max;
|
|
37
|
+
exports._maxBy = _maxBy;
|
|
38
|
+
exports._minBy = _minBy;
|
|
39
|
+
exports._maxByOrUndefined = _maxByOrUndefined;
|
|
40
|
+
exports._minByOrUndefined = _minByOrUndefined;
|
|
41
|
+
exports._zip = _zip;
|
|
4
42
|
const is_util_1 = require("../is.util");
|
|
5
43
|
const types_1 = require("../types");
|
|
6
44
|
/**
|
|
@@ -20,14 +58,12 @@ function _chunk(array, size = 1) {
|
|
|
20
58
|
return idx % size === 0 ? [...arr, [item]] : [...arr.slice(0, -1), [...arr.slice(-1)[0], item]];
|
|
21
59
|
}, []);
|
|
22
60
|
}
|
|
23
|
-
exports._chunk = _chunk;
|
|
24
61
|
/**
|
|
25
62
|
* Removes duplicates from given array.
|
|
26
63
|
*/
|
|
27
64
|
function _uniq(a) {
|
|
28
65
|
return [...new Set(a)];
|
|
29
66
|
}
|
|
30
|
-
exports._uniq = _uniq;
|
|
31
67
|
/**
|
|
32
68
|
* Pushes an item to an array if it's not already there.
|
|
33
69
|
* Mutates the array (same as normal `push`) and also returns it for chaining convenience.
|
|
@@ -48,7 +84,6 @@ function _pushUniq(a, ...items) {
|
|
|
48
84
|
}
|
|
49
85
|
return a;
|
|
50
86
|
}
|
|
51
|
-
exports._pushUniq = _pushUniq;
|
|
52
87
|
/**
|
|
53
88
|
* Like _pushUniq but uses a mapper to determine uniqueness (like _uniqBy).
|
|
54
89
|
* Mutates the array (same as normal `push`).
|
|
@@ -64,7 +99,6 @@ function _pushUniqBy(a, mapper, ...items) {
|
|
|
64
99
|
});
|
|
65
100
|
return a;
|
|
66
101
|
}
|
|
67
|
-
exports._pushUniqBy = _pushUniqBy;
|
|
68
102
|
/**
|
|
69
103
|
* This method is like `_.uniq` except that it accepts `iteratee` which is
|
|
70
104
|
* invoked for each element in `array` to generate the criterion by which
|
|
@@ -94,7 +128,6 @@ function _uniqBy(arr, mapper) {
|
|
|
94
128
|
.values(),
|
|
95
129
|
];
|
|
96
130
|
}
|
|
97
|
-
exports._uniqBy = _uniqBy;
|
|
98
131
|
/**
|
|
99
132
|
* const a = [
|
|
100
133
|
* {id: 'id1', a: 'a1'},
|
|
@@ -118,14 +151,12 @@ exports._uniqBy = _uniqBy;
|
|
|
118
151
|
function _by(items, mapper) {
|
|
119
152
|
return Object.fromEntries(items.map((item, i) => [mapper(item, i), item]).filter(([k]) => k !== undefined));
|
|
120
153
|
}
|
|
121
|
-
exports._by = _by;
|
|
122
154
|
/**
|
|
123
155
|
* Map an array of items by a key, that is calculated by a Mapper.
|
|
124
156
|
*/
|
|
125
157
|
function _mapBy(items, mapper) {
|
|
126
158
|
return new Map(items.map((item, i) => [mapper(item, i), item]).filter(([k]) => k !== undefined));
|
|
127
159
|
}
|
|
128
|
-
exports._mapBy = _mapBy;
|
|
129
160
|
/**
|
|
130
161
|
* const a = [1, 2, 3, 4, 5]
|
|
131
162
|
*
|
|
@@ -146,7 +177,6 @@ function _groupBy(items, mapper) {
|
|
|
146
177
|
return map;
|
|
147
178
|
}, {});
|
|
148
179
|
}
|
|
149
|
-
exports._groupBy = _groupBy;
|
|
150
180
|
/**
|
|
151
181
|
* _sortBy([{age: 20}, {age: 10}], 'age')
|
|
152
182
|
* // => [{age: 10}, {age: 20}]
|
|
@@ -163,14 +193,12 @@ function _sortBy(items, mapper, mutate = false, dir = 'asc') {
|
|
|
163
193
|
return String(a).localeCompare(String(b)) * mod;
|
|
164
194
|
});
|
|
165
195
|
}
|
|
166
|
-
exports._sortBy = _sortBy;
|
|
167
196
|
/**
|
|
168
197
|
* Alias for _sortBy with descending order.
|
|
169
198
|
*/
|
|
170
199
|
function _sortDescBy(items, mapper, mutate = false) {
|
|
171
200
|
return _sortBy(items, mapper, mutate, 'desc');
|
|
172
201
|
}
|
|
173
|
-
exports._sortDescBy = _sortDescBy;
|
|
174
202
|
/**
|
|
175
203
|
* Similar to `Array.find`, but the `predicate` may return `END` to stop the iteration early.
|
|
176
204
|
*
|
|
@@ -185,7 +213,6 @@ function _find(items, predicate) {
|
|
|
185
213
|
return item;
|
|
186
214
|
}
|
|
187
215
|
}
|
|
188
|
-
exports._find = _find;
|
|
189
216
|
/**
|
|
190
217
|
* Similar to `Array.findLast`, but the `predicate` may return `END` to stop the iteration early.
|
|
191
218
|
*
|
|
@@ -196,22 +223,18 @@ exports._find = _find;
|
|
|
196
223
|
function _findLast(items, predicate) {
|
|
197
224
|
return _find(items.slice().reverse(), predicate);
|
|
198
225
|
}
|
|
199
|
-
exports._findLast = _findLast;
|
|
200
226
|
function _takeWhile(items, predicate) {
|
|
201
227
|
let proceed = true;
|
|
202
228
|
return items.filter((v, index) => (proceed &&= predicate(v, index)));
|
|
203
229
|
}
|
|
204
|
-
exports._takeWhile = _takeWhile;
|
|
205
230
|
function _takeRightWhile(items, predicate) {
|
|
206
231
|
let proceed = true;
|
|
207
232
|
return [...items].reverse().filter((v, index) => (proceed &&= predicate(v, index)));
|
|
208
233
|
}
|
|
209
|
-
exports._takeRightWhile = _takeRightWhile;
|
|
210
234
|
function _dropWhile(items, predicate) {
|
|
211
235
|
let proceed = false;
|
|
212
236
|
return items.filter((v, index) => (proceed ||= !predicate(v, index)));
|
|
213
237
|
}
|
|
214
|
-
exports._dropWhile = _dropWhile;
|
|
215
238
|
function _dropRightWhile(items, predicate) {
|
|
216
239
|
let proceed = false;
|
|
217
240
|
return [...items]
|
|
@@ -219,7 +242,22 @@ function _dropRightWhile(items, predicate) {
|
|
|
219
242
|
.filter((v, index) => (proceed ||= !predicate(v, index)))
|
|
220
243
|
.reverse();
|
|
221
244
|
}
|
|
222
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Returns true if the _count >= limit.
|
|
247
|
+
* _count counts how many times the Predicate returns true, and stops
|
|
248
|
+
* when it reaches the limit.
|
|
249
|
+
*/
|
|
250
|
+
function _countAtLeast(items, predicate, limit) {
|
|
251
|
+
return _count(items, predicate, limit) >= limit;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Returns true if the _count <> limit.
|
|
255
|
+
* _count counts how many times the Predicate returns true, and stops
|
|
256
|
+
* when it reaches the limit.
|
|
257
|
+
*/
|
|
258
|
+
function _countLessThan(items, predicate, limit) {
|
|
259
|
+
return _count(items, predicate, limit) < limit;
|
|
260
|
+
}
|
|
223
261
|
/**
|
|
224
262
|
* Counts how many items match the predicate.
|
|
225
263
|
*
|
|
@@ -242,7 +280,6 @@ function _count(items, predicate, limit) {
|
|
|
242
280
|
}
|
|
243
281
|
return count;
|
|
244
282
|
}
|
|
245
|
-
exports._count = _count;
|
|
246
283
|
function _countBy(items, mapper) {
|
|
247
284
|
const map = {};
|
|
248
285
|
let i = 0;
|
|
@@ -252,7 +289,6 @@ function _countBy(items, mapper) {
|
|
|
252
289
|
}
|
|
253
290
|
return map;
|
|
254
291
|
}
|
|
255
|
-
exports._countBy = _countBy;
|
|
256
292
|
// investigate: _groupBy
|
|
257
293
|
/**
|
|
258
294
|
* Returns an intersection between 2 arrays.
|
|
@@ -269,7 +305,6 @@ function _intersection(a1, a2) {
|
|
|
269
305
|
const a2set = a2 instanceof Set ? a2 : new Set(a2);
|
|
270
306
|
return a1.filter(v => a2set.has(v));
|
|
271
307
|
}
|
|
272
|
-
exports._intersection = _intersection;
|
|
273
308
|
/**
|
|
274
309
|
* Returns true if there is at least 1 item common between 2 arrays.
|
|
275
310
|
* Otherwise returns false.
|
|
@@ -282,7 +317,6 @@ function _intersectsWith(a1, a2) {
|
|
|
282
317
|
const a2set = a2 instanceof Set ? a2 : new Set(a2);
|
|
283
318
|
return a1.some(v => a2set.has(v));
|
|
284
319
|
}
|
|
285
|
-
exports._intersectsWith = _intersectsWith;
|
|
286
320
|
/**
|
|
287
321
|
* @example
|
|
288
322
|
* _difference([2, 1], [2, 3])
|
|
@@ -291,7 +325,6 @@ exports._intersectsWith = _intersectsWith;
|
|
|
291
325
|
function _difference(source, ...diffs) {
|
|
292
326
|
return diffs.reduce((a, b) => a.filter(c => !b.includes(c)), source);
|
|
293
327
|
}
|
|
294
|
-
exports._difference = _difference;
|
|
295
328
|
/**
|
|
296
329
|
* Returns the sum of items, or 0 for empty array.
|
|
297
330
|
*/
|
|
@@ -302,7 +335,6 @@ function _sum(items) {
|
|
|
302
335
|
}
|
|
303
336
|
return sum;
|
|
304
337
|
}
|
|
305
|
-
exports._sum = _sum;
|
|
306
338
|
function _sumBy(items, mapper) {
|
|
307
339
|
let sum = 0;
|
|
308
340
|
let i = 0;
|
|
@@ -315,7 +347,6 @@ function _sumBy(items, mapper) {
|
|
|
315
347
|
}
|
|
316
348
|
return sum;
|
|
317
349
|
}
|
|
318
|
-
exports._sumBy = _sumBy;
|
|
319
350
|
/**
|
|
320
351
|
* Map an array of T to a StringMap<V>,
|
|
321
352
|
* by returning a tuple of [key, value] from a mapper function.
|
|
@@ -339,7 +370,6 @@ function _mapToObject(array, mapper) {
|
|
|
339
370
|
}
|
|
340
371
|
return m;
|
|
341
372
|
}
|
|
342
|
-
exports._mapToObject = _mapToObject;
|
|
343
373
|
/**
|
|
344
374
|
* Randomly shuffle an array values.
|
|
345
375
|
* Fisher–Yates algorithm.
|
|
@@ -353,7 +383,6 @@ function _shuffle(array, mutate = false) {
|
|
|
353
383
|
}
|
|
354
384
|
return a;
|
|
355
385
|
}
|
|
356
|
-
exports._shuffle = _shuffle;
|
|
357
386
|
/**
|
|
358
387
|
* Returns last item of non-empty array.
|
|
359
388
|
* Throws if array is empty.
|
|
@@ -363,14 +392,12 @@ function _last(array) {
|
|
|
363
392
|
throw new Error('_last called on empty array');
|
|
364
393
|
return array[array.length - 1];
|
|
365
394
|
}
|
|
366
|
-
exports._last = _last;
|
|
367
395
|
/**
|
|
368
396
|
* Returns last item of the array (or undefined if array is empty).
|
|
369
397
|
*/
|
|
370
398
|
function _lastOrUndefined(array) {
|
|
371
399
|
return array[array.length - 1];
|
|
372
400
|
}
|
|
373
|
-
exports._lastOrUndefined = _lastOrUndefined;
|
|
374
401
|
/**
|
|
375
402
|
* Returns the first item of non-empty array.
|
|
376
403
|
* Throws if array is empty.
|
|
@@ -380,14 +407,12 @@ function _first(array) {
|
|
|
380
407
|
throw new Error('_first called on empty array');
|
|
381
408
|
return array[0];
|
|
382
409
|
}
|
|
383
|
-
exports._first = _first;
|
|
384
410
|
function _minOrUndefined(array) {
|
|
385
411
|
const a = array.filter(is_util_1._isNotNullish);
|
|
386
412
|
if (!a.length)
|
|
387
413
|
return;
|
|
388
414
|
return a.reduce((min, item) => (min <= item ? min : item));
|
|
389
415
|
}
|
|
390
|
-
exports._minOrUndefined = _minOrUndefined;
|
|
391
416
|
/**
|
|
392
417
|
* Filters out nullish values (undefined and null).
|
|
393
418
|
*/
|
|
@@ -397,14 +422,12 @@ function _min(array) {
|
|
|
397
422
|
throw new Error('_min called on empty array');
|
|
398
423
|
return a.reduce((min, item) => (min <= item ? min : item));
|
|
399
424
|
}
|
|
400
|
-
exports._min = _min;
|
|
401
425
|
function _maxOrUndefined(array) {
|
|
402
426
|
const a = array.filter(is_util_1._isNotNullish);
|
|
403
427
|
if (!a.length)
|
|
404
428
|
return;
|
|
405
429
|
return a.reduce((max, item) => (max >= item ? max : item));
|
|
406
430
|
}
|
|
407
|
-
exports._maxOrUndefined = _maxOrUndefined;
|
|
408
431
|
/**
|
|
409
432
|
* Filters out nullish values (undefined and null).
|
|
410
433
|
*/
|
|
@@ -414,21 +437,18 @@ function _max(array) {
|
|
|
414
437
|
throw new Error('_max called on empty array');
|
|
415
438
|
return a.reduce((max, item) => (max >= item ? max : item));
|
|
416
439
|
}
|
|
417
|
-
exports._max = _max;
|
|
418
440
|
function _maxBy(array, mapper) {
|
|
419
441
|
const max = _maxByOrUndefined(array, mapper);
|
|
420
442
|
if (max === undefined)
|
|
421
443
|
throw new Error(`_maxBy returned undefined`);
|
|
422
444
|
return max;
|
|
423
445
|
}
|
|
424
|
-
exports._maxBy = _maxBy;
|
|
425
446
|
function _minBy(array, mapper) {
|
|
426
447
|
const min = _minByOrUndefined(array, mapper);
|
|
427
448
|
if (min === undefined)
|
|
428
449
|
throw new Error(`_minBy returned undefined`);
|
|
429
450
|
return min;
|
|
430
451
|
}
|
|
431
|
-
exports._minBy = _minBy;
|
|
432
452
|
// todo: looks like it _maxByOrUndefined/_minByOrUndefined can be DRYer
|
|
433
453
|
function _maxByOrUndefined(array, mapper) {
|
|
434
454
|
if (!array.length)
|
|
@@ -444,7 +464,6 @@ function _maxByOrUndefined(array, mapper) {
|
|
|
444
464
|
}
|
|
445
465
|
return maxItem;
|
|
446
466
|
}
|
|
447
|
-
exports._maxByOrUndefined = _maxByOrUndefined;
|
|
448
467
|
function _minByOrUndefined(array, mapper) {
|
|
449
468
|
if (!array.length)
|
|
450
469
|
return;
|
|
@@ -459,7 +478,6 @@ function _minByOrUndefined(array, mapper) {
|
|
|
459
478
|
}
|
|
460
479
|
return minItem;
|
|
461
480
|
}
|
|
462
|
-
exports._minByOrUndefined = _minByOrUndefined;
|
|
463
481
|
function _zip(array1, array2) {
|
|
464
482
|
const len = Math.min(array1.length, array2.length);
|
|
465
483
|
const res = [];
|
|
@@ -468,4 +486,3 @@ function _zip(array1, array2) {
|
|
|
468
486
|
}
|
|
469
487
|
return res;
|
|
470
488
|
}
|
|
471
|
-
exports._zip = _zip;
|
package/dist/array/range.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._range = _range;
|
|
4
|
+
exports._rangeIterable = _rangeIterable;
|
|
5
|
+
exports._rangeAsyncIterable = _rangeAsyncIterable;
|
|
4
6
|
const asyncIterable2_1 = require("../iter/asyncIterable2");
|
|
5
7
|
const iterable2_1 = require("../iter/iterable2");
|
|
6
8
|
function _range(fromIncl, toExcl, step = 1) {
|
|
@@ -9,7 +11,6 @@ function _range(fromIncl, toExcl, step = 1) {
|
|
|
9
11
|
}
|
|
10
12
|
return Array.from({ length: Math.ceil((toExcl - fromIncl) / step) }, (_, i) => i * step + fromIncl);
|
|
11
13
|
}
|
|
12
|
-
exports._range = _range;
|
|
13
14
|
function _rangeIterable(fromIncl, toExcl, step = 1) {
|
|
14
15
|
if (toExcl === undefined) {
|
|
15
16
|
toExcl = fromIncl;
|
|
@@ -23,7 +24,6 @@ function _rangeIterable(fromIncl, toExcl, step = 1) {
|
|
|
23
24
|
},
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
|
-
exports._rangeIterable = _rangeIterable;
|
|
27
27
|
function _rangeAsyncIterable(fromIncl, toExcl, step = 1) {
|
|
28
28
|
if (toExcl === undefined) {
|
|
29
29
|
toExcl = fromIncl;
|
|
@@ -37,4 +37,3 @@ function _rangeAsyncIterable(fromIncl, toExcl, step = 1) {
|
|
|
37
37
|
},
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
-
exports._rangeAsyncIterable = _rangeAsyncIterable;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.localDate = exports.LocalDate = void 0;
|
|
4
|
+
exports.todayString = todayString;
|
|
4
5
|
const assert_1 = require("../error/assert");
|
|
5
6
|
const is_util_1 = require("../is.util");
|
|
6
7
|
const iterable2_1 = require("../iter/iterable2");
|
|
@@ -626,4 +627,3 @@ Object.setPrototypeOf(exports.localDate, localDateFactory);
|
|
|
626
627
|
function todayString() {
|
|
627
628
|
return exports.localDate.fromDate(new Date()).toISODate();
|
|
628
629
|
}
|
|
629
|
-
exports.todayString = todayString;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.localTime = exports.LocalTime = exports.ISODayOfWeek = void 0;
|
|
4
|
+
exports.nowUnix = nowUnix;
|
|
4
5
|
const assert_1 = require("../error/assert");
|
|
5
6
|
const is_util_1 = require("../is.util");
|
|
6
7
|
const time_util_1 = require("../time/time.util");
|
|
@@ -823,4 +824,3 @@ Object.setPrototypeOf(exports.localTime, localTimeFactory);
|
|
|
823
824
|
function nowUnix() {
|
|
824
825
|
return Math.floor(Date.now() / 1000);
|
|
825
826
|
}
|
|
826
|
-
exports.nowUnix = nowUnix;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._AsyncMemo = void 0;
|
|
4
|
+
exports._getAsyncMemo = _getAsyncMemo;
|
|
4
5
|
const assert_1 = require("../error/assert");
|
|
5
6
|
const types_1 = require("../types");
|
|
6
7
|
const decorator_util_1 = require("./decorator.util");
|
|
@@ -115,4 +116,3 @@ function _getAsyncMemo(method) {
|
|
|
115
116
|
(0, assert_1._assert)(typeof method?.getInstanceCache === 'function', 'method is not an AsyncMemo instance');
|
|
116
117
|
return method;
|
|
117
118
|
}
|
|
118
|
-
exports._getAsyncMemo = _getAsyncMemo;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._createPromiseDecorator =
|
|
3
|
+
exports._createPromiseDecorator = _createPromiseDecorator;
|
|
4
4
|
const decorator_util_1 = require("./decorator.util");
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
@@ -83,4 +83,3 @@ function _createPromiseDecorator(cfg, decoratorParams = {}) {
|
|
|
83
83
|
return pd;
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
exports._createPromiseDecorator = _createPromiseDecorator;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._Debounce = _Debounce;
|
|
4
|
+
exports._Throttle = _Throttle;
|
|
4
5
|
const debounce_1 = require("./debounce");
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
6
7
|
function _Debounce(wait, opt = {}) {
|
|
@@ -10,7 +11,6 @@ function _Debounce(wait, opt = {}) {
|
|
|
10
11
|
return descriptor;
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
exports._Debounce = _Debounce;
|
|
14
14
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
15
|
function _Throttle(wait, opt = {}) {
|
|
16
16
|
return (target, key, descriptor) => {
|
|
@@ -19,4 +19,3 @@ function _Throttle(wait, opt = {}) {
|
|
|
19
19
|
return descriptor;
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
exports._Throttle = _Throttle;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._debounce = _debounce;
|
|
4
|
+
exports._throttle = _throttle;
|
|
4
5
|
function _debounce(func, wait, opt = {}) {
|
|
5
6
|
let lastArgs;
|
|
6
7
|
let lastThis;
|
|
@@ -107,7 +108,6 @@ function _debounce(func, wait, opt = {}) {
|
|
|
107
108
|
debounced.pending = pending;
|
|
108
109
|
return debounced;
|
|
109
110
|
}
|
|
110
|
-
exports._debounce = _debounce;
|
|
111
111
|
function _throttle(func, wait, opt = {}) {
|
|
112
112
|
return _debounce(func, wait, {
|
|
113
113
|
leading: true,
|
|
@@ -116,4 +116,3 @@ function _throttle(func, wait, opt = {}) {
|
|
|
116
116
|
maxWait: wait,
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
exports._throttle = _throttle;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._getMethodSignature = _getMethodSignature;
|
|
4
|
+
exports._getTargetMethodSignature = _getTargetMethodSignature;
|
|
5
|
+
exports._getArgsSignature = _getArgsSignature;
|
|
4
6
|
/**
|
|
5
7
|
* @returns
|
|
6
8
|
* e.g `NameOfYourClass.methodName`
|
|
@@ -10,14 +12,12 @@ function _getMethodSignature(ctx, keyStr) {
|
|
|
10
12
|
const { instanceId } = ctx;
|
|
11
13
|
return `${ctx.constructor.name}${instanceId ? `#${instanceId}` : ''}.${keyStr}`;
|
|
12
14
|
}
|
|
13
|
-
exports._getMethodSignature = _getMethodSignature;
|
|
14
15
|
/**
|
|
15
16
|
* @returns `NameOfYourClass.methodName`
|
|
16
17
|
*/
|
|
17
18
|
function _getTargetMethodSignature(target, keyStr) {
|
|
18
19
|
return `${target.constructor.name}.${keyStr}`;
|
|
19
20
|
}
|
|
20
|
-
exports._getTargetMethodSignature = _getTargetMethodSignature;
|
|
21
21
|
/**
|
|
22
22
|
* @example
|
|
23
23
|
* e.g for method (a: string, b: string, c: string)
|
|
@@ -34,4 +34,3 @@ function _getArgsSignature(args = [], logArgs = true) {
|
|
|
34
34
|
})
|
|
35
35
|
.join(', ');
|
|
36
36
|
}
|
|
37
|
-
exports._getArgsSignature = _getArgsSignature;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._LogMethod =
|
|
3
|
+
exports._LogMethod = _LogMethod;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
const time_util_1 = require("../time/time.util");
|
|
6
6
|
const decorator_util_1 = require("./decorator.util");
|
|
@@ -71,7 +71,6 @@ function _LogMethod(opt = {}) {
|
|
|
71
71
|
return descriptor;
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
exports._LogMethod = _LogMethod;
|
|
75
74
|
// eslint-disable-next-line max-params
|
|
76
75
|
function logFinished(logger, callSignature, started, sma, logResultFn, res, err) {
|
|
77
76
|
const millis = Date.now() - started;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._Memo = void 0;
|
|
4
|
+
exports._getMemo = _getMemo;
|
|
4
5
|
const assert_1 = require("../error/assert");
|
|
5
6
|
const types_1 = require("../types");
|
|
6
7
|
const decorator_util_1 = require("./decorator.util");
|
|
@@ -84,4 +85,3 @@ function _getMemo(method) {
|
|
|
84
85
|
(0, assert_1._assert)(typeof method?.getInstanceCache === 'function', 'method is not a Memo instance');
|
|
85
86
|
return method;
|
|
86
87
|
}
|
|
87
|
-
exports._getMemo = _getMemo;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._memoFn =
|
|
3
|
+
exports._memoFn = _memoFn;
|
|
4
4
|
const memo_util_1 = require("./memo.util");
|
|
5
5
|
/**
|
|
6
6
|
* Only supports Sync functions.
|
|
@@ -30,4 +30,3 @@ function _memoFn(fn, opt = {}) {
|
|
|
30
30
|
Object.assign(memoizedFn, { cache });
|
|
31
31
|
return memoizedFn;
|
|
32
32
|
}
|
|
33
|
-
exports._memoFn = _memoFn;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._memoFnAsync =
|
|
3
|
+
exports._memoFnAsync = _memoFnAsync;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const memo_util_1 = require("./memo.util");
|
|
6
6
|
/**
|
|
@@ -36,4 +36,3 @@ function _memoFnAsync(fn, opt) {
|
|
|
36
36
|
Object.assign(memoizedFn, { cache });
|
|
37
37
|
return memoizedFn;
|
|
38
38
|
}
|
|
39
|
-
exports._memoFnAsync = _memoFnAsync;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._Retry =
|
|
3
|
+
exports._Retry = _Retry;
|
|
4
4
|
const __1 = require("..");
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
6
6
|
function _Retry(opt = {}) {
|
|
@@ -10,4 +10,3 @@ function _Retry(opt = {}) {
|
|
|
10
10
|
return descriptor;
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
exports._Retry = _Retry;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports._Timeout =
|
|
3
|
+
exports._Timeout = _Timeout;
|
|
4
4
|
const assert_1 = require("../error/assert");
|
|
5
5
|
const pTimeout_1 = require("../promise/pTimeout");
|
|
6
6
|
const decorator_util_1 = require("./decorator.util");
|
|
@@ -20,4 +20,3 @@ function _Timeout(opt) {
|
|
|
20
20
|
return descriptor;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
exports._Timeout = _Timeout;
|
package/dist/define.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._lazyValue = _lazyValue;
|
|
4
|
+
exports._defineLazyProperty = _defineLazyProperty;
|
|
5
|
+
exports._defineLazyProps = _defineLazyProps;
|
|
6
|
+
exports._defineProperty = _defineProperty;
|
|
7
|
+
exports._defineProps = _defineProps;
|
|
8
|
+
exports._defineNonNullishProps = _defineNonNullishProps;
|
|
4
9
|
const object_util_1 = require("./object/object.util");
|
|
5
10
|
const types_1 = require("./types");
|
|
6
11
|
/**
|
|
@@ -23,7 +28,6 @@ function _lazyValue(fn) {
|
|
|
23
28
|
return result;
|
|
24
29
|
});
|
|
25
30
|
}
|
|
26
|
-
exports._lazyValue = _lazyValue;
|
|
27
31
|
/**
|
|
28
32
|
* interface Obj {
|
|
29
33
|
* v: number
|
|
@@ -56,7 +60,6 @@ function _defineLazyProperty(obj, propertyName, fn) {
|
|
|
56
60
|
});
|
|
57
61
|
return obj;
|
|
58
62
|
}
|
|
59
|
-
exports._defineLazyProperty = _defineLazyProperty;
|
|
60
63
|
/**
|
|
61
64
|
* Like _defineLazyProperty, but allows to define multiple props at once.
|
|
62
65
|
*/
|
|
@@ -64,7 +67,6 @@ function _defineLazyProps(obj, props) {
|
|
|
64
67
|
Object.entries(props).forEach(([k, fn]) => _defineLazyProperty(obj, k, fn));
|
|
65
68
|
return obj;
|
|
66
69
|
}
|
|
67
|
-
exports._defineLazyProps = _defineLazyProps;
|
|
68
70
|
/**
|
|
69
71
|
* Same as Object.defineProperty, but with better (least restricting) defaults.
|
|
70
72
|
*
|
|
@@ -90,7 +92,6 @@ function _defineProperty(obj, prop, pd) {
|
|
|
90
92
|
...pd,
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
|
-
exports._defineProperty = _defineProperty;
|
|
94
95
|
/**
|
|
95
96
|
* Object.defineProperties with better defaults.
|
|
96
97
|
* See _defineProperty for exact defaults definition.
|
|
@@ -104,7 +105,6 @@ function _defineProps(obj, props) {
|
|
|
104
105
|
...pd,
|
|
105
106
|
})));
|
|
106
107
|
}
|
|
107
|
-
exports._defineProps = _defineProps;
|
|
108
108
|
/**
|
|
109
109
|
* Like _defineProps, but skips props with nullish values.
|
|
110
110
|
*/
|
|
@@ -115,4 +115,3 @@ function _defineNonNullishProps(obj, props) {
|
|
|
115
115
|
return [k, pd];
|
|
116
116
|
}));
|
|
117
117
|
}
|
|
118
|
-
exports._defineNonNullishProps = _defineNonNullishProps;
|