@oscarpalmer/atoms 0.217.0 → 0.218.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/insert.mjs +1 -1
- package/dist/array/slice.mjs +27 -14
- package/dist/array/sort.mjs +2 -1
- package/dist/color/misc/get.mjs +3 -1
- package/dist/color/space/hex.mjs +1 -1
- package/dist/function/retry.d.mts +1 -1
- package/dist/function/retry.mjs +5 -2
- package/dist/index.d.mts +163 -154
- package/dist/index.mjs +227 -145
- package/dist/internal/array/find.mjs +57 -34
- package/dist/internal/array/insert.mjs +1 -1
- package/dist/internal/array/match.mjs +21 -17
- package/dist/internal/array/sets.mjs +7 -1
- package/dist/internal/math/aggregate.mjs +4 -1
- package/dist/internal/number.d.mts +1 -1
- package/dist/internal/number.mjs +4 -2
- package/dist/internal/plan/plan.generate.mjs +3 -3
- package/dist/internal/random.d.mts +6 -0
- package/dist/internal/random.mjs +13 -2
- package/dist/internal/result/attempt.mjs +4 -4
- package/dist/internal/string/misc.mjs +2 -1
- package/dist/internal/subscription.mjs +1 -1
- package/dist/internal/value/equal.mjs +2 -1
- package/dist/internal/value/partial.mjs +3 -1
- package/dist/models/plan.model.d.mts +2 -0
- package/dist/models/plan.model.mjs +3 -1
- package/dist/models/string/string.fuzzy.model.d.mts +1 -1
- package/dist/models/string/string.misc.model.mjs +1 -1
- package/dist/models/value/value.merge.model.d.mts +1 -1
- package/dist/plan/index.d.mts +1 -4
- package/dist/plan/index.mjs +2 -3
- package/dist/plan/use.mjs +4 -4
- package/dist/promise/index.d.mts +6 -4
- package/dist/promise/index.mjs +4 -4
- package/dist/promise/misc.mjs +5 -2
- package/dist/promise/timed.mjs +2 -2
- package/dist/queue.mjs +4 -5
- package/dist/random.d.mts +2 -2
- package/dist/random.mjs +3 -3
- package/dist/result/match.mjs +2 -2
- package/dist/result/misc.mjs +3 -10
- package/dist/result/work/pipe.d.mts +24 -22
- package/dist/result/work/pipe.mjs +7 -3
- package/dist/string/fuzzy.mjs +1 -1
- package/dist/string/index.mjs +1 -1
- package/dist/value/clone.mjs +1 -1
- package/dist/value/merge.mjs +17 -4
- package/package.json +1 -1
package/dist/random.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
1
|
+
import { getRandom, getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
2
2
|
//#region src/random.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Get a random boolean
|
|
@@ -50,4 +50,4 @@ export declare function getRandomItems<Value>(array: Value[], amount: number): V
|
|
|
50
50
|
*/
|
|
51
51
|
export declare function getRandomItems<Value>(array: Value[]): Value[];
|
|
52
52
|
//#endregion
|
|
53
|
-
export { getRandomFloatingNumber as getRandomFloat, getRandomInteger };
|
|
53
|
+
export { getRandom, getRandomFloatingNumber as getRandomFloat, getRandomInteger };
|
package/dist/random.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
1
|
+
import { getRandom, getRandomFloatingNumber, getRandomInteger } from "./internal/random.mjs";
|
|
2
2
|
import { shuffle } from "./internal/array/shuffle.mjs";
|
|
3
3
|
import { join } from "./internal/string/misc.mjs";
|
|
4
4
|
import { RANDOM_ALPHABET, RANDOM_BOOLEAN_MODIFIER, RANDOM_HEX_CHARACTERS } from "./models/random.model.mjs";
|
|
@@ -9,7 +9,7 @@ import { RANDOM_ALPHABET, RANDOM_BOOLEAN_MODIFIER, RANDOM_HEX_CHARACTERS } from
|
|
|
9
9
|
* @returns Random boolean
|
|
10
10
|
*/
|
|
11
11
|
function getRandomBoolean() {
|
|
12
|
-
return
|
|
12
|
+
return getRandom() > RANDOM_BOOLEAN_MODIFIER;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Get a random string of characters with a specified length
|
|
@@ -59,4 +59,4 @@ function getRandomItems(array, amount) {
|
|
|
59
59
|
return typeof amount !== "number" || amount <= 0 || amount >= array.length ? shuffle(array) : shuffle(array).slice(0, amount);
|
|
60
60
|
}
|
|
61
61
|
//#endregion
|
|
62
|
-
export { getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
|
|
62
|
+
export { getRandom, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems };
|
package/dist/result/match.mjs
CHANGED
|
@@ -20,10 +20,10 @@ function handleResult(result, first, second) {
|
|
|
20
20
|
error = second;
|
|
21
21
|
}
|
|
22
22
|
if (isOk(result)) {
|
|
23
|
-
if (typeof ok !== "function") throw new
|
|
23
|
+
if (typeof ok !== "function") throw new TypeError(MATCH_MESSAGE_OK);
|
|
24
24
|
return ok(result.value);
|
|
25
25
|
}
|
|
26
|
-
if (typeof error !== "function") throw new
|
|
26
|
+
if (typeof error !== "function") throw new TypeError(MATCH_MESSAGE_ERROR);
|
|
27
27
|
return error(result.error, result.original);
|
|
28
28
|
}
|
|
29
29
|
function matchResult(result, first, second) {
|
package/dist/result/misc.mjs
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { error, isError, isOk, isResult, ok, unwrap } from "../internal/result/misc.mjs";
|
|
2
2
|
//#region src/result/misc.ts
|
|
3
|
-
/**
|
|
4
|
-
* Converts a _Result_ to a _Promise_
|
|
5
|
-
*
|
|
6
|
-
* Resolves if ok, rejects for error
|
|
7
|
-
*
|
|
8
|
-
* @param result _Result_ to convert
|
|
9
|
-
* @returns Promised result
|
|
10
|
-
*/
|
|
11
3
|
async function toPromise(result) {
|
|
12
4
|
const actual = typeof result === "function" ? result() : result;
|
|
13
|
-
if (!isResult(actual))
|
|
14
|
-
|
|
5
|
+
if (!isResult(actual)) throw new TypeError(RESULT_MESSAGE_PROMISE);
|
|
6
|
+
if (isOk(actual)) return actual.value;
|
|
7
|
+
throw actual.error;
|
|
15
8
|
}
|
|
16
9
|
const RESULT_MESSAGE_PROMISE = "toPromise expected to receive a Result";
|
|
17
10
|
//#endregion
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { GenericCallback } from "../../models/index.mjs";
|
|
2
2
|
import { Result, UnwrapValue } from "../../models/result.model.mjs";
|
|
3
3
|
//#region src/result/work/pipe.d.ts
|
|
4
|
+
type InitialAsyncPipeValue<Initial> = GenericCallback | Initial | Promise<Initial> | Result<Initial>;
|
|
5
|
+
type InitialPipeValue<Initial> = GenericCallback | Initial | Result<Initial>;
|
|
4
6
|
type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
5
7
|
/**
|
|
6
8
|
* Attempt to pipe a value through a function
|
|
@@ -10,7 +12,7 @@ type WrapValue<Value> = Result<UnwrapValue<Value>>;
|
|
|
10
12
|
* @param initial Initial value
|
|
11
13
|
* @returns _Piped_ result
|
|
12
14
|
*/
|
|
13
|
-
export declare function attemptAsyncPipe<Initial, Piped>(initial:
|
|
15
|
+
export declare function attemptAsyncPipe<Initial, Piped>(initial: InitialAsyncPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Piped): Promise<WrapValue<Piped>>;
|
|
14
16
|
/**
|
|
15
17
|
* Attempt to pipe a value through a series of functions
|
|
16
18
|
*
|
|
@@ -19,7 +21,7 @@ export declare function attemptAsyncPipe<Initial, Piped>(initial: GenericCallbac
|
|
|
19
21
|
* @param initial Initial value
|
|
20
22
|
* @returns _Piped_ result
|
|
21
23
|
*/
|
|
22
|
-
export declare function attemptAsyncPipe<Initial, First, Second>(initial:
|
|
24
|
+
export declare function attemptAsyncPipe<Initial, First, Second>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): Promise<WrapValue<Second>>;
|
|
23
25
|
/**
|
|
24
26
|
* Attempt to pipe a value through a series of functions
|
|
25
27
|
*
|
|
@@ -28,7 +30,7 @@ export declare function attemptAsyncPipe<Initial, First, Second>(initial: Generi
|
|
|
28
30
|
* @param initial Initial value
|
|
29
31
|
* @returns _Piped_ result
|
|
30
32
|
*/
|
|
31
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial:
|
|
33
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): Promise<WrapValue<Third>>;
|
|
32
34
|
/**
|
|
33
35
|
* Attempt to pipe a value through a series of functions
|
|
34
36
|
*
|
|
@@ -37,7 +39,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third>(initial:
|
|
|
37
39
|
* @param initial Initial value
|
|
38
40
|
* @returns _Piped_ result
|
|
39
41
|
*/
|
|
40
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial:
|
|
42
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): Promise<WrapValue<Fourth>>;
|
|
41
43
|
/**
|
|
42
44
|
* Attempt to pipe a value through a series of functions
|
|
43
45
|
*
|
|
@@ -46,7 +48,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth>(
|
|
|
46
48
|
* @param initial Initial value
|
|
47
49
|
* @returns _Piped_ result
|
|
48
50
|
*/
|
|
49
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial:
|
|
51
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): Promise<WrapValue<Fifth>>;
|
|
50
52
|
/**
|
|
51
53
|
* Attempt to pipe a value through a series of functions
|
|
52
54
|
*
|
|
@@ -55,7 +57,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
55
57
|
* @param initial Initial value
|
|
56
58
|
* @returns _Piped_ result
|
|
57
59
|
*/
|
|
58
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial:
|
|
60
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): Promise<WrapValue<Sixth>>;
|
|
59
61
|
/**
|
|
60
62
|
* Attempt to pipe a value through a series of functions
|
|
61
63
|
*
|
|
@@ -64,7 +66,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
64
66
|
* @param initial Initial value
|
|
65
67
|
* @returns _Piped_ result
|
|
66
68
|
*/
|
|
67
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial:
|
|
69
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): Promise<WrapValue<Seventh>>;
|
|
68
70
|
/**
|
|
69
71
|
* Attempt to pipe a value through a series of functions
|
|
70
72
|
*
|
|
@@ -73,7 +75,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
73
75
|
* @param initial Initial value
|
|
74
76
|
* @returns _Piped_ result
|
|
75
77
|
*/
|
|
76
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial:
|
|
78
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): Promise<WrapValue<Eighth>>;
|
|
77
79
|
/**
|
|
78
80
|
* Attempt to pipe a value through a series of functions
|
|
79
81
|
*
|
|
@@ -82,7 +84,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
82
84
|
* @param initial Initial value
|
|
83
85
|
* @returns _Piped_ result
|
|
84
86
|
*/
|
|
85
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial:
|
|
87
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): Promise<WrapValue<Ninth>>;
|
|
86
88
|
/**
|
|
87
89
|
* Attempt to pipe a value through a series of functions
|
|
88
90
|
*
|
|
@@ -91,7 +93,7 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
91
93
|
* @param initial Initial value
|
|
92
94
|
* @returns _Piped_ result
|
|
93
95
|
*/
|
|
94
|
-
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial:
|
|
96
|
+
export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialAsyncPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): Promise<WrapValue<Tenth>>;
|
|
95
97
|
/**
|
|
96
98
|
* Attempt to pipe a result through a series of functions
|
|
97
99
|
*
|
|
@@ -100,84 +102,84 @@ export declare function attemptAsyncPipe<Initial, First, Second, Third, Fourth,
|
|
|
100
102
|
* @param initial Initial result
|
|
101
103
|
* @returns _Piped_ result
|
|
102
104
|
*/
|
|
103
|
-
export declare function attemptAsyncPipe<Initial>(initial:
|
|
105
|
+
export declare function attemptAsyncPipe<Initial>(initial: InitialAsyncPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): Promise<WrapValue<Initial>>;
|
|
104
106
|
/**
|
|
105
107
|
* Attempt to pipe a value through a function
|
|
106
108
|
*
|
|
107
109
|
* @param initial Initial value
|
|
108
110
|
* @returns _Piped_ result
|
|
109
111
|
*/
|
|
110
|
-
export declare function attemptPipe<Initial, Pipe>(initial:
|
|
112
|
+
export declare function attemptPipe<Initial, Pipe>(initial: InitialPipeValue<Initial>, pipe: (value: UnwrapValue<Initial>) => Pipe): WrapValue<Pipe>;
|
|
111
113
|
/**
|
|
112
114
|
* Attempt to pipe a value through a series of functions
|
|
113
115
|
*
|
|
114
116
|
* @param initial Initial value
|
|
115
117
|
* @returns _Piped_ result
|
|
116
118
|
*/
|
|
117
|
-
export declare function attemptPipe<Initial, First, Second>(initial:
|
|
119
|
+
export declare function attemptPipe<Initial, First, Second>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second): WrapValue<Second>;
|
|
118
120
|
/**
|
|
119
121
|
* Attempt to pipe a value through a series of functions
|
|
120
122
|
*
|
|
121
123
|
* @param initial Initial value
|
|
122
124
|
* @returns _Piped_ result
|
|
123
125
|
*/
|
|
124
|
-
export declare function attemptPipe<Initial, First, Second, Third>(initial:
|
|
126
|
+
export declare function attemptPipe<Initial, First, Second, Third>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third): WrapValue<Third>;
|
|
125
127
|
/**
|
|
126
128
|
* Attempt to pipe a value through a series of functions
|
|
127
129
|
*
|
|
128
130
|
* @param initial Initial value
|
|
129
131
|
* @returns _Piped_ result
|
|
130
132
|
*/
|
|
131
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial:
|
|
133
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth): WrapValue<Fourth>;
|
|
132
134
|
/**
|
|
133
135
|
* Attempt to pipe a value through a series of functions
|
|
134
136
|
*
|
|
135
137
|
* @param initial Initial value
|
|
136
138
|
* @returns _Piped_ result
|
|
137
139
|
*/
|
|
138
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial:
|
|
140
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth): WrapValue<Fifth>;
|
|
139
141
|
/**
|
|
140
142
|
* Attempt to pipe a value through a series of functions
|
|
141
143
|
*
|
|
142
144
|
* @param initial Initial value
|
|
143
145
|
* @returns _Piped_ result
|
|
144
146
|
*/
|
|
145
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial:
|
|
147
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth): WrapValue<Sixth>;
|
|
146
148
|
/**
|
|
147
149
|
* Attempt to pipe a value through a series of functions
|
|
148
150
|
*
|
|
149
151
|
* @param initial Initial value
|
|
150
152
|
* @returns _Piped_ result
|
|
151
153
|
*/
|
|
152
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial:
|
|
154
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh): WrapValue<Seventh>;
|
|
153
155
|
/**
|
|
154
156
|
* Attempt to pipe a value through a series of functions
|
|
155
157
|
*
|
|
156
158
|
* @param initial Initial value
|
|
157
159
|
* @returns _Piped_ result
|
|
158
160
|
*/
|
|
159
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial:
|
|
161
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth): WrapValue<Eighth>;
|
|
160
162
|
/**
|
|
161
163
|
* Attempt to pipe a value through a series of functions
|
|
162
164
|
*
|
|
163
165
|
* @param initial Initial value
|
|
164
166
|
* @returns _Piped_ result
|
|
165
167
|
*/
|
|
166
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial:
|
|
168
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth): WrapValue<Ninth>;
|
|
167
169
|
/**
|
|
168
170
|
* Attempt to pipe a value through a series of functions
|
|
169
171
|
*
|
|
170
172
|
* @param initial Initial value
|
|
171
173
|
* @returns _Piped_ result
|
|
172
174
|
*/
|
|
173
|
-
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial:
|
|
175
|
+
export declare function attemptPipe<Initial, First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth>(initial: InitialPipeValue<Initial>, first: (value: UnwrapValue<Initial>) => First, second: (value: UnwrapValue<First>) => Second, third: (value: UnwrapValue<Second>) => Third, fourth: (value: UnwrapValue<Third>) => Fourth, fifth: (value: UnwrapValue<Fourth>) => Fifth, sixth: (value: UnwrapValue<Fifth>) => Sixth, seventh: (value: UnwrapValue<Sixth>) => Seventh, eighth: (value: UnwrapValue<Seventh>) => Eighth, ninth: (value: UnwrapValue<Eighth>) => Ninth, tenth: (value: UnwrapValue<Ninth>) => Tenth): WrapValue<Tenth>;
|
|
174
176
|
/**
|
|
175
177
|
* Attempt to pipe a result through a series of functions
|
|
176
178
|
*
|
|
177
179
|
* @param initial Initial result
|
|
178
180
|
* @returns _Piped_ result
|
|
179
181
|
*/
|
|
180
|
-
export declare function attemptPipe<Initial>(initial:
|
|
182
|
+
export declare function attemptPipe<Initial>(initial: InitialPipeValue<Initial>, first?: (value: UnwrapValue<Initial>) => unknown, ...seconds: Array<(value: unknown) => unknown>): WrapValue<Initial>;
|
|
181
183
|
export declare namespace attemptPipe {
|
|
182
184
|
export var async: typeof attemptAsyncPipe;
|
|
183
185
|
}
|
|
@@ -3,9 +3,11 @@ import { asyncAttempt, attempt } from "../../internal/result/attempt.mjs";
|
|
|
3
3
|
import { asyncPipe, pipe } from "../../internal/function/work.mjs";
|
|
4
4
|
//#region src/result/work/pipe.ts
|
|
5
5
|
async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
6
|
-
return asyncAttempt(() => {
|
|
6
|
+
return asyncAttempt(async () => {
|
|
7
7
|
if (isError(initial)) throw initial.error;
|
|
8
|
-
|
|
8
|
+
let value;
|
|
9
|
+
if (typeof initial === "function") value = initial();
|
|
10
|
+
else value = isOk(initial) ? initial.value : initial;
|
|
9
11
|
if (first == null) return value;
|
|
10
12
|
return asyncPipe(value, ...[first, ...seconds]);
|
|
11
13
|
});
|
|
@@ -13,7 +15,9 @@ async function attemptAsyncPipe(initial, first, ...seconds) {
|
|
|
13
15
|
function attemptPipe(initial, first, ...seconds) {
|
|
14
16
|
return attempt(() => {
|
|
15
17
|
if (isError(initial)) throw initial.error;
|
|
16
|
-
|
|
18
|
+
let value;
|
|
19
|
+
if (typeof initial === "function") value = initial();
|
|
20
|
+
else value = isOk(initial) ? initial.value : initial;
|
|
17
21
|
if (first == null) return value;
|
|
18
22
|
return pipe(value, ...[first, ...seconds]);
|
|
19
23
|
});
|
package/dist/string/fuzzy.mjs
CHANGED
|
@@ -23,7 +23,7 @@ Object.defineProperties(Fuzzy.prototype, {
|
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
function createFuzzyItems(items) {
|
|
26
|
-
return items.
|
|
26
|
+
return items.toSorted((first, second) => first.haystack.localeCompare(second.haystack)).map(({ item }) => item);
|
|
27
27
|
}
|
|
28
28
|
function createFuzzyOptions(input, state) {
|
|
29
29
|
const options = isPlainObject(input) ? input : {};
|
package/dist/string/index.mjs
CHANGED
|
@@ -20,7 +20,7 @@ function dedent(value, ...values) {
|
|
|
20
20
|
}
|
|
21
21
|
if (lengths.length === 0) return actual.trim();
|
|
22
22
|
const minimum = min(lengths);
|
|
23
|
-
const pattern = new RegExp(
|
|
23
|
+
const pattern = new RegExp(String.raw`^\s{0,${minimum}}`);
|
|
24
24
|
let result = "";
|
|
25
25
|
for (let index = 0; index < length; index += 1) {
|
|
26
26
|
const line = lines[index];
|
package/dist/value/clone.mjs
CHANGED
|
@@ -16,7 +16,7 @@ function clone(value, options) {
|
|
|
16
16
|
function cloneAny(value, parameters, depth, options) {
|
|
17
17
|
switch (true) {
|
|
18
18
|
case value === null || CLONE_PRIMITIVES[typeof value]: return value;
|
|
19
|
-
case value instanceof Date: return new Date(value
|
|
19
|
+
case value instanceof Date: return new Date(value);
|
|
20
20
|
case typeof value === "function":
|
|
21
21
|
parameters.options ??= createCloneOptions(options);
|
|
22
22
|
return parameters.options.copyFunctions ? value : void 0;
|
package/dist/value/merge.mjs
CHANGED
|
@@ -43,6 +43,12 @@ function createMergingOptions(input) {
|
|
|
43
43
|
actual.skipNullableInArrays = options.skipNullableInArrays === true;
|
|
44
44
|
return actual;
|
|
45
45
|
}
|
|
46
|
+
function getFullKey(prefix, key, options) {
|
|
47
|
+
let full;
|
|
48
|
+
if (options.replaceableObjects == null) full = void 0;
|
|
49
|
+
else full = prefix == null ? key : `${prefix}.${key}`;
|
|
50
|
+
return full;
|
|
51
|
+
}
|
|
46
52
|
function getReplaceableObjects(value) {
|
|
47
53
|
const items = (Array.isArray(value) ? value : [value]).filter((item) => typeof item === "string" || item instanceof RegExp);
|
|
48
54
|
if (items.length === 0) return;
|
|
@@ -70,6 +76,9 @@ function initializeAssigner(options) {
|
|
|
70
76
|
function initializeMerger(options) {
|
|
71
77
|
return new Merger(createMergingOptions(options));
|
|
72
78
|
}
|
|
79
|
+
function isMergeable(next, previous, options, full) {
|
|
80
|
+
return isArrayOrPlainObject(next) && isArrayOrPlainObject(previous) && !(options.replaceableObjects?.(full) ?? false);
|
|
81
|
+
}
|
|
73
82
|
/**
|
|
74
83
|
* Merge multiple arrays or objects into a single one
|
|
75
84
|
*
|
|
@@ -96,9 +105,9 @@ function mergeObjects(values, options, destination, prefix) {
|
|
|
96
105
|
const key = keys[innerIndex];
|
|
97
106
|
const next = item[key];
|
|
98
107
|
const previous = merged[key];
|
|
99
|
-
if (next
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
108
|
+
if (skipMerge(next, options, isArray)) continue;
|
|
109
|
+
const fullKey = getFullKey(prefix, key, options);
|
|
110
|
+
if (isMergeable(next, previous, options, fullKey)) merged[key] = mergeObjects([previous, next], options, destination == null ? void 0 : merged[key], fullKey);
|
|
102
111
|
else merged[key] = next;
|
|
103
112
|
}
|
|
104
113
|
}
|
|
@@ -110,7 +119,11 @@ function mergeValues(values, options, prefix) {
|
|
|
110
119
|
if (actual.length === 0) return {};
|
|
111
120
|
if (options.assignValues && actual.length === 2 && !Array.isArray(actual[0]) && Object.keys(actual[0]).length === 0) return Object.assign(actual[0], actual[1]);
|
|
112
121
|
if (actual.length > 1) return mergeObjects(actual, options, options.assignValues ? actual[0] : void 0, prefix);
|
|
113
|
-
|
|
122
|
+
if (options.assignValues) return actual[0];
|
|
123
|
+
return Array.isArray(actual[0]) ? actual[0].slice() : { ...actual[0] };
|
|
124
|
+
}
|
|
125
|
+
function skipMerge(next, options, isArray) {
|
|
126
|
+
return next == null && (options.skipNullableAny || isArray && options.skipNullableInArrays);
|
|
114
127
|
}
|
|
115
128
|
assign.initialize = initializeAssigner;
|
|
116
129
|
merge.initialize = initializeMerger;
|