functype 0.8.61 → 0.8.62
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/Map-BNxKlujn.mjs +46 -0
- package/dist/Map-BNxKlujn.mjs.map +1 -0
- package/dist/branded/Brand.d.ts +46 -0
- package/dist/branded/index.d.ts +1 -48
- package/dist/branded/index.mjs +23 -2
- package/dist/branded/index.mjs.map +1 -1
- package/dist/collections/index.d.ts +8 -0
- package/dist/companion/Companion.d.ts +23 -0
- package/dist/companion/index.d.ts +1 -0
- package/dist/core/base/Base.d.ts +10 -0
- package/dist/core/base/index.d.ts +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/info/Info.d.ts +26 -0
- package/dist/core/info/index.d.ts +1 -0
- package/dist/core/task/Task.d.ts +57 -0
- package/dist/core/task/index.d.ts +1 -0
- package/dist/core/throwable/Throwable.d.ts +18 -0
- package/dist/core/throwable/index.d.ts +1 -0
- package/dist/either/Either.d.ts +57 -0
- package/dist/either/index.d.ts +1 -3
- package/dist/either/index.mjs +13 -2
- package/dist/either/index.mjs.map +1 -1
- package/dist/error/ParseError.d.ts +6 -0
- package/dist/error/index.d.ts +1 -0
- package/dist/fpromise/FPromise.d.ts +369 -0
- package/dist/fpromise/index.d.ts +2 -3
- package/dist/fpromise/index.mjs +6 -2
- package/dist/fpromise/index.mjs.map +1 -1
- package/dist/fpromise/retry.d.ts +106 -0
- package/dist/functor/index.d.ts +18 -0
- package/dist/hkt/index.d.ts +49 -0
- package/dist/identity/Identity.d.ts +5 -0
- package/dist/identity/index.d.ts +1 -0
- package/dist/index-CgMYHgdG.mjs +1286 -0
- package/dist/index-CgMYHgdG.mjs.map +1 -0
- package/dist/index.d.ts +28 -3
- package/dist/index.mjs +174 -2
- package/dist/index.mjs.map +1 -1
- package/dist/iterable/index.d.ts +25 -0
- package/dist/list/List.d.ts +45 -0
- package/dist/list/index.d.ts +1 -3
- package/dist/list/index.mjs +5 -2
- package/dist/list/index.mjs.map +1 -1
- package/dist/map/Map.d.ts +19 -0
- package/dist/map/index.d.ts +2 -3
- package/dist/map/index.mjs +7 -2
- package/dist/map/index.mjs.map +1 -1
- package/dist/map/shim.d.ts +2 -0
- package/dist/option/Option.d.ts +164 -0
- package/dist/option/index.d.ts +1 -870
- package/dist/option/index.mjs +7 -2
- package/dist/option/index.mjs.map +1 -1
- package/dist/serializable/Serializable.d.ts +15 -0
- package/dist/serializable/index.d.ts +1 -0
- package/dist/set/Set.d.ts +16 -0
- package/dist/set/index.d.ts +2 -3
- package/dist/set/index.mjs +5 -2
- package/dist/set/index.mjs.map +1 -1
- package/dist/set/shim.d.ts +2 -0
- package/dist/try/Try.d.ts +20 -0
- package/dist/try/index.d.ts +1 -3
- package/dist/try/index.mjs +44 -2
- package/dist/try/index.mjs.map +1 -1
- package/dist/tuple/Tuple.d.ts +11 -0
- package/dist/tuple/index.d.ts +1 -1
- package/dist/tuple/index.mjs +27 -2
- package/dist/tuple/index.mjs.map +1 -1
- package/dist/typeable/Typeable.d.ts +10 -0
- package/dist/typeable/index.d.ts +1 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/isIterable.d.ts +1 -0
- package/dist/valuable/Valuable.d.ts +13 -0
- package/dist/valuable/index.d.ts +1 -0
- package/package.json +7 -6
- package/dist/Tuple-GXgoHfiN.d.ts +0 -54
- package/dist/chunk-A3EHNBZM.mjs +0 -2
- package/dist/chunk-A3EHNBZM.mjs.map +0 -1
- package/dist/chunk-OQWAJKZJ.mjs +0 -2
- package/dist/chunk-OQWAJKZJ.mjs.map +0 -1
- package/dist/chunk-TQJDL6YW.mjs +0 -2
- package/dist/chunk-TQJDL6YW.mjs.map +0 -1
package/dist/list/index.mjs
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { e as r } from "../index-CgMYHgdG.mjs";
|
|
2
|
+
export {
|
|
3
|
+
r as List
|
|
4
|
+
};
|
|
5
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/list/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Collection } from '../collections';
|
|
2
|
+
import { Traversable, Typeable } from '../index';
|
|
3
|
+
import { IterableType } from '../iterable';
|
|
4
|
+
import { Option } from '../option/Option';
|
|
5
|
+
import { Tuple } from '../tuple/Tuple';
|
|
6
|
+
import { Valuable } from '../valuable/Valuable';
|
|
7
|
+
import { IESMap } from './shim';
|
|
8
|
+
type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap">;
|
|
9
|
+
export type Map<K, V> = {
|
|
10
|
+
add(item: Tuple<[K, V]>): Map<K, V>;
|
|
11
|
+
remove(value: K): Map<K, V>;
|
|
12
|
+
map<U>(f: (value: V) => U): Map<K, U>;
|
|
13
|
+
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => IterableType<[K2, V2]>): Map<K2, V2>;
|
|
14
|
+
get(key: K): Option<V>;
|
|
15
|
+
getOrElse(key: K, defaultValue: V): V;
|
|
16
|
+
orElse(key: K, alternative: Option<V>): Option<V>;
|
|
17
|
+
} & SafeTraversable<K, V> & Collection<Tuple<[K, V]>> & Typeable<"Map"> & Valuable<"Map", IESMap<K, V>>;
|
|
18
|
+
export declare const Map: <K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>;
|
|
19
|
+
export {};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
import '../branded/index.js';
|
|
1
|
+
export * from './Map';
|
|
2
|
+
export * from './shim';
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import "../index-CgMYHgdG.mjs";
|
|
2
|
+
import { M as t } from "../Map-BNxKlujn.mjs";
|
|
3
|
+
import "../tuple/index.mjs";
|
|
4
|
+
export {
|
|
5
|
+
t as Map
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/map/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { AsyncFunctor, Functor, Type } from '../functor';
|
|
2
|
+
import { Typeable } from '../typeable/Typeable';
|
|
3
|
+
import { Valuable } from '../valuable/Valuable';
|
|
4
|
+
import { Either, List, Traversable } from '../index';
|
|
5
|
+
/**
|
|
6
|
+
* Option type module
|
|
7
|
+
* @module Option
|
|
8
|
+
* @category Core
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* The Option type represents a value that may or may not exist.
|
|
12
|
+
* It's used to handle potentially null or undefined values in a type-safe way.
|
|
13
|
+
* @typeParam T - The type of the value contained in the Option
|
|
14
|
+
*/
|
|
15
|
+
export type Option<T extends Type> = {
|
|
16
|
+
/** Tag identifying if this is a Some or None variant */
|
|
17
|
+
readonly _tag: "Some" | "None";
|
|
18
|
+
/** The contained value (undefined for None) */
|
|
19
|
+
readonly value: T | undefined;
|
|
20
|
+
/** Whether this Option contains no value */
|
|
21
|
+
isEmpty: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Extracts the value if present
|
|
24
|
+
* @throws Error if the Option is None
|
|
25
|
+
* @returns The contained value
|
|
26
|
+
*/
|
|
27
|
+
get(): T;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the contained value or a default value if None
|
|
30
|
+
* @param defaultValue - The value to return if this Option is None
|
|
31
|
+
* @returns The contained value or defaultValue
|
|
32
|
+
*/
|
|
33
|
+
getOrElse(defaultValue: T): T;
|
|
34
|
+
/**
|
|
35
|
+
* Returns the contained value or throws a specified error if None
|
|
36
|
+
* @param error - The error to throw if this Option is None
|
|
37
|
+
* @returns The contained value
|
|
38
|
+
* @throws The specified error if the Option is None
|
|
39
|
+
*/
|
|
40
|
+
getOrThrow(error: Error): T;
|
|
41
|
+
/**
|
|
42
|
+
* Returns this Option if it contains a value, otherwise returns the alternative
|
|
43
|
+
* @param alternative - The alternative Option to return if this is None
|
|
44
|
+
* @returns This Option or the alternative
|
|
45
|
+
*/
|
|
46
|
+
orElse(alternative: Option<T>): Option<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns the contained value or null if None
|
|
49
|
+
* @returns The contained value or null
|
|
50
|
+
*/
|
|
51
|
+
orNull(): T | null;
|
|
52
|
+
/**
|
|
53
|
+
* Maps the value inside the Option using the provided function
|
|
54
|
+
* @param f - The mapping function
|
|
55
|
+
* @returns A new Option containing the mapped value, or None if this Option is None
|
|
56
|
+
*/
|
|
57
|
+
map<U extends Type>(f: (value: T) => U): Option<U>;
|
|
58
|
+
/**
|
|
59
|
+
* Returns this Option if it contains a value that satisfies the predicate, otherwise returns None
|
|
60
|
+
* @param predicate - The predicate function to test the value
|
|
61
|
+
* @returns This Option or None
|
|
62
|
+
*/
|
|
63
|
+
filter(predicate: (value: T) => boolean): Option<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Maps the value using a function that returns an Option
|
|
66
|
+
* @param f - The mapping function returning an Option
|
|
67
|
+
* @returns The result of applying f to the contained value, or None if this Option is None
|
|
68
|
+
*/
|
|
69
|
+
flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
|
|
70
|
+
/**
|
|
71
|
+
* Maps the value using an async function that returns an Option
|
|
72
|
+
* @param f - The async mapping function returning an Option
|
|
73
|
+
* @returns Promise of the result of applying f to the contained value, or None if this Option is None
|
|
74
|
+
*/
|
|
75
|
+
flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>;
|
|
76
|
+
/**
|
|
77
|
+
* Applies a binary operator to a start value and the contained value
|
|
78
|
+
* @param f - The binary operator
|
|
79
|
+
* @returns The result of the reduction
|
|
80
|
+
*/
|
|
81
|
+
reduce<U>(f: (acc: U, value: T) => U): U;
|
|
82
|
+
/**
|
|
83
|
+
* Applies a binary operator to the contained value and a start value
|
|
84
|
+
* @param f - The binary operator
|
|
85
|
+
* @returns The result of the reduction
|
|
86
|
+
*/
|
|
87
|
+
reduceRight<U>(f: (acc: U, value: T) => U): U;
|
|
88
|
+
/**
|
|
89
|
+
* Pattern matches over the Option, applying onNone if None and onSome if Some
|
|
90
|
+
* @param onNone - Function to apply if the Option is None
|
|
91
|
+
* @param onSome - Function to apply if the Option has a value
|
|
92
|
+
* @returns The result of applying the appropriate function
|
|
93
|
+
*/
|
|
94
|
+
fold<U>(onNone: () => U, onSome: (value: T) => U): U;
|
|
95
|
+
/**
|
|
96
|
+
* Left-associative fold using the provided zero value and operation
|
|
97
|
+
* @param z - Zero/identity value
|
|
98
|
+
* @returns A function that takes an operation to apply
|
|
99
|
+
*/
|
|
100
|
+
foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
|
|
101
|
+
/**
|
|
102
|
+
* Right-associative fold using the provided zero value and operation
|
|
103
|
+
* @param z - Zero/identity value
|
|
104
|
+
* @returns A function that takes an operation to apply
|
|
105
|
+
*/
|
|
106
|
+
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
|
|
107
|
+
/**
|
|
108
|
+
* Converts this Option to a List
|
|
109
|
+
* @returns A List containing the value if Some, or empty List if None
|
|
110
|
+
*/
|
|
111
|
+
toList(): List<T>;
|
|
112
|
+
/**
|
|
113
|
+
* Checks if this Option contains the specified value
|
|
114
|
+
* @param value - The value to check for
|
|
115
|
+
* @returns true if this Option contains the value, false otherwise
|
|
116
|
+
*/
|
|
117
|
+
contains(value: T): boolean;
|
|
118
|
+
/** The number of elements in this Option (0 or 1) */
|
|
119
|
+
size: number;
|
|
120
|
+
/**
|
|
121
|
+
* Converts this Option to an Either
|
|
122
|
+
* @param left - The value to use for Left if this Option is None
|
|
123
|
+
* @returns Either.Right with the contained value if Some, or Either.Left with left if None
|
|
124
|
+
*/
|
|
125
|
+
toEither<E>(left: E): Either<E, T>;
|
|
126
|
+
/**
|
|
127
|
+
* Returns a string representation of this Option
|
|
128
|
+
* @returns A string representation
|
|
129
|
+
*/
|
|
130
|
+
toString(): string;
|
|
131
|
+
/**
|
|
132
|
+
* Returns a simple object representation of this Option
|
|
133
|
+
* @returns An object with _tag and value properties
|
|
134
|
+
*/
|
|
135
|
+
toValue(): {
|
|
136
|
+
_tag: "Some" | "None";
|
|
137
|
+
value: T;
|
|
138
|
+
};
|
|
139
|
+
} & (Traversable<T> & Functor<T> & Typeable<"Some" | "None"> & Valuable<"Some" | "None", T> & AsyncFunctor<T>);
|
|
140
|
+
/**
|
|
141
|
+
* Creates a Some variant of Option containing a value.
|
|
142
|
+
* @param value - The value to wrap in Some
|
|
143
|
+
* @returns A new Some instance containing the value
|
|
144
|
+
* @typeParam T - The type of the value
|
|
145
|
+
*/
|
|
146
|
+
export declare const Some: <T extends Type>(value: T) => Option<T>;
|
|
147
|
+
/**
|
|
148
|
+
* Creates a None variant of Option representing absence of a value.
|
|
149
|
+
* @returns A new None instance
|
|
150
|
+
* @typeParam T - The type that would be contained if this was a Some
|
|
151
|
+
*/
|
|
152
|
+
export declare const None: <T extends Type>() => Option<T>;
|
|
153
|
+
/**
|
|
154
|
+
* Safely wraps a value that might be null or undefined in an Option.
|
|
155
|
+
* Creates Some if the value is defined, None otherwise.
|
|
156
|
+
* @param value - The value to wrap (might be null/undefined)
|
|
157
|
+
* @returns Some(value) if value is defined, None otherwise
|
|
158
|
+
* @typeParam T - The type of the value
|
|
159
|
+
*/
|
|
160
|
+
export declare const Option: {
|
|
161
|
+
<T extends Type>(value: T | null | undefined): Option<T>;
|
|
162
|
+
from<T>(value: T): Option<T>;
|
|
163
|
+
none<T>(): Option<T>;
|
|
164
|
+
};
|