@oscarpalmer/atoms 0.199.0 → 0.200.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/flatten.d.mts +1 -1
- package/dist/array/from.d.mts +1 -1
- package/dist/array/group-by.d.mts +2 -2
- package/dist/array/sort.d.mts +4 -0
- package/dist/array/to-map.d.mts +2 -2
- package/dist/array/to-record.d.mts +2 -2
- package/dist/index.d.mts +61 -50
- package/dist/index.mjs +42 -23
- package/dist/internal/array/compact.d.mts +2 -2
- package/dist/promise/constants.d.mts +3 -1
- package/dist/promise/constants.mjs +3 -1
- package/dist/promise/helpers.d.mts +1 -2
- package/dist/promise/helpers.mjs +9 -1
- package/dist/promise/index.d.mts +34 -36
- package/dist/promise/index.mjs +25 -20
- package/dist/promise/misc.mjs +2 -2
- package/dist/promise/models.d.mts +7 -6
- package/dist/queue.d.mts +4 -0
- package/dist/string/fuzzy.d.mts +2 -0
- package/dist/string/fuzzy.mjs +2 -0
- package/dist/value/freeze.d.mts +2 -0
- package/dist/value/freeze.mjs +2 -0
- package/dist/value/merge.d.mts +1 -1
- package/dist/value/merge.mjs +2 -1
- package/package.json +4 -4
- package/plugin/index.js +1 -1
package/dist/array/flatten.d.mts
CHANGED
|
@@ -11,6 +11,6 @@ import { NestedArray } from "../models.mjs";
|
|
|
11
11
|
* flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare function flatten<Item>(array: Item[]): NestedArray<Item
|
|
14
|
+
declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { flatten };
|
package/dist/array/from.d.mts
CHANGED
|
@@ -62,7 +62,7 @@ declare function times(length: number): number[];
|
|
|
62
62
|
* times(5, index => index * 2); // => [0, 2, 4, 6, 8]
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): ReturnType<Callback
|
|
65
|
+
declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): Array<ReturnType<Callback>>;
|
|
66
66
|
/**
|
|
67
67
|
* Get an array with a specified length, filled with a specified value
|
|
68
68
|
*
|
|
@@ -155,7 +155,7 @@ declare namespace groupBy {
|
|
|
155
155
|
* // }
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
-
declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
158
|
+
declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
159
159
|
/**
|
|
160
160
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
161
161
|
*
|
|
@@ -201,7 +201,7 @@ declare function groupArraysBy<Item extends PlainObject, KeyCallback extends (it
|
|
|
201
201
|
* // }
|
|
202
202
|
* ```
|
|
203
203
|
*/
|
|
204
|
-
declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ValueCallback
|
|
204
|
+
declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ValueCallback>>>>;
|
|
205
205
|
/**
|
|
206
206
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
207
207
|
*
|
package/dist/array/sort.d.mts
CHANGED
|
@@ -172,6 +172,8 @@ declare function initializeSorter<Item>(descending?: boolean): Sorter<Item>;
|
|
|
172
172
|
/**
|
|
173
173
|
* Is the array sorted according to the sorters _(and the optional default direction)_?
|
|
174
174
|
*
|
|
175
|
+
* _Available as `isSorted` and `sort.is`_
|
|
176
|
+
*
|
|
175
177
|
* @param array Array to check
|
|
176
178
|
* @param sorters Sorters to determine sorting
|
|
177
179
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
@@ -181,6 +183,8 @@ declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter<Item>>
|
|
|
181
183
|
/**
|
|
182
184
|
* Is the array sorted according to the sorter _(and the optional default direction)_?
|
|
183
185
|
*
|
|
186
|
+
* _Available as `isSorted` and `sort.is`_
|
|
187
|
+
*
|
|
184
188
|
* @param array Array to check
|
|
185
189
|
* @param sorter Sorter to determine sorting
|
|
186
190
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
package/dist/array/to-map.d.mts
CHANGED
|
@@ -152,7 +152,7 @@ declare namespace toMap {
|
|
|
152
152
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
|
-
declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
155
|
+
declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
156
156
|
/**
|
|
157
157
|
* Create a _Map_ from an array of items using a callback and value, grouping values into arrays
|
|
158
158
|
*
|
|
@@ -192,7 +192,7 @@ declare function toMapArrays<Item extends PlainObject, KeyCallback extends (item
|
|
|
192
192
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], ReturnType<ValueCallback
|
|
195
|
+
declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], Array<ReturnType<ValueCallback>>>;
|
|
196
196
|
/**
|
|
197
197
|
* Create a _Map_ from an array of items using a key and value, grouping values into arrays
|
|
198
198
|
*
|
|
@@ -152,7 +152,7 @@ declare namespace toRecord {
|
|
|
152
152
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
153
153
|
* ```
|
|
154
154
|
*/
|
|
155
|
-
declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
155
|
+
declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
156
156
|
/**
|
|
157
157
|
* Create a record from an array of items using a callback and value, grouping values into arrays
|
|
158
158
|
*
|
|
@@ -192,7 +192,7 @@ declare function toRecordArrays<Item extends PlainObject, Callback extends (item
|
|
|
192
192
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
193
193
|
* ```
|
|
194
194
|
*/
|
|
195
|
-
declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<Callback
|
|
195
|
+
declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<Callback>>>>;
|
|
196
196
|
/**
|
|
197
197
|
* Create a record from an array of items using a key and value, grouping values into arrays
|
|
198
198
|
*
|
package/dist/index.d.mts
CHANGED
|
@@ -604,7 +604,7 @@ export declare namespace groupBy {
|
|
|
604
604
|
* // }
|
|
605
605
|
* ```
|
|
606
606
|
*/
|
|
607
|
-
export declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
607
|
+
export declare function groupArraysBy<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
608
608
|
/**
|
|
609
609
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
610
610
|
*
|
|
@@ -650,7 +650,7 @@ export declare function groupArraysBy<Item extends PlainObject, KeyCallback exte
|
|
|
650
650
|
* // }
|
|
651
651
|
* ```
|
|
652
652
|
*/
|
|
653
|
-
export declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<ValueCallback
|
|
653
|
+
export declare function groupArraysBy<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<ValueCallback>>>>;
|
|
654
654
|
/**
|
|
655
655
|
* Create a record from an array of items using a specific key and value, grouping values into arrays
|
|
656
656
|
*
|
|
@@ -745,7 +745,7 @@ export declare function chunk<Item>(array: Item[], size?: number): Item[][];
|
|
|
745
745
|
* compact([0, 1, '', 'hello', false, true, null, undefined]); // => [1, 'hello', true]
|
|
746
746
|
* ```
|
|
747
747
|
*/
|
|
748
|
-
export declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | '' | false | null | undefined
|
|
748
|
+
export declare function compact<Item>(array: Item[], strict: true): Array<Exclude<Item, 0 | '' | false | null | undefined>>;
|
|
749
749
|
/**
|
|
750
750
|
* Compact an array _(removing all `null` and `undefined` values)_
|
|
751
751
|
*
|
|
@@ -757,7 +757,7 @@ export declare function compact<Item>(array: Item[], strict: true): Exclude<Item
|
|
|
757
757
|
* compact([0, 1, '', 'hello', false, true, null, undefined]); // => [0, 1, '', 'hello', false, true]
|
|
758
758
|
* ```
|
|
759
759
|
*/
|
|
760
|
-
export declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined
|
|
760
|
+
export declare function compact<Item>(array: Item[]): Array<Exclude<Item, null | undefined>>;
|
|
761
761
|
//#endregion
|
|
762
762
|
//#region src/internal/array/get.d.ts
|
|
763
763
|
/**
|
|
@@ -1516,7 +1516,7 @@ export declare function findLast<Item>(array: Item[], value: Item): Item | undef
|
|
|
1516
1516
|
* flatten([1, [2, [3, 4], 5], 6]); // => [1, 2, 3, 4, 5, 6]
|
|
1517
1517
|
* ```
|
|
1518
1518
|
*/
|
|
1519
|
-
export declare function flatten<Item>(array: Item[]): NestedArray<Item
|
|
1519
|
+
export declare function flatten<Item>(array: Item[]): Array<NestedArray<Item>>;
|
|
1520
1520
|
//#endregion
|
|
1521
1521
|
//#region src/array/from.d.ts
|
|
1522
1522
|
/**
|
|
@@ -1582,7 +1582,7 @@ export declare function times(length: number): number[];
|
|
|
1582
1582
|
* times(5, index => index * 2); // => [0, 2, 4, 6, 8]
|
|
1583
1583
|
* ```
|
|
1584
1584
|
*/
|
|
1585
|
-
export declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): ReturnType<Callback
|
|
1585
|
+
export declare function times<Callback extends (index: number) => unknown>(length: number, callback: Callback): Array<ReturnType<Callback>>;
|
|
1586
1586
|
/**
|
|
1587
1587
|
* Get an array with a specified length, filled with a specified value
|
|
1588
1588
|
*
|
|
@@ -3017,6 +3017,8 @@ export declare function initializeSorter<Item>(descending?: boolean): Sorter<Ite
|
|
|
3017
3017
|
/**
|
|
3018
3018
|
* Is the array sorted according to the sorters _(and the optional default direction)_?
|
|
3019
3019
|
*
|
|
3020
|
+
* _Available as `isSorted` and `sort.is`_
|
|
3021
|
+
*
|
|
3020
3022
|
* @param array Array to check
|
|
3021
3023
|
* @param sorters Sorters to determine sorting
|
|
3022
3024
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
@@ -3026,6 +3028,8 @@ export declare function isSorted<Item>(array: Item[], sorters: Array<ArraySorter
|
|
|
3026
3028
|
/**
|
|
3027
3029
|
* Is the array sorted according to the sorter _(and the optional default direction)_?
|
|
3028
3030
|
*
|
|
3031
|
+
* _Available as `isSorted` and `sort.is`_
|
|
3032
|
+
*
|
|
3029
3033
|
* @param array Array to check
|
|
3030
3034
|
* @param sorter Sorter to determine sorting
|
|
3031
3035
|
* @param descending Sorted in descending order? _(defaults to `false`; overridden by individual sorters)_
|
|
@@ -3430,7 +3434,7 @@ export declare namespace toMap {
|
|
|
3430
3434
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3431
3435
|
* ```
|
|
3432
3436
|
*/
|
|
3433
|
-
export declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
3437
|
+
export declare function toMapArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Map<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
3434
3438
|
/**
|
|
3435
3439
|
* Create a _Map_ from an array of items using a callback and value, grouping values into arrays
|
|
3436
3440
|
*
|
|
@@ -3470,7 +3474,7 @@ export declare function toMapArrays<Item extends PlainObject, KeyCallback extend
|
|
|
3470
3474
|
* ); // => Map { 10 => [1, 3], 20 => [2] }
|
|
3471
3475
|
* ```
|
|
3472
3476
|
*/
|
|
3473
|
-
export declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], ReturnType<ValueCallback
|
|
3477
|
+
export declare function toMapArrays<Item extends PlainObject, ItemKey extends keyof Item, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, value: ValueCallback): Map<Item[ItemKey], Array<ReturnType<ValueCallback>>>;
|
|
3474
3478
|
/**
|
|
3475
3479
|
* Create a _Map_ from an array of items using a key and value, grouping values into arrays
|
|
3476
3480
|
*
|
|
@@ -3681,7 +3685,7 @@ export declare namespace toRecord {
|
|
|
3681
3685
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
3682
3686
|
* ```
|
|
3683
3687
|
*/
|
|
3684
|
-
export declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, ReturnType<ValueCallback
|
|
3688
|
+
export declare function toRecordArrays<Item, KeyCallback extends (item: Item, index: number, array: Item[]) => Key$1, ValueCallback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: KeyCallback, value: ValueCallback): Record<ReturnType<KeyCallback>, Array<ReturnType<ValueCallback>>>;
|
|
3685
3689
|
/**
|
|
3686
3690
|
* Create a record from an array of items using a callback and value, grouping values into arrays
|
|
3687
3691
|
*
|
|
@@ -3721,7 +3725,7 @@ export declare function toRecordArrays<Item extends PlainObject, Callback extend
|
|
|
3721
3725
|
* ); // => { 10: [1, 3], 20: [2] }
|
|
3722
3726
|
* ```
|
|
3723
3727
|
*/
|
|
3724
|
-
export declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, ReturnType<Callback
|
|
3728
|
+
export declare function toRecordArrays<Item extends PlainObject, ItemKey extends keyof Item, Callback extends (item: Item, index: number, array: Item[]) => unknown>(array: Item[], key: ItemKey, callback: Callback): Simplify<Record<KeyedValue<Item, ItemKey>, Array<ReturnType<Callback>>>>;
|
|
3725
3729
|
/**
|
|
3726
3730
|
* Create a record from an array of items using a key and value, grouping values into arrays
|
|
3727
3731
|
*
|
|
@@ -5008,7 +5012,7 @@ export type FulfilledPromise<Value> = {
|
|
|
5008
5012
|
};
|
|
5009
5013
|
export type PromiseData = {
|
|
5010
5014
|
last: number;
|
|
5011
|
-
result:
|
|
5015
|
+
result: ArrayOrPlainObject;
|
|
5012
5016
|
};
|
|
5013
5017
|
export type PromiseHandlers = {
|
|
5014
5018
|
resolve: (value: unknown[]) => void;
|
|
@@ -5033,6 +5037,7 @@ export type PromiseParameters = {
|
|
|
5033
5037
|
data: PromiseData;
|
|
5034
5038
|
handlers: PromiseHandlers;
|
|
5035
5039
|
index: number;
|
|
5040
|
+
key: Key$1;
|
|
5036
5041
|
value?: unknown;
|
|
5037
5042
|
};
|
|
5038
5043
|
/**
|
|
@@ -5048,7 +5053,7 @@ export type PromiseStrategy = 'complete' | 'first';
|
|
|
5048
5053
|
export declare class PromiseTimeoutError extends Error {
|
|
5049
5054
|
constructor();
|
|
5050
5055
|
}
|
|
5051
|
-
export type PromisesItems<Items extends
|
|
5056
|
+
export type PromisesItems<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]>; };
|
|
5052
5057
|
/**
|
|
5053
5058
|
* Options for handling multiple _Promises_
|
|
5054
5059
|
*/
|
|
@@ -5062,10 +5067,10 @@ export type PromisesOptions = {
|
|
|
5062
5067
|
*/
|
|
5063
5068
|
strategy?: PromiseStrategy;
|
|
5064
5069
|
};
|
|
5065
|
-
export type PromisesResult<Items extends
|
|
5066
|
-
export type PromisesUnwrapped<Items extends
|
|
5070
|
+
export type PromisesResult<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never; };
|
|
5071
|
+
export type PromisesUnwrapped<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never; };
|
|
5067
5072
|
export type PromisesValue<Value> = FulfilledPromise<Value> | RejectedPromise;
|
|
5068
|
-
export type PromisesValues<Items extends
|
|
5073
|
+
export type PromisesValues<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never; };
|
|
5069
5074
|
/**
|
|
5070
5075
|
* A _Promise_ that was rejected
|
|
5071
5076
|
*/
|
|
@@ -5098,7 +5103,7 @@ export declare function delay(time?: number): Promise<void>;
|
|
|
5098
5103
|
//#endregion
|
|
5099
5104
|
//#region src/promise/index.d.ts
|
|
5100
5105
|
/**
|
|
5101
|
-
* Wrap a _Promise_ with safety handlers
|
|
5106
|
+
* Wrap a _Promise_ with safety handlers
|
|
5102
5107
|
*
|
|
5103
5108
|
* @param promise _Promise_ to wrap
|
|
5104
5109
|
* @param options Options for the _Promise_
|
|
@@ -5106,7 +5111,7 @@ export declare function delay(time?: number): Promise<void>;
|
|
|
5106
5111
|
*/
|
|
5107
5112
|
export declare function attemptPromise<Value>(promise: Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
5108
5113
|
/**
|
|
5109
|
-
* Wrap a _Promise_-returning callback with safety handlers
|
|
5114
|
+
* Wrap a _Promise_-returning callback with safety handlers
|
|
5110
5115
|
*
|
|
5111
5116
|
* @param callback Callback to wrap
|
|
5112
5117
|
* @param options Options for the _Promise_
|
|
@@ -5114,7 +5119,7 @@ export declare function attemptPromise<Value>(promise: Promise<Value>, options?:
|
|
|
5114
5119
|
*/
|
|
5115
5120
|
export declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
5116
5121
|
/**
|
|
5117
|
-
* Wrap a callback with a _Promise_ and safety handlers
|
|
5122
|
+
* Wrap a callback with a _Promise_ and safety handlers
|
|
5118
5123
|
*
|
|
5119
5124
|
* @param callback Callback to wrap
|
|
5120
5125
|
* @param options Options for the _Promise_
|
|
@@ -5124,7 +5129,7 @@ export declare function attemptPromise<Value>(callback: () => Value, options?: P
|
|
|
5124
5129
|
/**
|
|
5125
5130
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
5126
5131
|
*
|
|
5127
|
-
*
|
|
5132
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results_
|
|
5128
5133
|
*
|
|
5129
5134
|
* @param items List of _Promises_
|
|
5130
5135
|
* @param options Options for handling the _Promises_
|
|
@@ -5132,78 +5137,76 @@ export declare function attemptPromise<Value>(callback: () => Value, options?: P
|
|
|
5132
5137
|
*/
|
|
5133
5138
|
export declare function promises<Items extends unknown[], Options extends PromisesOptions>(items: [...Items], options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
5134
5139
|
/**
|
|
5135
|
-
* Handle
|
|
5140
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
5136
5141
|
*
|
|
5137
|
-
*
|
|
5142
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an object of rejected and resolved results_
|
|
5138
5143
|
*
|
|
5139
|
-
* @param items
|
|
5144
|
+
* @param items Keyed _Promises_
|
|
5140
5145
|
* @param options Options for handling the _Promises_
|
|
5141
|
-
* @returns
|
|
5146
|
+
* @returns Keyed object of results
|
|
5142
5147
|
*/
|
|
5143
|
-
export declare function promises<
|
|
5148
|
+
export declare function promises<Items extends PlainObject, Options extends PromisesOptions>(items: Items, options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
5144
5149
|
/**
|
|
5145
5150
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
5146
5151
|
*
|
|
5147
|
-
*
|
|
5152
|
+
* _If the strategy is `first`, the function will reject on the first error encountered; otherwise, it returns an array of rejected and resolved results_
|
|
5148
5153
|
*
|
|
5149
5154
|
* @param items List of _Promises_
|
|
5150
|
-
* @param strategy Strategy for handling the _Promises_
|
|
5155
|
+
* @param strategy Strategy for handling the _Promises_
|
|
5151
5156
|
* @returns List of results
|
|
5152
5157
|
*/
|
|
5153
|
-
export declare function promises<Items extends unknown[]>(items: [...Items], strategy:
|
|
5158
|
+
export declare function promises<Items extends unknown[], Strategy extends PromiseStrategy>(items: [...Items], strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
5154
5159
|
/**
|
|
5155
|
-
* Handle
|
|
5160
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
5156
5161
|
*
|
|
5157
|
-
*
|
|
5162
|
+
* _If the strategy is `first`, the function will reject on the first error encountered; otherwise, it returns an object of rejected and resolved results_
|
|
5158
5163
|
*
|
|
5159
|
-
* @param items
|
|
5160
|
-
* @param strategy Strategy for handling the _Promises_
|
|
5161
|
-
* @returns
|
|
5164
|
+
* @param items Keyed _Promises_
|
|
5165
|
+
* @param strategy Strategy for handling the _Promises_
|
|
5166
|
+
* @returns Keyed object of results
|
|
5162
5167
|
*/
|
|
5163
|
-
export declare function promises<
|
|
5168
|
+
export declare function promises<Items extends PlainObject, Strategy extends PromiseStrategy>(items: Items, strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
5164
5169
|
/**
|
|
5165
|
-
* Handle a list of _Promises_, returning their results in an ordered array
|
|
5170
|
+
* Handle a list of _Promises_, returning their results in an ordered array
|
|
5166
5171
|
*
|
|
5167
5172
|
* @param items List of _Promises_
|
|
5168
|
-
* @param signal
|
|
5173
|
+
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
5169
5174
|
* @returns List of results
|
|
5170
5175
|
*/
|
|
5171
5176
|
export declare function promises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
5172
5177
|
/**
|
|
5173
|
-
* Handle
|
|
5178
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
5174
5179
|
*
|
|
5175
|
-
* @param items
|
|
5176
|
-
* @param signal
|
|
5177
|
-
* @returns
|
|
5180
|
+
* @param items Keyed _Promises_
|
|
5181
|
+
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
5182
|
+
* @returns Keyed object of results
|
|
5178
5183
|
*/
|
|
5179
|
-
export declare function promises<
|
|
5184
|
+
export declare function promises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
5180
5185
|
export declare namespace promises {
|
|
5181
5186
|
var result: typeof resultPromises;
|
|
5182
5187
|
}
|
|
5183
5188
|
/**
|
|
5184
5189
|
* Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_
|
|
5185
5190
|
*
|
|
5186
|
-
*
|
|
5191
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results_
|
|
5187
5192
|
*
|
|
5188
5193
|
* _Available as `resultPromises` and `promises.result`_
|
|
5189
5194
|
*
|
|
5190
5195
|
* @param items List of _Promises_
|
|
5191
|
-
* @param signal AbortSignal for aborting
|
|
5196
|
+
* @param signal AbortSignal for aborting all _Promises_
|
|
5192
5197
|
* @returns List of results
|
|
5193
5198
|
*/
|
|
5194
5199
|
export declare function resultPromises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
5195
5200
|
/**
|
|
5196
|
-
* Handle
|
|
5197
|
-
*
|
|
5198
|
-
* Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
|
|
5201
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object of results _({@link Result})_
|
|
5199
5202
|
*
|
|
5200
5203
|
* _Available as `resultPromises` and `promises.result`_
|
|
5201
5204
|
*
|
|
5202
|
-
* @param items
|
|
5203
|
-
* @param signal AbortSignal for aborting
|
|
5204
|
-
* @returns
|
|
5205
|
+
* @param items Keyed _Promises_
|
|
5206
|
+
* @param signal AbortSignal for aborting all _Promises_
|
|
5207
|
+
* @returns Keyed object of results
|
|
5205
5208
|
*/
|
|
5206
|
-
export declare function resultPromises<
|
|
5209
|
+
export declare function resultPromises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
5207
5210
|
//#endregion
|
|
5208
5211
|
//#region src/internal/result/misc.d.ts
|
|
5209
5212
|
/**
|
|
@@ -5947,6 +5950,8 @@ export declare namespace fuzzy {
|
|
|
5947
5950
|
/**
|
|
5948
5951
|
* Does the needle match the haystack in a fuzzy way?
|
|
5949
5952
|
*
|
|
5953
|
+
* _Available as `fuzzyMatch` and `fuzzy.match`_
|
|
5954
|
+
*
|
|
5950
5955
|
* @param haystack Haystack to search through
|
|
5951
5956
|
* @param needle Needle to search for
|
|
5952
5957
|
* @returns `true` if the needle matches the haystack in a fuzzy way, otherwise `false`
|
|
@@ -6486,6 +6491,8 @@ export declare namespace freeze {
|
|
|
6486
6491
|
/**
|
|
6487
6492
|
* Is the value frozen?
|
|
6488
6493
|
*
|
|
6494
|
+
* _Available as `isFrozen` and `freeze.is`_
|
|
6495
|
+
*
|
|
6489
6496
|
* @param value Value to check
|
|
6490
6497
|
* @returns `true` if the value is frozen, otherwise `false`
|
|
6491
6498
|
*/
|
|
@@ -6615,7 +6622,7 @@ export type Merger = {
|
|
|
6615
6622
|
* @param values Values to merge
|
|
6616
6623
|
* @returns Merged value
|
|
6617
6624
|
*/
|
|
6618
|
-
<Values extends ArrayOrPlainObject[]>(values: NestedPartial<Values[number]
|
|
6625
|
+
<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
|
|
6619
6626
|
};
|
|
6620
6627
|
/**
|
|
6621
6628
|
* Assign values from one or more objects to the first one
|
|
@@ -8499,6 +8506,8 @@ export declare function isQueueInstance<Instance>(name: string, value: unknown):
|
|
|
8499
8506
|
/**
|
|
8500
8507
|
* Create a keyed queue for an asynchronous callback function, where each key has its own queue
|
|
8501
8508
|
*
|
|
8509
|
+
* _Available as `keyedQueue` and `queue.keyed`_
|
|
8510
|
+
*
|
|
8502
8511
|
* @param callback Callback function for queued items
|
|
8503
8512
|
* @param options Queue options
|
|
8504
8513
|
*/
|
|
@@ -8506,6 +8515,8 @@ export declare function keyedQueue<Callback extends (key: string, ...parameters:
|
|
|
8506
8515
|
/**
|
|
8507
8516
|
* Create a keyed queue for an asynchronous callback function, where each key has its own queue
|
|
8508
8517
|
*
|
|
8518
|
+
* _Available as `keyedQueue` and `queue.keyed`_
|
|
8519
|
+
*
|
|
8509
8520
|
* @param callback Callback function for queued items
|
|
8510
8521
|
* @param options Queue options
|
|
8511
8522
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -2597,6 +2597,8 @@ const ABORT_OPTIONS = { once: true };
|
|
|
2597
2597
|
//#region src/promise/constants.ts
|
|
2598
2598
|
const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
2599
2599
|
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
2600
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY = "promises expected at least one promise-function or promise in the array or object";
|
|
2601
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
2600
2602
|
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
2601
2603
|
const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
2602
2604
|
const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
@@ -2665,7 +2667,15 @@ function createPromisesOptions(input) {
|
|
|
2665
2667
|
};
|
|
2666
2668
|
}
|
|
2667
2669
|
function getResultsFromPromises(promised) {
|
|
2668
|
-
|
|
2670
|
+
const isArray = Array.isArray(promised);
|
|
2671
|
+
const entries = isArray ? promised.map((value, index) => [index, value]) : Object.entries(promised);
|
|
2672
|
+
const { length } = entries;
|
|
2673
|
+
const results = isArray ? [] : {};
|
|
2674
|
+
for (let index = 0; index < length; index += 1) {
|
|
2675
|
+
const [key, value] = entries[index];
|
|
2676
|
+
results[key] = isFulfilled(value) ? ok(value.value) : error(value.reason);
|
|
2677
|
+
}
|
|
2678
|
+
return results;
|
|
2669
2679
|
}
|
|
2670
2680
|
function getStrategyOrDefault(value) {
|
|
2671
2681
|
return PROMISE_STRATEGY_ALL.has(value) ? value : PROMISE_STRATEGY_DEFAULT;
|
|
@@ -2719,13 +2729,13 @@ function cancelable(executor) {
|
|
|
2719
2729
|
return new CancelablePromise(executor);
|
|
2720
2730
|
}
|
|
2721
2731
|
function handleResult(status, parameters) {
|
|
2722
|
-
const { aborter, complete, data, handlers, index, value } = parameters;
|
|
2732
|
+
const { aborter, complete, data, handlers, index, key, value } = parameters;
|
|
2723
2733
|
if (aborter?.signal.aborted ?? false) return;
|
|
2724
2734
|
if (!complete && status === "rejected") {
|
|
2725
2735
|
settlePromise(handlers.reject, value, aborter);
|
|
2726
2736
|
return;
|
|
2727
2737
|
}
|
|
2728
|
-
data.result[
|
|
2738
|
+
data.result[key] = !complete ? value : status === "fulfilled" ? {
|
|
2729
2739
|
status,
|
|
2730
2740
|
value
|
|
2731
2741
|
} : {
|
|
@@ -2816,17 +2826,18 @@ async function attemptPromise(value, options) {
|
|
|
2816
2826
|
async function promises(items, options) {
|
|
2817
2827
|
const { signal, strategy } = createPromisesOptions(options);
|
|
2818
2828
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
2819
|
-
if (!
|
|
2820
|
-
const
|
|
2829
|
+
if (!isArrayOrPlainObject(items)) return Promise.reject(PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE);
|
|
2830
|
+
const isArray = Array.isArray(items);
|
|
2831
|
+
const actual = (isArray ? items.map((item, index) => [index, item]) : Object.entries(items)).map(([key, value]) => [key, typeof value === "function" ? value() : value]).filter(([, value]) => value instanceof Promise);
|
|
2821
2832
|
const { length } = actual;
|
|
2822
|
-
if (length === 0) return Promise.
|
|
2833
|
+
if (length === 0) return Promise.reject(PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY);
|
|
2823
2834
|
const complete = strategy === PROMISE_STRATEGY_DEFAULT;
|
|
2824
2835
|
const aborter = createAborter(signal, () => {
|
|
2825
2836
|
handlers.reject(signal?.reason);
|
|
2826
2837
|
});
|
|
2827
2838
|
const data = {
|
|
2828
2839
|
last: length - 1,
|
|
2829
|
-
result: []
|
|
2840
|
+
result: isArray ? [] : {}
|
|
2830
2841
|
};
|
|
2831
2842
|
let handlers;
|
|
2832
2843
|
return new Promise((resolve, reject) => {
|
|
@@ -2834,21 +2845,24 @@ async function promises(items, options) {
|
|
|
2834
2845
|
reject,
|
|
2835
2846
|
resolve
|
|
2836
2847
|
};
|
|
2837
|
-
for (let index = 0; index < length; index += 1)
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2848
|
+
for (let index = 0; index < length; index += 1) {
|
|
2849
|
+
const [key, promise] = actual[index];
|
|
2850
|
+
const parameters = {
|
|
2851
|
+
aborter,
|
|
2852
|
+
complete,
|
|
2853
|
+
data,
|
|
2854
|
+
handlers,
|
|
2855
|
+
index,
|
|
2856
|
+
key
|
|
2857
|
+
};
|
|
2858
|
+
promise.then((value) => {
|
|
2859
|
+
parameters.value = value;
|
|
2860
|
+
handleResult(PROMISE_TYPE_FULFILLED, parameters);
|
|
2861
|
+
}).catch((reason) => {
|
|
2862
|
+
parameters.value = reason;
|
|
2863
|
+
handleResult(PROMISE_TYPE_REJECTED, parameters);
|
|
2864
|
+
});
|
|
2865
|
+
}
|
|
2852
2866
|
});
|
|
2853
2867
|
}
|
|
2854
2868
|
async function resultPromises(items, signal) {
|
|
@@ -3050,6 +3064,8 @@ function fuzzy(items, configuration) {
|
|
|
3050
3064
|
}
|
|
3051
3065
|
/**
|
|
3052
3066
|
* Does the needle match the haystack in a fuzzy way?
|
|
3067
|
+
*
|
|
3068
|
+
* _Available as `fuzzyMatch` and `fuzzy.match`_
|
|
3053
3069
|
*
|
|
3054
3070
|
* @param haystack Haystack to search through
|
|
3055
3071
|
* @param needle Needle to search for
|
|
@@ -3792,6 +3808,8 @@ function freezeValue(value, references, flat) {
|
|
|
3792
3808
|
}
|
|
3793
3809
|
/**
|
|
3794
3810
|
* Is the value frozen?
|
|
3811
|
+
*
|
|
3812
|
+
* _Available as `isFrozen` and `freeze.is`_
|
|
3795
3813
|
*
|
|
3796
3814
|
* @param value Value to check
|
|
3797
3815
|
* @returns `true` if the value is frozen, otherwise `false`
|
|
@@ -3968,7 +3986,8 @@ function createMergeOptions(options) {
|
|
|
3968
3986
|
}
|
|
3969
3987
|
function getReplaceableObjects(value) {
|
|
3970
3988
|
const items = (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string" || item instanceof RegExp);
|
|
3971
|
-
if (items.length
|
|
3989
|
+
if (items.length === 0) return;
|
|
3990
|
+
return (name) => items.some((item) => typeof item === "string" ? item === name : item.test(name));
|
|
3972
3991
|
}
|
|
3973
3992
|
/**
|
|
3974
3993
|
* Create an assigner with predefined options
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* compact([0, 1, '', 'hello', false, true, null, undefined]); // => [1, 'hello', true]
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | '' | false | null | undefined
|
|
14
|
+
declare function compact<Item>(array: Item[], strict: true): Array<Exclude<Item, 0 | '' | false | null | undefined>>;
|
|
15
15
|
/**
|
|
16
16
|
* Compact an array _(removing all `null` and `undefined` values)_
|
|
17
17
|
*
|
|
@@ -23,6 +23,6 @@ declare function compact<Item>(array: Item[], strict: true): Exclude<Item, 0 | '
|
|
|
23
23
|
* compact([0, 1, '', 'hello', false, true, null, undefined]); // => [0, 1, '', 'hello', false, true]
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
declare function compact<Item>(array: Item[]): Exclude<Item, null | undefined
|
|
26
|
+
declare function compact<Item>(array: Item[]): Array<Exclude<Item, null | undefined>>;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { compact };
|
|
@@ -6,6 +6,8 @@ declare const PROMISE_ABORT_OPTIONS: {
|
|
|
6
6
|
};
|
|
7
7
|
declare const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
8
8
|
declare const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
9
|
+
declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY = "promises expected at least one promise-function or promise in the array or object";
|
|
10
|
+
declare const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
9
11
|
declare const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
10
12
|
declare const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
11
13
|
declare const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
@@ -14,4 +16,4 @@ declare const PROMISE_STRATEGY_DEFAULT: PromiseStrategy;
|
|
|
14
16
|
declare const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
15
17
|
declare const PROMISE_TYPE_REJECTED = "rejected";
|
|
16
18
|
//#endregion
|
|
17
|
-
export { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED };
|
|
19
|
+
export { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED };
|
|
@@ -3,6 +3,8 @@ const PROMISE_ABORT_EVENT = "abort";
|
|
|
3
3
|
const PROMISE_ABORT_OPTIONS = { once: true };
|
|
4
4
|
const PROMISE_ERROR_NAME = "PromiseTimeoutError";
|
|
5
5
|
const PROMISE_MESSAGE_EXPECTATION_ATTEMPT = "Attempt expected a function or a promise";
|
|
6
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY = "promises expected at least one promise-function or promise in the array or object";
|
|
7
|
+
const PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE = "promises expected an array or object holding promise-functions or promises";
|
|
6
8
|
const PROMISE_MESSAGE_EXPECTATION_RESULT = "toResult expected a Promise";
|
|
7
9
|
const PROMISE_MESSAGE_EXPECTATION_TIMED = "Timed function expected a Promise";
|
|
8
10
|
const PROMISE_MESSAGE_TIMEOUT = "Promise timed out";
|
|
@@ -11,4 +13,4 @@ const PROMISE_STRATEGY_DEFAULT = "complete";
|
|
|
11
13
|
const PROMISE_TYPE_FULFILLED = "fulfilled";
|
|
12
14
|
const PROMISE_TYPE_REJECTED = "rejected";
|
|
13
15
|
//#endregion
|
|
14
|
-
export { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED };
|
|
16
|
+
export { PROMISE_ABORT_EVENT, PROMISE_ABORT_OPTIONS, PROMISE_ERROR_NAME, PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_MESSAGE_EXPECTATION_RESULT, PROMISE_MESSAGE_EXPECTATION_TIMED, PROMISE_MESSAGE_TIMEOUT, PROMISE_STRATEGY_ALL, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { RequiredKeys } from "../models.mjs";
|
|
2
|
-
import { Result } from "../internal/result/models.mjs";
|
|
3
2
|
import { FulfilledPromise, PromiseOptions, PromiseStrategy, PromisesOptions, PromisesValue, RejectedPromise } from "./models.mjs";
|
|
4
3
|
//#region src/promise/helpers.d.ts
|
|
5
4
|
declare function createPromiseOptions(input: unknown): RequiredKeys<PromiseOptions, 'time'>;
|
|
6
5
|
declare function createPromisesOptions(input: unknown): RequiredKeys<PromisesOptions, 'strategy'>;
|
|
7
|
-
declare function getResultsFromPromises
|
|
6
|
+
declare function getResultsFromPromises(promised: Array<PromisesValue<unknown>> | Record<string, PromisesValue<unknown>>): unknown;
|
|
8
7
|
declare function getStrategyOrDefault(value: unknown): PromiseStrategy;
|
|
9
8
|
/**
|
|
10
9
|
* Is the value a fulfilled _Promise_ result?
|
package/dist/promise/helpers.mjs
CHANGED
|
@@ -27,7 +27,15 @@ function createPromisesOptions(input) {
|
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
function getResultsFromPromises(promised) {
|
|
30
|
-
|
|
30
|
+
const isArray = Array.isArray(promised);
|
|
31
|
+
const entries = isArray ? promised.map((value, index) => [index, value]) : Object.entries(promised);
|
|
32
|
+
const { length } = entries;
|
|
33
|
+
const results = isArray ? [] : {};
|
|
34
|
+
for (let index = 0; index < length; index += 1) {
|
|
35
|
+
const [key, value] = entries[index];
|
|
36
|
+
results[key] = isFulfilled(value) ? ok(value.value) : error(value.reason);
|
|
37
|
+
}
|
|
38
|
+
return results;
|
|
31
39
|
}
|
|
32
40
|
function getStrategyOrDefault(value) {
|
|
33
41
|
return PROMISE_STRATEGY_ALL.has(value) ? value : PROMISE_STRATEGY_DEFAULT;
|
package/dist/promise/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped,
|
|
1
|
+
import { PlainObject } from "../models.mjs";
|
|
2
|
+
import { PromiseOptions, PromiseStrategy, PromisesItems, PromisesOptions, PromisesResult, PromisesUnwrapped, PromisesValues } from "./models.mjs";
|
|
3
3
|
//#region src/promise/index.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* Wrap a _Promise_ with safety handlers
|
|
5
|
+
* Wrap a _Promise_ with safety handlers
|
|
6
6
|
*
|
|
7
7
|
* @param promise _Promise_ to wrap
|
|
8
8
|
* @param options Options for the _Promise_
|
|
@@ -10,7 +10,7 @@ import { PromiseOptions, PromisesItems, PromisesOptions, PromisesResult, Promise
|
|
|
10
10
|
*/
|
|
11
11
|
declare function attemptPromise<Value>(promise: Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
12
12
|
/**
|
|
13
|
-
* Wrap a _Promise_-returning callback with safety handlers
|
|
13
|
+
* Wrap a _Promise_-returning callback with safety handlers
|
|
14
14
|
*
|
|
15
15
|
* @param callback Callback to wrap
|
|
16
16
|
* @param options Options for the _Promise_
|
|
@@ -18,7 +18,7 @@ declare function attemptPromise<Value>(promise: Promise<Value>, options?: Promis
|
|
|
18
18
|
*/
|
|
19
19
|
declare function attemptPromise<Value>(callback: () => Promise<Value>, options?: PromiseOptions | AbortSignal | number): Promise<Value>;
|
|
20
20
|
/**
|
|
21
|
-
* Wrap a callback with a _Promise_ and safety handlers
|
|
21
|
+
* Wrap a callback with a _Promise_ and safety handlers
|
|
22
22
|
*
|
|
23
23
|
* @param callback Callback to wrap
|
|
24
24
|
* @param options Options for the _Promise_
|
|
@@ -28,7 +28,7 @@ declare function attemptPromise<Value>(callback: () => Value, options?: PromiseO
|
|
|
28
28
|
/**
|
|
29
29
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
30
30
|
*
|
|
31
|
-
*
|
|
31
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results_
|
|
32
32
|
*
|
|
33
33
|
* @param items List of _Promises_
|
|
34
34
|
* @param options Options for handling the _Promises_
|
|
@@ -36,77 +36,75 @@ declare function attemptPromise<Value>(callback: () => Value, options?: PromiseO
|
|
|
36
36
|
*/
|
|
37
37
|
declare function promises<Items extends unknown[], Options extends PromisesOptions>(items: [...Items], options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
38
38
|
/**
|
|
39
|
-
* Handle
|
|
39
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
40
40
|
*
|
|
41
|
-
*
|
|
41
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an object of rejected and resolved results_
|
|
42
42
|
*
|
|
43
|
-
* @param items
|
|
43
|
+
* @param items Keyed _Promises_
|
|
44
44
|
* @param options Options for handling the _Promises_
|
|
45
|
-
* @returns
|
|
45
|
+
* @returns Keyed object of results
|
|
46
46
|
*/
|
|
47
|
-
declare function promises<
|
|
47
|
+
declare function promises<Items extends PlainObject, Options extends PromisesOptions>(items: Items, options?: Options): Promise<Options['strategy'] extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
48
48
|
/**
|
|
49
49
|
* Handle a list of _Promises_, returning their results in an ordered array
|
|
50
50
|
*
|
|
51
|
-
*
|
|
51
|
+
* _If the strategy is `first`, the function will reject on the first error encountered; otherwise, it returns an array of rejected and resolved results_
|
|
52
52
|
*
|
|
53
53
|
* @param items List of _Promises_
|
|
54
|
-
* @param strategy Strategy for handling the _Promises_
|
|
54
|
+
* @param strategy Strategy for handling the _Promises_
|
|
55
55
|
* @returns List of results
|
|
56
56
|
*/
|
|
57
|
-
declare function promises<Items extends unknown[]>(items: [...Items], strategy:
|
|
57
|
+
declare function promises<Items extends unknown[], Strategy extends PromiseStrategy>(items: [...Items], strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
58
58
|
/**
|
|
59
|
-
* Handle
|
|
59
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
60
60
|
*
|
|
61
|
-
*
|
|
61
|
+
* _If the strategy is `first`, the function will reject on the first error encountered; otherwise, it returns an object of rejected and resolved results_
|
|
62
62
|
*
|
|
63
|
-
* @param items
|
|
64
|
-
* @param strategy Strategy for handling the _Promises_
|
|
65
|
-
* @returns
|
|
63
|
+
* @param items Keyed _Promises_
|
|
64
|
+
* @param strategy Strategy for handling the _Promises_
|
|
65
|
+
* @returns Keyed object of results
|
|
66
66
|
*/
|
|
67
|
-
declare function promises<
|
|
67
|
+
declare function promises<Items extends PlainObject, Strategy extends PromiseStrategy>(items: Items, strategy: Strategy): Promise<Strategy extends 'first' ? PromisesUnwrapped<Items> : PromisesValues<PromisesItems<Items>>>;
|
|
68
68
|
/**
|
|
69
|
-
* Handle a list of _Promises_, returning their results in an ordered array
|
|
69
|
+
* Handle a list of _Promises_, returning their results in an ordered array
|
|
70
70
|
*
|
|
71
71
|
* @param items List of _Promises_
|
|
72
|
-
* @param signal
|
|
72
|
+
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
73
73
|
* @returns List of results
|
|
74
74
|
*/
|
|
75
75
|
declare function promises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
76
76
|
/**
|
|
77
|
-
* Handle
|
|
77
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object
|
|
78
78
|
*
|
|
79
|
-
* @param items
|
|
80
|
-
* @param signal
|
|
81
|
-
* @returns
|
|
79
|
+
* @param items Keyed _Promises_
|
|
80
|
+
* @param signal _AbortSignal_ for aborting all _Promises_
|
|
81
|
+
* @returns Keyed object of results
|
|
82
82
|
*/
|
|
83
|
-
declare function promises<
|
|
83
|
+
declare function promises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesValues<PromisesItems<Items>>>;
|
|
84
84
|
declare namespace promises {
|
|
85
85
|
var result: typeof resultPromises;
|
|
86
86
|
}
|
|
87
87
|
/**
|
|
88
88
|
* Handle a list of _Promises_, returning their results in an ordered array of results _({@link Result})_
|
|
89
89
|
*
|
|
90
|
-
*
|
|
90
|
+
* _Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results_
|
|
91
91
|
*
|
|
92
92
|
* _Available as `resultPromises` and `promises.result`_
|
|
93
93
|
*
|
|
94
94
|
* @param items List of _Promises_
|
|
95
|
-
* @param signal AbortSignal for aborting
|
|
95
|
+
* @param signal AbortSignal for aborting all _Promises_
|
|
96
96
|
* @returns List of results
|
|
97
97
|
*/
|
|
98
98
|
declare function resultPromises<Items extends unknown[]>(items: [...Items], signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
99
99
|
/**
|
|
100
|
-
* Handle
|
|
101
|
-
*
|
|
102
|
-
* Depending on the strategy, the function will either reject on the first error encountered or return an array of rejected and resolved results
|
|
100
|
+
* Handle keyed _Promises_, returning their results in a similarly keyed object of results _({@link Result})_
|
|
103
101
|
*
|
|
104
102
|
* _Available as `resultPromises` and `promises.result`_
|
|
105
103
|
*
|
|
106
|
-
* @param items
|
|
107
|
-
* @param signal AbortSignal for aborting
|
|
108
|
-
* @returns
|
|
104
|
+
* @param items Keyed _Promises_
|
|
105
|
+
* @param signal AbortSignal for aborting all _Promises_
|
|
106
|
+
* @returns Keyed object of results
|
|
109
107
|
*/
|
|
110
|
-
declare function resultPromises<
|
|
108
|
+
declare function resultPromises<Items extends PlainObject>(items: Items, signal?: AbortSignal): Promise<PromisesResult<PromisesItems<Items>>>;
|
|
111
109
|
//#endregion
|
|
112
110
|
export { attemptPromise, promises, resultPromises };
|
package/dist/promise/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { isArrayOrPlainObject } from "../internal/is.mjs";
|
|
1
2
|
import { createAborter } from "../internal/abort.mjs";
|
|
2
|
-
import { PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
3
|
+
import { PROMISE_MESSAGE_EXPECTATION_ATTEMPT, PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY, PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE, PROMISE_STRATEGY_DEFAULT, PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
3
4
|
import { createPromiseOptions, createPromisesOptions, getResultsFromPromises } from "./helpers.mjs";
|
|
4
5
|
import { handleResult, settlePromise } from "./misc.mjs";
|
|
5
6
|
import { getTimedPromise } from "./timed.mjs";
|
|
@@ -31,17 +32,18 @@ async function attemptPromise(value, options) {
|
|
|
31
32
|
async function promises(items, options) {
|
|
32
33
|
const { signal, strategy } = createPromisesOptions(options);
|
|
33
34
|
if (signal?.aborted ?? false) return Promise.reject(signal?.reason);
|
|
34
|
-
if (!
|
|
35
|
-
const
|
|
35
|
+
if (!isArrayOrPlainObject(items)) return Promise.reject(PROMISE_MESSAGE_EXPECTATION_ITEMS_TYPE);
|
|
36
|
+
const isArray = Array.isArray(items);
|
|
37
|
+
const actual = (isArray ? items.map((item, index) => [index, item]) : Object.entries(items)).map(([key, value]) => [key, typeof value === "function" ? value() : value]).filter(([, value]) => value instanceof Promise);
|
|
36
38
|
const { length } = actual;
|
|
37
|
-
if (length === 0) return Promise.
|
|
39
|
+
if (length === 0) return Promise.reject(PROMISE_MESSAGE_EXPECTATION_ITEMS_EMPTY);
|
|
38
40
|
const complete = strategy === PROMISE_STRATEGY_DEFAULT;
|
|
39
41
|
const aborter = createAborter(signal, () => {
|
|
40
42
|
handlers.reject(signal?.reason);
|
|
41
43
|
});
|
|
42
44
|
const data = {
|
|
43
45
|
last: length - 1,
|
|
44
|
-
result: []
|
|
46
|
+
result: isArray ? [] : {}
|
|
45
47
|
};
|
|
46
48
|
let handlers;
|
|
47
49
|
return new Promise((resolve, reject) => {
|
|
@@ -49,21 +51,24 @@ async function promises(items, options) {
|
|
|
49
51
|
reject,
|
|
50
52
|
resolve
|
|
51
53
|
};
|
|
52
|
-
for (let index = 0; index < length; index += 1)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
54
|
+
for (let index = 0; index < length; index += 1) {
|
|
55
|
+
const [key, promise] = actual[index];
|
|
56
|
+
const parameters = {
|
|
57
|
+
aborter,
|
|
58
|
+
complete,
|
|
59
|
+
data,
|
|
60
|
+
handlers,
|
|
61
|
+
index,
|
|
62
|
+
key
|
|
63
|
+
};
|
|
64
|
+
promise.then((value) => {
|
|
65
|
+
parameters.value = value;
|
|
66
|
+
handleResult(PROMISE_TYPE_FULFILLED, parameters);
|
|
67
|
+
}).catch((reason) => {
|
|
68
|
+
parameters.value = reason;
|
|
69
|
+
handleResult(PROMISE_TYPE_REJECTED, parameters);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
67
72
|
});
|
|
68
73
|
}
|
|
69
74
|
async function resultPromises(items, signal) {
|
package/dist/promise/misc.mjs
CHANGED
|
@@ -14,13 +14,13 @@ function cancelable(executor) {
|
|
|
14
14
|
return new CancelablePromise(executor);
|
|
15
15
|
}
|
|
16
16
|
function handleResult(status, parameters) {
|
|
17
|
-
const { aborter, complete, data, handlers, index, value } = parameters;
|
|
17
|
+
const { aborter, complete, data, handlers, index, key, value } = parameters;
|
|
18
18
|
if (aborter?.signal.aborted ?? false) return;
|
|
19
19
|
if (!complete && status === "rejected") {
|
|
20
20
|
settlePromise(handlers.reject, value, aborter);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
data.result[
|
|
23
|
+
data.result[key] = !complete ? value : status === "fulfilled" ? {
|
|
24
24
|
status,
|
|
25
25
|
value
|
|
26
26
|
} : {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GenericCallback } from "../models.mjs";
|
|
1
|
+
import { ArrayOrPlainObject, GenericCallback, Key } from "../models.mjs";
|
|
2
2
|
import { Result } from "../internal/result/models.mjs";
|
|
3
3
|
import { Aborter } from "../internal/abort.mjs";
|
|
4
4
|
import { PROMISE_TYPE_FULFILLED, PROMISE_TYPE_REJECTED } from "./constants.mjs";
|
|
@@ -31,7 +31,7 @@ type FulfilledPromise<Value> = {
|
|
|
31
31
|
};
|
|
32
32
|
type PromiseData = {
|
|
33
33
|
last: number;
|
|
34
|
-
result:
|
|
34
|
+
result: ArrayOrPlainObject;
|
|
35
35
|
};
|
|
36
36
|
type PromiseHandlers = {
|
|
37
37
|
resolve: (value: unknown[]) => void;
|
|
@@ -56,6 +56,7 @@ type PromiseParameters = {
|
|
|
56
56
|
data: PromiseData;
|
|
57
57
|
handlers: PromiseHandlers;
|
|
58
58
|
index: number;
|
|
59
|
+
key: Key;
|
|
59
60
|
value?: unknown;
|
|
60
61
|
};
|
|
61
62
|
/**
|
|
@@ -71,7 +72,7 @@ type PromiseStrategy = 'complete' | 'first';
|
|
|
71
72
|
declare class PromiseTimeoutError extends Error {
|
|
72
73
|
constructor();
|
|
73
74
|
}
|
|
74
|
-
type PromisesItems<Items extends
|
|
75
|
+
type PromisesItems<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Promise<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Promise<Value> : Promise<Items[ItemsKey]>; };
|
|
75
76
|
/**
|
|
76
77
|
* Options for handling multiple _Promises_
|
|
77
78
|
*/
|
|
@@ -85,10 +86,10 @@ type PromisesOptions = {
|
|
|
85
86
|
*/
|
|
86
87
|
strategy?: PromiseStrategy;
|
|
87
88
|
};
|
|
88
|
-
type PromisesResult<Items extends
|
|
89
|
-
type PromisesUnwrapped<Items extends
|
|
89
|
+
type PromisesResult<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? Result<Awaited<Value>> : never; };
|
|
90
|
+
type PromisesUnwrapped<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends GenericCallback ? ReturnType<Items[ItemsKey]> extends Promise<infer Value> ? Awaited<Value> : never : Items[ItemsKey] extends Promise<infer Value> ? Awaited<Value> : never; };
|
|
90
91
|
type PromisesValue<Value> = FulfilledPromise<Value> | RejectedPromise;
|
|
91
|
-
type PromisesValues<Items extends
|
|
92
|
+
type PromisesValues<Items extends ArrayOrPlainObject> = { [ItemsKey in keyof Items]: Items[ItemsKey] extends Promise<infer Value> ? PromisesValue<Awaited<Value>> : never; };
|
|
92
93
|
/**
|
|
93
94
|
* A _Promise_ that was rejected
|
|
94
95
|
*/
|
package/dist/queue.d.mts
CHANGED
|
@@ -216,6 +216,8 @@ declare function isQueueInstance<Instance>(name: string, value: unknown): value
|
|
|
216
216
|
/**
|
|
217
217
|
* Create a keyed queue for an asynchronous callback function, where each key has its own queue
|
|
218
218
|
*
|
|
219
|
+
* _Available as `keyedQueue` and `queue.keyed`_
|
|
220
|
+
*
|
|
219
221
|
* @param callback Callback function for queued items
|
|
220
222
|
* @param options Queue options
|
|
221
223
|
*/
|
|
@@ -223,6 +225,8 @@ declare function keyedQueue<Callback extends (key: string, ...parameters: any[])
|
|
|
223
225
|
/**
|
|
224
226
|
* Create a keyed queue for an asynchronous callback function, where each key has its own queue
|
|
225
227
|
*
|
|
228
|
+
* _Available as `keyedQueue` and `queue.keyed`_
|
|
229
|
+
*
|
|
226
230
|
* @param callback Callback function for queued items
|
|
227
231
|
* @param options Queue options
|
|
228
232
|
*/
|
package/dist/string/fuzzy.d.mts
CHANGED
|
@@ -115,6 +115,8 @@ declare namespace fuzzy {
|
|
|
115
115
|
/**
|
|
116
116
|
* Does the needle match the haystack in a fuzzy way?
|
|
117
117
|
*
|
|
118
|
+
* _Available as `fuzzyMatch` and `fuzzy.match`_
|
|
119
|
+
*
|
|
118
120
|
* @param haystack Haystack to search through
|
|
119
121
|
* @param needle Needle to search for
|
|
120
122
|
* @returns `true` if the needle matches the haystack in a fuzzy way, otherwise `false`
|
package/dist/string/fuzzy.mjs
CHANGED
package/dist/value/freeze.d.mts
CHANGED
package/dist/value/freeze.mjs
CHANGED
package/dist/value/merge.d.mts
CHANGED
|
@@ -60,7 +60,7 @@ type Merger = {
|
|
|
60
60
|
* @param values Values to merge
|
|
61
61
|
* @returns Merged value
|
|
62
62
|
*/
|
|
63
|
-
<Values extends ArrayOrPlainObject[]>(values: NestedPartial<Values[number]
|
|
63
|
+
<Values extends ArrayOrPlainObject[]>(values: Array<NestedPartial<Values[number]>>): UnionToIntersection<Values[number]>;
|
|
64
64
|
};
|
|
65
65
|
/**
|
|
66
66
|
* Assign values from one or more objects to the first one
|
package/dist/value/merge.mjs
CHANGED
|
@@ -29,7 +29,8 @@ function createMergeOptions(options) {
|
|
|
29
29
|
}
|
|
30
30
|
function getReplaceableObjects(value) {
|
|
31
31
|
const items = (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string" || item instanceof RegExp);
|
|
32
|
-
if (items.length
|
|
32
|
+
if (items.length === 0) return;
|
|
33
|
+
return (name) => items.some((item) => typeof item === "string" ? item === name : item.test(name));
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Create an assigner with predefined options
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oscarpalmer/atoms",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.200.0",
|
|
4
4
|
"description": "Atomic utilities for making your JavaScript better.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -278,10 +278,10 @@
|
|
|
278
278
|
"watch": "npx vite build --watch"
|
|
279
279
|
},
|
|
280
280
|
"devDependencies": {
|
|
281
|
-
"@oxlint/plugins": "^1.
|
|
282
|
-
"@types/node": "^26.
|
|
281
|
+
"@oxlint/plugins": "^1.82",
|
|
282
|
+
"@types/node": "^26.5",
|
|
283
283
|
"@vitest/coverage-istanbul": "^4.1",
|
|
284
|
-
"eslint": "^10.
|
|
284
|
+
"eslint": "^10.10",
|
|
285
285
|
"jsdom": "^30",
|
|
286
286
|
"tsdown": "^0.23",
|
|
287
287
|
"typescript": "^6",
|
package/plugin/index.js
CHANGED
|
@@ -29,7 +29,7 @@ export const mathPlugins = [
|
|
|
29
29
|
export const miscPlugins = [
|
|
30
30
|
tryCatchPlugin,
|
|
31
31
|
getPlugin('number', 'getNumber', new Set(['Number']), true, true),
|
|
32
|
-
getPlugin('promise', 'promises', new Set(['all', 'allSettled']), true),
|
|
32
|
+
getPlugin('promise', 'promises', new Set(['all', 'allKeyed', 'allSettled']), true),
|
|
33
33
|
getPlugin('value', 'assign', new Set(['assign']), true),
|
|
34
34
|
getPlugin('value', 'clone', new Set(['structuredClone']), true, true),
|
|
35
35
|
getPlugin('value', 'equal', new Set(['is']), true),
|