functype 0.48.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,4 @@
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-rgysbeU6.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-lfO2nRVW.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 };
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-BJIRbUKB.js";
2
+ import { $ as TestClockTag, $t as TaskFailure, A as OptionConstructor, An as ValidatedBrand, At as ValidationRule, B as fromBinary, Bn as ContainerOps, Bt as TaskErrorInfo, C as Functype, Cn as NonEmptyString, Ct as OptionKind, D as List, Dn as PositiveNumber, Dt as FieldValidation, E as Collection, En as PositiveInteger, Et as FoldableUtils, F as Set, Fn as Applicative, Ft as TypedError, G as MatchableUtils, Gn as Doable, Gt as Async, H as fromYAML, Hn as Extractable, Ht as formatError, I as SerializationResult, In as AsyncMonad, It as TypedErrorContext, J as Map, Jt as Err, K as ESMap, Kn as ParseError, Kt as CancellationToken, L as createCustomSerializer, Ln as Functor, Lt as ErrorChainElement, M as Stack, Mn as Try, Mt as ErrorCode, N as Valuable, Nn as TypeNames, Nt as ErrorMessage, O as None, On as UUID, Ot as FormValidation, P as ValuableParams, Pn as Promisable, Pt as ErrorStatus, Q as TestClock, Qt as Task$1, R as createSerializationCompanion, Rn as Monad, Rt as ErrorFormatterOptions, S as tryCatchAsync, Sn as IntegerNumber, St as ListKind, T as FunctypeCollection, Tn as PatternString, Tt as UniversalContainer, U as Ref, Un as isExtractable, Ut as formatStackTrace, V as fromJSON, Vn as LazyList, Vt as createErrorSerializer, W as Matchable, Wn as DoResult, Wt as safeStringify, X as Traversable, Xt as Sync, Y as SafeTraversable, Yt as Ok, Z as Lazy, Zt as TaggedThrowable, _ as TypeCheckLeft, _n as Companion, _t as TagService, a as EmptyListError, an as createCancellationTokenSource, at as TimeoutError, b as isRight, bn as EmailAddress, bt as HKT, c as LeftError, cn as Throwable, ct as LayerError, d as isDoCapable, dn as Match, dt as Exit, en as TaskMetadata, et as TestContext, f as unwrap, fn as UntypedMatch, ft as ExitTag, g as TestEither, gn as isCompanion, gt as Tag, h as Right, hn as InstanceType, ht as HasService, i as DoGenerator, in as TaskSuccess, it as Task, j as Some, jn as ValidatedBrandCompanion, jt as Validator, k as Option, kn as UrlString, kt as Validation, l as LeftErrorType, ln as ThrowableType, lt as LayerInput, m as Left, mn as CompanionMethods, 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 Cond, pt as Context, q as ESMapType, qt as CancellationTokenSource, r as DoAsync, rn as TaskResult, rt as RIO, s as FailureErrorType, sn as NAME, st as Layer, t as $, tn as TaskOutcome, tt as IO, u as NoneError, un as Base, ut as LayerOutput, v as TypeCheckRight, vn as BoundedNumber, vt as Identity, w as FunctypeBase, wn as NonNegativeNumber, wt as TryKind, x as tryCatch, xn as ISO8601Date, xt as Kind, y as isLeft, yn as BoundedString, yt as EitherKind, z as createSerializer, zn as CollectionOps, zt as ErrorWithTaskInfo } from "./index-OdnROQtM.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-DmywDCE9.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, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, Exit as ExitType, ExitTag, 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, 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 };
package/dist/index.js CHANGED
@@ -1 +1 @@
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,et as B,f as V,g as H,h as U,i as W,it as G,j as K,k as q,l as J,m as Y,n as X,nt as Z,o as Q,ot as $,p as ee,q as te,r as ne,rt as re,s 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-CXh58HBk.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,U as Context,je as Do,Me as DoAsync,W as ESMap,xe as Either,fe as EmailAddress,Ne as EmptyListError,f as Err,Y as Exit,Pe as FailureError,ce as FoldableUtils,P as HKT,z as IO,l as ISO8601Date,H as Identity,k as IntegerNumber,V 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,ne as MatchableUtils,K as NAME,h as NonEmptyString,O as NonNegativeNumber,me as None,Ie as NoneError,d as Ok,he as Option,ge as OptionConstructor,$ as ParseError,A as PatternString,m as PositiveInteger,v as PositiveNumber,s as Ref,Ce as Right,ve as Set,_e as Some,X as Stack,J as Tag,S as Task,Q as TestClock,ie as TestClockTag,R as TestContext,b as Throwable,ee as TimeoutError,ye as Try,ze as Tuple,we as TypeCheckLeft,Te as TypeCheckRight,j as Typeable,ue as TypedError,te as UUID,_ as UrlString,M as ValidatedBrand,L as Validation,ae as Valuable,i as createBrander,q as createCancellationTokenSource,B as createCustomSerializer,E as createErrorSerializer,oe as createSerializationCompanion,Z as createSerializer,u as formatError,le as formatStackTrace,re as fromBinary,G as fromJSON,I 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
+ 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,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,O as D,Ot as O,P as k,Q as A,R as j,S as M,St as N,T as P,Tt as F,U as I,V as L,W as R,X as z,Y as B,Z as V,_ as H,_t as U,a as W,at as G,b as K,bt as q,c as J,ct as Y,d as X,dt as Z,et as Q,f as $,ft as ee,g as te,gt as ne,h as re,ht as ie,i as ae,it as oe,j as se,jt as ce,k as le,kt as ue,l as de,lt as fe,m as pe,mt as me,n as he,nt as ge,o as _e,ot as ve,p as ye,pt as be,q as xe,r as Se,rt as Ce,s as we,st as Te,t as Ee,tt as De,u as Oe,ut as ke,v as Ae,vt as je,w as Me,wt as Ne,x as Pe,xt as Fe,y as Ie,yt as Le,z as Re}from"./src-ByDeJzWj.js";import{r as ze,t as Be}from"./Tuple-eVwTSeSr.js";export{p as $,I as Base,xe as BoundedNumber,x as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,ze as Companion,v as Cond,te as Context,D as Do,le as DoAsync,W as ESMap,ve as Either,B as EmailAddress,c as EmptyListError,b as Err,re as Exit,se as FailureError,Ie as FoldableUtils,Ae as HKT,$ as IO,z as ISO8601Date,H as Identity,V as IntegerNumber,ye as InterruptedError,X as Layer,_e as Lazy,Le as LazyList,Te as Left,w as LeftError,ie as List,ae as Map,R as Match,Se as MatchableUtils,L as NAME,A as NonEmptyString,s as NonNegativeNumber,N as None,E as NoneError,C as Ok,f as Option,Ne as OptionConstructor,T as ParseError,Q as PatternString,De as PositiveInteger,ge as PositiveNumber,q as Ref,Y as Right,Fe as Set,F as Some,he as Stack,Oe as Tag,j as Task,we as TestClock,J as TestClockTag,de as TestContext,y as Throwable,pe as TimeoutError,je as Try,Be as Tuple,fe as TypeCheckLeft,ke as TypeCheckRight,ne as Typeable,M as TypedError,Ce as UUID,oe as UrlString,G as ValidatedBrand,Pe as Validation,Ee as Valuable,i as createBrander,Re as createCancellationTokenSource,g as createCustomSerializer,d as createErrorSerializer,m as createSerializationCompanion,O as createSerializer,Me as formatError,P as formatStackTrace,ue as fromBinary,l as fromJSON,ce as fromYAML,a as hasBrand,S as isCompanion,k as isDoCapable,K as isExtractable,Z as isLeft,ee as isRight,u as isTaggedThrowable,U as isTypeable,h as safeStringify,be as tryCatch,me as tryCatchAsync,_ as unwrap,o as unwrapBrand};
@@ -1,85 +1,2 @@
1
- import { mn as Doable, nn as Reshapeable, r as FunctypeCollection } from "../Functype-rgysbeU6.js";
2
- import { l as Type, n as Typeable } from "../Typeable-lfO2nRVW.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
1
+ import { D as List } from "../index-OdnROQtM.js";
85
2
  export { List };
@@ -1,2 +1 @@
1
- import{Z as e,nt as t}from"../Valuable-CXh58HBk.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={[Symbol.toStringTag]:`List`,_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
+ import{ht as e}from"../src-ByDeJzWj.js";export{e as List};
@@ -1,73 +1,2 @@
1
- import { b as Traversable, i as Collection } from "../Functype-rgysbeU6.js";
2
- import { a as Serializable, c as Foldable, l as Type, n as Typeable, s as Pipe } from "../Typeable-lfO2nRVW.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 [Symbol.toStringTag]: string;
13
- readonly _tag: "Map";
14
- add(item: Tuple<[K, V]>): Map<K, V>;
15
- remove(value: K): Map<K, V>;
16
- map<U>(f: (value: V) => U): Map<K, U>;
17
- ap<U>(ff: Map<K, (value: V) => U>): Map<K, U>;
18
- flatMap<K2, V2>(f: (entry: Tuple<[K, V]>) => Iterable<[K2, V2]>): Map<K2, V2>;
19
- flatMapAsync<U>(f: (value: V) => PromiseLike<Map<K, U>>): PromiseLike<Map<K, U>>;
20
- get(key: K): Option<V>;
21
- getOrElse(key: K, defaultValue: V): V;
22
- orElse(key: K, alternative: Option<V>): Option<V>;
23
- fold<U extends Type>(onEmpty: () => U, onValue: (value: Tuple<[K, V]>) => U): U;
24
- foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B;
25
- foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B;
26
- /**
27
- * Pattern matches over the Map, applying a handler function based on whether it's empty
28
- * @param patterns - Object with handler functions for Empty and NonEmpty variants
29
- * @returns The result of applying the matching handler function
30
- */
31
- match<R>(patterns: {
32
- Empty: () => R;
33
- NonEmpty: (entries: Array<Tuple<[K, V]>>) => R;
34
- }): R;
35
- toValue(): {
36
- _tag: "Map";
37
- value: [K, V][];
38
- };
39
- }
40
- declare const Map: (<K, V>(entries?: readonly (readonly [K, V])[] | IterableIterator<[K, V]> | null) => Map<K, V>) & {
41
- /**
42
- * Creates an empty Map
43
- * Returns a singleton instance for efficiency
44
- * @returns An empty Map instance
45
- */
46
- empty: <K, V>() => Map<K, V>;
47
- /**
48
- * Creates a Map from variadic key-value pair arguments
49
- * @param entries - Key-value pairs to create map from
50
- * @returns A Map containing the entries
51
- */
52
- of: <K, V>(...entries: [K, V][]) => Map<K, V>;
53
- /**
54
- * Creates a Map from JSON string
55
- * @param json - The JSON string
56
- * @returns Map instance
57
- */
58
- fromJSON: <K, V>(json: string) => Map<K, V>;
59
- /**
60
- * Creates a Map from YAML string
61
- * @param yaml - The YAML string
62
- * @returns Map instance
63
- */
64
- fromYAML: <K, V>(yaml: string) => Map<K, V>;
65
- /**
66
- * Creates a Map from binary string
67
- * @param binary - The binary string
68
- * @returns Map instance
69
- */
70
- fromBinary: <K, V>(binary: string) => Map<K, V>;
71
- };
72
- //#endregion
1
+ import { J as Map, Y as SafeTraversable } from "../index-OdnROQtM.js";
73
2
  export { Map, SafeTraversable };
package/dist/map/index.js CHANGED
@@ -1,2 +1 @@
1
- import{i as e,nt as t}from"../Valuable-CXh58HBk.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{[Symbol.toStringTag]:`FunctypeMap`,_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};
1
+ import{i as e}from"../src-ByDeJzWj.js";export{e as Map};
@@ -1,243 +1,2 @@
1
- import { mn as Doable, nn as Reshapeable, rn as Promisable, t as Functype } from "../Functype-rgysbeU6.js";
2
- import { l as Type } from "../Typeable-lfO2nRVW.js";
3
- import { List } from "../list/index.js";
4
- import { Either } from "../either/index.js";
5
-
6
- //#region src/option/Option.d.ts
7
- /**
8
- * Option type module
9
- * @module Option
10
- * @category Core
11
- */
12
- /**
13
- * The Option type represents a value that may or may not exist.
14
- * It's used to handle potentially null or undefined values in a type-safe way.
15
- * @typeParam T - The type of the value contained in the Option
16
- */
17
- interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
18
- /** The contained value (undefined for None) */
19
- readonly value: T | undefined;
20
- /** Whether this Option contains no value */
21
- isEmpty: boolean;
22
- /**
23
- * Returns true if this Option is a Some (contains a value)
24
- * @returns true if this Option contains a value, false otherwise
25
- */
26
- isSome(): this is Option<T> & {
27
- value: T;
28
- isEmpty: false;
29
- };
30
- /**
31
- * Returns true if this Option is a None (contains no value)
32
- * @returns true if this Option is empty, false otherwise
33
- */
34
- isNone(): this is Option<T> & {
35
- value: undefined;
36
- isEmpty: true;
37
- };
38
- /**
39
- * Returns the contained value or a default value if None
40
- * @param defaultValue - The value to return if this Option is None
41
- * @returns The contained value or defaultValue
42
- */
43
- orElse(defaultValue: T): T;
44
- /**
45
- * Returns the contained value or throws an error if None
46
- * @param error - Optional custom error to throw. If not provided, throws a default error
47
- * @returns The contained value
48
- * @throws The specified error or a default error if the Option is None
49
- */
50
- orThrow(error?: Error): T;
51
- /**
52
- * Returns this Option if it contains a value, otherwise returns the alternative container
53
- * @param alternative - The alternative Option to return if this is None
54
- * @returns This Option or the alternative
55
- */
56
- or(alternative: Option<T>): Option<T>;
57
- /**
58
- * Returns the contained value or null if None
59
- * @returns The contained value or null
60
- */
61
- orNull(): T | null;
62
- /**
63
- * Returns the contained value or undefined if None
64
- * @returns The contained value or undefined
65
- */
66
- orUndefined(): T | undefined;
67
- /**
68
- * Maps the value inside the Option using the provided function
69
- * @param f - The mapping function
70
- * @returns A new Option containing the mapped value, or None if this Option is None
71
- */
72
- map<U extends Type>(f: (value: T) => U): Option<U>;
73
- /**
74
- * Applies a wrapped function to a wrapped value (Applicative pattern)
75
- * @param ff - An Option containing a function from T to U
76
- * @returns A new Option containing the result of applying the function
77
- */
78
- ap<U extends Type>(ff: Option<(value: T) => U>): Option<U>;
79
- /**
80
- * Returns this Option if it contains a value that satisfies the predicate, otherwise returns None
81
- * @param predicate - The predicate function to test the value
82
- * @returns This Option or None
83
- */
84
- filter(predicate: (value: T) => boolean): Option<T>;
85
- /**
86
- * Maps the value using a function that returns an Option
87
- * @param f - The mapping function returning an Option
88
- * @returns The result of applying f to the contained value, or None if this Option is None
89
- */
90
- flatMap<U extends Type>(f: (value: T) => Option<U>): Option<U>;
91
- /**
92
- * Maps the value using an async function that returns an Option
93
- * @param f - The async mapping function returning an Option
94
- * @returns Promise of the result of applying f to the contained value, or None if this Option is None
95
- */
96
- flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>;
97
- /**
98
- * Applies a binary operator to a start value and the contained value
99
- * @param f - The binary operator
100
- * @returns The result of the reduction
101
- */
102
- reduce<U>(f: (acc: U, value: T) => U): U;
103
- /**
104
- * Applies a binary operator to the contained value and a start value
105
- * @param f - The binary operator
106
- * @returns The result of the reduction
107
- */
108
- reduceRight<U>(f: (acc: U, value: T) => U): U;
109
- /**
110
- * Pattern matches over the Option, applying onNone if None and onSome if Some
111
- * @param onNone - Function to apply if the Option is None
112
- * @param onSome - Function to apply if the Option has a value
113
- * @returns The result of applying the appropriate function
114
- */
115
- fold<U>(onNone: () => U, onSome: (value: T) => U): U;
116
- /**
117
- * Left-associative fold using the provided zero value and operation
118
- * @param z - Zero/identity value
119
- * @returns A function that takes an operation to apply
120
- */
121
- foldLeft<B>(z: B): (op: (b: B, a: T) => B) => B;
122
- /**
123
- * Right-associative fold using the provided zero value and operation
124
- * @param z - Zero/identity value
125
- * @returns A function that takes an operation to apply
126
- */
127
- foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
128
- /**
129
- * Converts this Option to a List
130
- * @returns A List containing the value if Some, or empty List if None
131
- */
132
- toList(): List<T>;
133
- /**
134
- * Checks if this Option contains the specified value
135
- * @param value - The value to check for
136
- * @returns true if this Option contains the value, false otherwise
137
- */
138
- contains(value: T): boolean;
139
- /** The number of elements in this Option (0 or 1) */
140
- size: number;
141
- /**
142
- * Converts this Option to an Either
143
- * @param left - The value to use for Left if this Option is None
144
- * @returns Either.Right with the contained value if Some, or Either.Left with left if None
145
- */
146
- toEither<E>(left: E): Either<E, T>;
147
- /**
148
- * Returns a string representation of this Option
149
- * @returns A string representation
150
- */
151
- toString(): string;
152
- /**
153
- * Returns a simple object representation of this Option
154
- * @returns An object with _tag and value properties
155
- */
156
- toValue(): {
157
- _tag: "Some" | "None";
158
- value: T;
159
- };
160
- /**
161
- * Pattern matches over the Option, applying a handler function based on the variant
162
- * @param patterns - Object with handler functions for Some and None variants
163
- * @returns The result of applying the matching handler function
164
- */
165
- match<R>(patterns: {
166
- Some: (value: T) => R;
167
- None: () => R;
168
- }): R;
169
- }
170
- /**
171
- * Creates a Some variant of Option containing a value.
172
- * @param value - The value to wrap in Some
173
- * @returns A new Some instance containing the value
174
- * @typeParam T - The type of the value
175
- */
176
- declare const Some: <T extends Type>(value: T) => Option<T>;
177
- /**
178
- * Creates a None variant of Option representing absence of a value.
179
- * @returns A new None instance
180
- * @typeParam T - The type that would be contained if this was a Some
181
- */
182
- declare const None: <T extends Type>() => Option<T>;
183
- /**
184
- * Safely wraps a value that might be null or undefined in an Option.
185
- * Creates Some if the value is defined, None otherwise.
186
- * @param value - The value to wrap (might be null/undefined)
187
- * @returns Some(value) if value is defined, None otherwise
188
- * @typeParam T - The type of the value
189
- */
190
- declare const OptionConstructor: <T extends Type>(value: T | null | undefined) => Option<T>;
191
- declare const Option: (<T extends Type>(value: T | null | undefined) => Option<T>) & {
192
- /**
193
- * Creates an Option from any value. Alias for Option function.
194
- * @param value - The value to wrap
195
- * @returns Some(value) if value is defined, None otherwise
196
- * @typeParam T - The type of the value
197
- */
198
- from: <T>(value: T) => Option<T>;
199
- /**
200
- * Returns a None instance. Alias for None function.
201
- * @returns A None instance
202
- * @typeParam T - The type that would be contained if this was a Some
203
- */
204
- none: <T>() => Option<T>;
205
- /**
206
- * Type guard to check if an Option is Some
207
- * @param option - The Option to check
208
- * @returns True if Option is Some
209
- */
210
- isSome: <T>(option: Option<T>) => option is Option<T> & {
211
- value: T;
212
- isEmpty: false;
213
- };
214
- /**
215
- * Type guard to check if an Option is None
216
- * @param option - The Option to check
217
- * @returns True if Option is None
218
- */
219
- isNone: <T>(option: Option<T>) => option is Option<T> & {
220
- value: undefined;
221
- isEmpty: true;
222
- };
223
- /**
224
- * Creates an Option from JSON string
225
- * @param json - The JSON string
226
- * @returns Option instance
227
- */
228
- fromJSON: <T>(json: string) => Option<T>;
229
- /**
230
- * Creates an Option from YAML string
231
- * @param yaml - The YAML string
232
- * @returns Option instance
233
- */
234
- fromYAML: <T>(yaml: string) => Option<T>;
235
- /**
236
- * Creates an Option from binary string
237
- * @param binary - The binary string
238
- * @returns Option instance
239
- */
240
- fromBinary: <T>(binary: string) => Option<T>;
241
- };
242
- //#endregion
1
+ import { A as OptionConstructor, O as None, j as Some, k as Option } from "../index-OdnROQtM.js";
243
2
  export { None, Option, OptionConstructor, Some };
@@ -1,2 +1 @@
1
- import{nt as e}from"../Valuable-CXh58HBk.js";import{t}from"../Companion-VlxcFhzb.js";import{Try as n}from"../try/index.js";import{List as r}from"../list/index.js";import{Left as i,Right as a}from"../either/index.js";import o from"safe-stable-stringify";const s=t=>({[Symbol.toStringTag]:`Option`,_tag:`Some`,value:t,isEmpty:!1,isSome(){return!0},isNone(){return!1},orElse:()=>t,orThrow:()=>t,or:e=>s(t),orNull:()=>t,orUndefined:()=>t,map:e=>s(e(t)),ap:e=>e._tag===`Some`&&e.value?s(e.value(t)):c,filter(e){return e(t)?s(t):c},count:e=>e(t)?1:0,find:e=>e(t)?s(t):c,exists:e=>e(t),forEach:e=>e(t),fold:(e,n)=>n(t),match:e=>e.Some(t),flatMap:e=>e(t),flatMapAsync:async e=>await e(t),reduce:e=>e(void 0,t),reduceRight:e=>e(void 0,t),foldLeft:e=>n=>n(e,t),foldRight:e=>n=>n(t,e),toList:()=>r([t]),contains:e=>e===t,size:1,toOption:()=>s(t),toEither:e=>a(t),toTry:()=>n(()=>t),toPromise:()=>Promise.resolve(t),toString:()=>`Some(${o(t)})`,toValue:()=>({_tag:`Some`,value:t}),pipe:e=>e(t),serialize:()=>e(`Some`,t),doUnwrap(){return{ok:!0,value:t}}}),c={[Symbol.toStringTag]:`Option`,_tag:`None`,value:void 0,isEmpty:!0,isSome(){return!1},isNone(){return!0},orElse:e=>e,orThrow(e){throw e??Error(`Cannot extract value from None`)},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:e=>c,ap:e=>c,filter(e){return c},count:e=>0,find:e=>c,exists:e=>!1,forEach:e=>{},flatMap:e=>c,flatMapAsync:e=>Promise.resolve(c),reduce:()=>void 0,reduceRight:()=>void 0,fold:(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,toList:()=>r([]),contains:()=>!1,size:0,toOption:()=>c,toEither:e=>i(e),toTry:()=>n(()=>{throw Error(`None`)}),toPromise:()=>Promise.reject(Error(`Cannot convert None to Promise`)),toString:()=>`None`,toValue:()=>({_tag:`None`,value:void 0}),pipe:e=>e(void 0),serialize:()=>e(`None`,null),doUnwrap(){return{ok:!1,empty:!0}}},l=()=>c,u=e=>e==null?l():s(e),d={from:e=>f(e),none:()=>l(),isSome:e=>e.isSome(),isNone:e=>e.isNone(),fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Some`?s(t.value):l()},fromYAML:e=>{let t=e.split(`
2
- `),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return l();let i=r===`null`?null:JSON.parse(r);return n===`Some`?s(i):l()},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return d.fromJSON(t)}},f=t(u,d);export{l as None,f as Option,u as OptionConstructor,s as Some};
1
+ import{Ct as e,St as t,Tt as n,wt as r}from"../src-ByDeJzWj.js";export{t as None,e as Option,r as OptionConstructor,n as Some};
@@ -1,54 +1,2 @@
1
- import { i as Collection, r as FunctypeCollection } from "../Functype-rgysbeU6.js";
2
- import { l as Type } from "../Typeable-lfO2nRVW.js";
3
- import { List } from "../list/index.js";
4
-
5
- //#region src/set/Set.d.ts
6
- interface Set<A> extends FunctypeCollection<A, "Set">, Collection<A> {
7
- add: (value: A) => Set<A>;
8
- remove: (value: A) => Set<A>;
9
- contains: (value: A) => boolean;
10
- has: (value: A) => boolean;
11
- map: <B>(f: (a: A) => B) => Set<B>;
12
- flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>;
13
- filter: (p: (a: A) => boolean) => Set<A>;
14
- filterNot: (p: (a: A) => boolean) => Set<A>;
15
- fold: <U extends Type>(onEmpty: () => U, onValue: (value: A) => U) => U;
16
- toList: () => List<A>;
17
- toSet: () => Set<A>;
18
- toArray: <B = A>() => B[];
19
- toString: () => string;
20
- }
21
- declare const Set: (<A>(iterable?: Iterable<A>) => Set<A>) & {
22
- /**
23
- * Creates an empty Set
24
- * Returns a singleton instance for efficiency
25
- * @returns An empty Set instance
26
- */
27
- empty: <A extends Type>() => Set<A>;
28
- /**
29
- * Creates a Set from variadic arguments
30
- * @param values - Values to create set from
31
- * @returns A Set containing the unique values
32
- */
33
- of: <A extends Type>(...values: A[]) => Set<A>;
34
- /**
35
- * Creates a Set from JSON string
36
- * @param json - The JSON string
37
- * @returns Set instance
38
- */
39
- fromJSON: <A>(json: string) => Set<A>;
40
- /**
41
- * Creates a Set from YAML string
42
- * @param yaml - The YAML string
43
- * @returns Set instance
44
- */
45
- fromYAML: <A>(yaml: string) => Set<A>;
46
- /**
47
- * Creates a Set from binary string
48
- * @param binary - The binary string
49
- * @returns Set instance
50
- */
51
- fromBinary: <A>(binary: string) => Set<A>;
52
- };
53
- //#endregion
1
+ import { F as Set } from "../index-OdnROQtM.js";
54
2
  export { Set };
package/dist/set/index.js CHANGED
@@ -1,2 +1 @@
1
- import{nt as e}from"../Valuable-CXh58HBk.js";import{t}from"../Companion-VlxcFhzb.js";import{Option as n}from"../option/index.js";import{List as r}from"../list/index.js";const i=globalThis.Set,a=t=>{let o=new i(t),s={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>o[Symbol.iterator](),add:e=>a([...o,e]),remove:e=>{let t=new i(o);return t.delete(e),a(t)},contains:e=>o.has(e),has:e=>o.has(e),map:e=>a(Array.from(o).map(e)),ap:e=>{let t=new i;for(let n of o)for(let r of e)t.add(r(n));return a(t)},flatMap:e=>{let t=new i;for(let n of o)for(let r of e(n))t.add(r);return a(t)},flatMapAsync:async e=>{let t=new i;for(let n of o){let r=await e(n);for(let e of r)t.add(e)}return a(t)},fold:(e,t)=>{if(o.size===0)return e();let n=Array.from(o);if(n.length===0)return e();let r=n[0];return r===void 0?e():t(r)},foldLeft:e=>t=>{let n=e;for(let e of o)n=t(n,e);return n},foldRight:e=>t=>Array.from(o).reduceRight((e,n)=>t(n,e),e),get size(){return o.size},get isEmpty(){return o.size===0},reduce:e=>{let t=Array.from(o);if(t.length===0)throw Error(`Cannot reduce empty Set`);return t.reduce(e)},reduceRight:e=>{let t=Array.from(o);if(t.length===0)throw Error(`Cannot reduceRight empty Set`);return t.reduceRight(e)},count:e=>{let t=0;for(let n of o)e(n)&&t++;return t},find:e=>{for(let t of o)if(e(t))return n(t);return n(null)},exists:e=>{for(let t of o)if(e(t))return!0;return!1},forEach:e=>{o.forEach(e)},filter:e=>{let t=new i;for(let n of o)e(n)&&t.add(n);return a(t)},filterNot:e=>{let t=new i;for(let n of o)e(n)||t.add(n);return a(t)},drop:e=>a(Array.from(o).slice(e)),dropRight:e=>a(Array.from(o).slice(0,-e)),dropWhile:e=>{let t=Array.from(o),n=t.findIndex(t=>!e(t));return a(n===-1?[]:t.slice(n))},flatten:()=>{let e=new i;for(let t of o)if(Array.isArray(t))for(let n of t)e.add(n);else if(t&&typeof t==`object`&&Symbol.iterator in t)for(let n of t)e.add(n);else e.add(t);return a(e)},get head(){return Array.from(o)[0]},get headOption(){let e=Array.from(o)[0];return n(e)},take:e=>a(Array.from(o).slice(0,Math.max(0,e))),takeWhile:e=>{let t=Array.from(o),n=[];for(let r of t){if(!e(r))break;n.push(r)}return a(n)},takeRight:e=>{let t=Array.from(o);return a(e<=0?[]:t.slice(-e))},get last(){let e=Array.from(o);return e[e.length-1]},get lastOption(){let e=Array.from(o);return n(e[e.length-1])},get tail(){return a(Array.from(o).slice(1))},get init(){let e=Array.from(o);return a(e.length===0?[]:e.slice(0,-1))},toList:()=>r(Array.from(o)),toSet:()=>s,toArray:()=>Array.from(o),toString:()=>`Set(${Array.from(o).toString()})`,toValue:()=>({_tag:`Set`,value:Array.from(o)}),pipe:e=>e(Array.from(o)),serialize:()=>e(`Set`,Array.from(o))};return s},o=e=>a(e),s=a([]),c={empty:()=>s,of:(...e)=>a(e),fromJSON:e=>l(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
2
- `)[1]?.split(`: `)[1];return l(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return c.fromJSON(t)}},l=t(o,c);export{l as Set};
1
+ import{xt as e}from"../src-ByDeJzWj.js";export{e as Set};