functype 0.44.0 → 0.46.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.
@@ -1,2 +1,188 @@
1
- import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-DKAUrDCz.js";
1
+ import { an as AsyncMonad, dn as Extractable, mn as Doable, n as FunctypeBase, nn as Reshapeable, rn as Promisable } from "../Functype-Dc440LS5.js";
2
+ import { l as Type } from "../Typeable-E4-aX9Gc.js";
3
+ import { Option } from "../option/index.js";
4
+ import { List } from "../list/index.js";
5
+
6
+ //#region src/either/Either.d.ts
7
+ /**
8
+ * Either type module
9
+ * @module Either
10
+ * @category Core
11
+ */
12
+ interface Either<L extends Type, R extends Type> extends FunctypeBase<R, "Left" | "Right">, Promisable<R>, Doable<R>, Reshapeable<R>, Extractable<R> {
13
+ readonly _tag: "Left" | "Right";
14
+ value: L | R;
15
+ isLeft(): this is Either<L, R> & {
16
+ readonly _tag: "Left";
17
+ value: L;
18
+ };
19
+ isRight(): this is Either<L, R> & {
20
+ readonly _tag: "Right";
21
+ value: R;
22
+ };
23
+ orElse: (defaultValue: R) => R;
24
+ orThrow: (error?: Error) => R;
25
+ or(alternative: Either<L, R>): Either<L, R>;
26
+ orNull: () => R | null;
27
+ orUndefined: () => R | undefined;
28
+ readonly map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
29
+ ap: <U extends Type>(ff: Either<L, (value: R) => U>) => Either<L, U>;
30
+ merge: <L1 extends Type, R1 extends Type>(other: Either<L1, R1>) => Either<L | L1, [R, R1]>;
31
+ mapAsync: <U extends Type>(f: (value: R) => Promise<U>) => Promise<Either<L, U>>;
32
+ flatMap: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U>;
33
+ flatMapAsync: <U extends Type>(f: (value: R) => Promise<Either<L, U>>) => Promise<Either<L, U>>;
34
+ toOption: () => Option<R>;
35
+ toList: () => List<R>;
36
+ toString: () => string;
37
+ [Symbol.iterator]: () => Iterator<R>;
38
+ yield: () => Generator<R, void, unknown>;
39
+ traverse: <U extends Type>(f: (value: R) => Either<L, U>) => Either<L, U[]>;
40
+ lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>;
41
+ tap: (f: (value: R) => void) => Either<L, R>;
42
+ tapLeft: (f: (value: L) => void) => Either<L, R>;
43
+ mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
44
+ bimap: <L2 extends Type, R2 extends Type>(fl: (value: L) => L2, fr: (value: R) => R2) => Either<L2, R2>;
45
+ fold: <T extends Type>(onLeft: (value: L) => T, onRight: (value: R) => T) => T;
46
+ swap: () => Either<R, L>;
47
+ /**
48
+ * Pipes the value through the provided function based on whether this is a Left or Right
49
+ * @param onLeft - The function to apply if this is a Left
50
+ * @param onRight - The function to apply if this is a Right
51
+ * @returns The result of applying the appropriate function
52
+ */
53
+ pipeEither<U extends Type>(onLeft: (value: L) => U, onRight: (value: R) => U): U;
54
+ /**
55
+ * Pipes the Either value through the provided function
56
+ * @param f - The function to apply to the value (Left or Right)
57
+ * @returns The result of applying the function to the value
58
+ */
59
+ pipe<U extends Type>(f: (value: L | R) => U): U;
60
+ /**
61
+ * Pattern matches over the Either, applying a handler function based on the variant
62
+ * @param patterns - Object with handler functions for Left and Right variants
63
+ * @returns The result of applying the matching handler function
64
+ */
65
+ match<T>(patterns: {
66
+ Left: (value: L) => T;
67
+ Right: (value: R) => T;
68
+ }): T;
69
+ /**
70
+ * Returns the value and tag for inspection
71
+ */
72
+ toValue(): {
73
+ _tag: "Left" | "Right";
74
+ value: L | R;
75
+ };
76
+ /**
77
+ * Custom JSON serialization that excludes getter properties
78
+ */
79
+ toJSON(): {
80
+ _tag: "Left" | "Right";
81
+ value: L | R;
82
+ };
83
+ }
84
+ type TestEither<L extends Type, R extends Type> = Either<L, R> & AsyncMonad<R>;
85
+ declare const Right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
86
+ declare const Left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
87
+ declare const isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
88
+ value: R;
89
+ };
90
+ declare const isLeft: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
91
+ value: L;
92
+ };
93
+ declare const tryCatch: <L extends Type, R extends Type>(f: () => R, onError: (error: unknown) => L) => Either<L, R>;
94
+ declare const TypeCheckRight: <L extends Type, R extends Type>(value: R) => TestEither<L, R>;
95
+ declare const TypeCheckLeft: <L extends Type, R extends Type>(value: L) => TestEither<L, R>;
96
+ declare const tryCatchAsync: <L extends Type, R extends Type>(f: () => Promise<R>, onError: (error: unknown) => L) => Promise<Either<L, R>>;
97
+ declare const Either: (<L extends Type, R extends Type>(value: R | L, isRight: boolean) => Either<L, R>) & {
98
+ /**
99
+ * Creates a Left instance
100
+ * @param value - The left value
101
+ * @returns Left Either
102
+ */
103
+ left: <L extends Type, R extends Type>(value: L) => Either<L, R>;
104
+ /**
105
+ * Creates a Right instance
106
+ * @param value - The right value
107
+ * @returns Right Either
108
+ */
109
+ right: <L extends Type, R extends Type>(value: R) => Either<L, R>;
110
+ /**
111
+ * Type guard to check if an Either is Right
112
+ * @param either - The Either to check
113
+ * @returns True if Either is Right
114
+ */
115
+ isRight: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
116
+ value: R;
117
+ };
118
+ /**
119
+ * Type guard to check if an Either is Left
120
+ * @param either - The Either to check
121
+ * @returns True if Either is Left
122
+ */
123
+ isLeft: <L extends Type, R extends Type>(either: Either<L, R>) => either is Either<L, R> & {
124
+ value: L;
125
+ };
126
+ /**
127
+ * Combines an array of Eithers into a single Either containing an array
128
+ * @param eithers - Array of Either values
129
+ * @returns Either with array of values or first Left encountered
130
+ */
131
+ sequence: <L extends Type, R extends Type>(eithers: Either<L, R>[]) => Either<L, R[]>;
132
+ /**
133
+ * Maps an array through a function that returns Either, then sequences the results
134
+ * @param arr - Array of values
135
+ * @param f - Function that returns Either
136
+ * @returns Either with array of results or first Left encountered
137
+ */
138
+ traverse: <L extends Type, R extends Type, U extends Type>(arr: R[], f: (value: R) => Either<L, U>) => Either<L, U[]>;
139
+ /**
140
+ * Creates an Either from a nullable value
141
+ * @param value - The value that might be null or undefined
142
+ * @param leftValue - The value to use for Left if value is null/undefined
143
+ * @returns Right if value is not null/undefined, Left otherwise
144
+ */
145
+ fromNullable: <L extends Type, R extends Type>(value: R | null | undefined, leftValue: L) => Either<L, R>;
146
+ /**
147
+ * Creates an Either based on a predicate
148
+ * @param value - The value to test
149
+ * @param predicate - The predicate function
150
+ * @param leftValue - The value to use for Left if predicate fails
151
+ * @returns Right if predicate passes, Left otherwise
152
+ */
153
+ fromPredicate: <L extends Type, R extends Type>(value: R, predicate: (value: R) => boolean, leftValue: L) => Either<L, R>;
154
+ /**
155
+ * Applicative apply - applies a wrapped function to a wrapped value
156
+ * @param eitherF - Either containing a function
157
+ * @param eitherV - Either containing a value
158
+ * @returns Either with function applied to value
159
+ */
160
+ ap: <L extends Type, R extends Type, U extends Type>(eitherF: Either<L, (value: R) => U>, eitherV: Either<L, R>) => Either<L, U>;
161
+ /**
162
+ * Creates an Either from a Promise
163
+ * @param promise - The Promise to convert
164
+ * @param onRejected - Function to convert rejection reason to Left value
165
+ * @returns Promise that resolves to Either
166
+ */
167
+ fromPromise: <L, R>(promise: Promise<R>, onRejected: (reason: unknown) => L) => Promise<Either<L, R>>;
168
+ /**
169
+ * Creates an Either from JSON string
170
+ * @param json - The JSON string
171
+ * @returns Either instance
172
+ */
173
+ fromJSON: <L extends Type, R extends Type>(json: string) => Either<L, R>;
174
+ /**
175
+ * Creates an Either from YAML string
176
+ * @param yaml - The YAML string
177
+ * @returns Either instance
178
+ */
179
+ fromYAML: <L extends Type, R extends Type>(yaml: string) => Either<L, R>;
180
+ /**
181
+ * Creates an Either from binary string
182
+ * @param binary - The binary string
183
+ * @returns Either instance
184
+ */
185
+ fromBinary: <L extends Type, R extends Type>(binary: string) => Either<L, R>;
186
+ };
187
+ //#endregion
2
188
  export { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
@@ -1 +1,2 @@
1
- import{ct as e,dt as t,ft as n,gt as r,ht as i,lt as a,mt as o,pt as s,ut as c}from"../src-BuPnddUO.js";export{e as Either,a as Left,c as Right,t as TypeCheckLeft,n as TypeCheckRight,s as isLeft,o as isRight,i as tryCatch,r as tryCatchAsync};
1
+ import{rt as e}from"../Valuable-B8h0iKI_.js";import{t}from"../Companion-VlxcFhzb.js";import{None as n,Some as r}from"../option/index.js";import{Try as i}from"../try/index.js";import{List as a}from"../list/index.js";import o from"safe-stable-stringify";const s=t=>({_tag:`Right`,value:t,isLeft(){return!1},isRight(){return!0},orElse:e=>t,orThrow:()=>t,or:e=>l(t),orNull:()=>t,orUndefined:()=>t,map:e=>l(e(t)),ap:e=>e._tag===`Right`?l(e.value(t)):u(e.value),mapAsync:e=>e(t).then(e=>l(e)).catch(e=>Promise.resolve(u(e))),merge:e=>e.isLeft()?u(e.value):l([t,e.value]),flatMap:e=>e(t),flatMapAsync:e=>e(t).catch(e=>u(e)),toOption:()=>r(t),toList:()=>a([t]),toEither:e=>l(t),toTry:()=>i(()=>t),toJSON(){return{_tag:`Right`,value:t}},toString:()=>`Right(${o(t)})`,*[Symbol.iterator](){yield t},*yield(){yield t},traverse:e=>{let n=e(t);return n.isLeft()?u(n.value):l([n.value])},*lazyMap(e){yield l(e(t))},tap:e=>(e(t),l(t)),tapLeft:e=>l(t),mapLeft:e=>l(t),bimap:(e,n)=>l(n(t)),fold:(e,n)=>n(t),foldLeft:e=>n=>n(e,t),foldRight:e=>n=>n(t,e),match:e=>e.Right(t),swap:()=>u(t),toPromise:()=>Promise.resolve(t),toValue:()=>({_tag:`Right`,value:t}),pipeEither:(e,n)=>n(t),pipe:e=>e(t),serialize:()=>e(`Right`,t),get size(){return 1},get isEmpty(){return!1},contains:e=>t===e,reduce:e=>t,reduceRight:e=>t,count:e=>e(t)?1:0,find:e=>e(t)?r(t):n(),exists:e=>e(t),forEach:e=>e(t),doUnwrap(){return{ok:!0,value:t}}}),c=t=>({_tag:`Left`,value:t,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:e=>{throw e??t},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>u(t),ap:e=>u(t),mapAsync:e=>Promise.resolve(u(t)),merge:e=>u(t),flatMap:e=>u(t),flatMapAsync:e=>Promise.resolve(u(t)),toOption:()=>n(),toList:()=>a(),toEither:e=>u(e),toTry:()=>i(()=>{throw Error(String(t))}),toJSON(){return{_tag:`Left`,value:t}},toString:()=>`Left(${o(t)})`,*[Symbol.iterator](){},*yield(){},traverse:e=>u(t),*lazyMap(e){yield u(t)},tap:e=>u(t),tapLeft:e=>(e(t),u(t)),mapLeft:e=>u(e(t)),bimap:(e,n)=>u(e(t)),fold:(e,n)=>e(t),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:e=>e.Left(t),swap:()=>l(t),toPromise:()=>Promise.reject(t),toValue:()=>({_tag:`Left`,value:t}),pipeEither:(e,n)=>e(t),pipe:e=>e(t),serialize:()=>e(`Left`,t),get size(){return 0},get isEmpty(){return!0},contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce a Left`)},reduceRight:e=>{throw Error(`Cannot reduceRight a Left`)},count:e=>0,find:e=>n(),exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:t}}}),l=e=>s(e),u=e=>c(e),d=e=>e.isRight(),f=e=>e.isLeft(),p=(e,t)=>{try{return l(e())}catch(e){return u(t(e))}},m=e=>s(e);console.assert(m);const h=e=>c(e);console.assert(h);const g=async(e,t)=>{try{return l(await e())}catch(e){return u(t(e))}},_=(e,t)=>t?l(e):u(e),v={left:e=>u(e),right:e=>l(e),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?u(t.value):e.map(e=>[...e,t.value]),l([])),traverse:(e,t)=>v.sequence(e.map(t)),fromNullable:(e,t)=>e==null?u(t):l(e),fromPredicate:(e,t,n)=>t(e)?l(e):u(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return l(await e)}catch(e){return u(t(e))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Right`?l(t.value):u(t.value)},fromYAML:e=>{let t=e.split(`
2
+ `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)throw Error(`Invalid YAML format for Either`);let i=JSON.parse(r);return n===`Right`?l(i):u(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return v.fromJSON(t)}},y=t(_,v);export{y as Either,u as Left,l as Right,h as TypeCheckLeft,m as TypeCheckRight,f as isLeft,d as isRight,p as tryCatch,g as tryCatchAsync};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,12 @@
1
- import { a as ExtractBrand, c as hasBrand, i as BrandedString, l as unwrapBrand, n as BrandedBoolean, o as Unwrap, r as BrandedNumber, s as createBrander, t as Brand } from "./Brand-BPeggBaO.js";
2
- import { $ as TestClockTag, $t as TaskFailure, A as OptionConstructor, An as PositiveNumber, At as ValidationRule, B as fromBinary, Bn as Functor, Bt as TaskErrorInfo, C as Functype, Cn as EmailAddress, Ct as OptionKind, D as List, Dn as NonNegativeNumber, Dt as FieldValidation, E as Collection, En as NonEmptyString, Et as FoldableUtils, F as Set, Fn as Try, Ft as TypedError, G as MatchableUtils, Gn as Extractable, Gt as Async, H as fromYAML, Hn as CollectionOps, Ht as formatError, I as SerializationResult, In as TypeNames, It as TypedErrorContext, J as Map, Jn as Doable, Jt as Err, K as ESMap, Kn as isExtractable, Kt as CancellationToken, L as createCustomSerializer, Ln as Promisable, Lt as ErrorChainElement, M as Stack, Mn as UrlString, Mt as ErrorCode, N as Valuable, Nn as ValidatedBrand, Nt as ErrorMessage, O as None, On as PatternString, Ot as FormValidation, P as ValuableParams, Pn as ValidatedBrandCompanion, Pt as ErrorStatus, Q as TestClock, Qt as Task$1, R as createSerializationCompanion, Rn as Applicative, Rt as ErrorFormatterOptions, S as tryCatchAsync, Sn as BoundedString, St as ListKind, T as FunctypeCollection, Tn as IntegerNumber, Tt as UniversalContainer, U as Ref, Un as ContainerOps, Ut as formatStackTrace, V as fromJSON, Vn as Monad, Vt as createErrorSerializer, W as Matchable, Wn as LazyList, Wt as safeStringify, X as Traversable, Xt as Sync, Y as SafeTraversable, Yn as ParseError, Yt as Ok, Z as Lazy, Zt as TaggedThrowable, _ as TypeCheckLeft, _n as CompanionMethods, _t as TagService, a as EmptyListError, an as createCancellationTokenSource, at as TimeoutError, b as isRight, bn as Companion, bt as HKT, c as LeftError, cn as FPromise, ct as LayerError, d as isDoCapable, dn as Throwable, dt as Exit, en as TaskMetadata, et as TestContext, f as unwrap, fn as ThrowableType, ft as ExitTag, g as TestEither, gn as Cond, gt as Tag, h as Right, hn as UntypedMatch, ht as HasService, i as DoGenerator, in as TaskSuccess, it as Task, j as Some, jn as UUID, jt as Validator, k as Option, kn as PositiveInteger, kt as Validation, l as LeftErrorType, ln as FPromiseCompanion, lt as LayerInput, m as Left, mn as Match, mt as ContextServices, n as Do, nn as TaskParams, nt as InterruptedError, o as FailureError, on as isTaggedThrowable, ot as UIO, p as Either, pn as Base, pt as Context, q as ESMapType, qn as DoResult, qt as CancellationTokenSource, r as DoAsync, rn as TaskResult, rt as RIO, s as FailureErrorType, sn as ErrorContext, st as Layer, t as $, tn as TaskOutcome, tt as IO, u as NoneError, un as NAME, ut as LayerOutput, v as TypeCheckRight, vn as InstanceType, vt as Identity, w as FunctypeBase, wn as ISO8601Date, wt as TryKind, x as tryCatch, xn as BoundedNumber, xt as Kind, y as isLeft, yn as isCompanion, yt as EitherKind, z as createSerializer, zn as AsyncMonad, zt as ErrorWithTaskInfo } from "./index-DKAUrDCz.js";
3
- import { a as isTypeable, c as Pipe, i as TypeableParams, l as Foldable, n as ExtractTag, o as Serializable, r as Typeable, s as SerializationMethods, t as Tuple, u as Type } from "./Tuple-C4maYbiO.js";
4
- export { $, Applicative, Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, BrandedBoolean as BrandedBooleanType, BrandedNumber, BrandedNumber as BrandedNumberType, BrandedString, BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, CollectionOps, Companion, CompanionMethods, Cond, ContainerOps, Context, Context as ContextType, ContextServices, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorContext, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, ExtractBrand, ExtractTag, Extractable, FPromise, FPromiseCompanion, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, HKT, HasService, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NonEmptyString, NonNegativeNumber, None, NoneError, Ok, Option, OptionConstructor, OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, SafeTraversable, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, Tag as TagType, TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, TestClock as TestClockType, TestClockTag, TestContext, TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, UIO, UUID, UniversalContainer, UntypedMatch, Unwrap, UrlString, ValidatedBrand, ValidatedBrand as ValidatedBrandType, ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
1
+ import { Brand, BrandedBoolean, BrandedNumber, BrandedString, ExtractBrand, Unwrap, createBrander, hasBrand, unwrap as unwrapBrand } from "./branded/index.js";
2
+ import { $ as Validation, $t as UrlString, A as UIO, At as isTaggedThrowable, B as Tag, Bt as isCompanion, C as TestClockTag, Ct as TaskFailure, D as RIO, Dt as TaskResult, E as InterruptedError, Et as TaskParams, F as Exit, Ft as Match, G as Kind, Gt as ISO8601Date, H as Identity, Ht as BoundedNumber, I as ExitTag, It as UntypedMatch, J as TryKind, Jt as NonNegativeNumber, K as ListKind, Kt as IntegerNumber, L as Context, Lt as Cond, M as LayerError, Mt as Throwable, N as LayerInput, Nt as ThrowableType, O as Task, Ot as TaskSuccess, P as LayerOutput, Pt as Base, Q as FormValidation, Qt as UUID, R as ContextServices, Rt as CompanionMethods, S as TestClock, St as Task$1, T as IO, Tt as TaskOutcome, U as EitherKind, Ut as BoundedString, V as TagService, Vt as Companion, W as HKT, Wt as EmailAddress, X as FoldableUtils, Xt as PositiveInteger, Y as UniversalContainer, Yt as PatternString, Z as FieldValidation, Zt as PositiveNumber, _ as MatchableUtils, _t as CancellationTokenSource, a as Stack, an as AsyncMonad, at as TypedError, b as Traversable, bt as Sync, c as SerializationResult, cn as CollectionOps, ct as ErrorFormatterOptions, d as createSerializer, dn as Extractable, dt as createErrorSerializer, en as ValidatedBrand, et as ValidationRule, f as fromBinary, fn as isExtractable, ft as formatError, g as Matchable, gt as CancellationToken, h as Ref, hn as ParseError, ht as Async, i as Collection, in as Applicative, it as ErrorStatus, j as Layer, jt as NAME, k as TimeoutError, kt as createCancellationTokenSource, l as createCustomSerializer, ln as ContainerOps, lt as ErrorWithTaskInfo, m as fromYAML, mn as Doable, mt as safeStringify, n as FunctypeBase, nt as ErrorCode, o as Valuable, on as Functor, ot as TypedErrorContext, p as fromJSON, pn as DoResult, pt as formatStackTrace, q as OptionKind, qt as NonEmptyString, r as FunctypeCollection, rn as Promisable, rt as ErrorMessage, s as ValuableParams, sn as Monad, st as ErrorChainElement, t as Functype, tn as ValidatedBrandCompanion, tt as Validator, u as createSerializationCompanion, un as LazyList, ut as TaskErrorInfo, v as ESMap, vt as Err, w as TestContext, wt as TaskMetadata, x as Lazy, xt as TaggedThrowable, y as ESMapType, yt as Ok, z as HasService, zt as InstanceType } from "./Functype-Dc440LS5.js";
3
+ import { a as Serializable, c as Foldable, i as isTypeable, l as Type, n as Typeable, o as SerializationMethods, r as TypeableParams, s as Pipe, t as ExtractTag } from "./Typeable-E4-aX9Gc.js";
4
+ import { Try, TypeNames } from "./try/index.js";
5
+ import { Tuple } from "./tuple/index.js";
6
+ import { Map, SafeTraversable } from "./map/index.js";
7
+ import { Set } from "./set/index.js";
8
+ import { None, Option, OptionConstructor, Some } from "./option/index.js";
9
+ import { List } from "./list/index.js";
10
+ import { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync } from "./either/index.js";
11
+ import { $, Do, DoAsync, DoGenerator, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap } from "./do/index.js";
12
+ export { $, Applicative, Async, AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, CollectionOps, Companion, CompanionMethods, Cond, ContainerOps, Context, Context as ContextType, ContextServices, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, type ExtractBrand, ExtractTag, Extractable, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, Functor, Functype, FunctypeBase, FunctypeCollection, HKT, HasService, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NonEmptyString, NonNegativeNumber, None, NoneError, Ok, Option, OptionConstructor, OptionKind, ParseError, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, SafeTraversable, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, Tag as TagType, TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, TestClock as TestClockType, TestClockTag, TestContext, TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, UIO, UUID, UniversalContainer, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./Brand-Cfr5zy8F.js";import{$ as s,A as c,At as l,B as u,C as d,Ct as f,D as p,Dt as m,E as h,Et as g,F as _,G as v,H as y,I as b,J as x,K as S,L as C,M as w,Mt as T,N as E,Nt as D,O,Ot as k,P as A,Pt as j,Q as M,R as N,S as P,St as F,T as I,Tt as L,U as R,V as z,W as B,X as V,Y as H,Z as U,_ as W,_t as G,a as K,at as q,b as J,bt as Y,c as X,ct as Z,d as Q,dt as $,et as ee,f as te,ft as ne,g as re,gt as ie,h as ae,ht as oe,i as se,it as ce,j as le,jt as ue,k as de,kt as fe,l as pe,lt as me,m as he,mt as ge,n as _e,nt as ve,o as ye,ot as be,p as xe,pt as Se,q as Ce,r as we,rt as Te,s as Ee,st as De,t as Oe,tt as ke,u as Ae,ut as je,v as Me,vt as Ne,w as Pe,wt as Fe,x as Ie,xt as Le,y as Re,yt as ze,z as Be}from"./src-BuPnddUO.js";import{n as Ve,t as He}from"./Tuple-CUljR3nx.js";export{p as $,v as Base,H as BoundedNumber,V as BoundedString,o as Brand,n as BrandedBoolean,i as BrandedNumber,t as BrandedString,Ve as Companion,Ce as Cond,re as Context,O as Do,de as DoAsync,K as ESMap,Z as Either,U as EmailAddress,c as EmptyListError,b as Err,ae as Exit,z as FPromise,y as FPromiseCompanion,le as FailureError,Re as FoldableUtils,Me as HKT,te as IO,M as ISO8601Date,W as Identity,s as IntegerNumber,xe as InterruptedError,Q as Layer,ye as Lazy,Le as LazyList,me as Left,w as LeftError,G as List,se as Map,S as Match,we as MatchableUtils,R as NAME,ee as NonEmptyString,ke as NonNegativeNumber,Fe as None,E as NoneError,C as Ok,L as Option,g as OptionConstructor,j as ParseError,ve as PatternString,Te as PositiveInteger,ce as PositiveNumber,F as Ref,je as Right,f as Set,m as Some,_e as Stack,Ae as Tag,N as Task,Ee as TestClock,X as TestClockTag,pe as TestContext,B as Throwable,he as TimeoutError,Y as Try,He as Tuple,$ as TypeCheckLeft,ne as TypeCheckRight,Ne as Typeable,P as TypedError,q as UUID,be as UrlString,De as ValidatedBrand,Ie as Validation,Oe as Valuable,e as createBrander,Be as createCancellationTokenSource,k as createCustomSerializer,d as createErrorSerializer,fe as createSerializationCompanion,l as createSerializer,Pe as formatError,I as formatStackTrace,ue as fromBinary,T as fromJSON,D as fromYAML,r as hasBrand,x as isCompanion,A as isDoCapable,J as isExtractable,Se as isLeft,ge as isRight,u as isTaggedThrowable,ze as isTypeable,h as safeStringify,oe as tryCatch,ie as tryCatchAsync,_ as unwrap,a as unwrapBrand};
1
+ import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,B as l,C as u,D as d,E as f,F as p,G as m,H as h,I as g,J as _,K as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as E,T as D,U as O,V as k,W as A,X as j,Y as M,Z as N,_ as P,a as F,at as I,b as L,c as R,d as z,f as B,g as V,h as H,i as U,it as W,j as G,k as K,l as q,m as J,n as Y,nt as X,o as Z,ot as Q,p as $,q as ee,r as te,rt as ne,s as re,st as ie,t as ae,tt as oe,u as se,v as ce,w as le,x as ue,y as de,z as fe}from"./Valuable-B8h0iKI_.js";import{t as pe}from"./Companion-VlxcFhzb.js";import{None as me,Option as he,OptionConstructor as ge,Some as _e}from"./option/index.js";import{Set as ve}from"./set/index.js";import{Try as ye}from"./try/index.js";import{List as be}from"./list/index.js";import{Either as xe,Left as Se,Right as Ce,TypeCheckLeft as we,TypeCheckRight as Te,isLeft as Ee,isRight as De,tryCatch as Oe,tryCatchAsync as ke}from"./either/index.js";import{$ as Ae,Do as je,DoAsync as Me,EmptyListError as Ne,FailureError as Pe,LeftError as Fe,NoneError as Ie,isDoCapable as Le,unwrap as Re}from"./do/index.js";import{Tuple as ze}from"./tuple/index.js";import{Map as Be}from"./map/index.js";export{Ae as $,x as Base,y as BoundedNumber,T as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,pe as Companion,p as Cond,H as Context,je as Do,Me as DoAsync,U as ESMap,xe as Either,fe as EmailAddress,Ne as EmptyListError,f as Err,J as Exit,Pe as FailureError,ce as FoldableUtils,P as HKT,z as IO,l as ISO8601Date,V as Identity,k as IntegerNumber,B as InterruptedError,se as Layer,F as Lazy,w as LazyList,Se as Left,Fe as LeftError,be as List,Be as Map,C as Match,te as MatchableUtils,G as NAME,h as NonEmptyString,O as NonNegativeNumber,me as None,Ie as NoneError,d as Ok,he as Option,ge as OptionConstructor,ie as ParseError,A as PatternString,m as PositiveInteger,v as PositiveNumber,s as Ref,Ce as Right,ve as Set,_e as Some,Y as Stack,q as Tag,S as Task,Z as TestClock,re as TestClockTag,R as TestContext,b as Throwable,$ as TimeoutError,ye as Try,ze as Tuple,we as TypeCheckLeft,Te as TypeCheckRight,j as Typeable,ue as TypedError,ee as UUID,_ as UrlString,M as ValidatedBrand,L as Validation,ae as Valuable,i as createBrander,K as createCancellationTokenSource,oe as createCustomSerializer,E as createErrorSerializer,X as createSerializationCompanion,ne as createSerializer,u as formatError,le as formatStackTrace,W as fromBinary,I as fromJSON,Q as fromYAML,a as hasBrand,g as isCompanion,Le as isDoCapable,de as isExtractable,Ee as isLeft,De as isRight,c as isTaggedThrowable,N as isTypeable,D as safeStringify,Oe as tryCatch,ke as tryCatchAsync,Re as unwrap,o as unwrapBrand};
@@ -1,2 +1,85 @@
1
- import { D as List } from "../index-DKAUrDCz.js";
1
+ import { mn as Doable, nn as Reshapeable, r as FunctypeCollection } from "../Functype-Dc440LS5.js";
2
+ import { l as Type, n as Typeable } from "../Typeable-E4-aX9Gc.js";
3
+ import { Option } from "../option/index.js";
4
+
5
+ //#region src/list/List.d.ts
6
+ interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
7
+ readonly length: number;
8
+ readonly [Symbol.iterator]: () => Iterator<A>;
9
+ map: <B>(f: (a: A) => B) => List<B>;
10
+ ap: <B>(ff: List<(value: A) => B>) => List<B>;
11
+ flatMap: <B>(f: (a: A) => Iterable<B>) => List<B>;
12
+ flatMapAsync: <B>(f: (a: A) => PromiseLike<Iterable<B>>) => PromiseLike<List<B>>;
13
+ filter<S extends A>(predicate: (a: A) => a is S): List<S>;
14
+ filter(predicate: (a: A) => unknown): List<A>;
15
+ filterNot: (p: (a: A) => boolean) => List<A>;
16
+ /** @internal */
17
+ filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>;
18
+ remove: (value: A) => List<A>;
19
+ removeAt: (index: number) => List<A>;
20
+ add: (item: A) => List<A>;
21
+ get: (index: number) => Option<A>;
22
+ concat: (other: List<A>) => List<A>;
23
+ take: (n: number) => List<A>;
24
+ takeWhile: (p: (a: A) => boolean) => List<A>;
25
+ takeRight: (n: number) => List<A>;
26
+ get last(): A | undefined;
27
+ get lastOption(): Option<A>;
28
+ get tail(): List<A>;
29
+ get init(): List<A>;
30
+ reverse: () => List<A>;
31
+ indexOf: (value: A) => number;
32
+ prepend: (item: A) => List<A>;
33
+ distinct: () => List<A>;
34
+ sorted: (compareFn?: (a: A, b: A) => number) => List<A>;
35
+ sortBy: <B>(f: (a: A) => B, compareFn?: (a: B, b: B) => number) => List<A>;
36
+ zip: <B>(other: List<B>) => List<[A, B]>;
37
+ zipWithIndex: () => List<[A, number]>;
38
+ groupBy: <K>(f: (a: A) => K) => globalThis.Map<K, List<A>>;
39
+ partition: (p: (a: A) => boolean) => [List<A>, List<A>];
40
+ span: (p: (a: A) => boolean) => [List<A>, List<A>];
41
+ slice: (start: number, end: number) => List<A>;
42
+ /**
43
+ * Pattern matches over the List, applying a handler function based on whether it's empty
44
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
45
+ * @returns The result of applying the matching handler function
46
+ */
47
+ match<R>(patterns: {
48
+ Empty: () => R;
49
+ NonEmpty: (values: A[]) => R;
50
+ }): R;
51
+ }
52
+ declare const List: (<A>(values?: Iterable<A>) => List<A>) & {
53
+ /**
54
+ * Creates an empty List
55
+ * Returns a singleton instance for efficiency
56
+ * @returns An empty List instance
57
+ */
58
+ empty: <A extends Type>() => List<A>;
59
+ /**
60
+ * Creates a List from variadic arguments
61
+ * @param values - Values to create list from
62
+ * @returns A List containing the values
63
+ */
64
+ of: <A extends Type>(...values: A[]) => List<A>;
65
+ /**
66
+ * Creates a List from JSON string
67
+ * @param json - The JSON string
68
+ * @returns List instance
69
+ */
70
+ fromJSON: <A>(json: string) => List<A>;
71
+ /**
72
+ * Creates a List from YAML string
73
+ * @param yaml - The YAML string
74
+ * @returns List instance
75
+ */
76
+ fromYAML: <A>(yaml: string) => List<A>;
77
+ /**
78
+ * Creates a List from binary string
79
+ * @param binary - The binary string
80
+ * @returns List instance
81
+ */
82
+ fromBinary: <A>(binary: string) => List<A>;
83
+ };
84
+ //#endregion
2
85
  export { List };
@@ -1 +1,2 @@
1
- import{_t as e}from"../src-BuPnddUO.js";export{e as List};
1
+ import{Z as e,rt as t}from"../Valuable-B8h0iKI_.js";import{t as n}from"../Companion-VlxcFhzb.js";import{None as r,Option as i}from"../option/index.js";import{Set as a}from"../set/index.js";import{Try as o}from"../try/index.js";import{Left as s,Right as c}from"../either/index.js";import l from"safe-stable-stringify";const u=n=>{let d=Array.from(n??[]),f={_tag:`List`,[Symbol.iterator]:()=>d[Symbol.iterator](),get size(){return d.length},get length(){return d.length},map:e=>u(d.map(e)),ap:e=>u(d.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>u(d.flatMap(t=>Array.from(e(t)))),flatMapAsync:async e=>u((await Promise.all(d.map(async t=>await e(t)))).flatMap(e=>Array.from(e))),forEach:e=>d.forEach(e),contains:e=>d.includes(e),count:e=>d.filter(e).length,exists:e=>d.some(e),filter:e=>u(d.filter(e)),filterNot:e=>u(d.filter(t=>!e(t))),filterType:t=>u(d.filter(n=>e(n,t))),find:(t,n)=>i(d.find(r=>t(r)&&(n?e(r,n):!0))),get head(){return d[0]},get headOption(){return d.length>0?i(d[0]):r()},get isEmpty(){return d.length===0},toArray:()=>[...d],reduce:e=>d.reduce(e),reduceRight:e=>d.reduceRight(e),fold:(e,t)=>{if(d.length===0)return e();let n=d[0];return t(n)},foldLeft:e=>t=>d.reduce(t,e),foldRight:e=>t=>d.reduceRight((e,n)=>t(n,e),e),match:e=>d.length===0?e.Empty():e.NonEmpty([...d]),remove:e=>u(d.filter(t=>t!==e)),removeAt:e=>e<0||e>=d.length?f:u([...d.slice(0,e),...d.slice(e+1)]),add:e=>u([...d,e]),get:e=>i(d[e]),concat:e=>u([...d,...e.toArray()]),take:e=>u(d.slice(0,Math.max(0,e))),takeWhile:e=>{let t=[];for(let n of d){if(!e(n))break;t.push(n)}return u(t)},takeRight:e=>u(e<=0?[]:d.slice(-e)),get last(){return d[d.length-1]},get lastOption(){return d.length>0?i(d[d.length-1]):r()},get tail(){return u(d.slice(1))},get init(){return u(d.length===0?[]:d.slice(0,-1))},reverse:()=>u([...d].reverse()),indexOf:e=>d.indexOf(e),prepend:e=>u([e,...d]),distinct:()=>{let e=new globalThis.Set,t=[];for(let n of d)e.has(n)||(e.add(n),t.push(n));return u(t)},sorted:e=>u([...d].sort(e)),sortBy:(e,t)=>u([...d].sort((n,r)=>{let i=e(n),a=e(r);return t?t(i,a):i<a?-1:i>a?1:0})),zip:e=>{let t=e.toArray(),n=Math.min(d.length,t.length),r=[];for(let e=0;e<n;e++)r.push([d[e],t[e]]);return u(r)},zipWithIndex:()=>u(d.map((e,t)=>[e,t])),groupBy:e=>{let t=new globalThis.Map;for(let n of d){let r=e(n),i=t.get(r)??[];i.push(n),t.set(r,i)}let n=new globalThis.Map;for(let[e,r]of t)n.set(e,u(r));return n},partition:e=>{let t=[],n=[];for(let r of d)e(r)?t.push(r):n.push(r);return[u(t),u(n)]},span:e=>{let t=d.findIndex(t=>!e(t));return t===-1?[u([...d]),u([])]:[u(d.slice(0,t)),u(d.slice(t))]},slice:(e,t)=>u(d.slice(e,t)),drop:e=>u(d.slice(e)),dropRight:e=>u(d.slice(0,-e)),dropWhile:e=>u(d.slice(d.findIndex(t=>!e(t)))),flatten:()=>u(d.flatMap(e=>Array.isArray(e)?e:[e])),toList:()=>f,toSet:()=>a(d),toOption:()=>d.length>0?i(d[0]):r(),toEither:e=>d.length>0?c(d[0]):s(e),toTry:()=>d.length>0?o(()=>d[0]):o(()=>{throw Error(`Empty list`)}),toString:()=>`List(${l(d)})`,toValue:()=>({_tag:`List`,value:d}),pipe:e=>e([...d]),serialize:()=>t(`List`,d),doUnwrap(){return d.length===0?{ok:!1,empty:!0}:{ok:!0,value:d[0]}}};return f},d=e=>u(e),f=u([]),p={empty:()=>f,of:(...e)=>u(e),fromJSON:e=>m(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
2
+ `)[1]?.split(`: `)[1];return m(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return p.fromJSON(t)}},m=n(d,p);export{m as List};
@@ -1,2 +1,72 @@
1
- import { J as Map, Y as SafeTraversable } from "../index-DKAUrDCz.js";
1
+ import { b as Traversable, i as Collection } from "../Functype-Dc440LS5.js";
2
+ import { a as Serializable, c as Foldable, l as Type, n as Typeable, s as Pipe } from "../Typeable-E4-aX9Gc.js";
3
+ import { Tuple } from "../tuple/index.js";
4
+ import { Option } from "../option/index.js";
5
+
6
+ //#region src/map/Map.d.ts
7
+ /**
8
+ * A traversable interface for map that excludes map and flatMap operations
9
+ */
10
+ type SafeTraversable<K, V> = Omit<Traversable<Tuple<[K, V]>>, "map" | "flatMap" | "flatMapAsync" | "ap">;
11
+ 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]> {
12
+ readonly _tag: "Map";
13
+ add(item: Tuple<[K, V]>): Map<K, V>;
14
+ remove(value: K): Map<K, V>;
15
+ map<U>(f: (value: V) => U): Map<K, U>;
16
+ ap<U>(ff: Map<K, (value: V) => U>): Map<K, U>;
17
+ flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => Iterable<[K2, V2]>): Map<K2, V2>;
18
+ flatMapAsync<U>(f: (value: V) => PromiseLike<Map<K, U>>): PromiseLike<Map<K, U>>;
19
+ get(key: K): Option<V>;
20
+ getOrElse(key: K, defaultValue: V): V;
21
+ orElse(key: K, alternative: Option<V>): Option<V>;
22
+ fold<U extends Type>(onEmpty: () => U, onValue: (value: Tuple<[K, V]>) => U): U;
23
+ foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B;
24
+ foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B;
25
+ /**
26
+ * Pattern matches over the Map, applying a handler function based on whether it's empty
27
+ * @param patterns - Object with handler functions for Empty and NonEmpty variants
28
+ * @returns The result of applying the matching handler function
29
+ */
30
+ match<R>(patterns: {
31
+ Empty: () => R;
32
+ NonEmpty: (entries: Array<Tuple<[K, V]>>) => R;
33
+ }): R;
34
+ toValue(): {
35
+ _tag: "Map";
36
+ value: [K, V][];
37
+ };
38
+ }
39
+ declare const Map: (<K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>) & {
40
+ /**
41
+ * Creates an empty Map
42
+ * Returns a singleton instance for efficiency
43
+ * @returns An empty Map instance
44
+ */
45
+ empty: <K, V>() => Map<K, V>;
46
+ /**
47
+ * Creates a Map from variadic key-value pair arguments
48
+ * @param entries - Key-value pairs to create map from
49
+ * @returns A Map containing the entries
50
+ */
51
+ of: <K, V>(...entries: [K, V][]) => Map<K, V>;
52
+ /**
53
+ * Creates a Map from JSON string
54
+ * @param json - The JSON string
55
+ * @returns Map instance
56
+ */
57
+ fromJSON: <K, V>(json: string) => Map<K, V>;
58
+ /**
59
+ * Creates a Map from YAML string
60
+ * @param yaml - The YAML string
61
+ * @returns Map instance
62
+ */
63
+ fromYAML: <K, V>(yaml: string) => Map<K, V>;
64
+ /**
65
+ * Creates a Map from binary string
66
+ * @param binary - The binary string
67
+ * @returns Map instance
68
+ */
69
+ fromBinary: <K, V>(binary: string) => Map<K, V>;
70
+ };
71
+ //#endregion
2
72
  export { Map, SafeTraversable };
package/dist/map/index.js CHANGED
@@ -1 +1,2 @@
1
- import{i as e}from"../src-BuPnddUO.js";export{e as Map};
1
+ import{i as e,rt as t}from"../Valuable-B8h0iKI_.js";import{t as n}from"../Companion-VlxcFhzb.js";import{Option as r}from"../option/index.js";import{Set as i}from"../set/index.js";import{List as a}from"../list/index.js";import{Tuple as o}from"../tuple/index.js";const s=n=>{let c={values:new e(n)},l=()=>Array.from(c.values.entries()).map(([e,t])=>o([e,t])),u=t=>s(new e(c.values).set(t.toArray()[0],t.toArray()[1]).entries()),d=t=>{let n=new e(c.values);return n.delete(t)?s(n.entries()):s(c.values.entries())},f=e=>{let t=e.toArray();return c.values.get(t[0])===t[1]},p=()=>c.values.size,m=e=>s(Array.from(c.values.entries()).map(([t,n])=>[t,e(n)])),h=e=>s(s(c.values.entries()).toList().flatMap(e).toArray()),g=e=>{let t=[];for(let[n,r]of c.values.entries()){let i=e.get(n);i._tag===`Some`&&i.value&&t.push([n,i.value(r)])}return s(t)},_=async t=>{let n=new e;for(let[e,r]of c.values.entries()){let e=await t(r);for(let t of e.toList()){let[e,r]=t.toArray();n.set(e,r)}}return s(n.entries())},v=e=>a(l()).reduce(e),y=e=>a(l()).reduceRight(e),b=e=>t=>a(l()).foldLeft(e)(t),x=e=>t=>a(l()).foldRight(e)(t),S=e=>r(c.values.get(e)),C=(e,t)=>r(c.values.get(e)).orElse(t),w=()=>c.values.size===0,T=(e,t)=>r(c.values.get(e)).or(t),E=(e,t)=>{if(w())return e();let n=l();if(n.length===0)return e();let r=n[0];return r===void 0?e():t(r)},D=()=>a(l()),O=()=>i(l()),k=()=>`Map(${l().toString()})`,A=e=>w()?e.Empty():e.NonEmpty(l());return{_tag:`Map`,[Symbol.iterator]:()=>c.values.entries(),add:u,remove:d,contains:f,get size(){return p()},map:m,ap:g,flatMap:h,flatMapAsync:_,reduce:v,reduceRight:y,foldLeft:b,foldRight:x,fold:E,match:A,get:S,getOrElse:C,get isEmpty(){return w()},orElse:T,toList:D,toSet:O,toString:k,toValue:()=>({_tag:`Map`,value:Array.from(c.values.entries())}),pipe:e=>e(Array.from(c.values.entries())),serialize:()=>t(`Map`,Array.from(c.values.entries()))}},c=e=>s(e),l=s([]),u={empty:()=>l,of:(...e)=>s(e),fromJSON:e=>d(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
2
+ `)[1]?.split(`: `)[1];return d(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return u.fromJSON(t)}},d=n(c,u);export{d as Map};