@oscarpalmer/atoms 0.186.2 → 0.187.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 +4 -4
- package/dist/array/find.d.mts +4 -4
- package/dist/array/first.d.mts +4 -4
- package/dist/array/get.d.mts +27 -1
- package/dist/array/get.mjs +5 -3
- package/dist/array/group-by.d.mts +6 -6
- package/dist/array/last.d.mts +4 -4
- package/dist/array/match.d.mts +7 -6
- package/dist/array/move.d.mts +7 -7
- package/dist/array/move.mjs +1 -1
- package/dist/array/select.d.mts +1 -0
- package/dist/array/slice.d.mts +3 -3
- package/dist/array/sort.d.mts +10 -7
- package/dist/array/sort.mjs +4 -3
- package/dist/array/swap.d.mts +1 -1
- package/dist/array/swap.mjs +1 -1
- package/dist/array/to-map.d.mts +32 -32
- package/dist/array/to-record.d.mts +6 -6
- package/dist/array/to-set.d.mts +6 -6
- package/dist/beacon.d.mts +6 -0
- package/dist/beacon.mjs +3 -0
- package/dist/color/index.d.mts +6 -2
- package/dist/color/index.mjs +6 -2
- package/dist/color/instance.d.mts +78 -14
- package/dist/color/instance.mjs +78 -14
- package/dist/color/misc/get.d.mts +39 -11
- package/dist/color/misc/get.mjs +39 -11
- package/dist/color/misc/is.d.mts +26 -11
- package/dist/color/misc/is.mjs +26 -11
- package/dist/color/misc/state.mjs +1 -1
- package/dist/color/models.d.mts +7 -4
- package/dist/color/space/hex.d.mts +15 -6
- package/dist/color/space/hex.mjs +15 -6
- package/dist/color/space/hsl.d.mts +10 -4
- package/dist/color/space/hsl.mjs +10 -4
- package/dist/color/space/rgb.d.mts +21 -12
- package/dist/color/space/rgb.mjs +21 -12
- package/dist/function/assert.d.mts +20 -14
- package/dist/function/assert.mjs +19 -13
- package/dist/function/limit.d.mts +8 -6
- package/dist/function/limit.mjs +8 -6
- package/dist/function/memoize.d.mts +15 -4
- package/dist/function/memoize.mjs +18 -4
- package/dist/function/once.d.mts +5 -3
- package/dist/function/once.mjs +5 -3
- package/dist/function/retry.d.mts +5 -2
- package/dist/function/retry.mjs +3 -1
- package/dist/function/work.d.mts +146 -98
- package/dist/{kalas.d.mts → herald.d.mts} +17 -8
- package/dist/{kalas.mjs → herald.mjs} +22 -13
- package/dist/index.d.mts +1464 -708
- package/dist/index.mjs +677 -324
- package/dist/internal/array/index-of.d.mts +4 -4
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/shuffle.d.mts +1 -0
- package/dist/internal/array/shuffle.mjs +2 -1
- package/dist/internal/is.d.mts +26 -8
- package/dist/internal/is.mjs +26 -8
- package/dist/internal/math/aggregate.d.mts +9 -9
- package/dist/internal/number.d.mts +13 -2
- package/dist/internal/number.mjs +13 -2
- package/dist/internal/random.d.mts +4 -2
- package/dist/internal/random.mjs +7 -5
- package/dist/internal/result.d.mts +17 -11
- package/dist/internal/result.mjs +10 -14
- package/dist/internal/string.d.mts +16 -1
- package/dist/internal/string.mjs +24 -1
- package/dist/internal/value/compare.d.mts +5 -2
- package/dist/internal/value/compare.mjs +5 -2
- package/dist/internal/value/equal.d.mts +12 -3
- package/dist/internal/value/equal.mjs +7 -4
- package/dist/internal/value/get.d.mts +17 -17
- package/dist/internal/value/has.d.mts +55 -11
- package/dist/internal/value/set.d.mts +24 -0
- package/dist/is.d.mts +12 -0
- package/dist/is.mjs +16 -1
- package/dist/logger.d.mts +7 -6
- package/dist/logger.mjs +6 -5
- package/dist/math.d.mts +36 -18
- package/dist/math.mjs +6 -3
- package/dist/models.d.mts +3 -3
- package/dist/promise/delay.d.mts +2 -0
- package/dist/promise/helpers.d.mts +6 -4
- package/dist/promise/helpers.mjs +6 -4
- package/dist/promise/index.d.mts +49 -38
- package/dist/promise/misc.d.mts +10 -7
- package/dist/promise/misc.mjs +4 -3
- package/dist/promise/models.d.mts +18 -19
- package/dist/promise/models.mjs +4 -3
- package/dist/promise/timed.d.mts +8 -6
- package/dist/query.d.mts +2 -0
- package/dist/query.mjs +2 -0
- package/dist/queue.d.mts +15 -4
- package/dist/queue.mjs +10 -3
- package/dist/random.d.mts +9 -2
- package/dist/random.mjs +7 -2
- package/dist/result/index.d.mts +14 -8
- package/dist/result/match.d.mts +18 -10
- package/dist/result/misc.d.mts +14 -7
- package/dist/result/misc.mjs +4 -2
- package/dist/result/models.d.mts +2 -0
- package/dist/result/work/flow.d.mts +86 -62
- package/dist/result/work/pipe.d.mts +55 -33
- package/dist/sized/map.d.mts +19 -16
- package/dist/sized/map.mjs +4 -4
- package/dist/sized/set.d.mts +20 -16
- package/dist/sized/set.mjs +8 -7
- package/dist/string/case.d.mts +8 -0
- package/dist/string/case.mjs +8 -0
- package/dist/string/fuzzy.d.mts +19 -5
- package/dist/string/fuzzy.mjs +7 -0
- package/dist/string/index.d.mts +17 -2
- package/dist/string/index.mjs +7 -9
- package/dist/string/match.d.mts +3 -0
- package/dist/string/match.mjs +3 -0
- package/dist/string/normalize.d.mts +6 -2
- package/dist/string/normalize.mjs +5 -2
- package/dist/string/template.d.mts +38 -9
- package/dist/string/template.mjs +19 -19
- package/dist/value/clone.d.mts +25 -4
- package/dist/value/clone.mjs +36 -22
- package/dist/value/collection.d.mts +9 -6
- package/dist/value/collection.mjs +3 -2
- package/dist/value/diff.d.mts +3 -1
- package/dist/value/diff.mjs +1 -0
- package/dist/value/freeze.d.mts +118 -9
- package/dist/value/freeze.mjs +56 -14
- package/dist/value/index.d.mts +1 -2
- package/dist/value/index.mjs +1 -2
- package/dist/value/merge.d.mts +11 -5
- package/dist/value/merge.mjs +2 -2
- package/dist/value/omit.d.mts +1 -0
- package/dist/value/omit.mjs +1 -0
- package/dist/value/pick.d.mts +1 -0
- package/dist/value/pick.mjs +1 -0
- package/dist/value/shake.d.mts +1 -0
- package/dist/value/shake.mjs +1 -0
- package/dist/value/smush.d.mts +1 -0
- package/dist/value/smush.mjs +1 -0
- package/dist/value/transform.d.mts +7 -3
- package/dist/value/unsmush.d.mts +1 -0
- package/dist/value/unsmush.mjs +1 -0
- package/package.json +11 -7
- package/src/array/filter.ts +4 -4
- package/src/array/find.ts +4 -4
- package/src/array/first.ts +4 -4
- package/src/array/get.ts +40 -5
- package/src/array/group-by.ts +6 -6
- package/src/array/last.ts +4 -4
- package/src/array/match.ts +7 -6
- package/src/array/move.ts +7 -7
- package/src/array/select.ts +1 -0
- package/src/array/slice.ts +3 -3
- package/src/array/sort.ts +15 -10
- package/src/array/swap.ts +1 -1
- package/src/array/to-map.ts +32 -32
- package/src/array/to-record.ts +6 -6
- package/src/array/to-set.ts +6 -6
- package/src/beacon.ts +6 -0
- package/src/color/index.ts +6 -2
- package/src/color/instance.ts +78 -14
- package/src/color/misc/get.ts +39 -11
- package/src/color/misc/is.ts +26 -11
- package/src/color/misc/state.ts +1 -1
- package/src/color/models.ts +7 -4
- package/src/color/space/hex.ts +15 -6
- package/src/color/space/hsl.ts +10 -4
- package/src/color/space/rgb.ts +21 -12
- package/src/function/assert.ts +20 -14
- package/src/function/limit.ts +8 -6
- package/src/function/memoize.ts +24 -5
- package/src/function/once.ts +5 -3
- package/src/function/retry.ts +7 -3
- package/src/function/work.ts +146 -98
- package/src/{kalas.ts → herald.ts} +23 -14
- package/src/index.ts +3 -2
- package/src/internal/array/index-of.ts +4 -4
- package/src/internal/array/insert.ts +1 -1
- package/src/internal/array/shuffle.ts +2 -1
- package/src/internal/is.ts +26 -8
- package/src/internal/math/aggregate.ts +9 -9
- package/src/internal/number.ts +13 -2
- package/src/internal/random.ts +10 -4
- package/src/internal/result.ts +30 -29
- package/src/internal/string.ts +28 -0
- package/src/internal/value/compare.ts +5 -2
- package/src/internal/value/equal.ts +13 -4
- package/src/internal/value/get.ts +17 -17
- package/src/internal/value/has.ts +54 -11
- package/src/internal/value/set.ts +24 -0
- package/src/is.ts +15 -1
- package/src/logger.ts +8 -7
- package/src/math.ts +36 -18
- package/src/models.ts +3 -3
- package/src/promise/delay.ts +2 -0
- package/src/promise/helpers.ts +6 -4
- package/src/promise/index.ts +49 -38
- package/src/promise/misc.ts +10 -7
- package/src/promise/models.ts +18 -19
- package/src/promise/timed.ts +8 -6
- package/src/query.ts +2 -0
- package/src/queue.ts +15 -4
- package/src/random.ts +8 -1
- package/src/result/index.ts +14 -8
- package/src/result/match.ts +18 -10
- package/src/result/misc.ts +17 -9
- package/src/result/models.ts +2 -0
- package/src/result/work/flow.ts +86 -62
- package/src/result/work/pipe.ts +55 -33
- package/src/sized/map.ts +20 -17
- package/src/sized/set.ts +21 -17
- package/src/string/case.ts +8 -0
- package/src/string/fuzzy.ts +19 -5
- package/src/string/index.ts +18 -15
- package/src/string/match.ts +3 -0
- package/src/string/normalize.ts +6 -2
- package/src/string/template.ts +69 -18
- package/src/value/clone.ts +51 -26
- package/src/value/collection.ts +9 -6
- package/src/value/diff.ts +3 -1
- package/src/value/freeze.ts +239 -25
- package/src/value/index.ts +0 -1
- package/src/value/merge.ts +11 -5
- package/src/value/omit.ts +1 -0
- package/src/value/pick.ts +1 -0
- package/src/value/shake.ts +1 -0
- package/src/value/smush.ts +1 -0
- package/src/value/transform.ts +7 -3
- package/src/value/unsmush.ts +1 -0
|
@@ -30,6 +30,7 @@ export type EqualOptions = {
|
|
|
30
30
|
type Equalizer = {
|
|
31
31
|
/**
|
|
32
32
|
* Are two strings equal?
|
|
33
|
+
*
|
|
33
34
|
* @param first First string
|
|
34
35
|
* @param second Second string
|
|
35
36
|
* @param ignoreCase If `true`, comparison will be case-insensitive
|
|
@@ -39,6 +40,7 @@ type Equalizer = {
|
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
42
|
* Are two values equal?
|
|
43
|
+
*
|
|
42
44
|
* @param first First value
|
|
43
45
|
* @param second Second value
|
|
44
46
|
* @returns `true` if the values are equal, otherwise `false`
|
|
@@ -47,12 +49,14 @@ type Equalizer = {
|
|
|
47
49
|
|
|
48
50
|
/**
|
|
49
51
|
* Deregister a equality comparison handler for a specific class
|
|
52
|
+
*
|
|
50
53
|
* @param constructor Class constructor
|
|
51
54
|
*/
|
|
52
55
|
deregister: <Instance>(constructor: Constructor<Instance>) => void;
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* Register a equality comparison function for a specific class
|
|
59
|
+
*
|
|
56
60
|
* @param constructor Class constructor
|
|
57
61
|
* @param handler Comparison function
|
|
58
62
|
*/
|
|
@@ -81,7 +85,8 @@ type OptionsKeys<Values> = {
|
|
|
81
85
|
/**
|
|
82
86
|
* Deregister a equality comparison handler for a specific class
|
|
83
87
|
*
|
|
84
|
-
*
|
|
88
|
+
* _Available as `deregisterEqualizer` and `equal.deregister`_
|
|
89
|
+
*
|
|
85
90
|
* @param constructor Class constructor
|
|
86
91
|
*/
|
|
87
92
|
export function deregisterEqualizer<Instance>(constructor: Constructor<Instance>): void {
|
|
@@ -109,6 +114,7 @@ function filterKey(key: string | symbol, options: Options): boolean {
|
|
|
109
114
|
|
|
110
115
|
/**
|
|
111
116
|
* Are two strings equal?
|
|
117
|
+
*
|
|
112
118
|
* @param first First string
|
|
113
119
|
* @param second Second string
|
|
114
120
|
* @param ignoreCase If `true`, comparison will be case-insensitive
|
|
@@ -118,6 +124,7 @@ export function equal(first: string, second: string, ignoreCase?: boolean): bool
|
|
|
118
124
|
|
|
119
125
|
/**
|
|
120
126
|
* Are two values equal?
|
|
127
|
+
*
|
|
121
128
|
* @param first First value
|
|
122
129
|
* @param second Second value
|
|
123
130
|
* @param options Comparison options
|
|
@@ -331,7 +338,7 @@ function equalValue(first: unknown, second: unknown, options: Options): boolean
|
|
|
331
338
|
return equalArrayBuffer(first, second, options);
|
|
332
339
|
|
|
333
340
|
case first instanceof Date && second instanceof Date:
|
|
334
|
-
return Object.is(
|
|
341
|
+
return Object.is(first.getTime(), (second as Date).getTime());
|
|
335
342
|
|
|
336
343
|
case first instanceof DataView && second instanceof DataView:
|
|
337
344
|
return equalDataView(first, second, options);
|
|
@@ -410,7 +417,8 @@ function getEqualOptions(input?: boolean | EqualOptions): Options {
|
|
|
410
417
|
/**
|
|
411
418
|
* Create an equalizer with predefined options
|
|
412
419
|
*
|
|
413
|
-
*
|
|
420
|
+
* _Available as `initializeEqualizer` and `equal.initialize`_
|
|
421
|
+
*
|
|
414
422
|
* @param options Comparison options
|
|
415
423
|
* @returns Equalizer function
|
|
416
424
|
*/
|
|
@@ -428,7 +436,8 @@ export function initializeEqualizer(options?: EqualOptions): Equalizer {
|
|
|
428
436
|
/**
|
|
429
437
|
* Register a equality comparison function for a specific class
|
|
430
438
|
*
|
|
431
|
-
*
|
|
439
|
+
* _Available as `registerEqualizer` and `equal.register`_
|
|
440
|
+
*
|
|
432
441
|
* @param constructor Class constructor
|
|
433
442
|
* @param handler Comparison function
|
|
434
443
|
*/
|
|
@@ -7,19 +7,19 @@ import {getNestedValue} from './misc';
|
|
|
7
7
|
/**
|
|
8
8
|
* Get the value from an object using a known path
|
|
9
9
|
*
|
|
10
|
+
* @param data Object to get value from
|
|
11
|
+
* @param path Path for value
|
|
12
|
+
* @returns Found value, or `undefined`
|
|
13
|
+
*
|
|
10
14
|
* @example
|
|
11
15
|
* ```typescript
|
|
12
16
|
* const data = {foo: {bar: {baz: 42}}};
|
|
13
17
|
*
|
|
14
|
-
* getValue(data, 'foo'); // {bar: {baz: 42}}
|
|
15
|
-
* getValue(data, 'foo.bar'); // {baz: 42}
|
|
16
|
-
* getValue(data, 'foo.bar.baz'); // 42
|
|
17
|
-
* getValue(data, 'foo.nope'); // undefined
|
|
18
|
+
* getValue(data, 'foo'); // => {bar: {baz: 42}}
|
|
19
|
+
* getValue(data, 'foo.bar'); // => {baz: 42}
|
|
20
|
+
* getValue(data, 'foo.bar.baz'); // => 42
|
|
21
|
+
* getValue(data, 'foo.nope'); // => undefined
|
|
18
22
|
* ```
|
|
19
|
-
*
|
|
20
|
-
* @param data Object to get value from
|
|
21
|
-
* @param path Path for value
|
|
22
|
-
* @returns Found value, or `undefined`
|
|
23
23
|
*/
|
|
24
24
|
export function getValue<Data extends PlainObject, Path extends NestedKeys<Data>>(
|
|
25
25
|
data: Data,
|
|
@@ -29,20 +29,20 @@ export function getValue<Data extends PlainObject, Path extends NestedKeys<Data>
|
|
|
29
29
|
/**
|
|
30
30
|
* Get the value from an object using an unknown path
|
|
31
31
|
*
|
|
32
|
+
* @param data Object to get value from
|
|
33
|
+
* @param path Path for value
|
|
34
|
+
* @param ignoreCase If `true`, path matching is case-insensitive
|
|
35
|
+
* @returns Found value, or `undefined`
|
|
36
|
+
*
|
|
32
37
|
* @example
|
|
33
38
|
* ```typescript
|
|
34
39
|
* const data = {foo: {bar: {baz: 42}}};
|
|
35
40
|
*
|
|
36
|
-
* getValue(data, 'foo'); // {bar: {baz: 42}}
|
|
37
|
-
* getValue(data, 'foo.bar'); // {baz: 42}
|
|
38
|
-
* getValue(data, 'Foo.Bar.Baz', true); // 42
|
|
39
|
-
* getValue(data, 'foo.nope'); // undefined
|
|
41
|
+
* getValue(data, 'foo'); // => {bar: {baz: 42}}
|
|
42
|
+
* getValue(data, 'foo.bar'); // => {baz: 42}
|
|
43
|
+
* getValue(data, 'Foo.Bar.Baz', true); // => 42
|
|
44
|
+
* getValue(data, 'foo.nope'); // => undefined
|
|
40
45
|
* ```
|
|
41
|
-
*
|
|
42
|
-
* @param data Object to get value from
|
|
43
|
-
* @param path Path for value
|
|
44
|
-
* @param ignoreCase If `true`, path matching is case-insensitive
|
|
45
|
-
* @returns Found value, or `undefined`
|
|
46
46
|
*/
|
|
47
47
|
export function getValue<Data extends PlainObject>(
|
|
48
48
|
data: Data,
|
|
@@ -5,10 +5,21 @@ import {getNestedValue} from './misc';
|
|
|
5
5
|
// #region Functions
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Check if a
|
|
8
|
+
* Check if a property is defined in an object
|
|
9
|
+
*
|
|
9
10
|
* @param data Object to check in
|
|
10
|
-
* @param path Path for property
|
|
11
|
+
* @param path Path for property, e.g., `foo.bar.baz`
|
|
11
12
|
* @returns `true` if the property exists, `false` otherwise
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
17
|
+
*
|
|
18
|
+
* hasValue(data, 'foo'); // => true
|
|
19
|
+
* hasValue(data, 'foo.bar'); // => true
|
|
20
|
+
* hasValue(data, 'foo.bar.baz'); // => true
|
|
21
|
+
* hasValue(data, 'foo.nope'); // => false
|
|
22
|
+
* ```
|
|
12
23
|
*/
|
|
13
24
|
export function hasValue<Data extends PlainObject, Path extends NestedKeys<Data>>(
|
|
14
25
|
data: Data,
|
|
@@ -16,11 +27,22 @@ export function hasValue<Data extends PlainObject, Path extends NestedKeys<Data>
|
|
|
16
27
|
): boolean;
|
|
17
28
|
|
|
18
29
|
/**
|
|
19
|
-
* Check if a
|
|
30
|
+
* Check if a property is defined in an object
|
|
31
|
+
*
|
|
20
32
|
* @param data Object to check in
|
|
21
|
-
* @param path Path for property
|
|
33
|
+
* @param path Path for property, e.g., `foo.bar.baz`
|
|
22
34
|
* @param ignoreCase If `true`, the path matching is case-insensitive
|
|
23
35
|
* @returns `true` if the property exists, `false` otherwise
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
40
|
+
*
|
|
41
|
+
* hasValue(data, 'foo'); // => true
|
|
42
|
+
* hasValue(data, 'foo.bar'); // => true
|
|
43
|
+
* hasValue(data, 'Foo.Bar.Baz', true); // => true
|
|
44
|
+
* hasValue(data, 'foo.nope'); // => false
|
|
45
|
+
* ```
|
|
24
46
|
*/
|
|
25
47
|
export function hasValue<Data extends PlainObject>(
|
|
26
48
|
data: Data,
|
|
@@ -35,28 +57,49 @@ export function hasValue(data: PlainObject, path: string, ignoreCase?: boolean):
|
|
|
35
57
|
hasValue.get = hasValueResult;
|
|
36
58
|
|
|
37
59
|
/**
|
|
38
|
-
* Check if a
|
|
60
|
+
* Check if a property is defined in an object, and get its value if it is
|
|
61
|
+
*
|
|
62
|
+
* _Available as `hasValueResult` and `hasValue.get`_
|
|
39
63
|
*
|
|
40
|
-
* Available as `hasValueResult` and `hasValue.get`
|
|
41
64
|
* @param data Object to check in
|
|
42
|
-
* @param path Path for property
|
|
65
|
+
* @param path Path for property, e.g., `foo.bar.baz`
|
|
43
66
|
* @param ignoreCase If `true`, the path matching is case-insensitive
|
|
44
67
|
* @returns Result object
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
72
|
+
*
|
|
73
|
+
* hasValueResult(data, 'foo'); // => {ok: true, value: {bar: {baz: 42}}}
|
|
74
|
+
* hasValueResult(data, 'foo.bar'); // => {ok: true, value: {baz: 42}}
|
|
75
|
+
* hasValueResult(data, 'foo.bar.baz'); // => {ok: true, value: 42}
|
|
76
|
+
* hasValueResult(data, 'foo.nope'); // => {ok: false, error: 'Expected property to exist in object'}
|
|
77
|
+
* ```
|
|
45
78
|
*/
|
|
46
79
|
export function hasValueResult<Data extends PlainObject, Path extends NestedKeys<Data>>(
|
|
47
80
|
data: Data,
|
|
48
81
|
path: Path,
|
|
49
|
-
ignoreCase?: boolean,
|
|
50
82
|
): Result<NestedValue<Data, ToString<Path>>, string>;
|
|
51
83
|
|
|
52
84
|
/**
|
|
53
|
-
* Check if a
|
|
85
|
+
* Check if a property is defined in an object, and get its value if it is
|
|
86
|
+
*
|
|
87
|
+
* _Available as `hasValueResult` and `hasValue.get`_
|
|
54
88
|
*
|
|
55
|
-
* Available as `hasValueResult` and `hasValue.get`
|
|
56
89
|
* @param data Object to check in
|
|
57
|
-
* @param path Path for property
|
|
90
|
+
* @param path Path for property, e.g., `foo.bar.baz`
|
|
58
91
|
* @param ignoreCase If `true`, the path matching is case-insensitive
|
|
59
92
|
* @returns Result object
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
97
|
+
*
|
|
98
|
+
* hasValueResult(data, 'foo'); // => {ok: true, value: {bar: {baz: 42}}}
|
|
99
|
+
* hasValueResult(data, 'foo.bar'); // => {ok: true, value: {baz: 42}}
|
|
100
|
+
* hasValueResult(data, 'Foo.Bar.Baz', true); // => {ok: true, value: 42}
|
|
101
|
+
* hasValueResult(data, 'foo.nope'); // => {ok: false, error: 'Expected property to exist in object'}
|
|
102
|
+
* ```
|
|
60
103
|
*/
|
|
61
104
|
export function hasValueResult<Data extends PlainObject>(
|
|
62
105
|
data: Data,
|
|
@@ -6,10 +6,18 @@ import {getPaths, handleValue} from './misc';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Update the value in an object using a known path
|
|
9
|
+
*
|
|
9
10
|
* @param data Object to set value in
|
|
10
11
|
* @param path Path for value, e.g., `foo.bar.baz`
|
|
11
12
|
* @param updater Function to update the current value
|
|
12
13
|
* @returns Updated object
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
18
|
+
*
|
|
19
|
+
* setValue(data, 'foo.bar.baz', (current) => current + 1); // => {foo: {bar: {baz: 43}}}
|
|
20
|
+
* ```
|
|
13
21
|
*/
|
|
14
22
|
export function setValue<Data extends PlainObject, Path extends NestedKeys<Data>>(
|
|
15
23
|
data: Data,
|
|
@@ -19,10 +27,18 @@ export function setValue<Data extends PlainObject, Path extends NestedKeys<Data>
|
|
|
19
27
|
|
|
20
28
|
/**
|
|
21
29
|
* Set the value in an object using a known path
|
|
30
|
+
*
|
|
22
31
|
* @param data Object to set value in
|
|
23
32
|
* @param path Path for value, e.g., `foo.bar.baz`
|
|
24
33
|
* @param value Value to set
|
|
25
34
|
* @returns Updated object
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
39
|
+
*
|
|
40
|
+
* setValue(data, 'foo.bar.baz', 99); // => {foo: {bar: {baz: 99}}}
|
|
41
|
+
* ```
|
|
26
42
|
*/
|
|
27
43
|
export function setValue<Data extends PlainObject, Path extends NestedKeys<Data>>(
|
|
28
44
|
data: Data,
|
|
@@ -32,11 +48,19 @@ export function setValue<Data extends PlainObject, Path extends NestedKeys<Data>
|
|
|
32
48
|
|
|
33
49
|
/**
|
|
34
50
|
* Set the value in an object using an unknown path
|
|
51
|
+
*
|
|
35
52
|
* @param data Object to set value in
|
|
36
53
|
* @param path Path for value, e.g., `foo.bar.baz`
|
|
37
54
|
* @param value Value to set
|
|
38
55
|
* @param ignoreCase If `true`, the path matching is case-insensitive
|
|
39
56
|
* @returns Updated object
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const data = {foo: {bar: {baz: 42}}};
|
|
61
|
+
*
|
|
62
|
+
* setValue(data, 'Foo.Bar.Baz', 99, true); // => {foo: {bar: {baz: 99}}}
|
|
63
|
+
* ```
|
|
40
64
|
*/
|
|
41
65
|
export function setValue<Data extends PlainObject>(
|
|
42
66
|
data: Data,
|
package/src/is.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {getString} from './internal/string';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Is the value empty, or only containing `null` or `undefined` values?
|
|
9
|
+
*
|
|
9
10
|
* @param value Value to check
|
|
10
11
|
* @returns `true` if the value is considered empty, otherwise `false`
|
|
11
12
|
*/
|
|
@@ -22,7 +23,9 @@ export function isEmpty(value: unknown): boolean {
|
|
|
22
23
|
const {length} = values;
|
|
23
24
|
|
|
24
25
|
for (let index = 0; index < length; index += 1) {
|
|
25
|
-
|
|
26
|
+
const item = values[index];
|
|
27
|
+
|
|
28
|
+
if (Array.isArray(item) ? item[1] != null : item != null) {
|
|
26
29
|
return false;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
@@ -32,6 +35,7 @@ export function isEmpty(value: unknown): boolean {
|
|
|
32
35
|
|
|
33
36
|
/**
|
|
34
37
|
* Is the value not empty, or holding non-empty values?
|
|
38
|
+
*
|
|
35
39
|
* @param value Value to check
|
|
36
40
|
* @returns `true` if the value is not considered empty, otherwise `false`
|
|
37
41
|
*/
|
|
@@ -41,6 +45,7 @@ export function isNonEmpty(value: unknown): boolean {
|
|
|
41
45
|
|
|
42
46
|
/**
|
|
43
47
|
* Is the value not `undefined` or `null`?
|
|
48
|
+
*
|
|
44
49
|
* @param value Value to check
|
|
45
50
|
* @returns `true` if the value is not `undefined` or `null`, otherwise `false`
|
|
46
51
|
*/
|
|
@@ -50,6 +55,7 @@ export function isNonNullable<Value>(value: Value): value is Exclude<Value, unde
|
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* Is the value not `undefined`, `null`, or stringified as an empty _(no whitespace)_ string?
|
|
58
|
+
*
|
|
53
59
|
* @param value Value to check
|
|
54
60
|
* @returns `true` if the value is not `undefined`, `null`, or matches an empty string, otherwise `false`
|
|
55
61
|
*/
|
|
@@ -61,6 +67,7 @@ export function isNonNullableOrEmpty<Value>(
|
|
|
61
67
|
|
|
62
68
|
/**
|
|
63
69
|
* Is the value not `undefined`, `null`, or stringified as a whitespace-only string?
|
|
70
|
+
*
|
|
64
71
|
* @param value Value to check
|
|
65
72
|
* @returns `true` if the value is not `undefined`, `null`, or matches a whitespace-only string, otherwise `false`
|
|
66
73
|
*/
|
|
@@ -72,6 +79,7 @@ export function isNonNullableOrWhitespace<Value>(
|
|
|
72
79
|
|
|
73
80
|
/**
|
|
74
81
|
* Is the value not a number or a number-like string?
|
|
82
|
+
*
|
|
75
83
|
* @param value Value to check
|
|
76
84
|
* @returns `true` if the value is not a number or a number-like string, otherwise `false`
|
|
77
85
|
*/
|
|
@@ -81,6 +89,7 @@ export function isNonNumerical<Value>(value: Value): value is Exclude<Value, num
|
|
|
81
89
|
|
|
82
90
|
/**
|
|
83
91
|
* Is the value not an object _(or function)_?
|
|
92
|
+
*
|
|
84
93
|
* @param value Value to check
|
|
85
94
|
* @returns `true` if the value is not an object, otherwise `false`
|
|
86
95
|
*/
|
|
@@ -90,6 +99,7 @@ export function isNonObject<Value>(value: Value): value is Exclude<Value, object
|
|
|
90
99
|
|
|
91
100
|
/**
|
|
92
101
|
* Is the value `undefined` or `null`?
|
|
102
|
+
*
|
|
93
103
|
* @param value Value to check
|
|
94
104
|
* @returns `true` if the value is `undefined` or `null`, otherwise `false`
|
|
95
105
|
*/
|
|
@@ -99,6 +109,7 @@ export function isNullable(value: unknown): value is undefined | null {
|
|
|
99
109
|
|
|
100
110
|
/**
|
|
101
111
|
* Is the value `undefined`, `null`, or stringified as an empty _(no whitespace)_ string?
|
|
112
|
+
*
|
|
102
113
|
* @param value Value to check
|
|
103
114
|
* @returns `true` if the value is nullable or matches an empty string, otherwise `false`
|
|
104
115
|
*/
|
|
@@ -108,6 +119,7 @@ export function isNullableOrEmpty(value: unknown): value is undefined | null | '
|
|
|
108
119
|
|
|
109
120
|
/**
|
|
110
121
|
* Is the value `undefined`, `null`, or stringified as a whitespace-only string?
|
|
122
|
+
*
|
|
111
123
|
* @param value Value to check
|
|
112
124
|
* @returns `true` if the value is nullable or matches a whitespace-only string, otherwise `false`
|
|
113
125
|
*/
|
|
@@ -117,6 +129,7 @@ export function isNullableOrWhitespace(value: unknown): value is undefined | nul
|
|
|
117
129
|
|
|
118
130
|
/**
|
|
119
131
|
* Is the value a number or a number-like string?
|
|
132
|
+
*
|
|
120
133
|
* @param value Value to check
|
|
121
134
|
* @returns `true` if the value is a number or a number-like string, otherwise `false`
|
|
122
135
|
*/
|
|
@@ -129,6 +142,7 @@ export function isNumerical(value: unknown): value is number | `${number}` {
|
|
|
129
142
|
|
|
130
143
|
/**
|
|
131
144
|
* Is the value an object _(or function)_?
|
|
145
|
+
*
|
|
132
146
|
* @param value Value to check
|
|
133
147
|
* @returns `true` if the value matches, otherwise `false`
|
|
134
148
|
*/
|
package/src/logger.ts
CHANGED
|
@@ -79,19 +79,20 @@ class Logger {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
82
|
-
* Start a
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
82
|
+
* Start a timed logger with a label
|
|
83
|
+
*
|
|
84
|
+
* @param label Label for the logger
|
|
85
|
+
* @returns _Timed_ instance
|
|
85
86
|
*/
|
|
86
|
-
time(label: string):
|
|
87
|
-
return new
|
|
87
|
+
time(label: string): Timed {
|
|
88
|
+
return new Timed(label);
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* A named timer that can be used to log durations to the console
|
|
93
94
|
*/
|
|
94
|
-
class
|
|
95
|
+
class Timed {
|
|
95
96
|
#logger: typeof console.timeLog | undefined;
|
|
96
97
|
#stopper: typeof console.timeEnd | undefined;
|
|
97
98
|
|
|
@@ -165,6 +166,6 @@ let enabled = true;
|
|
|
165
166
|
|
|
166
167
|
// #region Exports
|
|
167
168
|
|
|
168
|
-
export {logger, type Logger, type
|
|
169
|
+
export {logger, type Logger, type Timed};
|
|
169
170
|
|
|
170
171
|
// #endregion
|
package/src/math.ts
CHANGED
|
@@ -13,9 +13,10 @@ import type {NumericalValues, PlainObject} from './models';
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Get the average value from a list of items
|
|
16
|
+
*
|
|
16
17
|
* @param items List of items
|
|
17
18
|
* @param callback Callback to get an item's value
|
|
18
|
-
* @returns Average value, or `NaN` if no average can be calculated
|
|
19
|
+
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
19
20
|
*/
|
|
20
21
|
export function average<Item>(
|
|
21
22
|
items: Item[],
|
|
@@ -24,9 +25,10 @@ export function average<Item>(
|
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Get the average value from a list of items
|
|
28
|
+
*
|
|
27
29
|
* @param items List of items
|
|
28
30
|
* @param key Key to use for value
|
|
29
|
-
* @returns Average value, or `NaN` if no average can be calculated
|
|
31
|
+
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
30
32
|
*/
|
|
31
33
|
export function average<Item extends PlainObject>(
|
|
32
34
|
items: Item[],
|
|
@@ -35,8 +37,9 @@ export function average<Item extends PlainObject>(
|
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
* Get the average value from a list of numbers
|
|
40
|
+
*
|
|
38
41
|
* @param numbers List of numbers
|
|
39
|
-
* @returns Average value, or `NaN` if no average can be calculated
|
|
42
|
+
* @returns Average value, or `Number.NaN` if no average can be calculated
|
|
40
43
|
*/
|
|
41
44
|
export function average(numbers: number[]): number;
|
|
42
45
|
|
|
@@ -48,9 +51,10 @@ export function average(array: unknown[], key?: unknown): number {
|
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
53
|
* Round a number up
|
|
54
|
+
*
|
|
51
55
|
* @param value Number to round up
|
|
52
56
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
53
|
-
* @returns Rounded number, or `NaN` if the value if unable to be rounded
|
|
57
|
+
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
54
58
|
*/
|
|
55
59
|
export function ceil(value: number, decimals?: number): number {
|
|
56
60
|
return roundNumber(Math.ceil, value, decimals);
|
|
@@ -58,10 +62,11 @@ export function ceil(value: number, decimals?: number): number {
|
|
|
58
62
|
|
|
59
63
|
/**
|
|
60
64
|
* Count the number of items in an array that match a specific value
|
|
65
|
+
*
|
|
61
66
|
* @param array Array to count for
|
|
62
67
|
* @param callback Callback to get an item's value
|
|
63
68
|
* @param value Value to match and count
|
|
64
|
-
* @returns Number of items that match the condition, or `NaN` if no count can be calculated
|
|
69
|
+
* @returns Number of items that match the condition, or `Number.NaN` if no count can be calculated
|
|
65
70
|
*/
|
|
66
71
|
export function count<Item>(
|
|
67
72
|
array: Item[],
|
|
@@ -71,10 +76,11 @@ export function count<Item>(
|
|
|
71
76
|
|
|
72
77
|
/**
|
|
73
78
|
* Count the number of items in an array that have a specific value
|
|
79
|
+
*
|
|
74
80
|
* @param array Array to count for
|
|
75
81
|
* @param key Key to use for value
|
|
76
82
|
* @param value Value to match and count
|
|
77
|
-
* @returns Number of items with the specified key value, or `NaN` if no count can be calculated
|
|
83
|
+
* @returns Number of items with the specified key value, or `Number.NaN` if no count can be calculated
|
|
78
84
|
*/
|
|
79
85
|
export function count<Item extends PlainObject, ItemKey extends keyof Item>(
|
|
80
86
|
array: Item[],
|
|
@@ -84,8 +90,9 @@ export function count<Item extends PlainObject, ItemKey extends keyof Item>(
|
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
92
|
* Count the number of items in an array
|
|
93
|
+
*
|
|
87
94
|
* @param values Array to count for
|
|
88
|
-
* @returns Number of items, or `NaN` if no count can be calculated
|
|
95
|
+
* @returns Number of items, or `Number.NaN` if no count can be calculated
|
|
89
96
|
*/
|
|
90
97
|
export function count(values: unknown[]): number;
|
|
91
98
|
|
|
@@ -117,9 +124,10 @@ export function count(array: unknown[], key?: unknown, value?: unknown): number
|
|
|
117
124
|
|
|
118
125
|
/**
|
|
119
126
|
* Round a number down
|
|
127
|
+
*
|
|
120
128
|
* @param value Number to round down
|
|
121
129
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
122
|
-
* @returns Rounded number, or `NaN` if the value if unable to be rounded
|
|
130
|
+
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
123
131
|
*/
|
|
124
132
|
export function floor(value: number, decimals?: number): number {
|
|
125
133
|
return roundNumber(Math.floor, value, decimals);
|
|
@@ -127,9 +135,10 @@ export function floor(value: number, decimals?: number): number {
|
|
|
127
135
|
|
|
128
136
|
/**
|
|
129
137
|
* Get the median value from a list of items
|
|
138
|
+
*
|
|
130
139
|
* @param array List of items
|
|
131
140
|
* @param callback Callback to get an item's value
|
|
132
|
-
* @returns Median value, or `NaN` if no median can be calculated
|
|
141
|
+
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
133
142
|
*/
|
|
134
143
|
export function median<Item>(
|
|
135
144
|
array: Item[],
|
|
@@ -138,9 +147,10 @@ export function median<Item>(
|
|
|
138
147
|
|
|
139
148
|
/**
|
|
140
149
|
* Get the median value from a list of items
|
|
150
|
+
*
|
|
141
151
|
* @param array List of items
|
|
142
152
|
* @param key Key to use for value
|
|
143
|
-
* @returns Median value, or `NaN` if no median can be calculated
|
|
153
|
+
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
144
154
|
*/
|
|
145
155
|
export function median<Item extends PlainObject>(
|
|
146
156
|
array: Item[],
|
|
@@ -149,8 +159,9 @@ export function median<Item extends PlainObject>(
|
|
|
149
159
|
|
|
150
160
|
/**
|
|
151
161
|
* Get the median value from a list of numbers
|
|
162
|
+
*
|
|
152
163
|
* @param array List of numbers
|
|
153
|
-
* @returns Median value, or `NaN` if no median can be calculated
|
|
164
|
+
* @returns Median value, or `Number.NaN` if no median can be calculated
|
|
154
165
|
*/
|
|
155
166
|
export function median(array: number[]): number;
|
|
156
167
|
|
|
@@ -189,9 +200,10 @@ export function median(array: unknown[], key?: unknown): number {
|
|
|
189
200
|
|
|
190
201
|
/**
|
|
191
202
|
* Get the minimum value from a list of items
|
|
203
|
+
*
|
|
192
204
|
* @param items List of items
|
|
193
205
|
* @param callback Callback to get an item's value
|
|
194
|
-
* @returns Minimum value, or `NaN` if no minimum can be found
|
|
206
|
+
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
195
207
|
*/
|
|
196
208
|
export function min<Item>(
|
|
197
209
|
items: Item[],
|
|
@@ -200,9 +212,10 @@ export function min<Item>(
|
|
|
200
212
|
|
|
201
213
|
/**
|
|
202
214
|
* Get the minimum value from a list of items
|
|
215
|
+
*
|
|
203
216
|
* @param items List of items
|
|
204
217
|
* @param key Key to use for value
|
|
205
|
-
* @returns Minimum value, or `NaN` if no minimum can be found
|
|
218
|
+
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
206
219
|
*/
|
|
207
220
|
export function min<Item extends PlainObject>(
|
|
208
221
|
items: Item[],
|
|
@@ -211,8 +224,9 @@ export function min<Item extends PlainObject>(
|
|
|
211
224
|
|
|
212
225
|
/**
|
|
213
226
|
* Get the minimum value from a list of numbers
|
|
227
|
+
*
|
|
214
228
|
* @param values List of numbers
|
|
215
|
-
* @returns Minimum value, or `NaN` if no minimum can be found
|
|
229
|
+
* @returns Minimum value, or `Number.NaN` if no minimum can be found
|
|
216
230
|
*/
|
|
217
231
|
export function min(values: number[]): number;
|
|
218
232
|
|
|
@@ -222,9 +236,10 @@ export function min(array: unknown[], key?: unknown): number {
|
|
|
222
236
|
|
|
223
237
|
/**
|
|
224
238
|
* Round a number
|
|
239
|
+
*
|
|
225
240
|
* @param value Number to round
|
|
226
241
|
* @param decimals Number of decimal places to round to _(defaults to `0`)_
|
|
227
|
-
* @returns Rounded number, or `NaN` if the value if unable to be rounded
|
|
242
|
+
* @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
|
|
228
243
|
*/
|
|
229
244
|
export function round(value: number, decimals?: number): number {
|
|
230
245
|
return roundNumber(Math.round, value, decimals);
|
|
@@ -250,9 +265,10 @@ function roundNumber(
|
|
|
250
265
|
|
|
251
266
|
/**
|
|
252
267
|
* Get the sum of a list of items
|
|
268
|
+
*
|
|
253
269
|
* @param items List of items
|
|
254
270
|
* @param callback Callback to get an item's value
|
|
255
|
-
* @returns Sum of the values, or `NaN` if no sum can be calculated
|
|
271
|
+
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
256
272
|
*/
|
|
257
273
|
export function sum<Item>(
|
|
258
274
|
items: Item[],
|
|
@@ -261,9 +277,10 @@ export function sum<Item>(
|
|
|
261
277
|
|
|
262
278
|
/**
|
|
263
279
|
* Get the sum of a list of items
|
|
280
|
+
*
|
|
264
281
|
* @param items List of items
|
|
265
282
|
* @param key Key to use for value
|
|
266
|
-
* @returns Sum of the values, or `NaN` if no sum can be calculated
|
|
283
|
+
* @returns Sum of the values, or `Number.NaN` if no sum can be calculated
|
|
267
284
|
*/
|
|
268
285
|
export function sum<Item extends PlainObject>(
|
|
269
286
|
items: Item[],
|
|
@@ -272,8 +289,9 @@ export function sum<Item extends PlainObject>(
|
|
|
272
289
|
|
|
273
290
|
/**
|
|
274
291
|
* Get the sum of a list of numbers
|
|
292
|
+
*
|
|
275
293
|
* @param values List of numbers
|
|
276
|
-
* @returns Sum of the numbers, or `NaN` if no sum can be calculated
|
|
294
|
+
* @returns Sum of the numbers, or `Number.NaN` if no sum can be calculated
|
|
277
295
|
*/
|
|
278
296
|
export function sum(values: number[]): number;
|
|
279
297
|
|
package/src/models.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type AsyncCancelableCallback<Callback extends GenericAsyncCallback | Gene
|
|
|
21
21
|
/**
|
|
22
22
|
* For matching any `void`, `Date`, primitive, or `RegExp` values
|
|
23
23
|
*
|
|
24
|
-
* (Thanks, type-fest!)
|
|
24
|
+
* _(Thanks, type-fest!)_
|
|
25
25
|
*/
|
|
26
26
|
export type BuiltIns = void | Date | Primitive | RegExp;
|
|
27
27
|
|
|
@@ -139,7 +139,7 @@ type _NestedValue<Value, Path extends string> = Path extends `${infer ItemKey}.$
|
|
|
139
139
|
: never;
|
|
140
140
|
|
|
141
141
|
/**
|
|
142
|
-
* The nested (keyed) values of an object _(up to 5 levels deep)_
|
|
142
|
+
* The nested _(keyed)_ values of an object _(up to 5 levels deep)_
|
|
143
143
|
*/
|
|
144
144
|
export type NestedValues<Value extends PlainObject> = {
|
|
145
145
|
[Path in NestedKeys<Value>]: NestedValue<Value, Path>;
|
|
@@ -267,7 +267,7 @@ export type TypedArray =
|
|
|
267
267
|
* ```typescript
|
|
268
268
|
* type A = {a: string};
|
|
269
269
|
* type B = {b: number};
|
|
270
|
-
* type C = UnionToIntersection<A | B>; // {a: string} & {b: number}
|
|
270
|
+
* type C = UnionToIntersection<A | B>; // => {a: string} & {b: number}
|
|
271
271
|
* ```
|
|
272
272
|
*
|
|
273
273
|
* Thanks, type-fest!
|
package/src/promise/delay.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {PROMISE_ABORT_OPTIONS, PROMISE_ABORT_EVENT, type PromiseOptions} from '.
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Create a delayed promise that resolves after a certain amount of time, or rejects if aborted
|
|
10
|
+
*
|
|
10
11
|
* @param options Options for the delay
|
|
11
12
|
* @returns Delayed promise
|
|
12
13
|
*/
|
|
@@ -14,6 +15,7 @@ export function delay(options?: PromiseOptions): Promise<void>;
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Create a delayed promise that resolves after a certain amount of time
|
|
18
|
+
*
|
|
17
19
|
* @param time How long to wait for _(in milliseconds; defaults to `0`)_
|
|
18
20
|
* @returns Delayed promise
|
|
19
21
|
*/
|