functype 0.8.67 → 0.8.69

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.
Files changed (48) hide show
  1. package/README.md +136 -6
  2. package/dist/Either-BfXNbTHo.d.ts +533 -0
  3. package/dist/Map-vivbm5n0.d.ts +65 -0
  4. package/dist/{Tuple-DfdXAbL_.d.ts → Valuable-CtuVEKTZ.d.ts} +17 -10
  5. package/dist/chunk-5DWCHDSA.mjs +39 -0
  6. package/dist/chunk-5DWCHDSA.mjs.map +1 -0
  7. package/dist/chunk-7PQA3W7W.mjs +2 -0
  8. package/dist/chunk-7PQA3W7W.mjs.map +1 -0
  9. package/dist/either/index.d.ts +2 -3
  10. package/dist/either/index.mjs +1 -1
  11. package/dist/fpromise/index.d.ts +373 -3
  12. package/dist/fpromise/index.mjs +1 -1
  13. package/dist/index.d.ts +533 -2
  14. package/dist/index.mjs +1 -1
  15. package/dist/list/index.d.ts +2 -3
  16. package/dist/list/index.mjs +1 -1
  17. package/dist/map/index.d.ts +4 -3
  18. package/dist/map/index.mjs +1 -1
  19. package/dist/option/index.d.ts +2 -987
  20. package/dist/option/index.mjs +1 -1
  21. package/dist/set/index.d.ts +2 -3
  22. package/dist/set/index.mjs +1 -1
  23. package/dist/try/index.d.ts +59 -3
  24. package/dist/try/index.mjs +1 -1
  25. package/dist/tuple/index.d.ts +12 -1
  26. package/dist/tuple/index.mjs +1 -1
  27. package/package.json +17 -16
  28. package/readme/BUNDLE_OPTIMIZATION.md +74 -0
  29. package/readme/FPromise-Assessment.md +43 -0
  30. package/readme/HKT.md +110 -0
  31. package/readme/ROADMAP.md +113 -0
  32. package/readme/TASK-IMPLEMENTATION.md +290 -0
  33. package/readme/TASK-TODO.md +40 -0
  34. package/readme/TASK-UPDATES.md +64 -0
  35. package/readme/TUPLE-EXAMPLES.md +79 -0
  36. package/readme/TaskMigration.md +129 -0
  37. package/readme/ai-guide.md +406 -0
  38. package/readme/examples.md +2093 -0
  39. package/readme/quick-reference.md +514 -0
  40. package/readme/task-cancellation-progress.md +258 -0
  41. package/readme/task-error-handling.md +128 -0
  42. package/readme/task-quick-reference.md +157 -0
  43. package/readme/tasks.md +205 -0
  44. package/readme/type-index.md +238 -0
  45. package/dist/chunk-NTL4HYMA.mjs +0 -18
  46. package/dist/chunk-NTL4HYMA.mjs.map +0 -1
  47. package/dist/chunk-PXFJPCM7.mjs +0 -2
  48. package/dist/chunk-PXFJPCM7.mjs.map +0 -1
@@ -0,0 +1,533 @@
1
+ import { a as Type, F as Functor, T as Typeable, V as Valuable, b as AsyncFunctor, E as ExtractTag } from './Valuable-CtuVEKTZ.js';
2
+
3
+ /**
4
+ * Foldable type class represents data structures that can be folded to a summary value.
5
+ *
6
+ * @typeParam A - The type of elements in the data structure
7
+ */
8
+ type Foldable<A> = {
9
+ /**
10
+ * Pattern matches over the structure, applying specific handlers for each variant
11
+ * @param onEmpty - Function to apply if the structure is empty or has no value
12
+ * @param onValue - Function to apply if the structure has a value
13
+ * @returns The result of applying the appropriate function
14
+ */
15
+ fold<B>(onEmpty: () => B, onValue: (value: A) => B): B;
16
+ /**
17
+ * Left-associative fold using the provided zero value and operation
18
+ * @param z - Zero/identity value
19
+ * @returns A function that takes an operation to apply
20
+ */
21
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
22
+ /**
23
+ * Right-associative fold using the provided zero value and operation
24
+ * @param z - Zero/identity value
25
+ * @returns A function that takes an operation to apply
26
+ */
27
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
28
+ };
29
+
30
+ /**
31
+ * Pattern matching interface for functional data types.
32
+ *
33
+ * @typeParam A - The type of elements in the data structure
34
+ * @typeParam Tags - The type of tags used for pattern matching
35
+ */
36
+ type Matchable<A, Tags extends string = string> = {
37
+ /**
38
+ * Pattern matches against this data structure, applying handlers for each variant based on tag.
39
+ * Similar to fold but with stronger type safety for tag-based variants.
40
+ *
41
+ * The return type is inferred from the pattern handlers when not explicitly specified.
42
+ *
43
+ * @param patterns - An object containing handler functions for each variant
44
+ * @returns The result of applying the matching handler function
45
+ */
46
+ match<R>(patterns: Record<Tags, (value: A) => R>): R;
47
+ };
48
+ /**
49
+ * Utility functions for working with Matchable data structures
50
+ */
51
+ declare const MatchableUtils: {
52
+ /**
53
+ * Helper function to create a default case for pattern matching
54
+ *
55
+ * @param handler - The default handler function to apply
56
+ * @returns A function that always applies the default handler
57
+ */
58
+ default: <A, R>(handler: (value: A) => R) => (value: A) => R;
59
+ /**
60
+ * Helper function to create a match pattern that guards based on a predicate
61
+ *
62
+ * @param predicate - The predicate function for guarding
63
+ * @param handler - The handler function to apply if the predicate passes
64
+ * @returns A function that applies the handler only if the predicate passes
65
+ */
66
+ when: <A, R>(predicate: (value: A) => boolean, handler: (value: A) => R) => (value: A) => R | undefined;
67
+ };
68
+
69
+ /**
70
+ * Pipe interface for functional data structures
71
+ * @typeParam T - The type of value to pipe
72
+ */
73
+ type Pipe<T extends Type> = {
74
+ /**
75
+ * Pipes the value through the provided function
76
+ * @param f - The function to apply to the value
77
+ * @returns The result of applying the function to the value
78
+ * @typeParam U - The return type of the function
79
+ */
80
+ pipe<U extends Type>(f: (value: T) => U): U;
81
+ };
82
+
83
+ /**
84
+ * Methods for different serialization formats
85
+ */
86
+ type SerializationMethods<T> = {
87
+ toJSON(): string;
88
+ toYAML(): string;
89
+ toBinary(): string;
90
+ };
91
+ type Serializable<T> = {
92
+ serialize(): SerializationMethods<T>;
93
+ };
94
+
95
+ /**
96
+ * Traversable typeclass for data structures that can be traversed through
97
+ */
98
+ type Traversable<A extends Type> = Functor<A> & {
99
+ get size(): number;
100
+ get isEmpty(): boolean;
101
+ contains(value: A): boolean;
102
+ reduce(f: (b: A, a: A) => A): A;
103
+ reduceRight(f: (b: A, a: A) => A): A;
104
+ };
105
+
106
+ /**
107
+ * Creates a Some variant of Option containing a value.
108
+ * @param value - The value to wrap in Some
109
+ * @returns A new Some instance containing the value
110
+ * @typeParam T - The type of the value
111
+ */
112
+ declare const Some: <T extends Type>(value: T) => Option<T>;
113
+ /**
114
+ * Creates a None variant of Option representing absence of a value.
115
+ * @returns A new None instance
116
+ * @typeParam T - The type that would be contained if this was a Some
117
+ */
118
+ declare const None: <T extends Type>() => Option<T>;
119
+ /**
120
+ * Safely wraps a value that might be null or undefined in an Option.
121
+ * Creates Some if the value is defined, None otherwise.
122
+ * @param value - The value to wrap (might be null/undefined)
123
+ * @returns Some(value) if value is defined, None otherwise
124
+ * @typeParam T - The type of the value
125
+ */
126
+ declare const OptionConstructor: <T extends Type>(value: T | null | undefined) => Option<T>;
127
+ /**
128
+ * Option type module
129
+ * @module Option
130
+ * @category Core
131
+ */
132
+ /**
133
+ * The Option type represents a value that may or may not exist.
134
+ * It's used to handle potentially null or undefined values in a type-safe way.
135
+ * @typeParam T - The type of the value contained in the Option
136
+ */
137
+ type Option<T extends Type> = {
138
+ /** Tag identifying if this is a Some or None variant */
139
+ readonly _tag: "Some" | "None";
140
+ /** The contained value (undefined for None) */
141
+ readonly value: T | undefined;
142
+ /** Whether this Option contains no value */
143
+ isEmpty: boolean;
144
+ /**
145
+ * Extracts the value if present
146
+ * @throws Error if the Option is None
147
+ * @returns The contained value
148
+ */
149
+ get(): T;
150
+ /**
151
+ * Returns the contained value or a default value if None
152
+ * @param defaultValue - The value to return if this Option is None
153
+ * @returns The contained value or defaultValue
154
+ */
155
+ getOrElse(defaultValue: T): T;
156
+ /**
157
+ * Returns the contained value or throws a specified error if None
158
+ * @param error - The error to throw if this Option is None
159
+ * @returns The contained value
160
+ * @throws The specified error if the Option is None
161
+ */
162
+ getOrThrow(error: Error): T;
163
+ /**
164
+ * Returns this Option if it contains a value, otherwise returns the alternative
165
+ * @param alternative - The alternative Option to return if this is None
166
+ * @returns This Option or the alternative
167
+ */
168
+ orElse(alternative: Option<T>): Option<T>;
169
+ /**
170
+ * Returns the contained value or null if None
171
+ * @returns The contained value or null
172
+ */
173
+ orNull(): T | null;
174
+ /**
175
+ * Returns the contained value or undefined if None
176
+ * @returns The contained value or undefined
177
+ */
178
+ orUndefined(): T | undefined;
179
+ /**
180
+ * Maps the value inside the Option using the provided function
181
+ * @param f - The mapping function
182
+ * @returns A new Option containing the mapped value, or None if this Option is None
183
+ */
184
+ map<U extends Type>(f: (value: T) => U): Option<U>;
185
+ /**
186
+ * Returns this Option if it contains a value that satisfies the predicate, otherwise returns None
187
+ * @param predicate - The predicate function to test the value
188
+ * @returns This Option or None
189
+ */
190
+ filter(predicate: (value: T) => boolean): Option<T>;
191
+ /**
192
+ * Maps the value using a function that returns an Option
193
+ * @param f - The mapping function returning an Option
194
+ * @returns The result of applying f to the contained value, or None if this Option is None
195
+ */
196
+ flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
197
+ /**
198
+ * Maps the value using an async function that returns an Option
199
+ * @param f - The async mapping function returning an Option
200
+ * @returns Promise of the result of applying f to the contained value, or None if this Option is None
201
+ */
202
+ flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>;
203
+ /**
204
+ * Applies a binary operator to a start value and the contained value
205
+ * @param f - The binary operator
206
+ * @returns The result of the reduction
207
+ */
208
+ reduce<U>(f: (acc: U, value: T) => U): U;
209
+ /**
210
+ * Applies a binary operator to the contained value and a start value
211
+ * @param f - The binary operator
212
+ * @returns The result of the reduction
213
+ */
214
+ reduceRight<U>(f: (acc: U, value: T) => U): U;
215
+ /**
216
+ * Pattern matches over the Option, applying onNone if None and onSome if Some
217
+ * @param onNone - Function to apply if the Option is None
218
+ * @param onSome - Function to apply if the Option has a value
219
+ * @returns The result of applying the appropriate function
220
+ */
221
+ fold<U>(onNone: () => U, onSome: (value: T) => U): U;
222
+ /**
223
+ * Left-associative fold using the provided zero value and operation
224
+ * @param z - Zero/identity value
225
+ * @returns A function that takes an operation to apply
226
+ */
227
+ foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
228
+ /**
229
+ * Right-associative fold using the provided zero value and operation
230
+ * @param z - Zero/identity value
231
+ * @returns A function that takes an operation to apply
232
+ */
233
+ foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
234
+ /**
235
+ * Converts this Option to a List
236
+ * @returns A List containing the value if Some, or empty List if None
237
+ */
238
+ toList(): List<T>;
239
+ /**
240
+ * Checks if this Option contains the specified value
241
+ * @param value - The value to check for
242
+ * @returns true if this Option contains the value, false otherwise
243
+ */
244
+ contains(value: T): boolean;
245
+ /** The number of elements in this Option (0 or 1) */
246
+ size: number;
247
+ /**
248
+ * Converts this Option to an Either
249
+ * @param left - The value to use for Left if this Option is None
250
+ * @returns Either.Right with the contained value if Some, or Either.Left with left if None
251
+ */
252
+ toEither<E>(left: E): Either<E, T>;
253
+ /**
254
+ * Returns a string representation of this Option
255
+ * @returns A string representation
256
+ */
257
+ toString(): string;
258
+ /**
259
+ * Returns a simple object representation of this Option
260
+ * @returns An object with _tag and value properties
261
+ */
262
+ toValue(): {
263
+ _tag: "Some" | "None";
264
+ value: T;
265
+ };
266
+ /**
267
+ * Pattern matches over the Option, applying a handler function based on the variant
268
+ * @param patterns - Object with handler functions for Some and None variants
269
+ * @returns The result of applying the matching handler function
270
+ */
271
+ match<R>(patterns: {
272
+ Some: (value: T) => R;
273
+ None: () => R;
274
+ }): R;
275
+ } & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<"Some" | "None", T> & AsyncFunctor<T> & Serializable<T> & Pipe<T> & Foldable<T> & Matchable<T, "Some" | "None">);
276
+ declare const Option: (<T extends Type>(value: T | null | undefined) => Option<T>) & {
277
+ /**
278
+ * Creates an Option from any value. Alias for Option function.
279
+ * @param value - The value to wrap
280
+ * @returns Some(value) if value is defined, None otherwise
281
+ * @typeParam T - The type of the value
282
+ */
283
+ from: <T>(value: T) => Option<T>;
284
+ /**
285
+ * Returns a None instance. Alias for None function.
286
+ * @returns A None instance
287
+ * @typeParam T - The type that would be contained if this was a Some
288
+ */
289
+ none: <T>() => Option<T>;
290
+ /**
291
+ * Creates an Option from JSON string
292
+ * @param json - The JSON string
293
+ * @returns Option instance
294
+ */
295
+ fromJSON: <T>(json: string) => Option<T>;
296
+ /**
297
+ * Creates an Option from YAML string
298
+ * @param yaml - The YAML string
299
+ * @returns Option instance
300
+ */
301
+ fromYAML: <T>(yaml: string) => Option<T>;
302
+ /**
303
+ * Creates an Option from binary string
304
+ * @param binary - The binary string
305
+ * @returns Option instance
306
+ */
307
+ fromBinary: <T>(binary: string) => Option<T>;
308
+ };
309
+
310
+ type IterableType<A extends Type> = {
311
+ count(p: (x: A) => boolean): number;
312
+ find(p: (a: A) => boolean): Option<A>;
313
+ forEach(f: (a: A) => void): void;
314
+ drop(n: number): IterableType<A>;
315
+ dropRight(n: number): IterableType<A>;
316
+ dropWhile(p: (a: A) => boolean): IterableType<A>;
317
+ exists(p: (a: A) => boolean): boolean;
318
+ filter(p: (a: A) => boolean): IterableType<A>;
319
+ filterNot(p: (a: A) => boolean): IterableType<A>;
320
+ flatten<B>(): IterableType<B>;
321
+ reduce(f: (b: A, a: A) => A): A;
322
+ reduceRight(f: (b: A, a: A) => A): A;
323
+ foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
324
+ foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
325
+ get head(): A | undefined;
326
+ get headOption(): Option<A>;
327
+ get isEmpty(): boolean;
328
+ map<B extends Type>(f: (a: A) => B): IterableType<B>;
329
+ flatMap<B extends Type>(f: (a: A) => IterableType<B>): IterableType<B>;
330
+ get size(): number;
331
+ toArray<B = A>(): readonly B[];
332
+ } & Iterable<A> & Functor<A> & AsyncFunctor<A> & Traversable<A>;
333
+
334
+ type Set<A> = {
335
+ add: (value: A) => Set<A>;
336
+ remove: (value: A) => Set<A>;
337
+ contains: (value: A) => boolean;
338
+ has: (value: A) => boolean;
339
+ map: <B>(f: (a: A) => B) => Set<B>;
340
+ flatMap: <B>(f: (a: A) => IterableType<B>) => Set<B>;
341
+ fold: <U extends Type>(onEmpty: () => U, onValue: (value: A) => U) => U;
342
+ toList: () => List<A>;
343
+ toSet: () => Set<A>;
344
+ toString: () => string;
345
+ } & IterableType<A> & Collection<A> & Typeable<"Set"> & Valuable<"Set", A[]> & Serializable<A[]> & Pipe<A[]> & Foldable<A>;
346
+ declare const Set: (<A>(iterable?: Iterable<A> | IterableType<A>) => Set<A>) & {
347
+ /**
348
+ * Creates a Set from JSON string
349
+ * @param json - The JSON string
350
+ * @returns Set instance
351
+ */
352
+ fromJSON: <A>(json: string) => Set<A>;
353
+ /**
354
+ * Creates a Set from YAML string
355
+ * @param yaml - The YAML string
356
+ * @returns Set instance
357
+ */
358
+ fromYAML: <A>(yaml: string) => Set<A>;
359
+ /**
360
+ * Creates a Set from binary string
361
+ * @param binary - The binary string
362
+ * @returns Set instance
363
+ */
364
+ fromBinary: <A>(binary: string) => Set<A>;
365
+ };
366
+
367
+ type List<A> = {
368
+ readonly length: number;
369
+ readonly [Symbol.iterator]: () => Iterator<A>;
370
+ map: <B>(f: (a: A) => B) => List<B>;
371
+ flatMap: <B>(f: (a: A) => IterableType<B>) => List<B>;
372
+ flatMapAsync: <B>(f: (a: A) => PromiseLike<IterableType<B>>) => PromiseLike<List<B>>;
373
+ forEach: (f: (a: A) => void) => void;
374
+ count: (p: (x: A) => boolean) => number;
375
+ exists: (p: (a: A) => boolean) => boolean;
376
+ filter<S extends A>(predicate: (a: A) => a is S): List<S>;
377
+ filter(predicate: (a: A) => unknown): List<A>;
378
+ filterNot: (p: (a: A) => boolean) => List<A>;
379
+ filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>;
380
+ find: <T extends A = A>(predicate: (a: A) => boolean, tag?: ExtractTag<T>) => Option<T>;
381
+ readonly head: A | undefined;
382
+ readonly headOption: Option<A>;
383
+ readonly isEmpty: boolean;
384
+ toArray: <B = A>() => B[];
385
+ reduce: (f: (prev: A, curr: A) => A) => A;
386
+ reduceRight: (f: (prev: A, curr: A) => A) => A;
387
+ foldLeft: <B>(z: B) => (op: (b: B, a: A) => B) => B;
388
+ foldRight: <B>(z: B) => (op: (a: A, b: B) => B) => B;
389
+ remove: (value: A) => List<A>;
390
+ removeAt: (index: number) => List<A>;
391
+ add: (item: A) => List<A>;
392
+ get: (index: number) => Option<A>;
393
+ concat: (other: List<A>) => List<A>;
394
+ toList: () => List<A>;
395
+ toSet: () => Set<A>;
396
+ toString: () => string;
397
+ toValue: () => {
398
+ _tag: "List";
399
+ value: A[];
400
+ };
401
+ drop: (n: number) => List<A>;
402
+ dropRight: (n: number) => List<A>;
403
+ dropWhile: (p: (a: A) => boolean) => List<A>;
404
+ flatten: <B>() => List<B>;
405
+ /**
406
+ * Pattern matches over the List, applying a handler function based on whether it's empty
407
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
408
+ * @returns The result of applying the matching handler function
409
+ */
410
+ match<R>(patterns: {
411
+ Empty: () => R;
412
+ NonEmpty: (values: A[]) => R;
413
+ }): R;
414
+ } & IterableType<A> & AsyncFunctor<A> & Typeable<"List"> & Serializable<A> & Pipe<A[]> & Foldable<A> & Matchable<A[], "Empty" | "NonEmpty">;
415
+ declare const List: (<A>(values?: Iterable<A>) => List<A>) & {
416
+ /**
417
+ * Creates a List from JSON string
418
+ * @param json - The JSON string
419
+ * @returns List instance
420
+ */
421
+ fromJSON: <A>(json: string) => List<A>;
422
+ /**
423
+ * Creates a List from YAML string
424
+ * @param yaml - The YAML string
425
+ * @returns List instance
426
+ */
427
+ fromYAML: <A>(yaml: string) => List<A>;
428
+ /**
429
+ * Creates a List from binary string
430
+ * @param binary - The binary string
431
+ * @returns List instance
432
+ */
433
+ fromBinary: <A>(binary: string) => List<A>;
434
+ };
435
+
436
+ /**
437
+ * Defines conversion methods for collection types
438
+ * @interface
439
+ * @module Collections
440
+ * @category Core
441
+ */
442
+ type Converters<A> = {
443
+ toList(): List<A>;
444
+ toSet(): Set<A>;
445
+ toString(): string;
446
+ };
447
+ /**
448
+ * Represents a collection with conversion capabilities
449
+ * @interface
450
+ * @module Collections
451
+ * @category Core
452
+ */
453
+ type Collection<A> = Converters<A>;
454
+
455
+ type TestEither<L extends Type, R extends Type> = Either<L, R> & Functor<R> & AsyncFunctor<R>;
456
+ declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
457
+ declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
458
+ declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
459
+ value: R;
460
+ };
461
+ declare const isLeft: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
462
+ value: L;
463
+ };
464
+ declare const tryCatch: <L extends Type, R extends Type>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
465
+ declare const TypeCheckRight: <L extends Type, R extends Type>(value: R) => TestEither<L, R>;
466
+ declare const TypeCheckLeft: <L extends Type, R extends Type>(value: L) => TestEither<L, R>;
467
+ declare const tryCatchAsync: <L extends Type, R extends Type>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
468
+ /**
469
+ * Either type module
470
+ * @module Either
471
+ * @category Core
472
+ */
473
+ type Either<L extends Type, R extends Type> = {
474
+ readonly _tag: "Left" | "Right";
475
+ value: L | R;
476
+ isLeft: () => boolean;
477
+ isRight: () => boolean;
478
+ getOrElse: (defaultValue: R) => R;
479
+ getOrThrow: () => R;
480
+ map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
481
+ merge: <L1 extends Type, R1 extends Type>(other: Either<L1, R1>) => Either<L | L1, [R, R1]>;
482
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
483
+ flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
484
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
485
+ toOption: () => Option<R>;
486
+ toList: () => List<R>;
487
+ toString: () => string;
488
+ [Symbol.iterator]: () => Iterator<R>;
489
+ yield: () => Generator<R, void, unknown>;
490
+ traverse: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U[]>;
491
+ lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>;
492
+ tap: (f: (value: R) => void) => Either<L, R>;
493
+ tapLeft: (f: (value: L) => void) => Either<L, R>;
494
+ mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
495
+ bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
496
+ fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
497
+ swap: () => Either<R, L>;
498
+ /**
499
+ * Pipes the value through the provided function based on whether this is a Left or Right
500
+ * @param onLeft - The function to apply if this is a Left
501
+ * @param onRight - The function to apply if this is a Right
502
+ * @returns The result of applying the appropriate function
503
+ */
504
+ pipeEither<U extends Type>(onLeft: (value: L) => U, onRight: (value: R) => U): U;
505
+ /**
506
+ * Pipes the Either value through the provided function
507
+ * @param f - The function to apply to the value
508
+ * @returns The result of applying the function to the value
509
+ */
510
+ pipe<U extends Type>(f: (value: L | R) => U): U;
511
+ /**
512
+ * Pattern matches over the Either, applying a handler function based on the variant
513
+ * @param patterns - Object with handler functions for Left and Right variants
514
+ * @returns The result of applying the matching handler function
515
+ */
516
+ match<T>(patterns: {
517
+ Left: (value: L) => T;
518
+ Right: (value: R) => T;
519
+ }): T;
520
+ } & Typeable<"Left" | "Right"> & Valuable<"Left" | "Right", L | R> & PromiseLike<R> & AsyncFunctor<R> & Serializable<R> & Pipe<L | R> & Foldable<R> & Matchable<L | R, "Left" | "Right">;
521
+ declare const Either: {
522
+ sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
523
+ traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
524
+ fromNullable: <L extends Type, R extends Type>(value: R | null | undefined, leftValue: L) => Either<L, R>;
525
+ fromPredicate: <L extends Type, R extends Type>(value: R, predicate: (value: R) => boolean, leftValue: L) => Either<L, R>;
526
+ ap: <L extends Type, R extends Type, U extends Type>(eitherF: Either<L, (value: R) => U>, eitherV: Either<L, R>) => Either<L, U>;
527
+ fromPromise: <L, R>(promise: Promise<R>, onRejected: (reason: unknown) => L) => Promise<Either<L, R>>;
528
+ fromJSON: <L extends Type, R extends Type>(json: string) => Either<L, R>;
529
+ fromYAML: <L extends Type, R extends Type>(yaml: string) => Either<L, R>;
530
+ fromBinary: <L extends Type, R extends Type>(binary: string) => Either<L, R>;
531
+ };
532
+
533
+ export { type Converters as C, Either as E, type Foldable as F, type IterableType as I, List as L, type Matchable as M, None as N, Option as O, type Pipe as P, Right as R, type Serializable as S, type Traversable as T, type Collection as a, type TestEither as b, Left as c, isLeft as d, TypeCheckRight as e, TypeCheckLeft as f, tryCatchAsync as g, MatchableUtils as h, isRight as i, Some as j, OptionConstructor as k, type SerializationMethods as l, Set as m, tryCatch as t };
@@ -0,0 +1,65 @@
1
+ import { T as Traversable, I as IterableType, O as Option, a as Collection, S as Serializable, P as Pipe, F as Foldable, M as Matchable } from './Either-BfXNbTHo.js';
2
+ import { a as Type, T as Typeable, V as Valuable } from './Valuable-CtuVEKTZ.js';
3
+ import { Tuple } from './tuple/index.js';
4
+
5
+ /**
6
+ * Type alias for the native JavaScript Map
7
+ * @interface
8
+ * @module Map
9
+ * @category Collections
10
+ */
11
+ type ESMapType<K, V> = Map<K, V>;
12
+ /**
13
+ * Reference to the native JavaScript Map
14
+ * @module Map
15
+ * @category Collections
16
+ */
17
+ declare const ESMap: MapConstructor;
18
+
19
+ /**
20
+ * A traversable interface for map that excludes map and flatMap operations
21
+ */
22
+ type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
23
+ type Map$1<K, V> = {
24
+ add(item: Tuple<[K, V]>): Map$1<K, V>;
25
+ remove(value: K): Map$1<K, V>;
26
+ map<U>(f: (value: V) => U): Map$1<K, U>;
27
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map$1<K2, V2>;
28
+ get(key: K): Option<V>;
29
+ getOrElse(key: K, defaultValue: V): V;
30
+ orElse(key: K, alternative: Option<V>): Option<V>;
31
+ fold<U extends Type>(onEmpty: () => U, onValue: (value: Tuple<[K, V]>) => U): U;
32
+ foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B;
33
+ foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B;
34
+ /**
35
+ * Pattern matches over the Map, applying a handler function based on whether it's empty
36
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
37
+ * @returns The result of applying the matching handler function
38
+ */
39
+ match<R>(patterns: {
40
+ Empty: () => R;
41
+ NonEmpty: (entries: Array<Tuple<[K, V]>>) => R;
42
+ }): R;
43
+ } & SafeTraversable<K, V> & Collection<Tuple<[K, V]>> & Typeable<"Map"> & Valuable<"Map", ESMapType<K, V>> & Serializable<[K, V][]> & Pipe<[K, V][]> & Foldable<Tuple<[K, V]>> & Matchable<Array<Tuple<[K, V]>>, "Empty" | "NonEmpty">;
44
+ declare const Map$1: (<K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map$1<K, V>) & {
45
+ /**
46
+ * Creates a Map from JSON string
47
+ * @param json - The JSON string
48
+ * @returns Map instance
49
+ */
50
+ fromJSON: <K, V>(json: string) => Map$1<K, V>;
51
+ /**
52
+ * Creates a Map from YAML string
53
+ * @param yaml - The YAML string
54
+ * @returns Map instance
55
+ */
56
+ fromYAML: <K, V>(yaml: string) => Map$1<K, V>;
57
+ /**
58
+ * Creates a Map from binary string
59
+ * @param binary - The binary string
60
+ * @returns Map instance
61
+ */
62
+ fromBinary: <K, V>(binary: string) => Map$1<K, V>;
63
+ };
64
+
65
+ export { type ESMapType as E, Map$1 as M, type SafeTraversable as S, ESMap as a };
@@ -1,4 +1,5 @@
1
1
  type Type = unknown;
2
+
2
3
  type AbstractFunctor<A extends Type> = {
3
4
  map(f: (value: A) => Type): AbstractFunctor<Type>;
4
5
  flatMap(f: (value: A) => AbstractFunctor<Type>): AbstractFunctor<Type>;
@@ -26,11 +27,20 @@ type Typeable<Tag extends string, T = object> = T & {
26
27
  declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
27
28
  declare function isTypeable<T>(value: unknown, tag: string): value is T;
28
29
 
30
+ /**
31
+ * Parameters for creating a Valuable instance
32
+ */
29
33
  type ValuableParams<Tag extends string, T, V> = {
30
34
  _tag: Tag;
31
35
  impl: T;
32
36
  value: V;
33
37
  };
38
+ /**
39
+ * Creates a Valuable wrapper that adds value extraction capabilities
40
+ * @param params - Configuration parameters
41
+ * @module Valuable
42
+ * @category Utilities
43
+ */
34
44
  declare function Valuable<Tag extends string, V, T = object>(params: ValuableParams<Tag, T, V>): T & {
35
45
  toValue: () => {
36
46
  _tag: Tag;
@@ -38,15 +48,12 @@ declare function Valuable<Tag extends string, V, T = object>(params: ValuablePar
38
48
  };
39
49
  _tag: Tag;
40
50
  };
51
+ /**
52
+ * Represents a type that can extract its inner value
53
+ * @interface
54
+ * @module Valuable
55
+ * @category Utilities
56
+ */
41
57
  type Valuable<Tag extends string, V, T = object> = ReturnType<typeof Valuable<Tag, V, T>>;
42
58
 
43
- type Tuple<T extends Type[]> = {
44
- get<K extends number>(index: K): T[K];
45
- map<U extends Type[]>(f: (value: T) => U): Tuple<U>;
46
- flatMap<U extends Type[]>(f: (value: T) => Tuple<U>): Tuple<U>;
47
- toArray(): T;
48
- [Symbol.iterator](): Iterator<T[number]>;
49
- } & ArrayFunctor<T> & Typeable<"Tuple"> & Valuable<"Tuple", T>;
50
- declare const Tuple: <T extends Type[]>(values: T) => Tuple<T>;
51
-
52
- export { type AsyncFunctor as A, type ExtractTag as E, type Functor as F, Typeable as T, Valuable as V, type Type as a, Tuple as b, type AbstractFunctor as c, type ArrayFunctor as d, type TypeableParams as e, isTypeable as i };
59
+ export { type AbstractFunctor as A, type ExtractTag as E, type Functor as F, Typeable as T, Valuable as V, type Type as a, type AsyncFunctor as b, type ArrayFunctor as c, type TypeableParams as d, type ValuableParams as e, isTypeable as i };