@oscarpalmer/atoms 0.217.0 → 0.219.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/array/filter.d.mts +38 -4
- package/dist/array/find.d.mts +34 -0
- package/dist/array/first.d.mts +40 -4
- package/dist/array/insert.mjs +1 -1
- package/dist/array/last.d.mts +46 -10
- package/dist/array/partition.d.mts +24 -8
- package/dist/array/reverse.d.mts +6 -0
- package/dist/array/reverse.mjs +6 -0
- package/dist/array/select.d.mts +97 -116
- package/dist/array/select.mjs +19 -15
- package/dist/array/single.d.mts +22 -0
- package/dist/array/single.mjs +1 -1
- package/dist/array/slice.mjs +27 -14
- package/dist/array/sort.d.mts +54 -0
- package/dist/array/sort.mjs +2 -1
- package/dist/color/misc/get.mjs +3 -1
- package/dist/color/space/hex.d.mts +8 -0
- package/dist/color/space/hex.mjs +9 -1
- package/dist/function/retry.d.mts +1 -1
- package/dist/function/retry.mjs +5 -2
- package/dist/index.d.mts +879 -324
- package/dist/index.mjs +480 -173
- package/dist/internal/array/callbacks.mjs +1 -1
- package/dist/internal/array/find.d.mts +3 -3
- package/dist/internal/array/find.mjs +90 -48
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/match.mjs +21 -17
- package/dist/internal/array/sets.mjs +7 -1
- package/dist/internal/array/shuffle.d.mts +5 -0
- package/dist/internal/array/shuffle.mjs +5 -0
- package/dist/internal/math/aggregate.d.mts +69 -21
- package/dist/internal/math/aggregate.mjs +4 -1
- package/dist/internal/math/misc.d.mts +14 -0
- package/dist/internal/math/misc.mjs +14 -0
- package/dist/internal/number.d.mts +19 -1
- package/dist/internal/number.mjs +22 -2
- package/dist/internal/plan/plan.generate.mjs +3 -3
- package/dist/internal/random.d.mts +6 -0
- package/dist/internal/random.mjs +13 -2
- package/dist/internal/result/attempt.mjs +4 -4
- package/dist/internal/string/case.d.mts +63 -0
- package/dist/internal/string/case.mjs +63 -0
- package/dist/internal/string/misc.d.mts +20 -0
- package/dist/internal/string/misc.mjs +22 -1
- package/dist/internal/subscription.mjs +1 -1
- package/dist/internal/value/equal.mjs +2 -1
- package/dist/internal/value/partial.mjs +3 -1
- package/dist/logger.d.mts +12 -0
- package/dist/logger.mjs +12 -0
- package/dist/math.d.mts +90 -0
- package/dist/math.mjs +7 -0
- package/dist/models/array/array.find.model.d.mts +26 -0
- package/dist/models/array/array.misc.model.d.mts +2 -4
- package/dist/models/index.d.mts +1 -1
- package/dist/models/plan.model.d.mts +2 -0
- package/dist/models/plan.model.mjs +3 -1
- package/dist/models/string/string.fuzzy.model.d.mts +1 -1
- package/dist/models/string/string.misc.model.mjs +1 -1
- package/dist/models/value/value.merge.model.d.mts +4 -4
- package/dist/plan/index.d.mts +1 -4
- package/dist/plan/index.mjs +2 -3
- package/dist/plan/use.mjs +4 -4
- package/dist/promise/index.d.mts +6 -4
- package/dist/promise/index.mjs +4 -4
- package/dist/promise/misc.d.mts +6 -0
- package/dist/promise/misc.mjs +11 -2
- package/dist/promise/timed.d.mts +3 -0
- package/dist/promise/timed.mjs +5 -2
- package/dist/queue.d.mts +0 -1
- package/dist/queue.mjs +5 -6
- package/dist/random.d.mts +2 -2
- package/dist/random.mjs +3 -3
- package/dist/result/match.mjs +2 -2
- package/dist/result/misc.mjs +3 -10
- package/dist/result/work/pipe.d.mts +24 -22
- package/dist/result/work/pipe.mjs +7 -3
- package/dist/string/fuzzy.mjs +1 -1
- package/dist/string/index.d.mts +15 -1
- package/dist/string/index.mjs +16 -2
- package/dist/string/match.d.mts +24 -0
- package/dist/string/match.mjs +24 -0
- package/dist/string/template.d.mts +4 -0
- package/dist/value/clone.mjs +1 -1
- package/dist/value/merge.mjs +17 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -49,7 +49,7 @@ export type KeyOrCallbackValue<Item, Arg extends KeyOrCallback<Item>> = Arg exte
|
|
|
49
49
|
/**
|
|
50
50
|
* A nested array
|
|
51
51
|
*/
|
|
52
|
-
export type NestedArray<Value> = Value extends
|
|
52
|
+
export type NestedArray<Value> = Value extends ReadonlyArray<infer NestedValue> ? NestedArray<NestedValue> : Value;
|
|
53
53
|
/**
|
|
54
54
|
* All nested keys of an object as dot notation strings _(up to 5 levels deep)_
|
|
55
55
|
*/
|
|
@@ -145,7 +145,7 @@ export type Unsubscriber = () => void;
|
|
|
145
145
|
* ); // => [{id: 1}, {id: 3}]
|
|
146
146
|
* ```
|
|
147
147
|
*/
|
|
148
|
-
export declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>):
|
|
148
|
+
export declare function exclude<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[];
|
|
149
149
|
/**
|
|
150
150
|
* Get a filtered array of items that do not match the value
|
|
151
151
|
*
|
|
@@ -165,7 +165,25 @@ export declare function exclude<Item, Callback extends (item: Item, index: numbe
|
|
|
165
165
|
* ); // => [{id: 1}, {id: 3}]
|
|
166
166
|
* ```
|
|
167
167
|
*/
|
|
168
|
-
export declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]):
|
|
168
|
+
export declare function exclude<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
|
|
169
|
+
/**
|
|
170
|
+
* Get a narrowed array of items that do not match the filter
|
|
171
|
+
*
|
|
172
|
+
* _Available as `exclude` and `filter.remove`_
|
|
173
|
+
*
|
|
174
|
+
* @param array Array to search in
|
|
175
|
+
* @param filter Type guard to exclude and narrow down the items
|
|
176
|
+
* @returns Narrowed array of items that do not match the filter
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* exclude(
|
|
181
|
+
* [1, 'a', 2, 'b'],
|
|
182
|
+
* (item): item is string => typeof item === 'string',
|
|
183
|
+
* ); // => [1, 2]
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function exclude<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Array<Exclude<Item, Narrowed>>;
|
|
169
187
|
/**
|
|
170
188
|
* Get a filtered array of items that do not match the filter
|
|
171
189
|
*
|
|
@@ -183,7 +201,7 @@ export declare function exclude<Item extends PlainObject, ItemKey extends keyof
|
|
|
183
201
|
* ); // => [{id: 1}, {id: 3}]
|
|
184
202
|
* ```
|
|
185
203
|
*/
|
|
186
|
-
export declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean):
|
|
204
|
+
export declare function exclude<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[];
|
|
187
205
|
/**
|
|
188
206
|
* Get a filtered array of items that do not match the given item
|
|
189
207
|
*
|
|
@@ -198,7 +216,7 @@ export declare function exclude<Item>(array: Item[], filter: (item: Item, index:
|
|
|
198
216
|
* exclude([1, 2, 3], 2); // => [1, 3]
|
|
199
217
|
* ```
|
|
200
218
|
*/
|
|
201
|
-
export declare function exclude<Item>(array: Item[], item: Item):
|
|
219
|
+
export declare function exclude<Item>(array: Item[], item: Item): Item[];
|
|
202
220
|
/**
|
|
203
221
|
* Get a filtered array of items
|
|
204
222
|
*
|
|
@@ -235,6 +253,22 @@ export declare function filter<Item, Callback extends (item: Item, index: number
|
|
|
235
253
|
* ```
|
|
236
254
|
*/
|
|
237
255
|
export declare function filter<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[];
|
|
256
|
+
/**
|
|
257
|
+
* Get a narrowed array of items matching the filter
|
|
258
|
+
*
|
|
259
|
+
* @param array Array to search in
|
|
260
|
+
* @param filter Type guard to match and narrow down the items
|
|
261
|
+
* @returns Narrowed array of items
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* filter(
|
|
266
|
+
* [{id: 1, tags: ['a', 'b']}, {id: 2}, {id: 3, tags: ['c']}],
|
|
267
|
+
* (item): item is {id: number; tags: string[]} => item.tags != null,
|
|
268
|
+
* ); // => [{id: 1, tags: ['a', 'b']}, {id: 3, tags: ['c']}]
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
export declare function filter<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed[];
|
|
238
272
|
/**
|
|
239
273
|
* Get a filtered array of items matching the filter
|
|
240
274
|
*
|
|
@@ -305,6 +339,22 @@ export declare function find<Item, Callback extends (item: Item, index: number,
|
|
|
305
339
|
* ```
|
|
306
340
|
*/
|
|
307
341
|
export declare function find<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
|
|
342
|
+
/**
|
|
343
|
+
* Get the first narrowed item matching the filter
|
|
344
|
+
*
|
|
345
|
+
* @param array Array to search in
|
|
346
|
+
* @param filter Type guard to match and narrow down the items
|
|
347
|
+
* @returns First narrowed item that matches the filter, or `undefined` if no match is found
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* find(
|
|
352
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
353
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
354
|
+
* ); // => {id: 2, value: 'a'}
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
export declare function find<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
|
|
308
358
|
/**
|
|
309
359
|
* Get the first item matching the filter
|
|
310
360
|
*
|
|
@@ -374,6 +424,24 @@ export declare function findLast<Item, Callback extends (item: Item, index: numb
|
|
|
374
424
|
* ```
|
|
375
425
|
*/
|
|
376
426
|
export declare function findLast<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
|
|
427
|
+
/**
|
|
428
|
+
* Get the last narrowed item matching the filter
|
|
429
|
+
*
|
|
430
|
+
* _Available as `findLast` and `find.last`_
|
|
431
|
+
*
|
|
432
|
+
* @param array Array to search in
|
|
433
|
+
* @param filter Type guard to match and narrow down the items
|
|
434
|
+
* @returns Last narrowed item that matches the filter, or `undefined` if no match is found
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* ```typescript
|
|
438
|
+
* findLast(
|
|
439
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
440
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
441
|
+
* ); // => {id: 3, value: 'b'}
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
export declare function findLast<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
|
|
377
445
|
/**
|
|
378
446
|
* Get the last item matching the filter
|
|
379
447
|
*
|
|
@@ -448,6 +516,22 @@ export declare function first<Item, Callback extends (item: Item, index: number,
|
|
|
448
516
|
* ```
|
|
449
517
|
*/
|
|
450
518
|
export declare function first<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
|
|
519
|
+
/**
|
|
520
|
+
* Get the first narrowed item matching the filter
|
|
521
|
+
*
|
|
522
|
+
* @param array Array to search in
|
|
523
|
+
* @param filter Type guard to match and narrow down the items
|
|
524
|
+
* @returns First narrowed item that matches the filter, or `undefined` if no match is found
|
|
525
|
+
*
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* first(
|
|
529
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
530
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
531
|
+
* ); // => {id: 2, value: 'a'}
|
|
532
|
+
* ```
|
|
533
|
+
*/
|
|
534
|
+
export declare function first<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
|
|
451
535
|
/**
|
|
452
536
|
* Get the first item matching the filter
|
|
453
537
|
*
|
|
@@ -481,7 +565,7 @@ export declare function first<Item>(array: Item[]): Item | undefined;
|
|
|
481
565
|
/**
|
|
482
566
|
* Get the first item matching the given value, or a default value if no match is found
|
|
483
567
|
*
|
|
484
|
-
* _Available as `firstOrDefault` and `first.
|
|
568
|
+
* _Available as `firstOrDefault` and `first.defaulted`_
|
|
485
569
|
*
|
|
486
570
|
* @param array Array to search in
|
|
487
571
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -503,7 +587,7 @@ export declare function firstOrDefault<Item, Callback extends (item: Item, index
|
|
|
503
587
|
/**
|
|
504
588
|
* Get the first item matching the given value by key, or a default value if no match is found
|
|
505
589
|
*
|
|
506
|
-
* _Available as `firstOrDefault` and `first.
|
|
590
|
+
* _Available as `firstOrDefault` and `first.defaulted`_
|
|
507
591
|
*
|
|
508
592
|
* @param array Array to search in
|
|
509
593
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -522,10 +606,30 @@ export declare function firstOrDefault<Item, Callback extends (item: Item, index
|
|
|
522
606
|
* ```
|
|
523
607
|
*/
|
|
524
608
|
export declare function firstOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
|
|
609
|
+
/**
|
|
610
|
+
* Get the first narrowed item matching the filter, or a default value if no match is found
|
|
611
|
+
*
|
|
612
|
+
* _Available as `firstOrDefault` and `first.defaulted`_
|
|
613
|
+
*
|
|
614
|
+
* @param array Array to search in
|
|
615
|
+
* @param defaultValue Default value to return if no match is found
|
|
616
|
+
* @param filter Type guard to match and narrow down the items
|
|
617
|
+
* @returns First narrowed item that matches the filter, or the default value if no match is found
|
|
618
|
+
*
|
|
619
|
+
* @example
|
|
620
|
+
* ```typescript
|
|
621
|
+
* firstOrDefault(
|
|
622
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
623
|
+
* {id: -1, value: 'c'},
|
|
624
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
625
|
+
* ); // => {id: 2, value: 'a'}
|
|
626
|
+
* ```
|
|
627
|
+
*/
|
|
628
|
+
export declare function firstOrDefault<Item, Narrowed extends Item, Default>(array: Item[], defaultValue: Default, filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | Default;
|
|
525
629
|
/**
|
|
526
630
|
* Get the first item matching the filter, or a default value if no match is found
|
|
527
631
|
*
|
|
528
|
-
* _Available as `firstOrDefault` and `first.
|
|
632
|
+
* _Available as `firstOrDefault` and `first.defaulted`_
|
|
529
633
|
*
|
|
530
634
|
* @param array Array to search in
|
|
531
635
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -545,7 +649,7 @@ export declare function firstOrDefault<Item>(array: Item[], defaultValue: Item,
|
|
|
545
649
|
/**
|
|
546
650
|
* Get the first item from an array, or a default value if the array is empty
|
|
547
651
|
*
|
|
548
|
-
* _Available as `firstOrDefault` and `first.
|
|
652
|
+
* _Available as `firstOrDefault` and `first.defaulted`_
|
|
549
653
|
*
|
|
550
654
|
* @param array Array to get from
|
|
551
655
|
* @param defaultValue Default value to return if the array is empty
|
|
@@ -787,9 +891,7 @@ export declare function getArray<Value>(value: Value): Value[];
|
|
|
787
891
|
* Comparison of an array within another array
|
|
788
892
|
*/
|
|
789
893
|
type ArrayComparison = "end" | "inside" | "invalid" | "outside" | "same" | "start";
|
|
790
|
-
type
|
|
791
|
-
type ArrayMapped<Item, Map extends ArrayMapKeyOrCallback<Item>> = Map extends ((item: Item, index: number, array: Item[]) => unknown) ? ReturnType<Map> : Map extends keyof Item ? Item[Map] : never;
|
|
792
|
-
type ArrayObjectKeysOf<Item> = { [Key in keyof Item]: Item[Key] extends PlainObject ? Key : never; }[keyof Item];
|
|
894
|
+
type ArrayFlattened<Value> = Value extends ReadonlyArray<infer Inner> ? Inner : Value;
|
|
793
895
|
//#endregion
|
|
794
896
|
//#region src/internal/array/match.d.ts
|
|
795
897
|
/**
|
|
@@ -1044,6 +1146,11 @@ export declare function startsWithArray<Item>(haystack: Item[], needle: Item[]):
|
|
|
1044
1146
|
*
|
|
1045
1147
|
* @param array Original array
|
|
1046
1148
|
* @returns Shuffled array
|
|
1149
|
+
*
|
|
1150
|
+
* @example
|
|
1151
|
+
* ```typescript
|
|
1152
|
+
* shuffle([1, 2, 3]); // => [3, 1, 2] (maybe? it's random, you know)
|
|
1153
|
+
* ```
|
|
1047
1154
|
*/
|
|
1048
1155
|
export declare function shuffle<Item>(array: Item[]): Item[];
|
|
1049
1156
|
//#endregion
|
|
@@ -1355,7 +1462,7 @@ export declare function intersection<First, Second>(first: First[], second: Seco
|
|
|
1355
1462
|
* @param array Array to search in
|
|
1356
1463
|
* @param callback Callback to get an item's value for matching
|
|
1357
1464
|
* @param value Value to match against
|
|
1358
|
-
* @returns
|
|
1465
|
+
* @returns Tuple of matching and non-matching items
|
|
1359
1466
|
*
|
|
1360
1467
|
* @example
|
|
1361
1468
|
* ```typescript
|
|
@@ -1366,14 +1473,14 @@ export declare function intersection<First, Second>(first: First[], second: Seco
|
|
|
1366
1473
|
* ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
|
|
1367
1474
|
* ```
|
|
1368
1475
|
*/
|
|
1369
|
-
export declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item[][];
|
|
1476
|
+
export declare function partition<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): [Item[], Item[]];
|
|
1370
1477
|
/**
|
|
1371
1478
|
* Get a partitioned array of items
|
|
1372
1479
|
*
|
|
1373
1480
|
* @param array Array to search in
|
|
1374
1481
|
* @param key Key to get an item's value for matching
|
|
1375
1482
|
* @param value Value to match against
|
|
1376
|
-
* @returns
|
|
1483
|
+
* @returns Tuple of matching and non-matching items
|
|
1377
1484
|
*
|
|
1378
1485
|
* @example
|
|
1379
1486
|
* ```typescript
|
|
@@ -1384,13 +1491,29 @@ export declare function partition<Item, Callback extends (item: Item, index: num
|
|
|
1384
1491
|
* ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
|
|
1385
1492
|
* ```
|
|
1386
1493
|
*/
|
|
1387
|
-
export declare function partition<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item[][];
|
|
1494
|
+
export declare function partition<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): [Item[], Item[]];
|
|
1495
|
+
/**
|
|
1496
|
+
* Get a partitioned array of items
|
|
1497
|
+
*
|
|
1498
|
+
* @param array Array to search in
|
|
1499
|
+
* @param filter Type guard to match and narrow down the items
|
|
1500
|
+
* @returns Tuple of matching and non-matching items
|
|
1501
|
+
*
|
|
1502
|
+
* @example
|
|
1503
|
+
* ```typescript
|
|
1504
|
+
* partition(
|
|
1505
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
1506
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
1507
|
+
* ); // => [[{id: 2, value: 'a'}, {id: 3, value: 'b'}], [{id: 1, value: 10}]]
|
|
1508
|
+
* ```
|
|
1509
|
+
*/
|
|
1510
|
+
export declare function partition<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): [Narrowed[], Array<Exclude<Item, Narrowed>>];
|
|
1388
1511
|
/**
|
|
1389
1512
|
* Get a partitioned array of items
|
|
1390
1513
|
*
|
|
1391
1514
|
* @param array Array to search in
|
|
1392
1515
|
* @param filter Filter callback to match items
|
|
1393
|
-
* @returns
|
|
1516
|
+
* @returns Tuple of matching and non-matching items
|
|
1394
1517
|
*
|
|
1395
1518
|
* @example
|
|
1396
1519
|
* ```typescript
|
|
@@ -1400,20 +1523,20 @@ export declare function partition<Item extends PlainObject, ItemKey extends keyo
|
|
|
1400
1523
|
* ); // => [[{id: 2}], [{id: 1}, {id: 3}]]
|
|
1401
1524
|
* ```
|
|
1402
1525
|
*/
|
|
1403
|
-
export declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): Item[][];
|
|
1526
|
+
export declare function partition<Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean): [Item[], Item[]];
|
|
1404
1527
|
/**
|
|
1405
1528
|
* Get a partitioned array of items matching the given item
|
|
1406
1529
|
*
|
|
1407
1530
|
* @param array Array to search in
|
|
1408
1531
|
* @param item Item to match against
|
|
1409
|
-
* @returns
|
|
1532
|
+
* @returns Tuple of matching and non-matching items
|
|
1410
1533
|
*
|
|
1411
1534
|
* @example
|
|
1412
1535
|
* ```typescript
|
|
1413
1536
|
* partition([1, 2, 3, 4, 5], 3); // => [[3], [1, 2, 4, 5]]
|
|
1414
1537
|
* ```
|
|
1415
1538
|
*/
|
|
1416
|
-
export declare function partition<Item>(array: Item[], item: Item): Item[][];
|
|
1539
|
+
export declare function partition<Item>(array: Item[], item: Item): [Item[], Item[]];
|
|
1417
1540
|
//#endregion
|
|
1418
1541
|
//#region src/array/push.d.ts
|
|
1419
1542
|
/**
|
|
@@ -1438,6 +1561,12 @@ export declare function push<Item>(array: Item[], pushed: Item[]): number;
|
|
|
1438
1561
|
*
|
|
1439
1562
|
* @param array Array to reverse
|
|
1440
1563
|
* @returns Reversed array
|
|
1564
|
+
*
|
|
1565
|
+
* @example
|
|
1566
|
+
* ```typescript
|
|
1567
|
+
* reverse([1, 2, 3]); // => [3, 2, 1]
|
|
1568
|
+
* reverse(['a', 'b', 'c']); // => ['c', 'b', 'a']
|
|
1569
|
+
* ```
|
|
1441
1570
|
*/
|
|
1442
1571
|
export declare function reverse<Item>(array: Item[]): Item[];
|
|
1443
1572
|
//#endregion
|
|
@@ -1482,6 +1611,28 @@ export declare function single<Item, Callback extends (item: Item, index: number
|
|
|
1482
1611
|
* ```
|
|
1483
1612
|
*/
|
|
1484
1613
|
export declare function single<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
|
|
1614
|
+
/**
|
|
1615
|
+
* Get the _only_ narrowed item matching the filter
|
|
1616
|
+
*
|
|
1617
|
+
* _Throws an error if multiple items match the filter_
|
|
1618
|
+
*
|
|
1619
|
+
* @param array Array to search in
|
|
1620
|
+
* @param filter Type guard to match and narrow down the items
|
|
1621
|
+
* @returns Only narrowed item that matches the filter, or `undefined` if no match is found
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
* ```typescript
|
|
1625
|
+
* single(
|
|
1626
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
1627
|
+
* (item): item is {id: number; value: number} => typeof item.value === 'number',
|
|
1628
|
+
* ); // => {id: 1, value: 10}
|
|
1629
|
+
* single(
|
|
1630
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
1631
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
1632
|
+
* ); // => throws an error as there are two matches
|
|
1633
|
+
* ```
|
|
1634
|
+
*/
|
|
1635
|
+
export declare function single<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
|
|
1485
1636
|
/**
|
|
1486
1637
|
* Get the _only_ item matching the filter
|
|
1487
1638
|
*
|
|
@@ -2024,7 +2175,7 @@ export declare function update<Item>(destination: Item[], updated: Item[]): Item
|
|
|
2024
2175
|
//#endregion
|
|
2025
2176
|
//#region src/array/last.d.ts
|
|
2026
2177
|
/**
|
|
2027
|
-
* Get the last
|
|
2178
|
+
* Get the last item matching the given value
|
|
2028
2179
|
*
|
|
2029
2180
|
* @param array Array to search in
|
|
2030
2181
|
* @param callback Callback to get an item's value for matching
|
|
@@ -2042,7 +2193,7 @@ export declare function update<Item>(destination: Item[], updated: Item[]): Item
|
|
|
2042
2193
|
*/
|
|
2043
2194
|
export declare function last<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], callback: Callback, value: ReturnType<Callback>): Item | undefined;
|
|
2044
2195
|
/**
|
|
2045
|
-
* Get the
|
|
2196
|
+
* Get the last item matching the given value by key
|
|
2046
2197
|
*
|
|
2047
2198
|
* @param array Array to search in
|
|
2048
2199
|
* @param key Key to get an item's value for matching
|
|
@@ -2059,6 +2210,22 @@ export declare function last<Item, Callback extends (item: Item, index: number,
|
|
|
2059
2210
|
* ```
|
|
2060
2211
|
*/
|
|
2061
2212
|
export declare function last<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): Item | undefined;
|
|
2213
|
+
/**
|
|
2214
|
+
* Get the last narrowed item matching the filter
|
|
2215
|
+
*
|
|
2216
|
+
* @param array Array to search in
|
|
2217
|
+
* @param filter Type guard to match and narrow down the items
|
|
2218
|
+
* @returns Last narrowed item that matches the filter, or `undefined` if no match is found
|
|
2219
|
+
*
|
|
2220
|
+
* @example
|
|
2221
|
+
* ```typescript
|
|
2222
|
+
* last(
|
|
2223
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
2224
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
2225
|
+
* ); // => {id: 3, value: 'b'}
|
|
2226
|
+
* ```
|
|
2227
|
+
*/
|
|
2228
|
+
export declare function last<Item, Narrowed extends Item>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | undefined;
|
|
2062
2229
|
/**
|
|
2063
2230
|
* Get the last item matching the filter
|
|
2064
2231
|
*
|
|
@@ -2088,9 +2255,9 @@ export declare function last<Item>(array: Item[], filter: (item: Item, index: nu
|
|
|
2088
2255
|
*/
|
|
2089
2256
|
export declare function last<Item>(array: Item[]): Item | undefined;
|
|
2090
2257
|
/**
|
|
2091
|
-
* Get the last item matching the given value
|
|
2258
|
+
* Get the last item matching the given value, or a default value if no match is found
|
|
2092
2259
|
*
|
|
2093
|
-
* _Available as `lastOrDefault` and `last.
|
|
2260
|
+
* _Available as `lastOrDefault` and `last.defaulted`_
|
|
2094
2261
|
*
|
|
2095
2262
|
* @param array Array to search in
|
|
2096
2263
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -2110,9 +2277,9 @@ export declare function last<Item>(array: Item[]): Item | undefined;
|
|
|
2110
2277
|
*/
|
|
2111
2278
|
export declare function lastOrDefault<Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], defaultValue: Item, callback: Callback, value: ReturnType<Callback>): Item;
|
|
2112
2279
|
/**
|
|
2113
|
-
* Get the last item matching the given value by key
|
|
2280
|
+
* Get the last item matching the given value by key, or a default value if no match is found
|
|
2114
2281
|
*
|
|
2115
|
-
* _Available as `lastOrDefault` and `last.
|
|
2282
|
+
* _Available as `lastOrDefault` and `last.defaulted`_
|
|
2116
2283
|
*
|
|
2117
2284
|
* @param array Array to search in
|
|
2118
2285
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -2132,9 +2299,29 @@ export declare function lastOrDefault<Item, Callback extends (item: Item, index:
|
|
|
2132
2299
|
*/
|
|
2133
2300
|
export declare function lastOrDefault<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], defaultValue: Item, key: ItemKey, value: Item[ItemKey]): Item;
|
|
2134
2301
|
/**
|
|
2135
|
-
* Get the last item matching the filter
|
|
2302
|
+
* Get the last narrowed item matching the filter, or a default value if no match is found
|
|
2303
|
+
*
|
|
2304
|
+
* _Available as `lastOrDefault` and `last.defaulted`_
|
|
2305
|
+
*
|
|
2306
|
+
* @param array Array to search in
|
|
2307
|
+
* @param defaultValue Default value to return if no match is found
|
|
2308
|
+
* @param filter Type guard to match and narrow down the items
|
|
2309
|
+
* @returns Last narrowed item that matches the filter, or the default value if no match is found
|
|
2310
|
+
*
|
|
2311
|
+
* @example
|
|
2312
|
+
* ```typescript
|
|
2313
|
+
* lastOrDefault(
|
|
2314
|
+
* [{id: 1, value: 10}, {id: 2, value: 'a'}, {id: 3, value: 'b'}],
|
|
2315
|
+
* {id: -1, value: 'c'},
|
|
2316
|
+
* (item): item is {id: number; value: string} => typeof item.value === 'string',
|
|
2317
|
+
* ); // => {id: 3, value: 'b'}
|
|
2318
|
+
* ```
|
|
2319
|
+
*/
|
|
2320
|
+
export declare function lastOrDefault<Item, Narrowed extends Item, Default>(array: Item[], defaultValue: Default, filter: (item: Item, index: number, array: Item[]) => item is Narrowed): Narrowed | Default;
|
|
2321
|
+
/**
|
|
2322
|
+
* Get the last item matching the filter, or a default value if no match is found
|
|
2136
2323
|
*
|
|
2137
|
-
* _Available as `lastOrDefault` and `last.
|
|
2324
|
+
* _Available as `lastOrDefault` and `last.defaulted`_
|
|
2138
2325
|
*
|
|
2139
2326
|
* @param array Array to search in
|
|
2140
2327
|
* @param defaultValue Default value to return if no match is found
|
|
@@ -2152,9 +2339,9 @@ export declare function lastOrDefault<Item extends PlainObject, ItemKey extends
|
|
|
2152
2339
|
*/
|
|
2153
2340
|
export declare function lastOrDefault<Item>(array: Item[], defaultValue: Item, filter: (item: Item, index: number, array: Item[]) => boolean): Item;
|
|
2154
2341
|
/**
|
|
2155
|
-
* Get the last item from an array
|
|
2342
|
+
* Get the last item from an array, or a default value if the array is empty
|
|
2156
2343
|
*
|
|
2157
|
-
* _Available as `lastOrDefault` and `last.
|
|
2344
|
+
* _Available as `lastOrDefault` and `last.defaulted`_
|
|
2158
2345
|
*
|
|
2159
2346
|
* @param array Array to get from
|
|
2160
2347
|
* @param defaultValue Default value to return if the array is empty
|
|
@@ -2336,190 +2523,172 @@ export declare namespace move {
|
|
|
2336
2523
|
//#endregion
|
|
2337
2524
|
//#region src/array/select.d.ts
|
|
2338
2525
|
/**
|
|
2339
|
-
* Get a
|
|
2340
|
-
*
|
|
2341
|
-
* @param array Array to search in
|
|
2342
|
-
* @param filterCallback Callback to get an item's value for matching
|
|
2343
|
-
* @param filterValue Value to match against
|
|
2344
|
-
* @param map Callback or key to map the matched items
|
|
2345
|
-
* @returns Filtered and mapped array of items
|
|
2526
|
+
* Get a narrowed, mapped, and flattened array of items
|
|
2346
2527
|
*
|
|
2347
|
-
*
|
|
2348
|
-
* ```typescript
|
|
2349
|
-
* select(
|
|
2350
|
-
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
2351
|
-
* item => item.id,
|
|
2352
|
-
* 2,
|
|
2353
|
-
* item => item.name,
|
|
2354
|
-
* ); // => ['Bob']
|
|
2355
|
-
* ```
|
|
2356
|
-
*/
|
|
2357
|
-
export declare function filterAndMap<Item, FilterCallback extends (item: Item, index: number, array: Item[]) => unknown, Map extends ArrayMapKeyOrCallback<Item>>(array: Item[], filterCallback: FilterCallback, filterValue: ReturnType<FilterCallback>, map: Map): Array<ArrayMapped<Item, Map>>;
|
|
2358
|
-
/**
|
|
2359
|
-
* Get a filtered and mapped array of items
|
|
2528
|
+
* _Available as `filterAndFlatMap`, `filterAndMap.flat`, and `select.flat`_
|
|
2360
2529
|
*
|
|
2361
|
-
* @param array Array to
|
|
2362
|
-
* @param
|
|
2363
|
-
* @param
|
|
2364
|
-
* @
|
|
2365
|
-
* @returns Filtered and mapped array of items
|
|
2530
|
+
* @param array Array to select from
|
|
2531
|
+
* @param filter Type guard to filter and narrow down the items
|
|
2532
|
+
* @param mapper Callback to map and flatten the narrowed items
|
|
2533
|
+
* @returns Narrowed, mapped, and flattened array of items
|
|
2366
2534
|
*
|
|
2367
2535
|
* @example
|
|
2368
2536
|
* ```typescript
|
|
2369
|
-
*
|
|
2370
|
-
* [{id: 1,
|
|
2371
|
-
*
|
|
2372
|
-
*
|
|
2373
|
-
*
|
|
2374
|
-
* ); // => ['Bob']
|
|
2537
|
+
* filterAndFlatMap(
|
|
2538
|
+
* [{id: 1, tags: ['a', 'b']}, {id: 2}, {id: 3, tags: ['c']}],
|
|
2539
|
+
* (item): item is {id: number; tags: string[]} => item.tags != null,
|
|
2540
|
+
* item => item.tags,
|
|
2541
|
+
* ); // => ['a', 'b', 'c']
|
|
2375
2542
|
* ```
|
|
2376
2543
|
*/
|
|
2377
|
-
export declare function
|
|
2544
|
+
export declare function filterAndFlatMap<Item, Narrowed extends Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed, mapper: (item: Narrowed, index: number, array: Item[]) => Mapped): Array<ArrayFlattened<Mapped>>;
|
|
2378
2545
|
/**
|
|
2379
|
-
* Get a filtered and
|
|
2546
|
+
* Get a filtered, mapped, and flattened array of items
|
|
2380
2547
|
*
|
|
2381
|
-
*
|
|
2382
|
-
*
|
|
2383
|
-
* @param
|
|
2384
|
-
* @
|
|
2548
|
+
* _Available as `filterAndFlatMap`, `filterAndMap.flat`, and `select.flat`_
|
|
2549
|
+
*
|
|
2550
|
+
* @param array Array to select from
|
|
2551
|
+
* @param filter Callback to filter the items
|
|
2552
|
+
* @param mapper Callback to map and flatten the filtered items
|
|
2553
|
+
* @returns Filtered, mapped, and flattened array of items
|
|
2385
2554
|
*
|
|
2386
2555
|
* @example
|
|
2387
2556
|
* ```typescript
|
|
2388
|
-
*
|
|
2389
|
-
* [{id: 1,
|
|
2390
|
-
* item => item.id
|
|
2391
|
-
* item => item.
|
|
2392
|
-
* ); // => ['
|
|
2557
|
+
* filterAndFlatMap(
|
|
2558
|
+
* [{id: 1, tags: ['a', 'b']}, {id: 2, tags: ['c']}, {id: 3, tags: ['d', 'e']}],
|
|
2559
|
+
* item => item.id !== 2,
|
|
2560
|
+
* item => item.tags,
|
|
2561
|
+
* ); // => ['a', 'b', 'd', 'e']
|
|
2393
2562
|
* ```
|
|
2394
2563
|
*/
|
|
2395
|
-
export declare function
|
|
2564
|
+
export declare function filterAndFlatMap<Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, mapper: (item: Item, index: number, array: Item[]) => Mapped): Array<ArrayFlattened<Mapped>>;
|
|
2396
2565
|
/**
|
|
2397
|
-
* Get a
|
|
2566
|
+
* Get a narrowed and mapped array of items
|
|
2398
2567
|
*
|
|
2399
|
-
*
|
|
2400
|
-
*
|
|
2401
|
-
* @param
|
|
2402
|
-
* @
|
|
2568
|
+
* _Available as `filterAndMap` and `select`_
|
|
2569
|
+
*
|
|
2570
|
+
* @param array Array to select from
|
|
2571
|
+
* @param filter Type guard to filter and narrow down the items
|
|
2572
|
+
* @param mapper Callback to map the narrowed items
|
|
2573
|
+
* @returns Narrowed and mapped array of items
|
|
2403
2574
|
*
|
|
2404
2575
|
* @example
|
|
2405
2576
|
* ```typescript
|
|
2406
|
-
*
|
|
2407
|
-
* [1, 2, 3,
|
|
2408
|
-
*
|
|
2409
|
-
*
|
|
2410
|
-
* ); // => [
|
|
2577
|
+
* filterAndMap(
|
|
2578
|
+
* [{id: 1, name: 'Alice'}, {id: 2}, {id: 3, name: 'Charlie'}],
|
|
2579
|
+
* (item): item is {id: number; name: string} => item.name != null,
|
|
2580
|
+
* item => item.name.toUpperCase(),
|
|
2581
|
+
* ); // => ['ALICE', 'CHARLIE']
|
|
2411
2582
|
* ```
|
|
2412
2583
|
*/
|
|
2413
|
-
export declare function filterAndMap<Item,
|
|
2584
|
+
export declare function filterAndMap<Item, Narrowed extends Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => item is Narrowed, mapper: (item: Narrowed, index: number, array: Item[]) => Mapped): Mapped[];
|
|
2414
2585
|
/**
|
|
2415
|
-
* Get a
|
|
2586
|
+
* Get a filtered and mapped array of items
|
|
2416
2587
|
*
|
|
2417
|
-
* _Available as `
|
|
2588
|
+
* _Available as `filterAndMap` and `select`_
|
|
2418
2589
|
*
|
|
2419
|
-
* @param array Array to
|
|
2420
|
-
* @param
|
|
2421
|
-
* @param
|
|
2422
|
-
* @
|
|
2423
|
-
* @returns Mapped and filtered array of items
|
|
2590
|
+
* @param array Array to select from
|
|
2591
|
+
* @param filter Callback to filter the items
|
|
2592
|
+
* @param mapper Callback to map the filtered items
|
|
2593
|
+
* @returns Filtered and mapped array of items
|
|
2424
2594
|
*
|
|
2425
2595
|
* @example
|
|
2426
2596
|
* ```typescript
|
|
2427
|
-
*
|
|
2597
|
+
* filterAndMap(
|
|
2428
2598
|
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
2599
|
+
* item => item.id === 2,
|
|
2429
2600
|
* item => item.name,
|
|
2430
|
-
* value => value.length,
|
|
2431
|
-
* 3,
|
|
2432
2601
|
* ); // => ['Bob']
|
|
2433
2602
|
* ```
|
|
2434
2603
|
*/
|
|
2435
|
-
export declare function
|
|
2604
|
+
export declare function filterAndMap<Item, Mapped>(array: Item[], filter: (item: Item, index: number, array: Item[]) => boolean, mapper: (item: Item, index: number, array: Item[]) => Mapped): Mapped[];
|
|
2436
2605
|
/**
|
|
2437
|
-
* Get a mapped and
|
|
2606
|
+
* Get a mapped, flattened, and narrowed array of items
|
|
2438
2607
|
*
|
|
2439
|
-
* _Available as `
|
|
2608
|
+
* _Available as `flatMapAndFilter`, `mapAndFilter.flat`, and `reverseSelect.flat`_
|
|
2440
2609
|
*
|
|
2441
|
-
* @param array Array to
|
|
2442
|
-
* @param
|
|
2443
|
-
* @param
|
|
2444
|
-
* @
|
|
2445
|
-
* @returns Mapped and filtered array of items
|
|
2610
|
+
* @param array Array to select from
|
|
2611
|
+
* @param mapper Callback to map and flatten the items
|
|
2612
|
+
* @param filter Type guard to filter and narrow down the flattened items
|
|
2613
|
+
* @returns Mapped, flattened, and narrowed array of items
|
|
2446
2614
|
*
|
|
2447
2615
|
* @example
|
|
2448
2616
|
* ```typescript
|
|
2449
|
-
*
|
|
2450
|
-
* [{id: 1,
|
|
2451
|
-
* item =>
|
|
2452
|
-
* '
|
|
2453
|
-
*
|
|
2454
|
-
* ); // => [{label: 'Bob'}]
|
|
2617
|
+
* flatMapAndFilter(
|
|
2618
|
+
* [{id: 1, values: [1, 'a']}, {id: 2, values: ['b', 2]}],
|
|
2619
|
+
* item => item.values,
|
|
2620
|
+
* (value): value is number => typeof value === 'number',
|
|
2621
|
+
* ); // => [1, 2]
|
|
2455
2622
|
* ```
|
|
2456
2623
|
*/
|
|
2457
|
-
export declare function
|
|
2624
|
+
export declare function flatMapAndFilter<Item, Mapped, Narrowed extends ArrayFlattened<Mapped>>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: ArrayFlattened<Mapped>, index: number, array: Item[]) => item is Narrowed): Narrowed[];
|
|
2458
2625
|
/**
|
|
2459
|
-
* Get a mapped and filtered array of items
|
|
2626
|
+
* Get a mapped, flattened, and filtered array of items
|
|
2460
2627
|
*
|
|
2461
|
-
* _Available as `
|
|
2628
|
+
* _Available as `flatMapAndFilter`, `mapAndFilter.flat`, and `reverseSelect.flat`_
|
|
2462
2629
|
*
|
|
2463
|
-
* @param array Array to
|
|
2464
|
-
* @param
|
|
2465
|
-
* @param
|
|
2466
|
-
* @
|
|
2467
|
-
* @returns Mapped and filtered array of items
|
|
2630
|
+
* @param array Array to select from
|
|
2631
|
+
* @param mapper Callback to map and flatten the items
|
|
2632
|
+
* @param filter Callback to filter the flattened items
|
|
2633
|
+
* @returns Mapped, flattened, and filtered array of items
|
|
2468
2634
|
*
|
|
2469
2635
|
* @example
|
|
2470
2636
|
* ```typescript
|
|
2471
|
-
*
|
|
2472
|
-
* [{
|
|
2473
|
-
*
|
|
2474
|
-
*
|
|
2475
|
-
*
|
|
2476
|
-
* ); // => [{tag: 'b'}]
|
|
2637
|
+
* flatMapAndFilter(
|
|
2638
|
+
* [{id: 1, tags: ['a', 'b']}, {id: 2, tags: ['c']}, {id: 3, tags: ['b', 'd']}],
|
|
2639
|
+
* item => item.tags,
|
|
2640
|
+
* tag => tag !== 'b',
|
|
2641
|
+
* ); // => ['a', 'c', 'd']
|
|
2477
2642
|
* ```
|
|
2478
2643
|
*/
|
|
2479
|
-
export declare function
|
|
2644
|
+
export declare function flatMapAndFilter<Item, Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: ArrayFlattened<Mapped>, index: number, array: Item[]) => boolean): Array<ArrayFlattened<Mapped>>;
|
|
2480
2645
|
/**
|
|
2481
|
-
* Get a mapped and
|
|
2646
|
+
* Get a mapped and narrowed array of items
|
|
2482
2647
|
*
|
|
2483
|
-
* _Available as `reverseSelect`
|
|
2648
|
+
* _Available as `mapAndFilter`, `reverseSelect`, `filterAndMap.reverse`, and `select.reverse`_
|
|
2484
2649
|
*
|
|
2485
|
-
* @param array Array to
|
|
2486
|
-
* @param
|
|
2487
|
-
* @param filter
|
|
2488
|
-
* @returns Mapped and
|
|
2650
|
+
* @param array Array to select from
|
|
2651
|
+
* @param mapper Callback to map the items
|
|
2652
|
+
* @param filter Type guard to filter and narrow down the mapped items
|
|
2653
|
+
* @returns Mapped and narrowed array of items
|
|
2489
2654
|
*
|
|
2490
2655
|
* @example
|
|
2491
2656
|
* ```typescript
|
|
2492
|
-
*
|
|
2493
|
-
* [{id: 1, name: 'Alice'}, {id: 2
|
|
2657
|
+
* mapAndFilter(
|
|
2658
|
+
* [{id: 1, name: 'Alice'}, {id: 2}, {id: 3, name: 'Charlie'}],
|
|
2494
2659
|
* item => item.name,
|
|
2495
|
-
*
|
|
2496
|
-
* ); // => ['
|
|
2660
|
+
* (name): name is string => name != null,
|
|
2661
|
+
* ); // => ['Alice', 'Charlie']
|
|
2497
2662
|
* ```
|
|
2498
2663
|
*/
|
|
2499
|
-
export declare function mapAndFilter<Item,
|
|
2664
|
+
export declare function mapAndFilter<Item, Mapped, Narrowed extends Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: Mapped, index: number, array: Item[]) => item is Narrowed): Narrowed[];
|
|
2500
2665
|
/**
|
|
2501
2666
|
* Get a mapped and filtered array of items
|
|
2502
2667
|
*
|
|
2503
|
-
* _Available as `reverseSelect`
|
|
2668
|
+
* _Available as `mapAndFilter`, `reverseSelect`, `filterAndMap.reverse`, and `select.reverse`_
|
|
2504
2669
|
*
|
|
2505
|
-
* @param array Array to
|
|
2506
|
-
* @param
|
|
2507
|
-
* @param
|
|
2670
|
+
* @param array Array to select from
|
|
2671
|
+
* @param mapper Callback to map the items
|
|
2672
|
+
* @param filter Callback to filter the mapped items
|
|
2508
2673
|
* @returns Mapped and filtered array of items
|
|
2509
2674
|
*
|
|
2510
2675
|
* @example
|
|
2511
2676
|
* ```typescript
|
|
2512
|
-
*
|
|
2513
|
-
* [1, 2,
|
|
2514
|
-
*
|
|
2515
|
-
*
|
|
2516
|
-
* ); // => [
|
|
2677
|
+
* mapAndFilter(
|
|
2678
|
+
* [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}, {id: 3, name: 'Charlie'}],
|
|
2679
|
+
* item => item.name,
|
|
2680
|
+
* name => name.length > 3,
|
|
2681
|
+
* ); // => ['Alice', 'Charlie']
|
|
2517
2682
|
* ```
|
|
2518
2683
|
*/
|
|
2519
|
-
export declare function mapAndFilter<Item,
|
|
2684
|
+
export declare function mapAndFilter<Item, Mapped>(array: Item[], mapper: (item: Item, index: number, array: Item[]) => Mapped, filter: (item: Mapped, index: number, array: Item[]) => boolean): Mapped[];
|
|
2520
2685
|
export declare namespace filterAndMap {
|
|
2686
|
+
export var flat: typeof filterAndFlatMap;
|
|
2521
2687
|
export var reverse: typeof mapAndFilter;
|
|
2522
2688
|
}
|
|
2689
|
+
export declare namespace mapAndFilter {
|
|
2690
|
+
export var flat: typeof flatMapAndFilter;
|
|
2691
|
+
}
|
|
2523
2692
|
//#endregion
|
|
2524
2693
|
//#region src/models/array/array.sort.model.d.ts
|
|
2525
2694
|
/**
|
|
@@ -2649,6 +2818,11 @@ declare function Sorter(this: any, sorters: SortHandler[]): void;
|
|
|
2649
2818
|
* @param sorters Sorters to use to determine sorting
|
|
2650
2819
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2651
2820
|
* @returns Index for item
|
|
2821
|
+
*
|
|
2822
|
+
* @example
|
|
2823
|
+
* ```typescript
|
|
2824
|
+
* getSortedIndex([1, 3, 2], 2, [{key: 'value', direction: 'asc'}]); // => 1
|
|
2825
|
+
* ```
|
|
2652
2826
|
*/
|
|
2653
2827
|
export declare function getSortedIndex<Item>(array: Item[], item: Item, sorters: Array<ArraySorter<Item>>, descending?: boolean): number;
|
|
2654
2828
|
/**
|
|
@@ -2663,6 +2837,11 @@ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorters:
|
|
|
2663
2837
|
* @param sorter Sorter to use to determine sorting
|
|
2664
2838
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2665
2839
|
* @returns Index for item
|
|
2840
|
+
*
|
|
2841
|
+
* @example
|
|
2842
|
+
* ```typescript
|
|
2843
|
+
* getSortedIndex([1, 3, 2], 2, {key: 'value', direction: 'asc'}); // => 1
|
|
2844
|
+
* ```
|
|
2666
2845
|
*/
|
|
2667
2846
|
export declare function getSortedIndex<Item>(array: Item[], item: Item, sorter: ArraySorter<Item>, descending?: boolean): number;
|
|
2668
2847
|
/**
|
|
@@ -2676,6 +2855,11 @@ export declare function getSortedIndex<Item>(array: Item[], item: Item, sorter:
|
|
|
2676
2855
|
* @param item Item to get the index for
|
|
2677
2856
|
* @param descending Sorted in descending order? _(defaults to `false`)_
|
|
2678
2857
|
* @returns Index for item
|
|
2858
|
+
*
|
|
2859
|
+
* @example
|
|
2860
|
+
* ```typescript
|
|
2861
|
+
* getSortedIndex([1, 3, 2], 2); // => 1
|
|
2862
|
+
* ```
|
|
2679
2863
|
*/
|
|
2680
2864
|
export declare function getSortedIndex<Item>(array: Item[], item: Item, descending?: boolean): number;
|
|
2681
2865
|
/**
|
|
@@ -2716,6 +2900,12 @@ export declare function initializeSorter<Item>(descending?: boolean): Sorter<Ite
|
|
|
2716
2900
|
* @param sorters Sorters to determine sorting
|
|
2717
2901
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2718
2902
|
* @returns `true` if sorted, otherwise `false`
|
|
2903
|
+
*
|
|
2904
|
+
* @example
|
|
2905
|
+
* ```typescript
|
|
2906
|
+
* isSorted([1, 2, 3], [{key: 'value', direction: 'asc'}]); // => true
|
|
2907
|
+
* isSorted([3, 2, 1], [{key: 'value', direction: 'asc'}]); // => false
|
|
2908
|
+
* ```
|
|
2719
2909
|
*/
|
|
2720
2910
|
export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): boolean;
|
|
2721
2911
|
/**
|
|
@@ -2727,6 +2917,12 @@ export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter
|
|
|
2727
2917
|
* @param sorter Sorter to determine sorting
|
|
2728
2918
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2729
2919
|
* @returns `true` if sorted, otherwise `false`
|
|
2920
|
+
*
|
|
2921
|
+
* @example
|
|
2922
|
+
* ```typescript
|
|
2923
|
+
* isSorted([1, 2, 3], {key: 'value', direction: 'asc'}); // => true
|
|
2924
|
+
* isSorted([3, 2, 1], {key: 'value', direction: 'asc'}); // => false
|
|
2925
|
+
* ```
|
|
2730
2926
|
*/
|
|
2731
2927
|
export declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): boolean;
|
|
2732
2928
|
/**
|
|
@@ -2737,6 +2933,12 @@ export declare function isSorted<Item>(array: Item[], sorter: ArraySorter<Item>,
|
|
|
2737
2933
|
* @param array Array to check
|
|
2738
2934
|
* @param descending Sorted in descending order? _(defaults to `false`)_
|
|
2739
2935
|
* @returns `true` if sorted, otherwise `false`
|
|
2936
|
+
*
|
|
2937
|
+
* @example
|
|
2938
|
+
* ```typescript
|
|
2939
|
+
* isSorted([1, 2, 3]); // => true
|
|
2940
|
+
* isSorted([3, 2, 1]); // => false
|
|
2941
|
+
* ```
|
|
2740
2942
|
*/
|
|
2741
2943
|
export declare function isSorted<Item>(array: Item[], descending?: boolean): boolean;
|
|
2742
2944
|
/**
|
|
@@ -2763,6 +2965,14 @@ export declare function sort<Item>(array: Item[], comparator: (first: Item, seco
|
|
|
2763
2965
|
* @param sorters Sorters to use for sorting
|
|
2764
2966
|
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2765
2967
|
* @returns Sorted array
|
|
2968
|
+
*
|
|
2969
|
+
* @example
|
|
2970
|
+
* ```typescript
|
|
2971
|
+
* sort(
|
|
2972
|
+
* [{id: 3}, {id: 1}, {id: 2}],
|
|
2973
|
+
* [{key: 'id', direction: 'asc'}],
|
|
2974
|
+
* ); // => [{id: 1}, {id: 2}, {id: 3}]
|
|
2975
|
+
* ```
|
|
2766
2976
|
*/
|
|
2767
2977
|
export declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Item>>, descending?: boolean): Item[];
|
|
2768
2978
|
/**
|
|
@@ -2772,6 +2982,14 @@ export declare function sort<Item>(array: Item[], sorters: Array<ArraySorter<Ite
|
|
|
2772
2982
|
* @param sorter Sorter to use for sorting
|
|
2773
2983
|
* @param descending Sort in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
2774
2984
|
* @returns Sorted array
|
|
2985
|
+
*
|
|
2986
|
+
* @example
|
|
2987
|
+
* ```typescript
|
|
2988
|
+
* sort(
|
|
2989
|
+
* [{id: 3}, {id: 1}, {id: 2}],
|
|
2990
|
+
* {key: 'id', direction: 'asc'},
|
|
2991
|
+
* ); // => [{id: 1}, {id: 2}, {id: 3}]
|
|
2992
|
+
* ```
|
|
2775
2993
|
*/
|
|
2776
2994
|
export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, descending?: boolean): Item[];
|
|
2777
2995
|
/**
|
|
@@ -2780,6 +2998,11 @@ export declare function sort<Item>(array: Item[], sorter: ArraySorter<Item>, des
|
|
|
2780
2998
|
* @param array Array to sort
|
|
2781
2999
|
* @param descending Sort in descending order? _(defaults to `false`)_
|
|
2782
3000
|
* @returns Sorted array
|
|
3001
|
+
*
|
|
3002
|
+
* @example
|
|
3003
|
+
* ```typescript
|
|
3004
|
+
* sort([3, 1, 2]); // => [1, 2, 3]
|
|
3005
|
+
* ```
|
|
2783
3006
|
*/
|
|
2784
3007
|
export declare function sort<Item>(array: Item[], descending?: boolean): Item[];
|
|
2785
3008
|
export declare namespace sort {
|
|
@@ -3378,7 +3601,7 @@ declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Cal
|
|
|
3378
3601
|
* @param options Retry options
|
|
3379
3602
|
* @returns Callback result
|
|
3380
3603
|
*/
|
|
3381
|
-
declare function asyncRetry<Callback extends
|
|
3604
|
+
declare function asyncRetry<Callback extends GenericAsyncCallback>(callback: Callback, options?: RetryOptions): Promise<ReturnType<Callback>>;
|
|
3382
3605
|
/**
|
|
3383
3606
|
* Retry a callback a specified number of times
|
|
3384
3607
|
*
|
|
@@ -4200,6 +4423,14 @@ export declare namespace pipe {
|
|
|
4200
4423
|
*
|
|
4201
4424
|
* @param value String to convert
|
|
4202
4425
|
* @returns Camel-cased string
|
|
4426
|
+
*
|
|
4427
|
+
* @example
|
|
4428
|
+
* ```typescript
|
|
4429
|
+
* camelCase('this is camel case'); // => 'thisIsCamelCase'
|
|
4430
|
+
* camelCase('ThisIsCamelCase'); // => 'thisIsCamelCase'
|
|
4431
|
+
* camelCase('this-is-camel-case'); // => 'thisIsCamelCase'
|
|
4432
|
+
* camelCase('this_is_camel_case'); // => 'thisIsCamelCase'
|
|
4433
|
+
* ```
|
|
4203
4434
|
*/
|
|
4204
4435
|
export declare function camelCase(value: string): string;
|
|
4205
4436
|
/**
|
|
@@ -4207,6 +4438,14 @@ export declare function camelCase(value: string): string;
|
|
|
4207
4438
|
*
|
|
4208
4439
|
* @param value String to capitalize
|
|
4209
4440
|
* @returns Capitalized string
|
|
4441
|
+
*
|
|
4442
|
+
* @example
|
|
4443
|
+
* ```typescript
|
|
4444
|
+
* capitalize('this is a test'); // => 'This is a test'
|
|
4445
|
+
* capitalize('This Is A Test'); // => 'This is a test'
|
|
4446
|
+
* capitalize('t'); // => 'T'
|
|
4447
|
+
* capitalize(''); // => ''
|
|
4448
|
+
* ```
|
|
4210
4449
|
*/
|
|
4211
4450
|
export declare function capitalize(value: string): string;
|
|
4212
4451
|
/**
|
|
@@ -4214,6 +4453,14 @@ export declare function capitalize(value: string): string;
|
|
|
4214
4453
|
*
|
|
4215
4454
|
* @param value String to convert
|
|
4216
4455
|
* @returns Kebab-cased string
|
|
4456
|
+
*
|
|
4457
|
+
* @example
|
|
4458
|
+
* ```typescript
|
|
4459
|
+
* kebabCase('this is kebab case'); // => 'this-is-kebab-case'
|
|
4460
|
+
* kebabCase('ThisIsKebabCase'); // => 'this-is-kebab-case'
|
|
4461
|
+
* kebabCase('this-is-kebab-case'); // => 'this-is-kebab-case'
|
|
4462
|
+
* kebabCase('this_is_kebab_case'); // => 'this-is-kebab-case'
|
|
4463
|
+
* ```
|
|
4217
4464
|
*/
|
|
4218
4465
|
export declare function kebabCase(value: string): string;
|
|
4219
4466
|
/**
|
|
@@ -4221,6 +4468,13 @@ export declare function kebabCase(value: string): string;
|
|
|
4221
4468
|
*
|
|
4222
4469
|
* @param value String to convert
|
|
4223
4470
|
* @returns Lower-cased string
|
|
4471
|
+
*
|
|
4472
|
+
* @example
|
|
4473
|
+
* ```typescript
|
|
4474
|
+
* lowerCase('THIS IS A TEST'); // => 'this is a test'
|
|
4475
|
+
* lowerCase('this is a test'); // => 'this is a test'
|
|
4476
|
+
* lowerCase('t'); // => 't'
|
|
4477
|
+
* ```
|
|
4224
4478
|
*/
|
|
4225
4479
|
export declare function lowerCase(value: string): string;
|
|
4226
4480
|
/**
|
|
@@ -4228,6 +4482,14 @@ export declare function lowerCase(value: string): string;
|
|
|
4228
4482
|
*
|
|
4229
4483
|
* @param value String to convert
|
|
4230
4484
|
* @returns Pascal-cased string
|
|
4485
|
+
*
|
|
4486
|
+
* @example
|
|
4487
|
+
* ```typescript
|
|
4488
|
+
* pascalCase('this is pascal case'); // => 'ThisIsPascalCase'
|
|
4489
|
+
* pascalCase('ThisIsPascalCase'); // => 'ThisIsPascalCase'
|
|
4490
|
+
* pascalCase('this-is-pascal-case'); // => 'ThisIsPascalCase'
|
|
4491
|
+
* pascalCase('this_is_pascal_case'); // => 'ThisIsPascalCase'
|
|
4492
|
+
* ```
|
|
4231
4493
|
*/
|
|
4232
4494
|
export declare function pascalCase(value: string): string;
|
|
4233
4495
|
/**
|
|
@@ -4235,6 +4497,14 @@ export declare function pascalCase(value: string): string;
|
|
|
4235
4497
|
*
|
|
4236
4498
|
* @param value String to convert
|
|
4237
4499
|
* @returns Snake-cased string
|
|
4500
|
+
*
|
|
4501
|
+
* @example
|
|
4502
|
+
* ```typescript
|
|
4503
|
+
* snakeCase('this is snake case'); // => 'this_is_snake_case'
|
|
4504
|
+
* snakeCase('ThisIsSnakeCase'); // => 'this_is_snake_case'
|
|
4505
|
+
* snakeCase('this-is-snake-case'); // => 'this_is_snake_case'
|
|
4506
|
+
* snakeCase('this_is_snake_case'); // => 'this_is_snake_case'
|
|
4507
|
+
* ```
|
|
4238
4508
|
*/
|
|
4239
4509
|
export declare function snakeCase(value: string): string;
|
|
4240
4510
|
/**
|
|
@@ -4242,6 +4512,14 @@ export declare function snakeCase(value: string): string;
|
|
|
4242
4512
|
*
|
|
4243
4513
|
* @param value String to convert
|
|
4244
4514
|
* @returns Title-cased string
|
|
4515
|
+
*
|
|
4516
|
+
* @example
|
|
4517
|
+
* ```typescript
|
|
4518
|
+
* titleCase('this is a test'); // => 'This Is A Test'
|
|
4519
|
+
* titleCase('This Is A Test'); // => 'This Is A Test'
|
|
4520
|
+
* titleCase('t'); // => 'T'
|
|
4521
|
+
* titleCase(''); // => ''
|
|
4522
|
+
* ```
|
|
4245
4523
|
*/
|
|
4246
4524
|
export declare function titleCase(value: string): string;
|
|
4247
4525
|
/**
|
|
@@ -4249,6 +4527,14 @@ export declare function titleCase(value: string): string;
|
|
|
4249
4527
|
*
|
|
4250
4528
|
* @param value String to convert
|
|
4251
4529
|
* @returns Upper-cased string
|
|
4530
|
+
*
|
|
4531
|
+
* @example
|
|
4532
|
+
* ```typescript
|
|
4533
|
+
* upperCase('this is a test'); // => 'THIS IS A TEST'
|
|
4534
|
+
* upperCase('This Is A Test'); // => 'THIS IS A TEST'
|
|
4535
|
+
* upperCase('t'); // => 'T'
|
|
4536
|
+
* upperCase(''); // => ''
|
|
4537
|
+
* ```
|
|
4252
4538
|
*/
|
|
4253
4539
|
export declare function upperCase(value: string): string;
|
|
4254
4540
|
//#endregion
|
|
@@ -4271,7 +4557,13 @@ export declare function upperCase(value: string): string;
|
|
|
4271
4557
|
* ```
|
|
4272
4558
|
*/
|
|
4273
4559
|
export declare function getString(value: unknown): string;
|
|
4560
|
+
/**
|
|
4561
|
+
* @internal
|
|
4562
|
+
*/
|
|
4274
4563
|
export declare function ignoreKey(key: string): boolean;
|
|
4564
|
+
/**
|
|
4565
|
+
* @internal
|
|
4566
|
+
*/
|
|
4275
4567
|
export declare function interpolate(strings: TemplateStringsArray, values: unknown[]): string;
|
|
4276
4568
|
/**
|
|
4277
4569
|
* Join an array of values into a string _(while ignoring empty values)_
|
|
@@ -4281,9 +4573,23 @@ export declare function interpolate(strings: TemplateStringsArray, values: unkno
|
|
|
4281
4573
|
* @param array Array of values
|
|
4282
4574
|
* @param delimiter Delimiter to use between values
|
|
4283
4575
|
* @returns Joined string
|
|
4576
|
+
* @example
|
|
4577
|
+
* ```typescript
|
|
4578
|
+
* join(['a', 'b', 'c']); // => 'abc'
|
|
4579
|
+
* join(['a', 'b', 'c'], ', '); // => 'a, b, c'
|
|
4580
|
+
* join(['a', '', 'c']); // => 'ac'
|
|
4581
|
+
* join([null, 'b', undefined]); // => 'b'
|
|
4582
|
+
* join([]); // => ''
|
|
4583
|
+
* ```
|
|
4284
4584
|
*/
|
|
4285
4585
|
export declare function join(array: unknown[], delimiter?: string): string;
|
|
4586
|
+
/**
|
|
4587
|
+
* @internal
|
|
4588
|
+
*/
|
|
4286
4589
|
export declare function tryDecode(value: string): string;
|
|
4590
|
+
/**
|
|
4591
|
+
* @internal
|
|
4592
|
+
*/
|
|
4287
4593
|
export declare function tryEncode(value: boolean | number | string): unknown;
|
|
4288
4594
|
/**
|
|
4289
4595
|
* Split a string into words _(and other readable parts)_
|
|
@@ -4826,132 +5132,6 @@ type Success<Value> = {
|
|
|
4826
5132
|
[Symbol.iterator]: () => Generator<never, Value>;
|
|
4827
5133
|
};
|
|
4828
5134
|
//#endregion
|
|
4829
|
-
//#region src/plan/result.d.ts
|
|
4830
|
-
/**
|
|
4831
|
-
* Attempt to run the generator to completion
|
|
4832
|
-
*
|
|
4833
|
-
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
4834
|
-
*
|
|
4835
|
-
* @param generator Generator to run
|
|
4836
|
-
* @param parameters Parameters for starting the run
|
|
4837
|
-
* @param signal Optional abort signal
|
|
4838
|
-
* @returns Promised result
|
|
4839
|
-
*/
|
|
4840
|
-
export declare function asyncAttemptRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
4841
|
-
/**
|
|
4842
|
-
* Attempt to run the generator to completion
|
|
4843
|
-
*
|
|
4844
|
-
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
4845
|
-
*
|
|
4846
|
-
* @param generator Generator to run
|
|
4847
|
-
* @param signal Optional abort signal
|
|
4848
|
-
* @returns Promised result
|
|
4849
|
-
*/
|
|
4850
|
-
export declare function asyncAttemptRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
4851
|
-
/**
|
|
4852
|
-
* Attempt to run the plan to completion
|
|
4853
|
-
*
|
|
4854
|
-
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
4855
|
-
*
|
|
4856
|
-
* @param plan Plan to run
|
|
4857
|
-
* @param parameters Parameters for starting the run
|
|
4858
|
-
* @param signal Optional abort signal
|
|
4859
|
-
* @returns Promised result
|
|
4860
|
-
*/
|
|
4861
|
-
export declare function asyncAttemptRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
4862
|
-
/**
|
|
4863
|
-
* Attempt to run the plan to completion
|
|
4864
|
-
*
|
|
4865
|
-
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
4866
|
-
*
|
|
4867
|
-
* @param plan Plan to run
|
|
4868
|
-
* @param signal Optional abort signal
|
|
4869
|
-
* @returns Promised result
|
|
4870
|
-
*/
|
|
4871
|
-
export declare function asyncAttemptRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
4872
|
-
/**
|
|
4873
|
-
* Attempt to run the generator to completion
|
|
4874
|
-
*
|
|
4875
|
-
* _Returns a {@link Result} instead of a raw value or throwing an error_
|
|
4876
|
-
*
|
|
4877
|
-
* @param generator Generator to run
|
|
4878
|
-
* @param parameters Parameters for starting the run
|
|
4879
|
-
* @returns Result
|
|
4880
|
-
*/
|
|
4881
|
-
export declare function attemptRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters): Result<PlanOk<Returned>, PlanError<Yielded, Returned>>;
|
|
4882
|
-
/**
|
|
4883
|
-
* Attempt to run the plan to completion
|
|
4884
|
-
*
|
|
4885
|
-
* _Returns a {@link Result} instead of a raw value or throwing an error_
|
|
4886
|
-
*
|
|
4887
|
-
* @param plan Plan to run
|
|
4888
|
-
* @param parameters Parameters for starting the run
|
|
4889
|
-
* @returns Result
|
|
4890
|
-
*/
|
|
4891
|
-
export declare function attemptRun<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters): Result<PlanOk<Returned>, PlanError<Yielded, Returned>>;
|
|
4892
|
-
export declare namespace attemptRun {
|
|
4893
|
-
export var async: typeof asyncAttemptRun;
|
|
4894
|
-
}
|
|
4895
|
-
//#endregion
|
|
4896
|
-
//#region src/plan/run.d.ts
|
|
4897
|
-
/**
|
|
4898
|
-
* Run an asynchronous generator to completion
|
|
4899
|
-
*
|
|
4900
|
-
* @param generator Generator to run
|
|
4901
|
-
* @param parameters Parameters for starting the run
|
|
4902
|
-
* @param signal Optional abort signal
|
|
4903
|
-
* @returns Result
|
|
4904
|
-
*/
|
|
4905
|
-
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
4906
|
-
/**
|
|
4907
|
-
* Run an asynchronous generator to completion
|
|
4908
|
-
*
|
|
4909
|
-
* @param generator Generator to run
|
|
4910
|
-
* @param signal Optional abort signal
|
|
4911
|
-
* @returns Result
|
|
4912
|
-
*/
|
|
4913
|
-
export declare function asyncRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
4914
|
-
/**
|
|
4915
|
-
* Run an asynchronous plan to completion
|
|
4916
|
-
*
|
|
4917
|
-
* @param plan Plan to run
|
|
4918
|
-
* @param parameters Parameters for starting the run
|
|
4919
|
-
* @param signal Optional abort signal
|
|
4920
|
-
* @returns Result
|
|
4921
|
-
*/
|
|
4922
|
-
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
4923
|
-
/**
|
|
4924
|
-
* Run an asynchronous plan to completion
|
|
4925
|
-
*
|
|
4926
|
-
* @param plan Plan to run
|
|
4927
|
-
* @param signal Optional abort signal
|
|
4928
|
-
* @returns Result
|
|
4929
|
-
*/
|
|
4930
|
-
export declare function asyncRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
4931
|
-
/**
|
|
4932
|
-
* Run a generator to completion
|
|
4933
|
-
*
|
|
4934
|
-
* @param generator Generator to run
|
|
4935
|
-
* @param parameters Parameters for starting the run
|
|
4936
|
-
* @returns Result
|
|
4937
|
-
*/
|
|
4938
|
-
export declare function run<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters): PlanReturned<Returned>;
|
|
4939
|
-
/**
|
|
4940
|
-
* Run a plan to completion
|
|
4941
|
-
*
|
|
4942
|
-
* @param plan Plan to run
|
|
4943
|
-
* @param parameters Parameters for starting the run
|
|
4944
|
-
* @returns Result
|
|
4945
|
-
*/
|
|
4946
|
-
export declare function run<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters): PlanReturned<Returned>;
|
|
4947
|
-
export declare namespace asyncRun {
|
|
4948
|
-
export var attempt: typeof asyncAttemptRun;
|
|
4949
|
-
}
|
|
4950
|
-
export declare namespace run {
|
|
4951
|
-
export var async: typeof asyncRun;
|
|
4952
|
-
export var attempt: typeof attemptRun;
|
|
4953
|
-
}
|
|
4954
|
-
//#endregion
|
|
4955
5135
|
//#region src/plan/index.d.ts
|
|
4956
5136
|
/**
|
|
4957
5137
|
* Create a plan for an asynchronous generator function
|
|
@@ -5118,6 +5298,132 @@ export declare namespace succeed {
|
|
|
5118
5298
|
export var async: typeof asyncSucceed;
|
|
5119
5299
|
}
|
|
5120
5300
|
//#endregion
|
|
5301
|
+
//#region src/plan/result.d.ts
|
|
5302
|
+
/**
|
|
5303
|
+
* Attempt to run the generator to completion
|
|
5304
|
+
*
|
|
5305
|
+
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
5306
|
+
*
|
|
5307
|
+
* @param generator Generator to run
|
|
5308
|
+
* @param parameters Parameters for starting the run
|
|
5309
|
+
* @param signal Optional abort signal
|
|
5310
|
+
* @returns Promised result
|
|
5311
|
+
*/
|
|
5312
|
+
export declare function asyncAttemptRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
5313
|
+
/**
|
|
5314
|
+
* Attempt to run the generator to completion
|
|
5315
|
+
*
|
|
5316
|
+
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
5317
|
+
*
|
|
5318
|
+
* @param generator Generator to run
|
|
5319
|
+
* @param signal Optional abort signal
|
|
5320
|
+
* @returns Promised result
|
|
5321
|
+
*/
|
|
5322
|
+
export declare function asyncAttemptRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
5323
|
+
/**
|
|
5324
|
+
* Attempt to run the plan to completion
|
|
5325
|
+
*
|
|
5326
|
+
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
5327
|
+
*
|
|
5328
|
+
* @param plan Plan to run
|
|
5329
|
+
* @param parameters Parameters for starting the run
|
|
5330
|
+
* @param signal Optional abort signal
|
|
5331
|
+
* @returns Promised result
|
|
5332
|
+
*/
|
|
5333
|
+
export declare function asyncAttemptRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
5334
|
+
/**
|
|
5335
|
+
* Attempt to run the plan to completion
|
|
5336
|
+
*
|
|
5337
|
+
* _Returns a promised {@link Result} instead of a raw value or throwing an error_
|
|
5338
|
+
*
|
|
5339
|
+
* @param plan Plan to run
|
|
5340
|
+
* @param signal Optional abort signal
|
|
5341
|
+
* @returns Promised result
|
|
5342
|
+
*/
|
|
5343
|
+
export declare function asyncAttemptRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<Result<PlanOk<Returned>, PlanError<Yielded, Returned>>>;
|
|
5344
|
+
/**
|
|
5345
|
+
* Attempt to run the generator to completion
|
|
5346
|
+
*
|
|
5347
|
+
* _Returns a {@link Result} instead of a raw value or throwing an error_
|
|
5348
|
+
*
|
|
5349
|
+
* @param generator Generator to run
|
|
5350
|
+
* @param parameters Parameters for starting the run
|
|
5351
|
+
* @returns Result
|
|
5352
|
+
*/
|
|
5353
|
+
export declare function attemptRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters): Result<PlanOk<Returned>, PlanError<Yielded, Returned>>;
|
|
5354
|
+
/**
|
|
5355
|
+
* Attempt to run the plan to completion
|
|
5356
|
+
*
|
|
5357
|
+
* _Returns a {@link Result} instead of a raw value or throwing an error_
|
|
5358
|
+
*
|
|
5359
|
+
* @param plan Plan to run
|
|
5360
|
+
* @param parameters Parameters for starting the run
|
|
5361
|
+
* @returns Result
|
|
5362
|
+
*/
|
|
5363
|
+
export declare function attemptRun<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters): Result<PlanOk<Returned>, PlanError<Yielded, Returned>>;
|
|
5364
|
+
export declare namespace attemptRun {
|
|
5365
|
+
export var async: typeof asyncAttemptRun;
|
|
5366
|
+
}
|
|
5367
|
+
//#endregion
|
|
5368
|
+
//#region src/plan/run.d.ts
|
|
5369
|
+
/**
|
|
5370
|
+
* Run an asynchronous generator to completion
|
|
5371
|
+
*
|
|
5372
|
+
* @param generator Generator to run
|
|
5373
|
+
* @param parameters Parameters for starting the run
|
|
5374
|
+
* @param signal Optional abort signal
|
|
5375
|
+
* @returns Result
|
|
5376
|
+
*/
|
|
5377
|
+
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => AsyncGenerator<Yielded, Returned>, parameters: Parameters, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
5378
|
+
/**
|
|
5379
|
+
* Run an asynchronous generator to completion
|
|
5380
|
+
*
|
|
5381
|
+
* @param generator Generator to run
|
|
5382
|
+
* @param signal Optional abort signal
|
|
5383
|
+
* @returns Result
|
|
5384
|
+
*/
|
|
5385
|
+
export declare function asyncRun<Yielded, Returned>(generator: () => AsyncGenerator<Yielded, Returned>, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
5386
|
+
/**
|
|
5387
|
+
* Run an asynchronous plan to completion
|
|
5388
|
+
*
|
|
5389
|
+
* @param plan Plan to run
|
|
5390
|
+
* @param parameters Parameters for starting the run
|
|
5391
|
+
* @param signal Optional abort signal
|
|
5392
|
+
* @returns Result
|
|
5393
|
+
*/
|
|
5394
|
+
export declare function asyncRun<Yielded, Returned, Parameters extends unknown[]>(plan: AsyncPlan<Yielded, Returned, Parameters>, parameters: Parameters, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
5395
|
+
/**
|
|
5396
|
+
* Run an asynchronous plan to completion
|
|
5397
|
+
*
|
|
5398
|
+
* @param plan Plan to run
|
|
5399
|
+
* @param signal Optional abort signal
|
|
5400
|
+
* @returns Result
|
|
5401
|
+
*/
|
|
5402
|
+
export declare function asyncRun<Yielded, Returned>(plan: AsyncPlan<Yielded, Returned, []>, signal?: AbortSignal): Promise<PlanReturned<Returned>>;
|
|
5403
|
+
/**
|
|
5404
|
+
* Run a generator to completion
|
|
5405
|
+
*
|
|
5406
|
+
* @param generator Generator to run
|
|
5407
|
+
* @param parameters Parameters for starting the run
|
|
5408
|
+
* @returns Result
|
|
5409
|
+
*/
|
|
5410
|
+
export declare function run<Yielded, Returned, Parameters extends unknown[]>(generator: (...parameters: Parameters) => Generator<Yielded, Returned>, ...parameters: Parameters): PlanReturned<Returned>;
|
|
5411
|
+
/**
|
|
5412
|
+
* Run a plan to completion
|
|
5413
|
+
*
|
|
5414
|
+
* @param plan Plan to run
|
|
5415
|
+
* @param parameters Parameters for starting the run
|
|
5416
|
+
* @returns Result
|
|
5417
|
+
*/
|
|
5418
|
+
export declare function run<Yielded, Returned, Parameters extends unknown[]>(plan: Plan<Yielded, Returned, Parameters>, ...parameters: Parameters): PlanReturned<Returned>;
|
|
5419
|
+
export declare namespace asyncRun {
|
|
5420
|
+
export var attempt: typeof asyncAttemptRun;
|
|
5421
|
+
}
|
|
5422
|
+
export declare namespace run {
|
|
5423
|
+
export var async: typeof asyncRun;
|
|
5424
|
+
export var attempt: typeof attemptRun;
|
|
5425
|
+
}
|
|
5426
|
+
//#endregion
|
|
5121
5427
|
//#region src/plan/use.d.ts
|
|
5122
5428
|
/**
|
|
5123
5429
|
* Create an asynchronous step from a callback
|
|
@@ -5281,6 +5587,7 @@ export declare function delay(options?: PromiseOptions): Promise<void>;
|
|
|
5281
5587
|
export declare function delay(time?: number): Promise<void>;
|
|
5282
5588
|
//#endregion
|
|
5283
5589
|
//#region src/promise/index.d.ts
|
|
5590
|
+
type AttemptPromiseOptions = PromiseOptions | AbortSignal | number;
|
|
5284
5591
|
/**
|
|
5285
5592
|
* Wrap a _Promise_ with safety handlers
|
|
5286
5593
|
*
|
|
@@ -5288,7 +5595,7 @@ export declare function delay(time?: number): Promise<void>;
|
|
|
5288
5595
|
* @param options Options for the _Promise_
|
|
5289
5596
|
* @returns Wrapped _Promise_
|
|
5290
5597
|
*/
|
|
5291
|
-
export declare function attemptPromise<Value>(promise: Promise<Value>, options?:
|
|
5598
|
+
export declare function attemptPromise<Value>(promise: Promise<Value>, options?: AttemptPromiseOptions): Promise<Value>;
|
|
5292
5599
|
/**
|
|
5293
5600
|
* Wrap a _Promise_-returning callback with safety handlers
|
|
5294
5601
|
*
|
|
@@ -5296,7 +5603,7 @@ export declare function attemptPromise<Value>(promise: Promise<Value>, options?:
|
|
|
5296
5603
|
* @param options Options for the _Promise_
|
|
5297
5604
|
* @returns _Promise_-wrapped callback
|
|
5298
5605
|
*/
|
|
5299
|
-
export declare function attemptPromise<Value>(callback: () => Promise<Value>, options?:
|
|
5606
|
+
export declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: AttemptPromiseOptions): Promise<Value>;
|
|
5300
5607
|
/**
|
|
5301
5608
|
* Wrap a callback with a _Promise_ and safety handlers
|
|
5302
5609
|
*
|
|
@@ -5304,7 +5611,7 @@ export declare function attemptPromise<Value>(callback: () => Promise<Value>, op
|
|
|
5304
5611
|
* @param options Options for the _Promise_
|
|
5305
5612
|
* @returns _Promise_-wrapped callback
|
|
5306
5613
|
*/
|
|
5307
|
-
export declare function attemptPromise<Value>(callback: () => Value, options?:
|
|
5614
|
+
export declare function attemptPromise<Value>(callback: () => Value, options?: AttemptPromiseOptions): Promise<Value>;
|
|
5308
5615
|
/**
|
|
5309
5616
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
5310
5617
|
*
|
|
@@ -5529,7 +5836,13 @@ export declare function isRejected(value: unknown): value is RejectedPromise;
|
|
|
5529
5836
|
* @returns Cancelable _Promise_
|
|
5530
5837
|
*/
|
|
5531
5838
|
export declare function cancelable<Value>(executor: (resolve: (value: Value) => void, reject: (reason: unknown) => void) => void): CancelablePromise<Value>;
|
|
5839
|
+
/**
|
|
5840
|
+
* @internal
|
|
5841
|
+
*/
|
|
5532
5842
|
export declare function handleResult(status: string, parameters: PromiseParameters): void;
|
|
5843
|
+
/**
|
|
5844
|
+
* @internal
|
|
5845
|
+
*/
|
|
5533
5846
|
export declare function settlePromise(settler: (value: any) => void, value: unknown, aborter?: Aborter): void;
|
|
5534
5847
|
/**
|
|
5535
5848
|
* Converts a _Promise_ to a promised result
|
|
@@ -5547,6 +5860,9 @@ export declare function toResult<Value>(callback: () => Promise<Value>): Promise
|
|
|
5547
5860
|
export declare function toResult<Value>(promise: Promise<Value>): Promise<Result<Value>>;
|
|
5548
5861
|
//#endregion
|
|
5549
5862
|
//#region src/promise/timed.d.ts
|
|
5863
|
+
/**
|
|
5864
|
+
* @internal
|
|
5865
|
+
*/
|
|
5550
5866
|
export declare function getTimedPromise<Value>(promise: Promise<Value>, time: number, signal?: AbortSignal): Promise<Value>;
|
|
5551
5867
|
/**
|
|
5552
5868
|
* Create a _Promise_ that should be settled within a certain amount of time
|
|
@@ -5840,6 +6156,8 @@ export declare namespace attemptFlow {
|
|
|
5840
6156
|
}
|
|
5841
6157
|
//#endregion
|
|
5842
6158
|
//#region src/result/work/pipe.d.ts
|
|
6159
|
+
type InitialAsyncPipeValue<Initial> = GenericCallback | Initial | Promise<Initial> | Result<Initial>;
|
|
6160
|
+
type InitialPipeValue<Initial> = GenericCallback | Initial | Result<Initial>;
|
|
5843
6161
|
type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
5844
6162
|
/**
|
|
5845
6163
|
* Attempt to pipe a value through a function
|
|
@@ -5849,7 +6167,7 @@ type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
|
5849
6167
|
* @param initial Initial value
|
|
5850
6168
|
* @returns _Piped_ result
|
|
5851
6169
|
*/
|
|
5852
|
-
export declare function attemptAsyncPipe<Initial, Piped>(initial:
|
|
6170
|
+
export declare function attemptAsyncPipe<Initial, Piped>(initial: InitialAsyncPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Piped): Promise<WrapValue<Piped>>;
|
|
5853
6171
|
/**
|
|
5854
6172
|
* Attempt to pipe a value through a series of functions
|
|
5855
6173
|
*
|
|
@@ -5858,7 +6176,7 @@ export declare function attemptAsyncPipe<Initial, Piped>(initial: GenericCallbac
|
|
|
5858
6176
|
* @param initial Initial value
|
|
5859
6177
|
* @returns _Piped_ result
|
|
5860
6178
|
*/
|
|
5861
|
-
export declare function attemptAsyncPipe<Initial, First, Second>(initial:
|
|
6179
|
+
export declare function attemptAsyncPipe<Initial, First, Second>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): Promise<WrapValue<Second>>;
|
|
5862
6180
|
/**
|
|
5863
6181
|
* Attempt to pipe a value through a series of functions
|
|
5864
6182
|
*
|
|
@@ -5867,7 +6185,7 @@ export declare function attemptAsyncPipe<Initial, First, Second>(initial: Generi
|
|
|
5867
6185
|
* @param initial Initial value
|
|
5868
6186
|
* @returns _Piped_ result
|
|
5869
6187
|
*/
|
|
5870
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial:
|
|
6188
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): Promise<WrapValue<Third>>;
|
|
5871
6189
|
/**
|
|
5872
6190
|
* Attempt to pipe a value through a series of functions
|
|
5873
6191
|
*
|
|
@@ -5876,7 +6194,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial:
|
|
|
5876
6194
|
* @param initial Initial value
|
|
5877
6195
|
* @returns _Piped_ result
|
|
5878
6196
|
*/
|
|
5879
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial:
|
|
6197
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): Promise<WrapValue<Fourth>>;
|
|
5880
6198
|
/**
|
|
5881
6199
|
* Attempt to pipe a value through a series of functions
|
|
5882
6200
|
*
|
|
@@ -5885,7 +6203,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(
|
|
|
5885
6203
|
* @param initial Initial value
|
|
5886
6204
|
* @returns _Piped_ result
|
|
5887
6205
|
*/
|
|
5888
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial:
|
|
6206
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): Promise<WrapValue<Fifth>>;
|
|
5889
6207
|
/**
|
|
5890
6208
|
* Attempt to pipe a value through a series of functions
|
|
5891
6209
|
*
|
|
@@ -5894,7 +6212,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5894
6212
|
* @param initial Initial value
|
|
5895
6213
|
* @returns _Piped_ result
|
|
5896
6214
|
*/
|
|
5897
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial:
|
|
6215
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): Promise<WrapValue<Sixth>>;
|
|
5898
6216
|
/**
|
|
5899
6217
|
* Attempt to pipe a value through a series of functions
|
|
5900
6218
|
*
|
|
@@ -5903,7 +6221,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5903
6221
|
* @param initial Initial value
|
|
5904
6222
|
* @returns _Piped_ result
|
|
5905
6223
|
*/
|
|
5906
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial:
|
|
6224
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): Promise<WrapValue<Seventh>>;
|
|
5907
6225
|
/**
|
|
5908
6226
|
* Attempt to pipe a value through a series of functions
|
|
5909
6227
|
*
|
|
@@ -5912,7 +6230,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5912
6230
|
* @param initial Initial value
|
|
5913
6231
|
* @returns _Piped_ result
|
|
5914
6232
|
*/
|
|
5915
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial:
|
|
6233
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): Promise<WrapValue<Eighth>>;
|
|
5916
6234
|
/**
|
|
5917
6235
|
* Attempt to pipe a value through a series of functions
|
|
5918
6236
|
*
|
|
@@ -5921,7 +6239,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5921
6239
|
* @param initial Initial value
|
|
5922
6240
|
* @returns _Piped_ result
|
|
5923
6241
|
*/
|
|
5924
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial:
|
|
6242
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): Promise<WrapValue<Ninth>>;
|
|
5925
6243
|
/**
|
|
5926
6244
|
* Attempt to pipe a value through a series of functions
|
|
5927
6245
|
*
|
|
@@ -5930,7 +6248,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5930
6248
|
* @param initial Initial value
|
|
5931
6249
|
* @returns _Piped_ result
|
|
5932
6250
|
*/
|
|
5933
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial:
|
|
6251
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): Promise<WrapValue<Tenth>>;
|
|
5934
6252
|
/**
|
|
5935
6253
|
* Attempt to pipe a result through a series of functions
|
|
5936
6254
|
*
|
|
@@ -5939,84 +6257,84 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
5939
6257
|
* @param initial Initial result
|
|
5940
6258
|
* @returns _Piped_ result
|
|
5941
6259
|
*/
|
|
5942
|
-
export declare function attemptAsyncPipe<Initial>(initial:
|
|
6260
|
+
export declare function attemptAsyncPipe<Initial>(initial: InitialAsyncPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): Promise<WrapValue<Initial>>;
|
|
5943
6261
|
/**
|
|
5944
6262
|
* Attempt to pipe a value through a function
|
|
5945
6263
|
*
|
|
5946
6264
|
* @param initial Initial value
|
|
5947
6265
|
* @returns _Piped_ result
|
|
5948
6266
|
*/
|
|
5949
|
-
export declare function attemptPipe<Initial, Pipe>(initial:
|
|
6267
|
+
export declare function attemptPipe<Initial, Pipe>(initial: InitialPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Pipe): WrapValue<Pipe>;
|
|
5950
6268
|
/**
|
|
5951
6269
|
* Attempt to pipe a value through a series of functions
|
|
5952
6270
|
*
|
|
5953
6271
|
* @param initial Initial value
|
|
5954
6272
|
* @returns _Piped_ result
|
|
5955
6273
|
*/
|
|
5956
|
-
export declare function attemptPipe<Initial, First, Second>(initial:
|
|
6274
|
+
export declare function attemptPipe<Initial, First, Second>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): WrapValue<Second>;
|
|
5957
6275
|
/**
|
|
5958
6276
|
* Attempt to pipe a value through a series of functions
|
|
5959
6277
|
*
|
|
5960
6278
|
* @param initial Initial value
|
|
5961
6279
|
* @returns _Piped_ result
|
|
5962
6280
|
*/
|
|
5963
|
-
export declare function attemptPipe<Initial, First, Second, Third>(initial:
|
|
6281
|
+
export declare function attemptPipe<Initial, First, Second, Third>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): WrapValue<Third>;
|
|
5964
6282
|
/**
|
|
5965
6283
|
* Attempt to pipe a value through a series of functions
|
|
5966
6284
|
*
|
|
5967
6285
|
* @param initial Initial value
|
|
5968
6286
|
* @returns _Piped_ result
|
|
5969
6287
|
*/
|
|
5970
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial:
|
|
6288
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): WrapValue<Fourth>;
|
|
5971
6289
|
/**
|
|
5972
6290
|
* Attempt to pipe a value through a series of functions
|
|
5973
6291
|
*
|
|
5974
6292
|
* @param initial Initial value
|
|
5975
6293
|
* @returns _Piped_ result
|
|
5976
6294
|
*/
|
|
5977
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial:
|
|
6295
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): WrapValue<Fifth>;
|
|
5978
6296
|
/**
|
|
5979
6297
|
* Attempt to pipe a value through a series of functions
|
|
5980
6298
|
*
|
|
5981
6299
|
* @param initial Initial value
|
|
5982
6300
|
* @returns _Piped_ result
|
|
5983
6301
|
*/
|
|
5984
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial:
|
|
6302
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): WrapValue<Sixth>;
|
|
5985
6303
|
/**
|
|
5986
6304
|
* Attempt to pipe a value through a series of functions
|
|
5987
6305
|
*
|
|
5988
6306
|
* @param initial Initial value
|
|
5989
6307
|
* @returns _Piped_ result
|
|
5990
6308
|
*/
|
|
5991
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial:
|
|
6309
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): WrapValue<Seventh>;
|
|
5992
6310
|
/**
|
|
5993
6311
|
* Attempt to pipe a value through a series of functions
|
|
5994
6312
|
*
|
|
5995
6313
|
* @param initial Initial value
|
|
5996
6314
|
* @returns _Piped_ result
|
|
5997
6315
|
*/
|
|
5998
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial:
|
|
6316
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): WrapValue<Eighth>;
|
|
5999
6317
|
/**
|
|
6000
6318
|
* Attempt to pipe a value through a series of functions
|
|
6001
6319
|
*
|
|
6002
6320
|
* @param initial Initial value
|
|
6003
6321
|
* @returns _Piped_ result
|
|
6004
6322
|
*/
|
|
6005
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial:
|
|
6323
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): WrapValue<Ninth>;
|
|
6006
6324
|
/**
|
|
6007
6325
|
* Attempt to pipe a value through a series of functions
|
|
6008
6326
|
*
|
|
6009
6327
|
* @param initial Initial value
|
|
6010
6328
|
* @returns _Piped_ result
|
|
6011
6329
|
*/
|
|
6012
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial:
|
|
6330
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): WrapValue<Tenth>;
|
|
6013
6331
|
/**
|
|
6014
6332
|
* Attempt to pipe a result through a series of functions
|
|
6015
6333
|
*
|
|
6016
6334
|
* @param initial Initial result
|
|
6017
6335
|
* @returns _Piped_ result
|
|
6018
6336
|
*/
|
|
6019
|
-
export declare function attemptPipe<Initial>(initial:
|
|
6337
|
+
export declare function attemptPipe<Initial>(initial: InitialPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
|
|
6020
6338
|
export declare namespace attemptPipe {
|
|
6021
6339
|
export var async: typeof attemptAsyncPipe;
|
|
6022
6340
|
}
|
|
@@ -6197,7 +6515,7 @@ export declare function getUuid(): string;
|
|
|
6197
6515
|
*
|
|
6198
6516
|
* @param value JSON string to parse
|
|
6199
6517
|
* @param reviver Reviver function to transform the parsed values
|
|
6200
|
-
* @returns Parsed value or `undefined` if parsing fails
|
|
6518
|
+
* @returns Parsed value, or `undefined` if parsing fails
|
|
6201
6519
|
*/
|
|
6202
6520
|
export declare function parse(value: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): unknown;
|
|
6203
6521
|
/**
|
|
@@ -6205,6 +6523,13 @@ export declare function parse(value: string, reviver?: (this: unknown, key: stri
|
|
|
6205
6523
|
*
|
|
6206
6524
|
* @param value String to trim
|
|
6207
6525
|
* @returns Trimmed string
|
|
6526
|
+
* @example
|
|
6527
|
+
* ```typescript
|
|
6528
|
+
* trim(' this is a test '); // => 'this is a test'
|
|
6529
|
+
* trim('this is a test'); // => 'this is a test'
|
|
6530
|
+
* trim(' '); // => ''
|
|
6531
|
+
* trim(''); // => ''
|
|
6532
|
+
* ```
|
|
6208
6533
|
*/
|
|
6209
6534
|
export declare function trim(value: string): string;
|
|
6210
6535
|
/**
|
|
@@ -6214,6 +6539,13 @@ export declare function trim(value: string): string;
|
|
|
6214
6539
|
* @param length Maximum length of the string after truncation
|
|
6215
6540
|
* @param suffix Suffix to append to the truncated string
|
|
6216
6541
|
* @returns Truncated string
|
|
6542
|
+
* @example
|
|
6543
|
+
* ```typescript
|
|
6544
|
+
* truncate('this is a test', 7); // => 'this is'
|
|
6545
|
+
* truncate('this is a test', 7, '...'); // => 'this ...'
|
|
6546
|
+
* truncate('this is a test', 20); // => 'this is a test'
|
|
6547
|
+
* truncate('this is a test', 0); // => ''
|
|
6548
|
+
* ```
|
|
6217
6549
|
*/
|
|
6218
6550
|
export declare function truncate(value: string, length: number, suffix?: string): string;
|
|
6219
6551
|
//#endregion
|
|
@@ -6225,6 +6557,14 @@ export declare function truncate(value: string, length: number, suffix?: string)
|
|
|
6225
6557
|
* @param needle String to look for
|
|
6226
6558
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
6227
6559
|
* @returns `true` if the string ends with the given substring, otherwise `false`
|
|
6560
|
+
*
|
|
6561
|
+
* @example
|
|
6562
|
+
* ```typescript
|
|
6563
|
+
* endsWith('this is a test', 'test'); // => true
|
|
6564
|
+
* endsWith('this is a test', 'Test'); // => false
|
|
6565
|
+
* endsWith('this is a test', 'Test', true); // => true
|
|
6566
|
+
* endsWith('this is a test', 'not'); // => false
|
|
6567
|
+
* ```
|
|
6228
6568
|
*/
|
|
6229
6569
|
export declare function endsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
6230
6570
|
/**
|
|
@@ -6234,6 +6574,14 @@ export declare function endsWith(haystack: string, needle: string, ignoreCase?:
|
|
|
6234
6574
|
* @param needle String to look for
|
|
6235
6575
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
6236
6576
|
* @returns `true` if the string includes the given substring, otherwise `false`
|
|
6577
|
+
*
|
|
6578
|
+
* @example
|
|
6579
|
+
* ```typescript
|
|
6580
|
+
* includes('this is a test', 'is'); // => true
|
|
6581
|
+
* includes('this is a test', 'Is'); // => false
|
|
6582
|
+
* includes('this is a test', 'Is', true); // => true
|
|
6583
|
+
* includes('this is a test', 'not'); // => false
|
|
6584
|
+
* ```
|
|
6237
6585
|
*/
|
|
6238
6586
|
export declare function includes(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
6239
6587
|
/**
|
|
@@ -6243,6 +6591,14 @@ export declare function includes(haystack: string, needle: string, ignoreCase?:
|
|
|
6243
6591
|
* @param needle String to look for
|
|
6244
6592
|
* @param ignoreCase Ignore case when matching? _(defaults to `false`)_
|
|
6245
6593
|
* @returns `true` if the string starts with the given substring, otherwise `false`
|
|
6594
|
+
*
|
|
6595
|
+
* @example
|
|
6596
|
+
* ```typescript
|
|
6597
|
+
* startsWith('this is a test', 'this'); // => true
|
|
6598
|
+
* startsWith('this is a test', 'This'); // => false
|
|
6599
|
+
* startsWith('this is a test', 'This', true); // => true
|
|
6600
|
+
* startsWith('this is a test', 'not'); // => false
|
|
6601
|
+
* ```
|
|
6246
6602
|
*/
|
|
6247
6603
|
export declare function startsWith(haystack: string, needle: string, ignoreCase?: boolean): boolean;
|
|
6248
6604
|
//#endregion
|
|
@@ -6388,6 +6744,10 @@ export declare function template(strings: TemplateStringsArray, ...values: unkno
|
|
|
6388
6744
|
* @param variables Variables to use
|
|
6389
6745
|
* @param options Templating options
|
|
6390
6746
|
* @returns Templated string
|
|
6747
|
+
* @example
|
|
6748
|
+
* ```typescript
|
|
6749
|
+
* template('Hello, {{name}}!', {name: 'World'}); // => 'Hello, World!'
|
|
6750
|
+
* ```
|
|
6391
6751
|
*/
|
|
6392
6752
|
export declare function template(value: string, variables?: PlainObject, options?: Partial<TemplateOptions>): string;
|
|
6393
6753
|
export declare namespace template {
|
|
@@ -6761,12 +7121,12 @@ export declare function unsmush<Value extends PlainObject>(value: Value): Unsmus
|
|
|
6761
7121
|
/**
|
|
6762
7122
|
* Options for assigning values
|
|
6763
7123
|
*/
|
|
6764
|
-
type AssignOptions = BaseOptions;
|
|
7124
|
+
type AssignOptions = { [Key in keyof BaseOptions]: BaseOptions[Key]; };
|
|
6765
7125
|
type BaseOptions = {
|
|
6766
7126
|
/**
|
|
6767
7127
|
* Key _(or key epxressions)_ for values that should be replaced
|
|
6768
7128
|
*
|
|
6769
|
-
* ```
|
|
7129
|
+
* ```typescript
|
|
6770
7130
|
* merge([{items: [1, 2, 3]}, {items: [99]}]); // => {items: [99]}
|
|
6771
7131
|
* ```
|
|
6772
7132
|
*/
|
|
@@ -6774,7 +7134,7 @@ type BaseOptions = {
|
|
|
6774
7134
|
/**
|
|
6775
7135
|
* Skip nullable values when merging objects?
|
|
6776
7136
|
*
|
|
6777
|
-
* ```
|
|
7137
|
+
* ```typescript
|
|
6778
7138
|
* merge({a: 1, b: 2}, {b: null, c: 3}, {d: null}); // => {a: 1, b: 2, c: 3}
|
|
6779
7139
|
* ```
|
|
6780
7140
|
*/
|
|
@@ -6782,7 +7142,7 @@ type BaseOptions = {
|
|
|
6782
7142
|
/**
|
|
6783
7143
|
* Skip nullable values when merging arrays?
|
|
6784
7144
|
*
|
|
6785
|
-
* ```
|
|
7145
|
+
* ```typescript
|
|
6786
7146
|
* merge([1, 2, 3], [null, null, 99]); // => [1, 2, 99]
|
|
6787
7147
|
* ```
|
|
6788
7148
|
*/
|
|
@@ -7673,6 +8033,14 @@ export declare function isRgbColor(value: unknown): value is RGBColor;
|
|
|
7673
8033
|
* @param value Value to normalize
|
|
7674
8034
|
* @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
|
|
7675
8035
|
* @returns Normalized hex color
|
|
8036
|
+
*
|
|
8037
|
+
* @example
|
|
8038
|
+
* ```typescript
|
|
8039
|
+
* getNormalizedHex('#abc'); // => '#aabbcc'
|
|
8040
|
+
* getNormalizedHex('#abc', true); // => '#aabbccff'
|
|
8041
|
+
* getNormalizedHex(123); // => '#000000'
|
|
8042
|
+
* getNormalizedHex(123, true); // => '#000000ff'
|
|
8043
|
+
* ```
|
|
7676
8044
|
*/
|
|
7677
8045
|
export declare function getNormalizedHex(value: unknown, alpha?: boolean): string;
|
|
7678
8046
|
/**
|
|
@@ -8217,7 +8585,19 @@ type TimeLogger = {
|
|
|
8217
8585
|
//#endregion
|
|
8218
8586
|
//#region src/logger.d.ts
|
|
8219
8587
|
declare function TimeLogger(this: any, label: string): void;
|
|
8588
|
+
/**
|
|
8589
|
+
* Is the value a _Logger_?
|
|
8590
|
+
*
|
|
8591
|
+
* @param value Value to check
|
|
8592
|
+
* @returns `true` if the value is a _Logger_, otherwise `false`
|
|
8593
|
+
*/
|
|
8220
8594
|
declare function isLogger(value: unknown): value is Lumberjack;
|
|
8595
|
+
/**
|
|
8596
|
+
* Is the value a _TimeLogger_?
|
|
8597
|
+
*
|
|
8598
|
+
* @param value Value to check
|
|
8599
|
+
* @returns `true` if the value is a _TimeLogger_, otherwise `false`
|
|
8600
|
+
*/
|
|
8221
8601
|
declare function isTimeLogger(value: unknown): value is TimeLogger;
|
|
8222
8602
|
/**
|
|
8223
8603
|
* A logger that can be used to log messages to the console
|
|
@@ -8230,6 +8610,11 @@ declare const Logger: Lumberjack;
|
|
|
8230
8610
|
/**
|
|
8231
8611
|
* Get the maximum value from a list of items
|
|
8232
8612
|
*
|
|
8613
|
+
* @param items List of items
|
|
8614
|
+
* @param callback Callback to get an item's value
|
|
8615
|
+
* @param first Return only the first item with the maximum value
|
|
8616
|
+
* @returns Item with the maximum value, or `undefined` if no maximum can be found
|
|
8617
|
+
*
|
|
8233
8618
|
* @example
|
|
8234
8619
|
* ```typescript
|
|
8235
8620
|
* max(
|
|
@@ -8239,16 +8624,16 @@ declare const Logger: Lumberjack;
|
|
|
8239
8624
|
*
|
|
8240
8625
|
* max([], item => item.value); // => []
|
|
8241
8626
|
* ```
|
|
8242
|
-
*
|
|
8243
|
-
* @param items List of items
|
|
8244
|
-
* @param callback Callback to get an item's value
|
|
8245
|
-
* @param first Return only the first item with the maximum value
|
|
8246
|
-
* @returns Item with the maximum value, or `undefined` if no maximum can be found
|
|
8247
8627
|
*/
|
|
8248
8628
|
export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
8249
8629
|
/**
|
|
8250
8630
|
* Get the maximum value from a list of items
|
|
8251
8631
|
*
|
|
8632
|
+
* @param items List of items
|
|
8633
|
+
* @param key Key to use for value
|
|
8634
|
+
* @param first Return only the first item with the maximum value
|
|
8635
|
+
* @returns Item with the maximum value, or `undefined` if no maximum can be found
|
|
8636
|
+
*
|
|
8252
8637
|
* @example
|
|
8253
8638
|
* ```typescript
|
|
8254
8639
|
* max(
|
|
@@ -8258,16 +8643,15 @@ export declare function max<Item>(items: Item[], callback: (item: Item, index: n
|
|
|
8258
8643
|
*
|
|
8259
8644
|
* max([], 'value'); // => []
|
|
8260
8645
|
* ```
|
|
8261
|
-
*
|
|
8262
|
-
* @param items List of items
|
|
8263
|
-
* @param key Key to use for value
|
|
8264
|
-
* @param first Return only the first item with the maximum value
|
|
8265
|
-
* @returns Item with the maximum value, or `undefined` if no maximum can be found
|
|
8266
8646
|
*/
|
|
8267
8647
|
export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
8268
8648
|
/**
|
|
8269
8649
|
* Get the maximum value from a list of items
|
|
8270
8650
|
*
|
|
8651
|
+
* @param items List of items
|
|
8652
|
+
* @param callback Callback to get an item's value
|
|
8653
|
+
* @returns Items with the maximum value
|
|
8654
|
+
*
|
|
8271
8655
|
* @example
|
|
8272
8656
|
* ```typescript
|
|
8273
8657
|
* max(
|
|
@@ -8277,15 +8661,15 @@ export declare function max<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
8277
8661
|
*
|
|
8278
8662
|
* max([], item => item.value); // => []
|
|
8279
8663
|
* ```
|
|
8280
|
-
*
|
|
8281
|
-
* @param items List of items
|
|
8282
|
-
* @param callback Callback to get an item's value
|
|
8283
|
-
* @returns Items with the maximum value
|
|
8284
8664
|
*/
|
|
8285
8665
|
export declare function max<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
8286
8666
|
/**
|
|
8287
8667
|
* Get the maximum value from a list of items
|
|
8288
8668
|
*
|
|
8669
|
+
* @param items List of items
|
|
8670
|
+
* @param key Key to use for value
|
|
8671
|
+
* @returns Items with the maximum value
|
|
8672
|
+
*
|
|
8289
8673
|
* @example
|
|
8290
8674
|
* ```typescript
|
|
8291
8675
|
* max(
|
|
@@ -8295,23 +8679,19 @@ export declare function max<Item>(items: Item[], callback: (item: Item, index: n
|
|
|
8295
8679
|
*
|
|
8296
8680
|
* max([], 'value'); // => []
|
|
8297
8681
|
* ```
|
|
8298
|
-
*
|
|
8299
|
-
* @param items List of items
|
|
8300
|
-
* @param key Key to use for value
|
|
8301
|
-
* @returns Items with the maximum value
|
|
8302
8682
|
*/
|
|
8303
8683
|
export declare function max<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
8304
8684
|
/**
|
|
8305
8685
|
* Get the maximum value from a list of numbers
|
|
8306
8686
|
*
|
|
8687
|
+
* @param values List of numbers
|
|
8688
|
+
* @returns Maximum value, or `Number.NaN` if no maximum can be found
|
|
8689
|
+
*
|
|
8307
8690
|
* @example
|
|
8308
8691
|
* ```typescript
|
|
8309
8692
|
* max([10, 20]); // => 20
|
|
8310
8693
|
* max([]); // => Number.NaN
|
|
8311
8694
|
* ```
|
|
8312
|
-
*
|
|
8313
|
-
* @param values List of numbers
|
|
8314
|
-
* @returns Maximum value, or `Number.NaN` if no maximum can be found
|
|
8315
8695
|
*/
|
|
8316
8696
|
export declare function max(values: number[]): number;
|
|
8317
8697
|
/**
|
|
@@ -8321,6 +8701,17 @@ export declare function max(values: number[]): number;
|
|
|
8321
8701
|
* @param callback Callback to get an item's value
|
|
8322
8702
|
* @param first Return only the first item with the minimum value
|
|
8323
8703
|
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
8704
|
+
*
|
|
8705
|
+
* @example
|
|
8706
|
+
* ```typescript
|
|
8707
|
+
* min(
|
|
8708
|
+
* [{id: 1, value: 10}, {id: 2, value: 5}],
|
|
8709
|
+
* item => item.value,
|
|
8710
|
+
* true,
|
|
8711
|
+
* ); // => {id: 2, value: 5}
|
|
8712
|
+
*
|
|
8713
|
+
* min([], item => item.value, true); // => undefined
|
|
8714
|
+
* ```
|
|
8324
8715
|
*/
|
|
8325
8716
|
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number, first: true): Item | undefined;
|
|
8326
8717
|
/**
|
|
@@ -8330,6 +8721,17 @@ export declare function min<Item>(items: Item[], callback: (item: Item, index: n
|
|
|
8330
8721
|
* @param key Key to use for value
|
|
8331
8722
|
* @param first Return only the first item with the minimum value
|
|
8332
8723
|
* @returns First item with the minimum value, or `undefined` if no minimum can be found
|
|
8724
|
+
*
|
|
8725
|
+
* @example
|
|
8726
|
+
* ```typescript
|
|
8727
|
+
* min(
|
|
8728
|
+
* [{id: 1, value: 10}, {id: 2, value: 5}],
|
|
8729
|
+
* 'value',
|
|
8730
|
+
* true,
|
|
8731
|
+
* ); // => {id: 2, value: 5}
|
|
8732
|
+
*
|
|
8733
|
+
* min([], 'value', true); // => undefined
|
|
8734
|
+
* ```
|
|
8333
8735
|
*/
|
|
8334
8736
|
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>, first: true): Item | undefined;
|
|
8335
8737
|
/**
|
|
@@ -8338,6 +8740,16 @@ export declare function min<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
8338
8740
|
* @param items List of items
|
|
8339
8741
|
* @param callback Callback to get an item's value
|
|
8340
8742
|
* @returns Items with the minimum value
|
|
8743
|
+
*
|
|
8744
|
+
* @example
|
|
8745
|
+
* ```typescript
|
|
8746
|
+
* min(
|
|
8747
|
+
* [{id: 1, value: 10}, {id: 2, value: 5}],
|
|
8748
|
+
* item => item.value,
|
|
8749
|
+
* ); // => [{id: 2, value: 5}]
|
|
8750
|
+
*
|
|
8751
|
+
* min([], item => item.value); // => []
|
|
8752
|
+
* ```
|
|
8341
8753
|
*/
|
|
8342
8754
|
export declare function min<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): Item[];
|
|
8343
8755
|
/**
|
|
@@ -8346,6 +8758,16 @@ export declare function min<Item>(items: Item[], callback: (item: Item, index: n
|
|
|
8346
8758
|
* @param items List of items
|
|
8347
8759
|
* @param key Key to use for value
|
|
8348
8760
|
* @returns Items with the minimum value
|
|
8761
|
+
*
|
|
8762
|
+
* @example
|
|
8763
|
+
* ```typescript
|
|
8764
|
+
* min(
|
|
8765
|
+
* [{id: 1, value: 10}, {id: 2, value: 5}],
|
|
8766
|
+
* 'value',
|
|
8767
|
+
* ); // => [{id: 2, value: 5}]
|
|
8768
|
+
*
|
|
8769
|
+
* min([], 'value'); // => []
|
|
8770
|
+
* ```
|
|
8349
8771
|
*/
|
|
8350
8772
|
export declare function min<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): Item[];
|
|
8351
8773
|
/**
|
|
@@ -8353,6 +8775,12 @@ export declare function min<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
8353
8775
|
*
|
|
8354
8776
|
* @param values List of numbers
|
|
8355
8777
|
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
8778
|
+
*
|
|
8779
|
+
* @example
|
|
8780
|
+
* ```typescript
|
|
8781
|
+
* min([10, 20]); // => 10
|
|
8782
|
+
* min([]); // => Number.NaN
|
|
8783
|
+
* ```
|
|
8356
8784
|
*/
|
|
8357
8785
|
export declare function min(values: number[]): number;
|
|
8358
8786
|
//#endregion
|
|
@@ -8363,6 +8791,13 @@ export declare function min(values: number[]): number;
|
|
|
8363
8791
|
* @param value Number to round down
|
|
8364
8792
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
8365
8793
|
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
8794
|
+
*
|
|
8795
|
+
* @example
|
|
8796
|
+
* ```typescript
|
|
8797
|
+
* floor(10.567, 2); // => 10.56
|
|
8798
|
+
* floor(10.567); // => 10
|
|
8799
|
+
* floor('abc'); // => Number.NaN
|
|
8800
|
+
* ```
|
|
8366
8801
|
*/
|
|
8367
8802
|
export declare function floor(value: number, decimals?: number): number;
|
|
8368
8803
|
/**
|
|
@@ -8371,6 +8806,13 @@ export declare function floor(value: number, decimals?: number): number;
|
|
|
8371
8806
|
* @param value Number to round
|
|
8372
8807
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
8373
8808
|
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
8809
|
+
*
|
|
8810
|
+
* @example
|
|
8811
|
+
* ```typescript
|
|
8812
|
+
* round(10.567, 2); // => 10.57
|
|
8813
|
+
* round(10.567); // => 11
|
|
8814
|
+
* round('abc'); // => Number.NaN
|
|
8815
|
+
* ```
|
|
8374
8816
|
*/
|
|
8375
8817
|
export declare function round(value: number, decimals?: number): number;
|
|
8376
8818
|
//#endregion
|
|
@@ -8381,6 +8823,16 @@ export declare function round(value: number, decimals?: number): number;
|
|
|
8381
8823
|
* @param items List of items
|
|
8382
8824
|
* @param callback Callback to get an item's value
|
|
8383
8825
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
8826
|
+
*
|
|
8827
|
+
* @example
|
|
8828
|
+
* ```typescript
|
|
8829
|
+
* average([
|
|
8830
|
+
* {value: 1},
|
|
8831
|
+
* {value: 2},
|
|
8832
|
+
* {value: 3},
|
|
8833
|
+
* ], item => item.value); // => 2
|
|
8834
|
+
* average([{value: 1}], item => item.nope); // => Number.NaN
|
|
8835
|
+
* ```
|
|
8384
8836
|
*/
|
|
8385
8837
|
export declare function average<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
8386
8838
|
/**
|
|
@@ -8389,6 +8841,12 @@ export declare function average<Item>(items: Item[], callback: (item: Item, inde
|
|
|
8389
8841
|
* @param items List of items
|
|
8390
8842
|
* @param key Key to use for value
|
|
8391
8843
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
8844
|
+
*
|
|
8845
|
+
* @example
|
|
8846
|
+
* ```typescript
|
|
8847
|
+
* average([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 2
|
|
8848
|
+
* average([{value: 1}], 'nope'); // => Number.NaN
|
|
8849
|
+
* ```
|
|
8392
8850
|
*/
|
|
8393
8851
|
export declare function average<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
8394
8852
|
/**
|
|
@@ -8396,6 +8854,12 @@ export declare function average<Item extends PlainObject>(items: Item[], key: ke
|
|
|
8396
8854
|
*
|
|
8397
8855
|
* @param numbers List of numbers
|
|
8398
8856
|
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
8857
|
+
*
|
|
8858
|
+
* @example
|
|
8859
|
+
* ```typescript
|
|
8860
|
+
* average([1, 2, 3, 4, 5]); // => 3
|
|
8861
|
+
* average([]); // => Number.NaN
|
|
8862
|
+
* ```
|
|
8399
8863
|
*/
|
|
8400
8864
|
export declare function average(numbers: number[]): number;
|
|
8401
8865
|
/**
|
|
@@ -8404,6 +8868,13 @@ export declare function average(numbers: number[]): number;
|
|
|
8404
8868
|
* @param value Number to round up
|
|
8405
8869
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
8406
8870
|
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
8871
|
+
*
|
|
8872
|
+
* @example
|
|
8873
|
+
* ```typescript
|
|
8874
|
+
* ceil(1.234, 2); // => 1.24
|
|
8875
|
+
* ceil(1.234); // => 2
|
|
8876
|
+
* ceil('abc'); // => Number.NaN
|
|
8877
|
+
* ```
|
|
8407
8878
|
*/
|
|
8408
8879
|
export declare function ceil(value: number, decimals?: number): number;
|
|
8409
8880
|
/**
|
|
@@ -8413,6 +8884,14 @@ export declare function ceil(value: number, decimals?: number): number;
|
|
|
8413
8884
|
* @param callback Callback to get an item's value
|
|
8414
8885
|
* @param value Value to match and count
|
|
8415
8886
|
* @returns Number of items that match the condition, or `Number.NaN` if no count can be calculated
|
|
8887
|
+
*
|
|
8888
|
+
* @example
|
|
8889
|
+
* ```typescript
|
|
8890
|
+
* count([1, 2, 3, 2], (item) => item, 2); // => 2
|
|
8891
|
+
* count([{value: 1}, {value: 2}, {value: 3}], 'value', 2); // => 1
|
|
8892
|
+
* count([1, 2, 3], (item) => item, 4); // => 0
|
|
8893
|
+
* count([], (item) => item, 1); // => Number.NaN
|
|
8894
|
+
* ```
|
|
8416
8895
|
*/
|
|
8417
8896
|
export declare function count<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => unknown, value: unknown): number;
|
|
8418
8897
|
/**
|
|
@@ -8422,6 +8901,12 @@ export declare function count<Item>(array: Item[], callback: (item: Item, index:
|
|
|
8422
8901
|
* @param key Key to use for value
|
|
8423
8902
|
* @param value Value to match and count
|
|
8424
8903
|
* @returns Number of items with the specified key value, or `Number.NaN` if no count can be calculated
|
|
8904
|
+
*
|
|
8905
|
+
* @example
|
|
8906
|
+
* ```typescript
|
|
8907
|
+
* count([{value: 1}, {value: 2}, {value: 3}], 'value', 2); // => 1
|
|
8908
|
+
* count([{value: 1}], 'nope', 1); // => Number.NaN
|
|
8909
|
+
* ```
|
|
8425
8910
|
*/
|
|
8426
8911
|
export declare function count<Item extends PlainObject, ItemKey extends keyof Item>(array: Item[], key: ItemKey, value: Item[ItemKey]): number;
|
|
8427
8912
|
/**
|
|
@@ -8429,6 +8914,12 @@ export declare function count<Item extends PlainObject, ItemKey extends keyof It
|
|
|
8429
8914
|
*
|
|
8430
8915
|
* @param values Array to count for
|
|
8431
8916
|
* @returns Number of items, or `Number.NaN` if no count can be calculated
|
|
8917
|
+
*
|
|
8918
|
+
* @example
|
|
8919
|
+
* ```typescript
|
|
8920
|
+
* count([1, 2, 3]); // => 3
|
|
8921
|
+
* count([]); // => Number.NaN
|
|
8922
|
+
* ```
|
|
8432
8923
|
*/
|
|
8433
8924
|
export declare function count(values: unknown[]): number;
|
|
8434
8925
|
/**
|
|
@@ -8437,6 +8928,13 @@ export declare function count(values: unknown[]): number;
|
|
|
8437
8928
|
* @param array List of items
|
|
8438
8929
|
* @param callback Callback to get an item's value
|
|
8439
8930
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
8931
|
+
*
|
|
8932
|
+
* @example
|
|
8933
|
+
* ```typescript
|
|
8934
|
+
* median([1, 2, 3, 4, 5]); // => 3
|
|
8935
|
+
* median([1, 2, 3, 4]); // => 2.5
|
|
8936
|
+
* median([]); // => Number.NaN
|
|
8937
|
+
* ```
|
|
8440
8938
|
*/
|
|
8441
8939
|
export declare function median<Item>(array: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
8442
8940
|
/**
|
|
@@ -8445,6 +8943,13 @@ export declare function median<Item>(array: Item[], callback: (item: Item, index
|
|
|
8445
8943
|
* @param array List of items
|
|
8446
8944
|
* @param key Key to use for value
|
|
8447
8945
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
8946
|
+
*
|
|
8947
|
+
* @example
|
|
8948
|
+
* ```typescript
|
|
8949
|
+
* median([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 2
|
|
8950
|
+
* median([{value: 1}, {value: 2}, {value: 3}, {value: 4}], 'value'); // => 2.5
|
|
8951
|
+
* median([], 'value'); // => Number.NaN
|
|
8952
|
+
* ```
|
|
8448
8953
|
*/
|
|
8449
8954
|
export declare function median<Item extends PlainObject>(array: Item[], key: keyof NumericalValues<Item>): number;
|
|
8450
8955
|
/**
|
|
@@ -8452,6 +8957,13 @@ export declare function median<Item extends PlainObject>(array: Item[], key: key
|
|
|
8452
8957
|
*
|
|
8453
8958
|
* @param array List of numbers
|
|
8454
8959
|
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
8960
|
+
*
|
|
8961
|
+
* @example
|
|
8962
|
+
* ```typescript
|
|
8963
|
+
* median([1, 2, 3, 4, 5]); // => 3
|
|
8964
|
+
* median([1, 2, 3, 4]); // => 2.5
|
|
8965
|
+
* median([]); // => Number.NaN
|
|
8966
|
+
* ```
|
|
8455
8967
|
*/
|
|
8456
8968
|
export declare function median(array: number[]): number;
|
|
8457
8969
|
/**
|
|
@@ -8460,6 +8972,13 @@ export declare function median(array: number[]): number;
|
|
|
8460
8972
|
* @param items List of items
|
|
8461
8973
|
* @param callback Callback to get an item's value
|
|
8462
8974
|
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
8975
|
+
*
|
|
8976
|
+
* @example
|
|
8977
|
+
* ```typescript
|
|
8978
|
+
* sum([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 6
|
|
8979
|
+
* sum([{value: 1}, {value: 2}, {value: 3}], item => item.value); // => 6
|
|
8980
|
+
* sum([]); // => Number.NaN
|
|
8981
|
+
* ```
|
|
8463
8982
|
*/
|
|
8464
8983
|
export declare function sum<Item>(items: Item[], callback: (item: Item, index: number, array: Item[]) => number): number;
|
|
8465
8984
|
/**
|
|
@@ -8468,6 +8987,13 @@ export declare function sum<Item>(items: Item[], callback: (item: Item, index: n
|
|
|
8468
8987
|
* @param items List of items
|
|
8469
8988
|
* @param key Key to use for value
|
|
8470
8989
|
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
8990
|
+
*
|
|
8991
|
+
* @example
|
|
8992
|
+
* ```typescript
|
|
8993
|
+
* sum([{value: 1}, {value: 2}, {value: 3}], 'value'); // => 6
|
|
8994
|
+
* sum([{value: 1}, {value: 2}, {value: 3}], item => item.value); // => 6
|
|
8995
|
+
* sum([]); // => Number.NaN
|
|
8996
|
+
* ```
|
|
8471
8997
|
*/
|
|
8472
8998
|
export declare function sum<Item extends PlainObject>(items: Item[], key: keyof NumericalValues<Item>): number;
|
|
8473
8999
|
/**
|
|
@@ -8475,6 +9001,12 @@ export declare function sum<Item extends PlainObject>(items: Item[], key: keyof
|
|
|
8475
9001
|
*
|
|
8476
9002
|
* @param values List of numbers
|
|
8477
9003
|
* @returns Sum of the numbers, or `Number.NaN` if no sum can be calculated
|
|
9004
|
+
*
|
|
9005
|
+
* @example
|
|
9006
|
+
* ```typescript
|
|
9007
|
+
* sum([1, 2, 3]); // => 6
|
|
9008
|
+
* sum([]); // => Number.NaN
|
|
9009
|
+
* ```
|
|
8478
9010
|
*/
|
|
8479
9011
|
export declare function sum(values: number[]): number;
|
|
8480
9012
|
//#endregion
|
|
@@ -8484,8 +9016,15 @@ export declare function sum(values: number[]): number;
|
|
|
8484
9016
|
*
|
|
8485
9017
|
* @param value Value to check
|
|
8486
9018
|
* @param minimum Minimum value
|
|
8487
|
-
* @param maximum Maximum value
|
|
9019
|
+
* @param maximum Maximum value _(inclusive)_
|
|
8488
9020
|
* @returns `true` if the value is between the minimum and maximum, otherwise `false`
|
|
9021
|
+
*
|
|
9022
|
+
* @example
|
|
9023
|
+
* ```typescript
|
|
9024
|
+
* between(5, 1, 10); // => true
|
|
9025
|
+
* between(0, 1, 10); // => false
|
|
9026
|
+
* between(10, 10, 10); // => true
|
|
9027
|
+
* ```
|
|
8489
9028
|
*/
|
|
8490
9029
|
export declare function between(value: number, minimum: number, maximum: number): boolean;
|
|
8491
9030
|
/**
|
|
@@ -8511,6 +9050,17 @@ export declare function clamp(value: number, minimum: number, maximum: number, l
|
|
|
8511
9050
|
*
|
|
8512
9051
|
* @param value Original value
|
|
8513
9052
|
* @returns Original value as a number, or `Number.NaN` if the value is unable to be parsed
|
|
9053
|
+
*
|
|
9054
|
+
* @example
|
|
9055
|
+
* ```typescript
|
|
9056
|
+
* getNumber(null) // => Number.NaN
|
|
9057
|
+
* getNumber('foo') // => Number.NaN
|
|
9058
|
+
* getNumber('123') // => 123
|
|
9059
|
+
* getNumber(true) // => 1
|
|
9060
|
+
* getNumber([1, 2, 3]) // => Number.NaN
|
|
9061
|
+
* getNumber({a: 1}) // => Number.NaN
|
|
9062
|
+
* getNumber(() => 123) // => 123
|
|
9063
|
+
* ```
|
|
8514
9064
|
*/
|
|
8515
9065
|
export declare function getNumber(value: unknown): number;
|
|
8516
9066
|
//#endregion
|
|
@@ -8741,7 +9291,6 @@ export declare function isKeyedQueue(value: unknown): value is KeyedQueue<Generi
|
|
|
8741
9291
|
* @returns `true` if the value is a queue, otherwise `false`
|
|
8742
9292
|
*/
|
|
8743
9293
|
export declare function isQueue(value: unknown): value is Queue<GenericCallback | GenericAsyncCallback>;
|
|
8744
|
-
export declare function isQueueInstance<Instance>(name: string, value: unknown): value is Instance;
|
|
8745
9294
|
/**
|
|
8746
9295
|
* Create a keyed queue for an asynchronous callback function, where each key has its own queue
|
|
8747
9296
|
*
|
|
@@ -8781,6 +9330,12 @@ export declare namespace queue {
|
|
|
8781
9330
|
}
|
|
8782
9331
|
//#endregion
|
|
8783
9332
|
//#region src/internal/random.d.ts
|
|
9333
|
+
/**
|
|
9334
|
+
* Get a random number between 0 _(inclusive)_ and 1 _(exclusive)_
|
|
9335
|
+
*
|
|
9336
|
+
* @returns Random number
|
|
9337
|
+
*/
|
|
9338
|
+
export declare function getRandom(): number;
|
|
8784
9339
|
/**
|
|
8785
9340
|
* Get a random floating-point number
|
|
8786
9341
|
*
|