@nlozgachev/pipelined 0.11.0 → 0.13.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/LICENCE +28 -0
- package/README.md +1 -1
- package/{types/src/Types/NonEmptyList.d.ts → dist/NonEmptyList-BlGFjor5.d.mts} +4 -3
- package/dist/NonEmptyList-BlGFjor5.d.ts +30 -0
- package/dist/Task-BB8Wmc1J.d.ts +677 -0
- package/dist/Task-ChKyH0pF.d.mts +677 -0
- package/dist/chunk-DBIC62UV.mjs +6 -0
- package/dist/chunk-QPTGO5AS.mjs +150 -0
- package/dist/composition.d.mts +495 -0
- package/dist/composition.d.ts +495 -0
- package/dist/composition.js +188 -0
- package/dist/composition.mjs +135 -0
- package/dist/core.d.mts +2170 -0
- package/dist/core.d.ts +2170 -0
- package/dist/core.js +698 -0
- package/dist/core.mjs +517 -0
- package/dist/types.d.mts +54 -0
- package/{types/src/Types/Brand.d.ts → dist/types.d.ts} +6 -4
- package/dist/types.js +41 -0
- package/dist/types.mjs +14 -0
- package/dist/utils.d.mts +1285 -0
- package/dist/utils.d.ts +1285 -0
- package/dist/utils.js +722 -0
- package/dist/utils.mjs +553 -0
- package/package.json +63 -69
- package/esm/mod.js +0 -3
- package/esm/package.json +0 -3
- package/esm/src/Composition/compose.js +0 -3
- package/esm/src/Composition/converge.js +0 -3
- package/esm/src/Composition/curry.js +0 -42
- package/esm/src/Composition/flip.js +0 -20
- package/esm/src/Composition/flow.js +0 -8
- package/esm/src/Composition/fn.js +0 -85
- package/esm/src/Composition/index.js +0 -13
- package/esm/src/Composition/juxt.js +0 -3
- package/esm/src/Composition/memoize.js +0 -66
- package/esm/src/Composition/not.js +0 -25
- package/esm/src/Composition/on.js +0 -12
- package/esm/src/Composition/pipe.js +0 -3
- package/esm/src/Composition/tap.js +0 -33
- package/esm/src/Composition/uncurry.js +0 -32
- package/esm/src/Core/Deferred.js +0 -30
- package/esm/src/Core/InternalTypes.js +0 -1
- package/esm/src/Core/Lens.js +0 -98
- package/esm/src/Core/Logged.js +0 -111
- package/esm/src/Core/Option.js +0 -191
- package/esm/src/Core/Optional.js +0 -160
- package/esm/src/Core/Predicate.js +0 -133
- package/esm/src/Core/Reader.js +0 -134
- package/esm/src/Core/Refinement.js +0 -115
- package/esm/src/Core/RemoteData.js +0 -211
- package/esm/src/Core/Result.js +0 -170
- package/esm/src/Core/State.js +0 -181
- package/esm/src/Core/Task.js +0 -223
- package/esm/src/Core/TaskOption.js +0 -106
- package/esm/src/Core/TaskResult.js +0 -127
- package/esm/src/Core/TaskValidation.js +0 -128
- package/esm/src/Core/These.js +0 -245
- package/esm/src/Core/Validation.js +0 -212
- package/esm/src/Core/index.js +0 -17
- package/esm/src/Types/Brand.js +0 -28
- package/esm/src/Types/NonEmptyList.js +0 -14
- package/esm/src/Types/index.js +0 -2
- package/esm/src/Utils/Arr.js +0 -570
- package/esm/src/Utils/Num.js +0 -124
- package/esm/src/Utils/Rec.js +0 -215
- package/esm/src/Utils/Str.js +0 -134
- package/esm/src/Utils/index.js +0 -4
- package/script/mod.js +0 -19
- package/script/package.json +0 -3
- package/script/src/Composition/compose.js +0 -6
- package/script/src/Composition/converge.js +0 -6
- package/script/src/Composition/curry.js +0 -48
- package/script/src/Composition/flip.js +0 -24
- package/script/src/Composition/flow.js +0 -11
- package/script/src/Composition/fn.js +0 -98
- package/script/src/Composition/index.js +0 -29
- package/script/src/Composition/juxt.js +0 -6
- package/script/src/Composition/memoize.js +0 -71
- package/script/src/Composition/not.js +0 -29
- package/script/src/Composition/on.js +0 -16
- package/script/src/Composition/pipe.js +0 -6
- package/script/src/Composition/tap.js +0 -37
- package/script/src/Composition/uncurry.js +0 -38
- package/script/src/Core/Deferred.js +0 -33
- package/script/src/Core/InternalTypes.js +0 -2
- package/script/src/Core/Lens.js +0 -101
- package/script/src/Core/Logged.js +0 -114
- package/script/src/Core/Option.js +0 -194
- package/script/src/Core/Optional.js +0 -163
- package/script/src/Core/Predicate.js +0 -136
- package/script/src/Core/Reader.js +0 -137
- package/script/src/Core/Refinement.js +0 -118
- package/script/src/Core/RemoteData.js +0 -214
- package/script/src/Core/Result.js +0 -173
- package/script/src/Core/State.js +0 -184
- package/script/src/Core/Task.js +0 -226
- package/script/src/Core/TaskOption.js +0 -109
- package/script/src/Core/TaskResult.js +0 -130
- package/script/src/Core/TaskValidation.js +0 -131
- package/script/src/Core/These.js +0 -248
- package/script/src/Core/Validation.js +0 -215
- package/script/src/Core/index.js +0 -33
- package/script/src/Types/Brand.js +0 -31
- package/script/src/Types/NonEmptyList.js +0 -18
- package/script/src/Types/index.js +0 -18
- package/script/src/Utils/Arr.js +0 -573
- package/script/src/Utils/Num.js +0 -127
- package/script/src/Utils/Rec.js +0 -218
- package/script/src/Utils/Str.js +0 -137
- package/script/src/Utils/index.js +0 -20
- package/types/mod.d.ts +0 -4
- package/types/mod.d.ts.map +0 -1
- package/types/src/Composition/compose.d.ts +0 -33
- package/types/src/Composition/compose.d.ts.map +0 -1
- package/types/src/Composition/converge.d.ts +0 -21
- package/types/src/Composition/converge.d.ts.map +0 -1
- package/types/src/Composition/curry.d.ts +0 -43
- package/types/src/Composition/curry.d.ts.map +0 -1
- package/types/src/Composition/flip.d.ts +0 -21
- package/types/src/Composition/flip.d.ts.map +0 -1
- package/types/src/Composition/flow.d.ts +0 -56
- package/types/src/Composition/flow.d.ts.map +0 -1
- package/types/src/Composition/fn.d.ts +0 -76
- package/types/src/Composition/fn.d.ts.map +0 -1
- package/types/src/Composition/index.d.ts +0 -14
- package/types/src/Composition/index.d.ts.map +0 -1
- package/types/src/Composition/juxt.d.ts +0 -18
- package/types/src/Composition/juxt.d.ts.map +0 -1
- package/types/src/Composition/memoize.d.ts +0 -46
- package/types/src/Composition/memoize.d.ts.map +0 -1
- package/types/src/Composition/not.d.ts +0 -26
- package/types/src/Composition/not.d.ts.map +0 -1
- package/types/src/Composition/on.d.ts +0 -13
- package/types/src/Composition/on.d.ts.map +0 -1
- package/types/src/Composition/pipe.d.ts +0 -56
- package/types/src/Composition/pipe.d.ts.map +0 -1
- package/types/src/Composition/tap.d.ts +0 -31
- package/types/src/Composition/tap.d.ts.map +0 -1
- package/types/src/Composition/uncurry.d.ts +0 -54
- package/types/src/Composition/uncurry.d.ts.map +0 -1
- package/types/src/Core/Deferred.d.ts +0 -49
- package/types/src/Core/Deferred.d.ts.map +0 -1
- package/types/src/Core/InternalTypes.d.ts +0 -23
- package/types/src/Core/InternalTypes.d.ts.map +0 -1
- package/types/src/Core/Lens.d.ts +0 -118
- package/types/src/Core/Lens.d.ts.map +0 -1
- package/types/src/Core/Logged.d.ts +0 -126
- package/types/src/Core/Logged.d.ts.map +0 -1
- package/types/src/Core/Option.d.ts +0 -209
- package/types/src/Core/Option.d.ts.map +0 -1
- package/types/src/Core/Optional.d.ts +0 -158
- package/types/src/Core/Optional.d.ts.map +0 -1
- package/types/src/Core/Predicate.d.ts +0 -161
- package/types/src/Core/Predicate.d.ts.map +0 -1
- package/types/src/Core/Reader.d.ts +0 -156
- package/types/src/Core/Reader.d.ts.map +0 -1
- package/types/src/Core/Refinement.d.ts +0 -138
- package/types/src/Core/Refinement.d.ts.map +0 -1
- package/types/src/Core/RemoteData.d.ts +0 -197
- package/types/src/Core/RemoteData.d.ts.map +0 -1
- package/types/src/Core/Result.d.ts +0 -182
- package/types/src/Core/Result.d.ts.map +0 -1
- package/types/src/Core/State.d.ts +0 -192
- package/types/src/Core/State.d.ts.map +0 -1
- package/types/src/Core/Task.d.ts +0 -219
- package/types/src/Core/Task.d.ts.map +0 -1
- package/types/src/Core/TaskOption.d.ts +0 -121
- package/types/src/Core/TaskOption.d.ts.map +0 -1
- package/types/src/Core/TaskResult.d.ts +0 -119
- package/types/src/Core/TaskResult.d.ts.map +0 -1
- package/types/src/Core/TaskValidation.d.ts +0 -144
- package/types/src/Core/TaskValidation.d.ts.map +0 -1
- package/types/src/Core/These.d.ts +0 -225
- package/types/src/Core/These.d.ts.map +0 -1
- package/types/src/Core/Validation.d.ts +0 -203
- package/types/src/Core/Validation.d.ts.map +0 -1
- package/types/src/Core/index.d.ts +0 -18
- package/types/src/Core/index.d.ts.map +0 -1
- package/types/src/Types/Brand.d.ts.map +0 -1
- package/types/src/Types/NonEmptyList.d.ts.map +0 -1
- package/types/src/Types/index.d.ts +0 -3
- package/types/src/Types/index.d.ts.map +0 -1
- package/types/src/Utils/Arr.d.ts +0 -403
- package/types/src/Utils/Arr.d.ts.map +0 -1
- package/types/src/Utils/Num.d.ts +0 -110
- package/types/src/Utils/Num.d.ts.map +0 -1
- package/types/src/Utils/Rec.d.ts +0 -143
- package/types/src/Utils/Rec.d.ts.map +0 -1
- package/types/src/Utils/Str.d.ts +0 -128
- package/types/src/Utils/Str.d.ts.map +0 -1
- package/types/src/Utils/index.d.ts +0 -5
- package/types/src/Utils/index.d.ts.map +0 -1
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { NonEmptyList } from "../Types/NonEmptyList.js";
|
|
2
|
-
import { WithErrors, WithKind, WithValue } from "./InternalTypes.js";
|
|
3
|
-
/**
|
|
4
|
-
* Validation represents a value that is either valid with a success value,
|
|
5
|
-
* or invalid with accumulated errors.
|
|
6
|
-
* Unlike Result, Validation can accumulate multiple errors instead of short-circuiting.
|
|
7
|
-
*
|
|
8
|
-
* Use Validation when you need to collect all errors (e.g., form validation).
|
|
9
|
-
* Use Result when you want to fail fast on the first error.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* const validateName = (name: string): Validation<string, string> =>
|
|
14
|
-
* name.length > 0 ? Validation.valid(name) : Validation.invalid("Name is required");
|
|
15
|
-
*
|
|
16
|
-
* const validateAge = (age: number): Validation<string, number> =>
|
|
17
|
-
* age >= 0 ? Validation.valid(age) : Validation.invalid("Age must be positive");
|
|
18
|
-
*
|
|
19
|
-
* // Accumulates all errors using ap
|
|
20
|
-
* pipe(
|
|
21
|
-
* Validation.valid((name: string) => (age: number) => ({ name, age })),
|
|
22
|
-
* Validation.ap(validateName("")),
|
|
23
|
-
* Validation.ap(validateAge(-1))
|
|
24
|
-
* );
|
|
25
|
-
* // Invalid(["Name is required", "Age must be positive"])
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export type Validation<E, A> = Valid<A> | Invalid<E>;
|
|
29
|
-
export type Valid<A> = WithKind<"Valid"> & WithValue<A>;
|
|
30
|
-
export type Invalid<E> = WithKind<"Invalid"> & WithErrors<E>;
|
|
31
|
-
export declare namespace Validation {
|
|
32
|
-
/**
|
|
33
|
-
* Wraps a value in a valid Validation.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* Validation.valid(42); // Valid(42)
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
const valid: <E, A>(value: A) => Validation<E, A>;
|
|
41
|
-
/**
|
|
42
|
-
* Creates an invalid Validation from a single error.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* Validation.invalid("Invalid input");
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
const invalid: <E>(error: E) => Invalid<E>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates an invalid Validation from multiple errors.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* Validation.invalidAll(["Invalid input"]);
|
|
56
|
-
* ```
|
|
57
|
-
*/
|
|
58
|
-
const invalidAll: <E>(errors: NonEmptyList<E>) => Invalid<E>;
|
|
59
|
-
/**
|
|
60
|
-
* Type guard that checks if a Validation is valid.
|
|
61
|
-
*/
|
|
62
|
-
const isValid: <E, A>(data: Validation<E, A>) => data is Valid<A>;
|
|
63
|
-
/**
|
|
64
|
-
* Type guard that checks if a Validation is invalid.
|
|
65
|
-
*/
|
|
66
|
-
const isInvalid: <E, A>(data: Validation<E, A>) => data is Invalid<E>;
|
|
67
|
-
/**
|
|
68
|
-
* Transforms the success value inside a Validation.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* pipe(Validation.valid(5), Validation.map(n => n * 2)); // Valid(10)
|
|
73
|
-
* pipe(Validation.invalid("oops"), Validation.map(n => n * 2)); // Invalid(["oops"])
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
const map: <A, B>(f: (a: A) => B) => <E>(data: Validation<E, A>) => Validation<E, B>;
|
|
77
|
-
/**
|
|
78
|
-
* Applies a function wrapped in a Validation to a value wrapped in a Validation.
|
|
79
|
-
* Accumulates errors from both sides.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* const add = (a: number) => (b: number) => a + b;
|
|
84
|
-
* pipe(
|
|
85
|
-
* Validation.valid(add),
|
|
86
|
-
* Validation.ap(Validation.valid(5)),
|
|
87
|
-
* Validation.ap(Validation.valid(3))
|
|
88
|
-
* ); // Valid(8)
|
|
89
|
-
*
|
|
90
|
-
* pipe(
|
|
91
|
-
* Validation.valid(add),
|
|
92
|
-
* Validation.ap(Validation.invalid<string, number>("bad a")),
|
|
93
|
-
* Validation.ap(Validation.invalid<string, number>("bad b"))
|
|
94
|
-
* ); // Invalid(["bad a", "bad b"])
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
|
-
const ap: <E, A>(arg: Validation<E, A>) => <B>(data: Validation<E, (a: A) => B>) => Validation<E, B>;
|
|
98
|
-
/**
|
|
99
|
-
* Extracts the value from a Validation by providing handlers for both cases.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* ```ts
|
|
103
|
-
* pipe(
|
|
104
|
-
* Validation.valid(42),
|
|
105
|
-
* Validation.fold(
|
|
106
|
-
* errors => `Errors: ${errors.join(", ")}`,
|
|
107
|
-
* value => `Value: ${value}`
|
|
108
|
-
* )
|
|
109
|
-
* );
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
const fold: <E, A, B>(onInvalid: (errors: NonEmptyList<E>) => B, onValid: (a: A) => B) => (data: Validation<E, A>) => B;
|
|
113
|
-
/**
|
|
114
|
-
* Pattern matches on a Validation, returning the result of the matching case.
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* pipe(
|
|
119
|
-
* validation,
|
|
120
|
-
* Validation.match({
|
|
121
|
-
* valid: value => `Got ${value}`,
|
|
122
|
-
* invalid: errors => `Failed: ${errors.join(", ")}`
|
|
123
|
-
* })
|
|
124
|
-
* );
|
|
125
|
-
* ```
|
|
126
|
-
*/
|
|
127
|
-
const match: <E, A, B>(cases: {
|
|
128
|
-
valid: (a: A) => B;
|
|
129
|
-
invalid: (errors: NonEmptyList<E>) => B;
|
|
130
|
-
}) => (data: Validation<E, A>) => B;
|
|
131
|
-
/**
|
|
132
|
-
* Returns the success value or a default value if the Validation is invalid.
|
|
133
|
-
* The default can be a different type, widening the result to `A | B`.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```ts
|
|
137
|
-
* pipe(Validation.valid(5), Validation.getOrElse(() => 0)); // 5
|
|
138
|
-
* pipe(Validation.invalid("oops"), Validation.getOrElse(() => 0)); // 0
|
|
139
|
-
* pipe(Validation.invalid("oops"), Validation.getOrElse(() => null)); // null — typed as number | null
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
const getOrElse: <E, A, B>(defaultValue: () => B) => (data: Validation<E, A>) => A | B;
|
|
143
|
-
/**
|
|
144
|
-
* Executes a side effect on the success value without changing the Validation.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```ts
|
|
148
|
-
* pipe(
|
|
149
|
-
* Validation.valid(5),
|
|
150
|
-
* Validation.tap(n => console.log("Value:", n)),
|
|
151
|
-
* Validation.map(n => n * 2)
|
|
152
|
-
* );
|
|
153
|
-
* ```
|
|
154
|
-
*/
|
|
155
|
-
const tap: <E, A>(f: (a: A) => void) => (data: Validation<E, A>) => Validation<E, A>;
|
|
156
|
-
/**
|
|
157
|
-
* Recovers from an Invalid state by providing a fallback Validation.
|
|
158
|
-
* The fallback receives the accumulated error list so callers can inspect which errors occurred.
|
|
159
|
-
* The fallback can produce a different success type, widening the result to `Validation<E, A | B>`.
|
|
160
|
-
*/
|
|
161
|
-
const recover: <E, A, B>(fallback: (errors: NonEmptyList<E>) => Validation<E, B>) => (data: Validation<E, A>) => Validation<E, A | B>;
|
|
162
|
-
/**
|
|
163
|
-
* Recovers from an Invalid state unless the errors contain any of the blocked errors.
|
|
164
|
-
* The fallback can produce a different success type, widening the result to `Validation<E, A | B>`.
|
|
165
|
-
*/
|
|
166
|
-
const recoverUnless: <E, A, B>(blockedErrors: readonly E[], fallback: () => Validation<E, B>) => (data: Validation<E, A>) => Validation<E, A | B>;
|
|
167
|
-
/**
|
|
168
|
-
* Combines two independent Validation instances into a tuple.
|
|
169
|
-
* If both are Valid, returns Valid with both values as a tuple.
|
|
170
|
-
* If either is Invalid, accumulates errors from both sides.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* Validation.product(
|
|
175
|
-
* Validation.valid("alice"),
|
|
176
|
-
* Validation.valid(30)
|
|
177
|
-
* ); // Valid(["alice", 30])
|
|
178
|
-
*
|
|
179
|
-
* Validation.product(
|
|
180
|
-
* Validation.invalid("Name required"),
|
|
181
|
-
* Validation.invalid("Age must be >= 0")
|
|
182
|
-
* ); // Invalid(["Name required", "Age must be >= 0"])
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
const product: <E, A, B>(first: Validation<E, A>, second: Validation<E, B>) => Validation<E, readonly [A, B]>;
|
|
186
|
-
/**
|
|
187
|
-
* Combines a non-empty list of Validation instances, accumulating all errors.
|
|
188
|
-
* If all are Valid, returns Valid with all values collected into an array.
|
|
189
|
-
* If any are Invalid, returns Invalid with all accumulated errors.
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* Validation.productAll([
|
|
194
|
-
* validateName(name),
|
|
195
|
-
* validateEmail(email),
|
|
196
|
-
* validateAge(age)
|
|
197
|
-
* ]);
|
|
198
|
-
* // Valid([name, email, age]) or Invalid([...all errors])
|
|
199
|
-
* ```
|
|
200
|
-
*/
|
|
201
|
-
const productAll: <E, A>(data: NonEmptyList<Validation<E, A>>) => Validation<E, readonly A[]>;
|
|
202
|
-
}
|
|
203
|
-
//# sourceMappingURL=Validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Validation.d.ts","sourceRoot":"","sources":["../../../src/src/Core/Validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AACxD,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAE7D,yBAAiB,UAAU,CAAC;IAC3B;;;;;;;OAOG;IACI,MAAM,KAAK,GAAI,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,KAAG,UAAU,CAAC,CAAC,EAAE,CAAC,CAGpD,CAAC;IAEH;;;;;;;OAOG;IACI,MAAM,OAAO,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,OAAO,CAAC,CAAC,CAG7C,CAAC;IAEH;;;;;;;OAOG;IACI,MAAM,UAAU,GAAI,CAAC,EAAE,QAAQ,YAAY,CAAC,CAAC,CAAC,KAAG,O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AAU,CAAC,CAAC,EAAE,CAAC,CAAC,KACtB,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAO/B,CAAC;IAEF;;;;;;;;;;;;;;OAcG;IACI,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAC9B,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAClC,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC,EAAE,CAQ5B,CAAC;CACF"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from "./Logged.js";
|
|
2
|
-
export * from "./Deferred.js";
|
|
3
|
-
export * from "./Lens.js";
|
|
4
|
-
export * from "./Option.js";
|
|
5
|
-
export * from "./Reader.js";
|
|
6
|
-
export * from "./Optional.js";
|
|
7
|
-
export * from "./Predicate.js";
|
|
8
|
-
export * from "./Refinement.js";
|
|
9
|
-
export * from "./RemoteData.js";
|
|
10
|
-
export * from "./State.js";
|
|
11
|
-
export * from "./Result.js";
|
|
12
|
-
export * from "./Task.js";
|
|
13
|
-
export * from "./TaskOption.js";
|
|
14
|
-
export * from "./TaskResult.js";
|
|
15
|
-
export * from "./TaskValidation.js";
|
|
16
|
-
export * from "./These.js";
|
|
17
|
-
export * from "./Validation.js";
|
|
18
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Core/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Brand.d.ts","sourceRoot":"","sources":["../../../src/src/Types/Brand.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,MAAM,EAAE,OAAO,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;CAAE,CAAC;AAEtE,yBAAiB,KAAK,CAAC;IACtB;;;;;;;;;;;;OAYG;IACI,MAAM,IAAI,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,QAAQ,OAAO,CAAC,KAAG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAyB,CAAC;IAE/F;;;;;;;;;OASG;IACI,MAAM,MAAM,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAG,CAAiB,CAAC;CACrF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NonEmptyList.d.ts","sourceRoot":"","sources":["../../../src/src/Types/NonEmptyList.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAEnD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,EAC/B,MAAM,SAAS,CAAC,EAAE,KAChB,IAAI,IAAI,YAAY,CAAC,CAAC,CAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/Types/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC"}
|
package/types/src/Utils/Arr.d.ts
DELETED
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
import { Option } from "../Core/Option.js";
|
|
2
|
-
import { Result } from "../Core/Result.js";
|
|
3
|
-
import { Task } from "../Core/Task.js";
|
|
4
|
-
import { NonEmptyList } from "../Types/NonEmptyList.js";
|
|
5
|
-
/**
|
|
6
|
-
* Functional array utilities that compose well with pipe.
|
|
7
|
-
* All functions are data-last and curried where applicable.
|
|
8
|
-
* Safe access functions return Option instead of throwing or returning undefined.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* pipe(
|
|
13
|
-
* [1, 2, 3, 4, 5],
|
|
14
|
-
* Arr.filter(n => n > 2),
|
|
15
|
-
* Arr.map(n => n * 10),
|
|
16
|
-
* Arr.head
|
|
17
|
-
* ); // Some(30)
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare namespace Arr {
|
|
21
|
-
/**
|
|
22
|
-
* Returns the first element of an array, or None if the array is empty.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* Arr.head([1, 2, 3]); // Some(1)
|
|
27
|
-
* Arr.head([]); // None
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
const head: <A>(data: readonly A[]) => Option<A>;
|
|
31
|
-
/**
|
|
32
|
-
* Returns the last element of an array, or None if the array is empty.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* Arr.last([1, 2, 3]); // Some(3)
|
|
37
|
-
* Arr.last([]); // None
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
const last: <A>(data: readonly A[]) => Option<A>;
|
|
41
|
-
/**
|
|
42
|
-
* Returns all elements except the first, or None if the array is empty.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* Arr.tail([1, 2, 3]); // Some([2, 3])
|
|
47
|
-
* Arr.tail([]); // None
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
const tail: <A>(data: readonly A[]) => Option<readonly A[]>;
|
|
51
|
-
/**
|
|
52
|
-
* Returns all elements except the last, or None if the array is empty.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```ts
|
|
56
|
-
* Arr.init([1, 2, 3]); // Some([1, 2])
|
|
57
|
-
* Arr.init([]); // None
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
const init: <A>(data: readonly A[]) => Option<readonly A[]>;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the first element matching the predicate, or None.
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* ```ts
|
|
66
|
-
* pipe([1, 2, 3, 4], Arr.findFirst(n => n > 2)); // Some(3)
|
|
67
|
-
* ```
|
|
68
|
-
*/
|
|
69
|
-
const findFirst: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Option<A>;
|
|
70
|
-
/**
|
|
71
|
-
* Returns the last element matching the predicate, or None.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* pipe([1, 2, 3, 4], Arr.findLast(n => n > 2)); // Some(4)
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
78
|
-
const findLast: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Option<A>;
|
|
79
|
-
/**
|
|
80
|
-
* Returns the index of the first element matching the predicate, or None.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```ts
|
|
84
|
-
* pipe([1, 2, 3, 4], Arr.findIndex(n => n > 2)); // Some(2)
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
const findIndex: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => Option<number>;
|
|
88
|
-
/**
|
|
89
|
-
* Transforms each element of an array.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* pipe([1, 2, 3], Arr.map(n => n * 2)); // [2, 4, 6]
|
|
94
|
-
* ```
|
|
95
|
-
*/
|
|
96
|
-
const map: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
97
|
-
/**
|
|
98
|
-
* Filters elements that satisfy the predicate.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* pipe([1, 2, 3, 4], Arr.filter(n => n % 2 === 0)); // [2, 4]
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
const filter: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
|
|
106
|
-
/**
|
|
107
|
-
* Splits an array into two groups based on a predicate.
|
|
108
|
-
* First group contains elements that satisfy the predicate,
|
|
109
|
-
* second group contains the rest.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* ```ts
|
|
113
|
-
* pipe([1, 2, 3, 4], Arr.partition(n => n % 2 === 0)); // [[2, 4], [1, 3]]
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
const partition: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly [readonly A[], readonly A[]];
|
|
117
|
-
/**
|
|
118
|
-
* Groups elements by a key function.
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```ts
|
|
122
|
-
* pipe(
|
|
123
|
-
* ["apple", "avocado", "banana"],
|
|
124
|
-
* Arr.groupBy(s => s[0])
|
|
125
|
-
* ); // { a: ["apple", "avocado"], b: ["banana"] }
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
const groupBy: <A>(f: (a: A) => string) => (data: readonly A[]) => Record<string, NonEmptyList<A>>;
|
|
129
|
-
/**
|
|
130
|
-
* Removes duplicate elements using strict equality.
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* ```ts
|
|
134
|
-
* Arr.uniq([1, 2, 2, 3, 1]); // [1, 2, 3]
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
const uniq: <A>(data: readonly A[]) => readonly A[];
|
|
138
|
-
/**
|
|
139
|
-
* Removes duplicate elements by comparing the result of a key function.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* pipe(
|
|
144
|
-
* [{id: 1, name: "a"}, {id: 1, name: "b"}, {id: 2, name: "c"}],
|
|
145
|
-
* Arr.uniqBy(x => x.id)
|
|
146
|
-
* ); // [{id: 1, name: "a"}, {id: 2, name: "c"}]
|
|
147
|
-
* ```
|
|
148
|
-
*/
|
|
149
|
-
const uniqBy: <A, B>(f: (a: A) => B) => (data: readonly A[]) => readonly A[];
|
|
150
|
-
/**
|
|
151
|
-
* Sorts an array using a comparison function. Returns a new array.
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```ts
|
|
155
|
-
* pipe([3, 1, 2], Arr.sortBy((a, b) => a - b)); // [1, 2, 3]
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
const sortBy: <A>(compare: (a: A, b: A) => number) => (data: readonly A[]) => readonly A[];
|
|
159
|
-
/**
|
|
160
|
-
* Pairs up elements from two arrays. Stops at the shorter array.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```ts
|
|
164
|
-
* pipe([1, 2, 3], Arr.zip(["a", "b"])); // [[1, "a"], [2, "b"]]
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
const zip: <B>(other: readonly B[]) => <A>(data: readonly A[]) => readonly (readonly [A, B])[];
|
|
168
|
-
/**
|
|
169
|
-
* Combines elements from two arrays using a function. Stops at the shorter array.
|
|
170
|
-
*
|
|
171
|
-
* @example
|
|
172
|
-
* ```ts
|
|
173
|
-
* pipe([1, 2], Arr.zipWith((a, b) => a + b, ["a", "b"])); // ["1a", "2b"]
|
|
174
|
-
* ```
|
|
175
|
-
*/
|
|
176
|
-
const zipWith: <A, B, C>(f: (a: A, b: B) => C) => (other: readonly B[]) => (data: readonly A[]) => readonly C[];
|
|
177
|
-
/**
|
|
178
|
-
* Inserts a separator between every element.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```ts
|
|
182
|
-
* pipe([1, 2, 3], Arr.intersperse(0)); // [1, 0, 2, 0, 3]
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
const intersperse: <A>(sep: A) => (data: readonly A[]) => readonly A[];
|
|
186
|
-
/**
|
|
187
|
-
* Splits an array into chunks of the given size.
|
|
188
|
-
*
|
|
189
|
-
* @example
|
|
190
|
-
* ```ts
|
|
191
|
-
* pipe([1, 2, 3, 4, 5], Arr.chunksOf(2)); // [[1, 2], [3, 4], [5]]
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
const chunksOf: (n: number) => <A>(data: readonly A[]) => readonly (readonly A[])[];
|
|
195
|
-
/**
|
|
196
|
-
* Flattens a nested array by one level.
|
|
197
|
-
*
|
|
198
|
-
* @example
|
|
199
|
-
* ```ts
|
|
200
|
-
* Arr.flatten([[1, 2], [3], [4, 5]]); // [1, 2, 3, 4, 5]
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
const flatten: <A>(data: readonly (readonly A[])[]) => readonly A[];
|
|
204
|
-
/**
|
|
205
|
-
* Maps each element to an array and flattens the result.
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```ts
|
|
209
|
-
* pipe([1, 2, 3], Arr.flatMap(n => [n, n * 10])); // [1, 10, 2, 20, 3, 30]
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
const flatMap: <A, B>(f: (a: A) => readonly B[]) => (data: readonly A[]) => readonly B[];
|
|
213
|
-
/**
|
|
214
|
-
* Reduces an array from the left.
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```ts
|
|
218
|
-
* pipe([1, 2, 3], Arr.reduce(0, (acc, n) => acc + n)); // 6
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
const reduce: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => B;
|
|
222
|
-
/**
|
|
223
|
-
* Maps each element to an Option and collects the results.
|
|
224
|
-
* Returns None if any mapping returns None.
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
* ```ts
|
|
228
|
-
* const parseNum = (s: string): Option<number> => {
|
|
229
|
-
* const n = Number(s);
|
|
230
|
-
* return isNaN(n) ? Option.none() : Option.some(n);
|
|
231
|
-
* };
|
|
232
|
-
*
|
|
233
|
-
* pipe(["1", "2", "3"], Arr.traverse(parseNum)); // Some([1, 2, 3])
|
|
234
|
-
* pipe(["1", "x", "3"], Arr.traverse(parseNum)); // None
|
|
235
|
-
* ```
|
|
236
|
-
*/
|
|
237
|
-
const traverse: <A, B>(f: (a: A) => Option<B>) => (data: readonly A[]) => Option<readonly B[]>;
|
|
238
|
-
/**
|
|
239
|
-
* Maps each element to a Result and collects the results.
|
|
240
|
-
* Returns the first Err if any mapping fails.
|
|
241
|
-
*
|
|
242
|
-
* @example
|
|
243
|
-
* ```ts
|
|
244
|
-
* pipe(
|
|
245
|
-
* [1, 2, 3],
|
|
246
|
-
* Arr.traverseResult(n => n > 0 ? Result.ok(n) : Result.err("negative"))
|
|
247
|
-
* ); // Ok([1, 2, 3])
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
const traverseResult: <E, A, B>(f: (a: A) => Result<E, B>) => (data: readonly A[]) => Result<E, readonly B[]>;
|
|
251
|
-
/**
|
|
252
|
-
* Maps each element to a Task and runs all in parallel.
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* pipe(
|
|
257
|
-
* [1, 2, 3],
|
|
258
|
-
* Arr.traverseTask(n => Task.resolve(n * 2))
|
|
259
|
-
* )(); // Promise<[2, 4, 6]>
|
|
260
|
-
* ```
|
|
261
|
-
*/
|
|
262
|
-
const traverseTask: <A, B>(f: (a: A) => Task<B>) => (data: readonly A[]) => Task<readonly B[]>;
|
|
263
|
-
/**
|
|
264
|
-
* Collects an array of Options into an Option of array.
|
|
265
|
-
* Returns None if any element is None.
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* ```ts
|
|
269
|
-
* Arr.sequence([Option.some(1), Option.some(2)]); // Some([1, 2])
|
|
270
|
-
* Arr.sequence([Option.some(1), Option.none()]); // None
|
|
271
|
-
* ```
|
|
272
|
-
*/
|
|
273
|
-
const sequence: <A>(data: readonly Option<A>[]) => Option<readonly A[]>;
|
|
274
|
-
/**
|
|
275
|
-
* Collects an array of Results into a Result of array.
|
|
276
|
-
* Returns the first Err if any element is Err.
|
|
277
|
-
*/
|
|
278
|
-
const sequenceResult: <E, A>(data: readonly Result<E, A>[]) => Result<E, readonly A[]>;
|
|
279
|
-
/**
|
|
280
|
-
* Collects an array of Tasks into a Task of array. Runs in parallel.
|
|
281
|
-
*/
|
|
282
|
-
const sequenceTask: <A>(data: readonly Task<A>[]) => Task<readonly A[]>;
|
|
283
|
-
/**
|
|
284
|
-
* Maps each element to a TaskResult and runs them sequentially.
|
|
285
|
-
* Returns the first Err encountered, or Ok of all results if all succeed.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```ts
|
|
289
|
-
* const validate = (n: number): TaskResult<string, number> =>
|
|
290
|
-
* n > 0 ? TaskResult.ok(n) : TaskResult.err("non-positive");
|
|
291
|
-
*
|
|
292
|
-
* pipe(
|
|
293
|
-
* [1, 2, 3],
|
|
294
|
-
* Arr.traverseTaskResult(validate)
|
|
295
|
-
* )(); // Deferred<Ok([1, 2, 3])>
|
|
296
|
-
*
|
|
297
|
-
* pipe(
|
|
298
|
-
* [1, -1, 3],
|
|
299
|
-
* Arr.traverseTaskResult(validate)
|
|
300
|
-
* )(); // Deferred<Err("non-positive")>
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
const traverseTaskResult: <E, A, B>(f: (a: A) => Task<Result<E, B>>) => (data: readonly A[]) => Task<Result<E, readonly B[]>>;
|
|
304
|
-
/**
|
|
305
|
-
* Collects an array of TaskResults into a TaskResult of array.
|
|
306
|
-
* Returns the first Err if any element is Err, runs sequentially.
|
|
307
|
-
*/
|
|
308
|
-
const sequenceTaskResult: <E, A>(data: readonly Task<Result<E, A>>[]) => Task<Result<E, readonly A[]>>;
|
|
309
|
-
/**
|
|
310
|
-
* Returns true if the array is non-empty (type guard).
|
|
311
|
-
*/
|
|
312
|
-
const isNonEmpty: <A>(data: readonly A[]) => data is NonEmptyList<A>;
|
|
313
|
-
/**
|
|
314
|
-
* Returns the length of an array.
|
|
315
|
-
*/
|
|
316
|
-
const size: <A>(data: readonly A[]) => number;
|
|
317
|
-
/**
|
|
318
|
-
* Returns true if any element satisfies the predicate.
|
|
319
|
-
*
|
|
320
|
-
* @example
|
|
321
|
-
* ```ts
|
|
322
|
-
* pipe([1, 2, 3], Arr.some(n => n > 2)); // true
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
const some: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
|
|
326
|
-
/**
|
|
327
|
-
* Returns true if all elements satisfy the predicate.
|
|
328
|
-
*
|
|
329
|
-
* @example
|
|
330
|
-
* ```ts
|
|
331
|
-
* pipe([1, 2, 3], Arr.every(n => n > 0)); // true
|
|
332
|
-
* ```
|
|
333
|
-
*/
|
|
334
|
-
const every: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => boolean;
|
|
335
|
-
/**
|
|
336
|
-
* Reverses an array. Returns a new array.
|
|
337
|
-
*
|
|
338
|
-
* @example
|
|
339
|
-
* ```ts
|
|
340
|
-
* Arr.reverse([1, 2, 3]); // [3, 2, 1]
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
const reverse: <A>(data: readonly A[]) => readonly A[];
|
|
344
|
-
/**
|
|
345
|
-
* Takes the first n elements from an array.
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* ```ts
|
|
349
|
-
* pipe([1, 2, 3, 4], Arr.take(2)); // [1, 2]
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
const take: (n: number) => <A>(data: readonly A[]) => readonly A[];
|
|
353
|
-
/**
|
|
354
|
-
* Drops the first n elements from an array.
|
|
355
|
-
*
|
|
356
|
-
* @example
|
|
357
|
-
* ```ts
|
|
358
|
-
* pipe([1, 2, 3, 4], Arr.drop(2)); // [3, 4]
|
|
359
|
-
* ```
|
|
360
|
-
*/
|
|
361
|
-
const drop: (n: number) => <A>(data: readonly A[]) => readonly A[];
|
|
362
|
-
/**
|
|
363
|
-
* Takes elements from the start while the predicate holds.
|
|
364
|
-
*
|
|
365
|
-
* @example
|
|
366
|
-
* ```ts
|
|
367
|
-
* pipe([1, 2, 3, 1], Arr.takeWhile(n => n < 3)); // [1, 2]
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
const takeWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
|
|
371
|
-
/**
|
|
372
|
-
* Drops elements from the start while the predicate holds.
|
|
373
|
-
*
|
|
374
|
-
* @example
|
|
375
|
-
* ```ts
|
|
376
|
-
* pipe([1, 2, 3, 1], Arr.dropWhile(n => n < 3)); // [3, 1]
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
const dropWhile: <A>(predicate: (a: A) => boolean) => (data: readonly A[]) => readonly A[];
|
|
380
|
-
/**
|
|
381
|
-
* Like `reduce`, but returns every intermediate accumulator as an array.
|
|
382
|
-
* The initial value is not included — the output has the same length as the input.
|
|
383
|
-
*
|
|
384
|
-
* @example
|
|
385
|
-
* ```ts
|
|
386
|
-
* pipe([1, 2, 3], Arr.scan(0, (acc, n) => acc + n)); // [1, 3, 6]
|
|
387
|
-
* ```
|
|
388
|
-
*/
|
|
389
|
-
const scan: <A, B>(initial: B, f: (acc: B, a: A) => B) => (data: readonly A[]) => readonly B[];
|
|
390
|
-
/**
|
|
391
|
-
* Splits an array at an index into a `[before, after]` tuple.
|
|
392
|
-
* Negative indices clamp to 0; indices beyond the array length clamp to the end.
|
|
393
|
-
*
|
|
394
|
-
* @example
|
|
395
|
-
* ```ts
|
|
396
|
-
* pipe([1, 2, 3, 4], Arr.splitAt(2)); // [[1, 2], [3, 4]]
|
|
397
|
-
* pipe([1, 2, 3], Arr.splitAt(0)); // [[], [1, 2, 3]]
|
|
398
|
-
* pipe([1, 2, 3], Arr.splitAt(10)); // [[1, 2, 3], []]
|
|
399
|
-
* ```
|
|
400
|
-
*/
|
|
401
|
-
const splitAt: (index: number) => <A>(data: readonly A[]) => readonly [readonly A[], readonly A[]];
|
|
402
|
-
}
|
|
403
|
-
//# sourceMappingURL=Arr.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Arr.d.ts","sourceRoot":"","sources":["../../../src/src/Utils/Arr.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAkB,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AACH,yBAAiB,GAAG,CAAC;IAGpB;;;;;;;;OAQG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAG,MAAM,CAAC,CAAC,CAA2D,CAAC;IAEjH;;;;;;;;OAQG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,MAAM,SAAS,CAAC,EAAE,KAAG,MAAM,CAAC,CAAC,CACgB,CAAC;IAEtE;;;;;;;;OAQG;IACI,MAAM,IAAI,GAAI,CAAC,EAAE,MAAM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