functype 0.8.80 → 0.8.82
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/README.md +43 -47
- package/dist/{Either-CfG7OVB-.d.ts → Either-CncND8cm.d.ts} +393 -217
- package/dist/Tuple-ZYh96cGE.d.ts +41 -0
- package/dist/Typeable-BBXrKPTY.d.ts +14 -0
- package/dist/chunk-B6FR572T.mjs +2 -0
- package/dist/{chunk-7PQA3W7W.mjs.map → chunk-B6FR572T.mjs.map} +1 -1
- package/dist/chunk-JMCOLAJY.mjs +42 -0
- package/dist/chunk-JMCOLAJY.mjs.map +1 -0
- package/dist/either/index.d.ts +2 -2
- package/dist/either/index.mjs +1 -1
- package/dist/fpromise/index.d.ts +2 -2
- package/dist/fpromise/index.mjs +1 -1
- package/dist/index.d.ts +69 -11
- package/dist/index.mjs +1 -1
- package/dist/list/index.d.ts +2 -2
- package/dist/list/index.mjs +1 -1
- package/dist/map/index.d.ts +58 -4
- package/dist/map/index.mjs +1 -1
- package/dist/option/index.d.ts +2 -2
- package/dist/option/index.mjs +1 -1
- package/dist/set/index.d.ts +2 -2
- package/dist/set/index.mjs +1 -1
- package/dist/try/index.d.ts +13 -4
- package/dist/try/index.mjs +1 -1
- package/dist/tuple/index.d.ts +2 -12
- package/dist/tuple/index.mjs +1 -1
- package/package.json +3 -3
- package/dist/Map-wkGSJvYa.d.ts +0 -65
- package/dist/Valuable-BI2O7E9Q.d.ts +0 -59
- package/dist/chunk-7PQA3W7W.mjs +0 -2
- package/dist/chunk-JIVKCD74.mjs +0 -42
- package/dist/chunk-JIVKCD74.mjs.map +0 -1
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { E as Either,
|
|
2
|
-
import '../
|
|
1
|
+
export { E as Either, d as Left, R as Right, c as TestEither, g as TypeCheckLeft, f as TypeCheckRight, e as isLeft, i as isRight, t as tryCatch, h as tryCatchAsync } from '../Either-CncND8cm.js';
|
|
2
|
+
import '../Typeable-BBXrKPTY.js';
|
package/dist/either/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{p as Either,i as Left,h as Right,n as TypeCheckLeft,m as TypeCheckRight,k as isLeft,j as isRight,l as tryCatch,o as tryCatchAsync}from'../chunk-
|
|
1
|
+
export{p as Either,i as Left,h as Right,n as TypeCheckLeft,m as TypeCheckRight,k as isLeft,j as isRight,l as tryCatch,o as tryCatchAsync}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/fpromise/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as Either } from '../Either-
|
|
2
|
-
import { T as Type } from '../
|
|
1
|
+
import { E as Either } from '../Either-CncND8cm.js';
|
|
2
|
+
import { T as Type } from '../Typeable-BBXrKPTY.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Error context information that provides additional metadata about errors.
|
package/dist/fpromise/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{J as FPromise,I as FPromiseCompanion}from'../chunk-
|
|
1
|
+
export{J as FPromise,I as FPromiseCompanion}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Brand } from './branded/index.js';
|
|
2
2
|
export { BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand, Unbrand, createBrander, hasBrand, unbrand } from './branded/index.js';
|
|
3
|
-
import { O as Option, E as Either, F as Foldable, L as List, P as Pipe, S as Serializable, M as Matchable
|
|
4
|
-
export {
|
|
5
|
-
import { T as Type, a as Typeable
|
|
6
|
-
export {
|
|
3
|
+
import { O as Option, E as Either, F as Foldable, L as List, A as AsyncMonad, T as Traversable, a as FunctypeBase, b as Extractable, P as Pipe, S as Serializable, M as Matchable } from './Either-CncND8cm.js';
|
|
4
|
+
export { s as Applicative, C as Collection, q as CollectionOps, r as ContainerOps, u as Functor, j as Functype, k as FunctypeCollection, d as Left, l as MatchableUtils, v as Monad, N as None, n as OptionConstructor, R as Right, o as SerializationMethods, p as Set, m as Some, c as TestEither, g as TypeCheckLeft, f as TypeCheckRight, e as isLeft, i as isRight, t as tryCatch, h as tryCatchAsync } from './Either-CncND8cm.js';
|
|
5
|
+
import { T as Type, a as Typeable } from './Typeable-BBXrKPTY.js';
|
|
6
|
+
export { E as ExtractTag, b as TypeableParams, i as isTypeable } from './Typeable-BBXrKPTY.js';
|
|
7
7
|
import { FPromise } from './fpromise/index.js';
|
|
8
8
|
export { ErrorContext, FPromiseCompanion } from './fpromise/index.js';
|
|
9
9
|
import { Try } from './try/index.js';
|
|
10
10
|
export { TypeNames } from './try/index.js';
|
|
11
|
-
export {
|
|
12
|
-
|
|
11
|
+
export { Map, SafeTraversable } from './map/index.js';
|
|
12
|
+
import { V as Valuable } from './Tuple-ZYh96cGE.js';
|
|
13
|
+
export { T as Tuple, a as ValuableParams } from './Tuple-ZYh96cGE.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* A brand with runtime validation
|
|
@@ -825,6 +826,31 @@ type Identity<T> = {
|
|
|
825
826
|
};
|
|
826
827
|
declare function Identity<T>(value: T): Identity<T>;
|
|
827
828
|
|
|
829
|
+
interface IterableType<A extends Type> extends Iterable<A>, AsyncMonad<A>, Traversable<A> {
|
|
830
|
+
count(p: (x: A) => boolean): number;
|
|
831
|
+
find(p: (a: A) => boolean): Option<A>;
|
|
832
|
+
forEach(f: (a: A) => void): void;
|
|
833
|
+
drop(n: number): IterableType<A>;
|
|
834
|
+
dropRight(n: number): IterableType<A>;
|
|
835
|
+
dropWhile(p: (a: A) => boolean): IterableType<A>;
|
|
836
|
+
exists(p: (a: A) => boolean): boolean;
|
|
837
|
+
filter(p: (a: A) => boolean): IterableType<A>;
|
|
838
|
+
filterNot(p: (a: A) => boolean): IterableType<A>;
|
|
839
|
+
flatten<B>(): IterableType<B>;
|
|
840
|
+
reduce(f: (b: A, a: A) => A): A;
|
|
841
|
+
reduceRight(f: (b: A, a: A) => A): A;
|
|
842
|
+
foldLeft<B>(z: B): (op: (b: B, a: A) => B) => B;
|
|
843
|
+
foldRight<B>(z: B): (op: (a: A, b: B) => B) => B;
|
|
844
|
+
get head(): A | undefined;
|
|
845
|
+
get headOption(): Option<A>;
|
|
846
|
+
get isEmpty(): boolean;
|
|
847
|
+
map<B extends Type>(f: (a: A) => B): IterableType<B>;
|
|
848
|
+
ap<B extends Type>(ff: IterableType<(value: A) => B>): IterableType<B>;
|
|
849
|
+
flatMap<B extends Type>(f: (a: A) => IterableType<B>): IterableType<B>;
|
|
850
|
+
get size(): number;
|
|
851
|
+
toArray<B = A>(): readonly B[];
|
|
852
|
+
}
|
|
853
|
+
|
|
828
854
|
/**
|
|
829
855
|
* Lazy type module
|
|
830
856
|
* @module Lazy
|
|
@@ -835,7 +861,7 @@ declare function Identity<T>(value: T): Identity<T>;
|
|
|
835
861
|
* It provides memoization and safe evaluation with integration to Option, Either, and Try.
|
|
836
862
|
* @typeParam T - The type of the value to be computed
|
|
837
863
|
*/
|
|
838
|
-
|
|
864
|
+
interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>, Pipe<T> {
|
|
839
865
|
/** Tag identifying this as a Lazy type */
|
|
840
866
|
readonly _tag: "Lazy";
|
|
841
867
|
/** Whether the computation has been evaluated */
|
|
@@ -871,6 +897,12 @@ type Lazy<T extends Type> = {
|
|
|
871
897
|
* @returns A new Lazy containing the mapped value
|
|
872
898
|
*/
|
|
873
899
|
map<U extends Type>(f: (value: T) => U): Lazy<U>;
|
|
900
|
+
/**
|
|
901
|
+
* Applies a wrapped function to a wrapped value (Applicative pattern)
|
|
902
|
+
* @param ff - A Lazy containing a function from T to U
|
|
903
|
+
* @returns A new Lazy containing the result
|
|
904
|
+
*/
|
|
905
|
+
ap<U extends Type>(ff: Lazy<(value: T) => U>): Lazy<U>;
|
|
874
906
|
/**
|
|
875
907
|
* Maps the value inside the Lazy using an async function
|
|
876
908
|
* @param f - The async mapping function
|
|
@@ -980,14 +1012,14 @@ type Lazy<T extends Type> = {
|
|
|
980
1012
|
toString(): string;
|
|
981
1013
|
/**
|
|
982
1014
|
* Converts the Lazy to a value object
|
|
983
|
-
* @returns Object representation of the Lazy
|
|
1015
|
+
* @returns Object representation of the Lazy with evaluation state
|
|
984
1016
|
*/
|
|
985
1017
|
toValue(): {
|
|
986
1018
|
_tag: "Lazy";
|
|
987
1019
|
evaluated: boolean;
|
|
988
1020
|
value?: T;
|
|
989
1021
|
};
|
|
990
|
-
}
|
|
1022
|
+
}
|
|
991
1023
|
/**
|
|
992
1024
|
* Creates a Lazy computation that defers evaluation until needed.
|
|
993
1025
|
* Results are memoized after first evaluation.
|
|
@@ -1203,6 +1235,20 @@ declare const LazyList: (<A extends Type>(iterable: Iterable<A>) => LazyList<A>)
|
|
|
1203
1235
|
cycle: <A extends Type>(iterable: Iterable<A>) => LazyList<A>;
|
|
1204
1236
|
};
|
|
1205
1237
|
|
|
1238
|
+
/**
|
|
1239
|
+
* Type alias for the native JavaScript Map
|
|
1240
|
+
* @interface
|
|
1241
|
+
* @module Map
|
|
1242
|
+
* @category Collections
|
|
1243
|
+
*/
|
|
1244
|
+
type ESMapType<K, V> = Map<K, V>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Reference to the native JavaScript Map
|
|
1247
|
+
* @module Map
|
|
1248
|
+
* @category Collections
|
|
1249
|
+
*/
|
|
1250
|
+
declare const ESMap: MapConstructor;
|
|
1251
|
+
|
|
1206
1252
|
/**
|
|
1207
1253
|
* Stack data structure - Last In, First Out (LIFO)
|
|
1208
1254
|
* Implements the Traversable interface for working with ordered collections
|
|
@@ -1236,6 +1282,18 @@ type Stack<A extends Type> = {
|
|
|
1236
1282
|
* @returns A new flattened Stack
|
|
1237
1283
|
*/
|
|
1238
1284
|
flatMap<B extends Type>(f: (a: A) => Stack<B>): Stack<B>;
|
|
1285
|
+
/**
|
|
1286
|
+
* Applies a Stack of functions to this Stack
|
|
1287
|
+
* @param ff - Stack of functions to apply
|
|
1288
|
+
* @returns A new Stack with applied functions
|
|
1289
|
+
*/
|
|
1290
|
+
ap<B extends Type>(ff: Stack<(value: A) => B>): Stack<B>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Maps each element to an async Stack and flattens the result
|
|
1293
|
+
* @param f - The async mapping function returning a Stack
|
|
1294
|
+
* @returns A promise of the new flattened Stack
|
|
1295
|
+
*/
|
|
1296
|
+
flatMapAsync<B extends Type>(f: (value: A) => PromiseLike<Stack<B>>): PromiseLike<Stack<B>>;
|
|
1239
1297
|
/**
|
|
1240
1298
|
* Convert the stack to a List
|
|
1241
1299
|
* @returns A List containing all elements
|
|
@@ -1260,7 +1318,7 @@ type Stack<A extends Type> = {
|
|
|
1260
1318
|
Empty: () => R;
|
|
1261
1319
|
NonEmpty: (values: A[]) => R;
|
|
1262
1320
|
}): R;
|
|
1263
|
-
} & Traversable<A> &
|
|
1321
|
+
} & Traversable<A> & Valuable<"Stack", A[]> & Serializable<A> & Pipe<A[]> & Foldable<A> & Matchable<A[], "Empty" | "NonEmpty">;
|
|
1264
1322
|
declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
1265
1323
|
/**
|
|
1266
1324
|
* Creates an empty stack
|
|
@@ -1293,4 +1351,4 @@ declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
|
1293
1351
|
fromBinary: <A>(binary: string) => Stack<A>;
|
|
1294
1352
|
};
|
|
1295
1353
|
|
|
1296
|
-
export { type Async,
|
|
1354
|
+
export { type Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, type CancellationToken, type CancellationTokenSource, Companion, Cond, ESMap, type ESMapType, Either, type EitherKind, EmailAddress, type ErrorChainElement, type ErrorFormatterOptions, type ErrorWithTaskInfo, FPromise, Foldable, FoldableUtils, FunctypeBase, HKT, ISO8601Date, Identity, IntegerNumber, type IterableType, type Kind, Lazy, LazyList, Lazy as LazyType, List, type ListKind, Match, Matchable, NAME, NonEmptyString, NonNegativeNumber, Option, type OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Serializable, Stack, type Sync, type TaggedThrowable, Task, type TaskErrorInfo, TaskException, type TaskInfo, type TaskParams, TaskResult, Throwable, type ThrowableType, Traversable, Try, type TryKind, Type, Typeable, UUID, type UniversalContainer, UrlString, ValidatedBrand, Valuable, createCancellationTokenSource, createErrorSerializer, formatError, formatStackTrace, isTaggedThrowable, safeStringify };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{F as Base,A as BoundedNumber,B as BoundedString,a as Companion,D as Cond,_ as ESMap,p as Either,w as EmailAddress,J as FPromise,I as FPromiseCompanion,U as FoldableUtils,W as HKT,z as ISO8601Date,X as Identity,t as IntegerNumber,Y as Lazy,Z as LazyList,i as Left,g as List,$ as Map,E as Match,aa as MatchableUtils,G as NAME,v as NonEmptyString,s as NonNegativeNumber,c as None,e as Option,d as OptionConstructor,T as ParseError,C as PatternString,u as PositiveInteger,r as PositiveNumber,h as Right,f as Set,b as Some,ba as Stack,O as Task,L as TaskException,M as TaskResult,H as Throwable,V as Try,n as TypeCheckLeft,m as TypeCheckRight,y as UUID,x as UrlString,q as ValidatedBrand,N as createCancellationTokenSource,S as createErrorSerializer,R as formatError,Q as formatStackTrace,k as isLeft,j as isRight,K as isTaggedThrowable,P as safeStringify,l as tryCatch,o as tryCatchAsync}from'./chunk-
|
|
1
|
+
export{F as Base,A as BoundedNumber,B as BoundedString,a as Companion,D as Cond,_ as ESMap,p as Either,w as EmailAddress,J as FPromise,I as FPromiseCompanion,U as FoldableUtils,W as HKT,z as ISO8601Date,X as Identity,t as IntegerNumber,Y as Lazy,Z as LazyList,i as Left,g as List,$ as Map,E as Match,aa as MatchableUtils,G as NAME,v as NonEmptyString,s as NonNegativeNumber,c as None,e as Option,d as OptionConstructor,T as ParseError,C as PatternString,u as PositiveInteger,r as PositiveNumber,h as Right,f as Set,b as Some,ba as Stack,O as Task,L as TaskException,M as TaskResult,H as Throwable,V as Try,n as TypeCheckLeft,m as TypeCheckRight,y as UUID,x as UrlString,q as ValidatedBrand,N as createCancellationTokenSource,S as createErrorSerializer,R as formatError,Q as formatStackTrace,k as isLeft,j as isRight,K as isTaggedThrowable,P as safeStringify,l as tryCatch,o as tryCatchAsync}from'./chunk-JMCOLAJY.mjs';export{d as Tuple,a as Typeable,c as Valuable,b as isTypeable}from'./chunk-B6FR572T.mjs';export{a as Brand,g as BrandedBoolean,f as BrandedNumber,e as BrandedString,d as createBrander,c as hasBrand,b as unbrand}from'./chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { L as List } from '../Either-
|
|
2
|
-
import '../
|
|
1
|
+
export { L as List } from '../Either-CncND8cm.js';
|
|
2
|
+
import '../Typeable-BBXrKPTY.js';
|
package/dist/list/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{g as List}from'../chunk-
|
|
1
|
+
export{g as List}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,4 +1,58 @@
|
|
|
1
|
-
import '../Either-
|
|
2
|
-
import '../
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { T as Traversable, C as Collection, S as Serializable, P as Pipe, F as Foldable, O as Option } from '../Either-CncND8cm.js';
|
|
2
|
+
import { a as Typeable, T as Type } from '../Typeable-BBXrKPTY.js';
|
|
3
|
+
import { T as Tuple } from '../Tuple-ZYh96cGE.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A traversable interface for map that excludes map and flatMap operations
|
|
7
|
+
*/
|
|
8
|
+
type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap" | "flatMapAsync" | "ap">;
|
|
9
|
+
interface Map<K, V> extends SafeTraversable<K, V>, Collection<Tuple<[K, V]>>, Typeable<"Map">, Serializable<[K, V][]>, Pipe<[K, V][]>, Foldable<Tuple<[K, V]>>, Iterable<[K, V]> {
|
|
10
|
+
readonly _tag: "Map";
|
|
11
|
+
add(item: Tuple<[K, V]>): Map<K, V>;
|
|
12
|
+
remove(value: K): Map<K, V>;
|
|
13
|
+
map<U>(f: (value: V) => U): Map<K, U>;
|
|
14
|
+
ap<U>(ff: Map<K, (value: V) => U>): Map<K, U>;
|
|
15
|
+
flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => Iterable<[K2, V2]>): Map<K2, V2>;
|
|
16
|
+
flatMapAsync<U>(f: (value: V) => PromiseLike<Map<K, U>>): PromiseLike<Map<K, U>>;
|
|
17
|
+
get(key: K): Option<V>;
|
|
18
|
+
getOrElse(key: K, defaultValue: V): V;
|
|
19
|
+
orElse(key: K, alternative: Option<V>): Option<V>;
|
|
20
|
+
fold<U extends Type>(onEmpty: () => U, onValue: (value: Tuple<[K, V]>) => U): U;
|
|
21
|
+
foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B;
|
|
22
|
+
foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B;
|
|
23
|
+
/**
|
|
24
|
+
* Pattern matches over the Map, applying a handler function based on whether it's empty
|
|
25
|
+
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|
|
26
|
+
* @returns The result of applying the matching handler function
|
|
27
|
+
*/
|
|
28
|
+
match<R>(patterns: {
|
|
29
|
+
Empty: () => R;
|
|
30
|
+
NonEmpty: (entries: Array<Tuple<[K, V]>>) => R;
|
|
31
|
+
}): R;
|
|
32
|
+
toValue(): {
|
|
33
|
+
_tag: "Map";
|
|
34
|
+
value: [K, V][];
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
declare const Map: (<K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>) & {
|
|
38
|
+
/**
|
|
39
|
+
* Creates a Map from JSON string
|
|
40
|
+
* @param json - The JSON string
|
|
41
|
+
* @returns Map instance
|
|
42
|
+
*/
|
|
43
|
+
fromJSON: <K, V>(json: string) => Map<K, V>;
|
|
44
|
+
/**
|
|
45
|
+
* Creates a Map from YAML string
|
|
46
|
+
* @param yaml - The YAML string
|
|
47
|
+
* @returns Map instance
|
|
48
|
+
*/
|
|
49
|
+
fromYAML: <K, V>(yaml: string) => Map<K, V>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a Map from binary string
|
|
52
|
+
* @param binary - The binary string
|
|
53
|
+
* @returns Map instance
|
|
54
|
+
*/
|
|
55
|
+
fromBinary: <K, V>(binary: string) => Map<K, V>;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { Map, type SafeTraversable };
|
package/dist/map/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{$ as Map}from'../chunk-
|
|
1
|
+
export{$ as Map}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { N as None, O as Option,
|
|
2
|
-
import '../
|
|
1
|
+
export { N as None, O as Option, n as OptionConstructor, m as Some } from '../Either-CncND8cm.js';
|
|
2
|
+
import '../Typeable-BBXrKPTY.js';
|
package/dist/option/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{c as None,e as Option,d as OptionConstructor,b as Some}from'../chunk-
|
|
1
|
+
export{c as None,e as Option,d as OptionConstructor,b as Some}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import '../
|
|
1
|
+
export { p as Set } from '../Either-CncND8cm.js';
|
|
2
|
+
import '../Typeable-BBXrKPTY.js';
|
package/dist/set/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{f as Set}from'../chunk-
|
|
1
|
+
export{f as Set}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { T as Type
|
|
1
|
+
import { a as FunctypeBase, b as Extractable, P as Pipe, E as Either } from '../Either-CncND8cm.js';
|
|
2
|
+
import { T as Type } from '../Typeable-BBXrKPTY.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Possible types of Try instances
|
|
6
6
|
*/
|
|
7
7
|
type TypeNames = "Success" | "Failure";
|
|
8
|
-
|
|
8
|
+
interface Try<T> extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T> {
|
|
9
9
|
readonly _tag: TypeNames;
|
|
10
10
|
readonly error: Error | undefined;
|
|
11
11
|
isSuccess: () => boolean;
|
|
12
12
|
isFailure: () => boolean;
|
|
13
13
|
get: () => T;
|
|
14
14
|
getOrElse: (defaultValue: T) => T;
|
|
15
|
+
getOrThrow: (error?: Error) => T;
|
|
15
16
|
orElse: (alternative: Try<T>) => Try<T>;
|
|
17
|
+
orNull: () => T | null;
|
|
18
|
+
orUndefined: () => T | undefined;
|
|
16
19
|
orThrow: (error: Error) => T;
|
|
17
20
|
toEither: () => Either<Error, T>;
|
|
18
21
|
map: <U>(f: (value: T) => U) => Try<U>;
|
|
22
|
+
ap: <U>(ff: Try<(value: T) => U>) => Try<U>;
|
|
19
23
|
flatMap: <U>(f: (value: T) => Try<U>) => Try<U>;
|
|
24
|
+
flatMapAsync: <U>(f: (value: T) => Promise<Try<U>>) => Promise<Try<U>>;
|
|
20
25
|
/**
|
|
21
26
|
* Pattern matches over the Try, applying onFailure if Failure and onSuccess if Success
|
|
22
27
|
* @param onFailure - Function to apply if the Try is Failure
|
|
@@ -34,7 +39,11 @@ type Try<T> = {
|
|
|
34
39
|
Success: (value: T) => R;
|
|
35
40
|
Failure: (error: Error) => R;
|
|
36
41
|
}): R;
|
|
37
|
-
|
|
42
|
+
toValue(): {
|
|
43
|
+
_tag: TypeNames;
|
|
44
|
+
value: T | Error;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
38
47
|
declare const Try: (<T>(f: () => T) => Try<T>) & {
|
|
39
48
|
/**
|
|
40
49
|
* Creates a Try from JSON string
|
package/dist/try/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{V as Try}from'../chunk-
|
|
1
|
+
export{V as Try}from'../chunk-JMCOLAJY.mjs';import'../chunk-B6FR572T.mjs';import'../chunk-TQJDL6YW.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/tuple/index.d.ts
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
type Tuple<T extends Type[]> = {
|
|
4
|
-
get<K extends number>(index: K): T[K];
|
|
5
|
-
map<U extends Type[]>(f: (value: T) => U): Tuple<U>;
|
|
6
|
-
flatMap<U extends Type[]>(f: (value: T) => Tuple<U>): Tuple<U>;
|
|
7
|
-
toArray(): T;
|
|
8
|
-
[Symbol.iterator](): Iterator<T[number]>;
|
|
9
|
-
} & ArrayFunctor<T> & Typeable<"Tuple"> & Valuable<"Tuple", T>;
|
|
10
|
-
declare const Tuple: <T extends Type[]>(values: T) => Tuple<T>;
|
|
11
|
-
|
|
12
|
-
export { Tuple };
|
|
1
|
+
import '../Typeable-BBXrKPTY.js';
|
|
2
|
+
export { T as Tuple } from '../Tuple-ZYh96cGE.js';
|
package/dist/tuple/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{d as Tuple}from'../chunk-
|
|
1
|
+
export{d as Tuple}from'../chunk-B6FR572T.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.82",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A smallish functional library for TypeScript",
|
|
6
6
|
"author": "jordan.burke@gmail.com",
|
|
@@ -139,12 +139,12 @@
|
|
|
139
139
|
},
|
|
140
140
|
"sideEffects": false,
|
|
141
141
|
"scripts": {
|
|
142
|
+
"clean": "rimraf dist",
|
|
142
143
|
"compile": "tsc --noEmit",
|
|
143
144
|
"build": "pnpm compile && pnpm lint && pnpm test",
|
|
144
145
|
"build:dev": "tsup --watch",
|
|
145
|
-
"build:prod": "pnpm compile && pnpm test && cross-env NODE_ENV=production tsup",
|
|
146
|
+
"build:prod": "pnpm clean && pnpm compile && pnpm test && cross-env NODE_ENV=production tsup",
|
|
146
147
|
"build:watch": "tsup --watch",
|
|
147
|
-
"build:publish": "pnpm build:prod && pnpm publish --access public",
|
|
148
148
|
"lint:fix": "eslint ./src --quiet --fix",
|
|
149
149
|
"lint:format": "prettier --loglevel warn --write \"./**/*.{ts,tsx,css,md,json}\" ",
|
|
150
150
|
"lint": "pnpm lint:format && pnpm lint:fix ",
|
package/dist/Map-wkGSJvYa.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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-CfG7OVB-.js';
|
|
2
|
-
import { T as Type, a as Typeable, V as Valuable } from './Valuable-BI2O7E9Q.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,59 +0,0 @@
|
|
|
1
|
-
type Type = unknown;
|
|
2
|
-
|
|
3
|
-
type AbstractFunctor<A extends Type> = {
|
|
4
|
-
map(f: (value: A) => Type): AbstractFunctor<Type>;
|
|
5
|
-
flatMap(f: (value: A) => AbstractFunctor<Type>): AbstractFunctor<Type>;
|
|
6
|
-
};
|
|
7
|
-
type Functor<A extends Type> = AbstractFunctor<A> & {
|
|
8
|
-
map<B extends Type>(f: (value: A) => B): Functor<B>;
|
|
9
|
-
flatMap<B extends Type>(f: (value: A) => Functor<B>): Functor<B>;
|
|
10
|
-
};
|
|
11
|
-
type AsyncFunctor<A extends Type> = {
|
|
12
|
-
flatMapAsync(f: (value: A) => PromiseLike<AsyncFunctor<A>>): PromiseLike<AsyncFunctor<A>>;
|
|
13
|
-
};
|
|
14
|
-
type ArrayFunctor<A extends Type[]> = AbstractFunctor<A> & {
|
|
15
|
-
map<U extends Type[]>(f: (value: A) => U): ArrayFunctor<U>;
|
|
16
|
-
flatMap<U extends Type[]>(f: (value: A) => ArrayFunctor<U>): ArrayFunctor<U>;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
type TypeableParams<Tag extends string, T> = {
|
|
20
|
-
_tag: Tag;
|
|
21
|
-
impl: T;
|
|
22
|
-
};
|
|
23
|
-
type ExtractTag<T> = T extends Typeable<infer Tag, unknown> ? Tag : never;
|
|
24
|
-
type Typeable<Tag extends string, T = object> = T & {
|
|
25
|
-
readonly _tag: Tag;
|
|
26
|
-
};
|
|
27
|
-
declare function Typeable<Tag extends string, T>({ _tag, impl }: TypeableParams<Tag, T>): Typeable<Tag, T>;
|
|
28
|
-
declare function isTypeable<T>(value: unknown, tag: string): value is T;
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Parameters for creating a Valuable instance
|
|
32
|
-
*/
|
|
33
|
-
type ValuableParams<Tag extends string, T, V> = {
|
|
34
|
-
_tag: Tag;
|
|
35
|
-
impl: T;
|
|
36
|
-
value: V;
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Creates a Valuable wrapper that adds value extraction capabilities
|
|
40
|
-
* @param params - Configuration parameters
|
|
41
|
-
* @module Valuable
|
|
42
|
-
* @category Utilities
|
|
43
|
-
*/
|
|
44
|
-
declare function Valuable<Tag extends string, V, T = object>(params: ValuableParams<Tag, T, V>): T & {
|
|
45
|
-
toValue: () => {
|
|
46
|
-
_tag: Tag;
|
|
47
|
-
value: V;
|
|
48
|
-
};
|
|
49
|
-
_tag: Tag;
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Represents a type that can extract its inner value
|
|
53
|
-
* @interface
|
|
54
|
-
* @module Valuable
|
|
55
|
-
* @category Utilities
|
|
56
|
-
*/
|
|
57
|
-
type Valuable<Tag extends string, V, T = object> = ReturnType<typeof Valuable<Tag, V, T>>;
|
|
58
|
-
|
|
59
|
-
export { type AsyncFunctor as A, type ExtractTag as E, type Functor as F, type Type as T, Valuable as V, Typeable as a, type AbstractFunctor as b, type ArrayFunctor as c, type TypeableParams as d, type ValuableParams as e, isTypeable as i };
|
package/dist/chunk-7PQA3W7W.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
function r({_tag:e,impl:t}){return {...t,_tag:e}}function n(e,t){return !e||typeof e!="object"||!("_tag"in e)?false:t?e._tag===t:true}function u(e){let t=r({_tag:e._tag,impl:e.impl});return {...t,toValue:()=>({_tag:t._tag,value:e.value})}}var a=e=>({_tag:"Tuple",map:t=>{let T=t(e);return a(T)},flatMap:t=>t(e),get:t=>e[t],toArray:()=>e,[Symbol.iterator](){let t=0;return {next:()=>t<e.length?{value:e[t++],done:false}:{value:void 0,done:true}}},toValue:()=>({_tag:"Tuple",value:e})});export{r as a,n as b,u as c,a as d};//# sourceMappingURL=chunk-7PQA3W7W.mjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-7PQA3W7W.mjs.map
|