functype 0.60.3 → 0.60.5
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 +1 -1
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/do/index.d.ts +1 -1
- package/dist/do/index.js +1 -1
- package/dist/either/index.d.ts +1 -1
- package/dist/either/index.js +1 -1
- package/dist/{full-interfaces-BPyQ4Hyv.js → full-interfaces-DT4nsgjh.js} +10 -2
- package/dist/{index-BFDvVJ8v.d.ts → index-P2ubIONw.d.ts} +42 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/list/index.d.ts +1 -1
- package/dist/list/index.js +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.js +1 -1
- package/dist/option/index.d.ts +1 -1
- package/dist/option/index.js +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.js +1 -1
- package/dist/{src-lZq532nx.js → src-DpQmW2iX.js} +3 -3
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +54 -43
- package/readme/BRAND_MIGRATION_GUIDE.md +230 -0
- package/readme/BUNDLE_OPTIMIZATION.md +74 -0
- package/readme/HKT.md +110 -0
- package/readme/ROADMAP.md +113 -0
- package/readme/TASK-TODO.md +33 -0
- package/readme/TUPLE-EXAMPLES.md +76 -0
- package/readme/ai-guide.md +384 -0
- package/readme/examples.md +1883 -0
- package/readme/quick-reference.md +462 -0
- package/readme/task-error-handling.md +283 -0
- package/readme/tasks.md +195 -0
- package/readme/type-index.md +225 -0
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
Functype is a lightweight functional programming library for TypeScript, drawing inspiration from functional programming paradigms, the Scala Standard Library, and ZIO. It provides a comprehensive set of utilities and abstractions designed to facilitate functional programming within TypeScript applications.
|
|
9
9
|
|
|
10
|
-
[API Documentation](https://jordanburke.github.io/functype/)
|
|
10
|
+
[API Documentation](https://jordanburke.github.io/functype/) · [Cheatsheet for Scala / cats / fp-ts users](./CHEATSHEET.md)
|
|
11
11
|
|
|
12
12
|
### CLI Documentation
|
|
13
13
|
|
package/dist/cli/exports.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"../full-interfaces-
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"../full-interfaces-DT4nsgjh.js";export{n as CATEGORIES,i as FULL_INTERFACES,r as INTERFACES,t as TYPES,e as VERSION};
|
package/dist/cli/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{J as e,kt as t,yt as n}from"../src-
|
|
2
|
+
import{J as e,kt as t,yt as n}from"../src-DpQmW2iX.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-DT4nsgjh.js";const c=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},l=(e,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${e}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((e,i)=>t(r.methods[i]).filter(e=>e.length>0).fold(()=>e,t=>{let r=e.add(i.toUpperCase());return n(t).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},u=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(o)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
|
|
5
5
|
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=e=>t(i[e]).map(t=>({name:e,data:t})).or(n(Object.entries(i)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let t=n(e.slice(2));return{flags:{json:t.contains(`--json`),full:t.contains(`--full`),help:t.exists(e=>e===`--help`||e===`-h`)},args:t.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=e=>t(s[e]).or(n(Object.entries(s)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([,e])=>e)),v=()=>{let e=n([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return n(Object.entries(s)).foldLeft(e)((e,[t,r])=>e.concat(n([`// ${t}`,r,``,`-`.repeat(60),``]))).toArray().join(`
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-
|
|
1
|
+
import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-P2ubIONw.js";
|
|
2
2
|
export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
package/dist/do/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-
|
|
1
|
+
import{F as e,I as t,L as n,M as r,N as i,P as a,R as o,j as s,z as c}from"../src-DpQmW2iX.js";export{s as $,r as Do,i as DoAsync,a as EmptyListError,e as FailureError,t as LeftError,n as NoneError,o as isDoCapable,c as unwrap};
|
package/dist/either/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-
|
|
1
|
+
import { C as isRight, S as isLeft, T as tryCatchAsync, _ as Right, b as TypeCheckLeft, g as LeftOf, h as Left, m as EitherBase, p as Either, v as RightOf, w as tryCatch, x as TypeCheckRight, y as TestEither } from "../index-P2ubIONw.js";
|
|
2
2
|
export { Either, EitherBase, Left, LeftOf, Right, RightOf, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-
|
|
1
|
+
import{_t as e,dt as t,ft as n,gt as r,ht as i,mt as a,pt as o,ut as s,vt as c}from"../src-DpQmW2iX.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=`0.60.
|
|
1
|
+
const e=`0.60.5`,t={Option:{description:`Safe nullable handling - Some<T> or None`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Option(v)`,`Option.none()`,`Some(v)`,`None()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.ap(ff)`],extract:[`.fold(n, s)`,`.foldAsync(n, s)`,`.orElse(d)`,`.orThrow()`,`.orNull()`,`.match({Some, None})`],check:[`.isSome`,`.isNone`,`.isDefined`,`.isEmpty`],other:[`Option.sequence(arr)`,`Option.traverse(arr, f)`]}},Either:{description:`Error handling with Left (error) or Right (success)`,interfaces:[`Functor`,`Monad`,`Foldable`,`Traversable`,`PromiseLike`],methods:{create:[`Right(v)`,`Left(e)`,`Either.right(v)`,`Either.left(e)`,`Either.void()`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(l, r)`,`.foldAsync(l, r)`,`.orElse(d)`,`.orThrow()`,`.match({Left, Right})`],check:[`.isRight`,`.isLeft`],other:[`Either.sequence(arr)`,`Either.traverse(arr, f)`,`Either.fromNullable(v, e)`]}},Try:{description:`Wrap operations that may throw - Success<T> or Failure`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Matchable`,`Serializable`,`Traversable`],methods:{create:[`Try(() => expr)`,`Try.success(v)`,`Try.failure(e)`,`Try.fromPromise(p)`],transform:[`.map(f)`,`.flatMap(f)`,`.recover(f)`,`.recoverWith(f)`],extract:[`.fold(f, s)`,`.foldAsync(f, s)`,`.orElse(d)`,`.orThrow()`,`.toOption()`,`.toEither()`],check:[`.isSuccess`,`.isFailure`],other:[`Try.sequence(arr)`,`Try.traverse(arr, f)`]}},List:{description:`Immutable array with functional operations`,interfaces:[`Functor`,`Monad`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`List([...])`,`List.of(...)`,`List.empty()`],transform:[`.map(f)`,`.flatMap(f)`,`.filter(p)`,`.take(n)`,`.takeWhile(p)`,`.takeRight(n)`,`.drop(n)`,`.dropWhile(p)`,`.concat(list)`,`.reverse()`,`.distinct()`,`.sorted()`,`.sortBy(f)`,`.zip(list)`,`.zipWithIndex()`,`.prepend(v)`,`.slice(s, e)`],extract:[`.fold(z, f)`,`.reduce(f)`,`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.indexOf(v)`,`.toArray()`],check:[`.isEmpty`,`.nonEmpty`,`.size`,`.contains(v)`],other:[`.groupBy(f)`,`.partition(p)`,`.span(p)`]}},Set:{description:`Immutable set of unique values`,interfaces:[`Functor`,`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Set([...])`,`Set.of(...)`,`Set.empty()`],transform:[`.map(f)`,`.filter(p)`,`.union(s)`,`.intersection(s)`,`.difference(s)`,`.add(v)`],extract:[`.fold(z, f)`,`.toArray()`],check:[`.has(v)`,`.isEmpty`,`.size`]}},Obj:{description:`Immutable object wrapper with fluent operations`,interfaces:[`KVTraversable`,`Foldable`,`Matchable`,`Extractable`,`Serializable`,`Reshapeable`,`Doable`],methods:{create:[`Obj({...})`,`Obj.of({...})`,`Obj.empty()`],transform:[`.set(k, v)`,`.assign(partial)`,`.merge(obj)`,`.when(cond, partial)`,`.omit(...keys)`,`.pick(...keys)`,`.map(f)`,`.flatMap(f)`],extract:[`.get(k)`,`.value()`,`.keys()`,`.values()`,`.entries()`,`.fold(n, s)`,`.match({Obj})`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Map:{description:`Immutable key-value store`,interfaces:[`KVTraversable`,`Collection`,`Serializable`],methods:{create:[`Map([[k, v], ...])`,`Map.of([k, v], ...)`,`Map.empty()`],transform:[`.set(k, v)`,`.delete(k)`,`.map(f)`,`.filter(p)`,`.add(k, v)`],extract:[`.get(k)`,`.keys()`,`.values()`,`.entries()`,`.fold(z, f)`],check:[`.has(k)`,`.isEmpty`,`.size`]}},Lazy:{description:`Deferred computation with memoization`,interfaces:[`Functor`,`Monad`,`Foldable`,`Extractable`,`Serializable`,`Traversable`],methods:{create:[`Lazy(() => expr)`],transform:[`.map(f)`,`.flatMap(f)`],extract:[`.fold(n, s)`,`.orElse(d)`,`.orThrow()`,`.get()`],check:[`.isEvaluated`]}},LazyList:{description:`Lazy sequences for large/infinite data`,interfaces:[`Functor`,`Monad`,`Iterable`],methods:{create:[`LazyList.from(iter)`,`LazyList.range(start, end)`,`LazyList.infinite(f)`],transform:[`.map(f)`,`.filter(p)`,`.take(n)`,`.takeRight(n)`,`.drop(n)`,`.takeWhile(p)`,`.dropWhile(p)`,`.concat(ll)`,`.reverse()`,`.distinct()`,`.zip(ll)`,`.zipWithIndex()`],extract:[`.head`,`.headOption`,`.tail`,`.last`,`.lastOption`,`.init`,`.toArray()`],check:[`.isEmpty`]}},Task:{description:`Async operations with cancellation and progress tracking. Returns TaskOutcome<T> (Ok/Err) which implements Functor, AsyncMonad, Foldable, Extractable, Serializable`,interfaces:[],methods:{create:[`Task(params).Async(fn, errFn)`,`Task(params).Sync(fn, errFn)`,`Task.ok(value)`,`Task.err(error)`,`Task.fromEither(either)`,`Task.fromTry(try)`,`Task.fromPromise(fn)`,`Task.fromNodeCallback(fn)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.fold(onErr, onOk)`,`.match({Ok, Err})`,`.orElse(v)`,`.orThrow()`,`.toEither()`,`.toOption()`],other:[`Task.cancellable(fn)`,`Task.withProgress(fn, onProgress)`,`Task.race(tasks, timeout?)`,`Task.getErrorChain(error)`,`Task.formatErrorChain(error)`]}},IO:{description:`Lazy effect type with typed errors and dependency injection`,interfaces:[`Functor`,`Monad`,`Foldable`,`Matchable`],methods:{create:[`IO(() => v)`,`IO.succeed(v)`,`IO.fail(e)`,`IO.sync(f)`,`IO.async(f)`,`IO.tryPromise({try, catch})`,`IO.fromEither(e)`,`IO.fromOption(o)`,`IO.fromTry(t)`],transform:[`.map(f)`,`.flatMap(f)`,`.tap(f)`,`.mapError(f)`,`.recover(v)`,`.recoverWith(f)`],extract:[`.run()`,`.runOrThrow()`,`.runSync()`,`.runSyncOrThrow()`,`.runExit()`,`.runOption()`,`.runTry()`,`.fold(onErr, onOk)`,`.match({failure, success})`],check:[],other:[`.catchTag(tag, f)`,`.catchAll(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`,`.delay(ms)`,`.zip(io)`,`.pipe(f)`,`IO.all([...])`,`IO.race([...])`,`IO.bracket(acquire, use, release)`,`IO.gen(function*() {...})`,`IO.Do.bind().map()`,`IO.service(Tag)`,`.provideService(Tag, impl)`,`.provideLayer(layer)`]}},Cond:{description:`Conditional expression builder - replace if-else chains`,interfaces:[],methods:{create:[`Cond<T>()`],other:[`.case(pred, result)`,`.otherwise(result)`,`.eval()`]}},Match:{description:`Pattern matching - replace switch statements`,interfaces:[],methods:{create:[`Match(value)`],other:[`.case(pattern, result)`,`.when(pred, result)`,`.default(result)`,`.done()`]}},Brand:{description:`Nominal typing without runtime overhead`,interfaces:[],methods:{create:[`Brand<K, T>(value)`],extract:[`.unwrap()`,`.toString()`]}},ValidatedBrand:{description:`Branded types with runtime validation`,interfaces:[],methods:{create:[`ValidatedBrand(validator)`,`.of(v)`,`.from(v)`,`.unsafeOf(v)`],check:[`.is(v)`],other:[`.refine(validator)`]}},Tuple:{description:`Fixed-size typed array`,interfaces:[`Typeable`,`Valuable`,`Iterable`],methods:{create:[`Tuple([a, b, ...])`,`Tuple.of(a, b, ...)`],extract:[`.first`,`.second`,`.toArray()`],transform:[`.map(f)`]}},Stack:{description:`Immutable LIFO stack`,interfaces:[`Foldable`,`Collection`,`Serializable`,`Traversable`],methods:{create:[`Stack()`,`Stack.of(...)`],transform:[`.push(v)`,`.pop()`],extract:[`.peek()`,`.toArray()`],check:[`.isEmpty`,`.size`]}},Http:{description:`HTTP fetch wrapper returning IO<never, HttpError, HttpResponse<unknown>> by default. Provide a validate function to get typed responses (BYOV: bring your own validator). Works with Zod, TypeBox, Valibot, or manual validators.`,interfaces:[],methods:{create:[`Http.get(url, { validate }?)`,`Http.post(url, { body, validate }?)`,`Http.put(url, { body, validate }?)`,`Http.patch(url, { body, validate }?)`,`Http.delete(url, { validate }?)`,`Http.request({ url, validate })`,`Http.client(config)`],transform:[`.map(f)`,`.flatMap(f)`,`.retry(n)`,`.retryWithDelay(n, ms)`,`.timeout(ms)`],extract:[`.run()`,`.runOrThrow()`,`.runOption()`,`.runTry()`],check:[],other:[`.catchTag(tag, handler)`,`.catchAll(handler)`,`.mapError(f)`,`.recover(fallback)`]}},HttpError:{description:`Three-variant ADT for HTTP failures: NetworkError | HttpStatusError | DecodeError`,interfaces:[],methods:{create:[`HttpError.networkError(url, method, cause)`,`HttpError.httpStatusError(url, method, status, statusText, body)`,`HttpError.decodeError(url, method, body, cause)`],check:[`HttpError.isNetworkError(e)`,`HttpError.isHttpStatusError(e)`,`HttpError.isDecodeError(e)`],other:[`HttpError.match(error, { NetworkError, HttpStatusError, DecodeError })`]}}},n={Functor:{description:`Transform contained values`,methods:[`.map<B>(f: A => B): Functor<B>`]},Applicative:{extends:`Functor`,description:`Apply wrapped functions`,methods:[`.ap<B>(ff: Applicative<A => B>): Applicative<B>`]},Monad:{extends:`Applicative`,description:`Chain operations returning wrapped values`,methods:[`.flatMap<B>(f: A => Monad<B>): Monad<B>`]},Foldable:{description:`Extract via pattern matching`,methods:[`.fold<B>(empty: () => B, f: A => B): B`,`.foldLeft<B>(z: B, op: (B, A) => B): B`,`.foldRight<B>(z: B, op: (A, B) => B): B`]},Extractable:{description:`Get contained value with fallback`,methods:[`.orElse(d: T): T`,`.orThrow(e?: Error): T`,`.orNull(): T | null`,`.orUndefined(): T | undefined`]},Matchable:{description:`Pattern match on type variants`,methods:[`.match<R>(patterns: Record<Tag, Handler>): R`]},Traversable:{description:`Iterate and check contents`,methods:[`.size: number`,`.isEmpty: boolean`,`.contains(v: A): boolean`,`.reduce<B>(f, init): B`]},Collection:{description:`Collection operations`,methods:[`.toArray(): A[]`,`.forEach(f: A => void): void`]},Serializable:{description:`Convert to string formats`,methods:[`.serialize().toJSON(): string`,`.serialize().toYAML(): string`]}},r={Core:[`Option`,`Either`,`Try`,`Obj`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`,`Http`,`HttpError`],Utility:[`Lazy`,`Cond`,`Match`,`Brand`,`ValidatedBrand`]},i={Option:`export interface Option<out T extends Type>
|
|
2
2
|
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
3
3
|
/** The contained value (undefined for None) */
|
|
4
4
|
readonly value: T | undefined
|
|
@@ -297,7 +297,15 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
297
297
|
orNull: () => T | null
|
|
298
298
|
orUndefined: () => T | undefined
|
|
299
299
|
toOption: () => Option<T>
|
|
300
|
-
|
|
300
|
+
/**
|
|
301
|
+
* Converts to Either<E, T>. Failure becomes Left(builder(error)) when given a function,
|
|
302
|
+
* or Left(leftValue) when given a value. Success becomes Right(value).
|
|
303
|
+
*
|
|
304
|
+
* Prefer the function form to thread the underlying Error's context into the Left:
|
|
305
|
+
*
|
|
306
|
+
* Try.fromYAML(text).toEither((e) => \`parse failed: \${e.message}\`)
|
|
307
|
+
*/
|
|
308
|
+
toEither: <E extends Type>(leftOrBuilder: E | ((err: Error) => E)) => Either<E, T>
|
|
301
309
|
toTry: () => Try<T>
|
|
302
310
|
map: <U>(f: (value: T) => U) => Try<U>
|
|
303
311
|
ap: <U>(ff: Try<(value: T) => U>) => Try<U>
|
|
@@ -511,7 +511,15 @@ interface Try<out T> extends FunctypeSum<T, TypeNames>, Extractable<T>, Pipe<T>,
|
|
|
511
511
|
orNull: () => T | null;
|
|
512
512
|
orUndefined: () => T | undefined;
|
|
513
513
|
toOption: () => Option<T>;
|
|
514
|
-
|
|
514
|
+
/**
|
|
515
|
+
* Converts to Either<E, T>. Failure becomes Left(builder(error)) when given a function,
|
|
516
|
+
* or Left(leftValue) when given a value. Success becomes Right(value).
|
|
517
|
+
*
|
|
518
|
+
* Prefer the function form to thread the underlying Error's context into the Left:
|
|
519
|
+
*
|
|
520
|
+
* Try.fromYAML(text).toEither((e) => `parse failed: ${e.message}`)
|
|
521
|
+
*/
|
|
522
|
+
toEither: <E extends Type>(leftOrBuilder: E | ((err: Error) => E)) => Either<E, T>;
|
|
515
523
|
toTry: () => Try<T>;
|
|
516
524
|
map: <U>(f: (value: T) => U) => Try<U>;
|
|
517
525
|
ap: <U>(ff: Try<(value: T) => U>) => Try<U>;
|
|
@@ -610,6 +618,21 @@ declare const Try: (<T>(f: () => T) => Try<T>) & {
|
|
|
610
618
|
* @returns Try instance
|
|
611
619
|
*/
|
|
612
620
|
fromBinary: <T>(binary: string) => Try<T>;
|
|
621
|
+
/**
|
|
622
|
+
* Combines an array of Trys into a single Try containing an array.
|
|
623
|
+
* Short-circuits on the first Failure, preserving its error.
|
|
624
|
+
* @param tries - Array of Try values
|
|
625
|
+
* @returns Success with array of values, or first Failure
|
|
626
|
+
*/
|
|
627
|
+
sequence: <T>(tries: Try<T>[]) => Try<T[]>;
|
|
628
|
+
/**
|
|
629
|
+
* Maps an array through a function returning Try, then sequences the results.
|
|
630
|
+
* Short-circuits on the first Failure.
|
|
631
|
+
* @param arr - Array of values
|
|
632
|
+
* @param f - Function returning Try
|
|
633
|
+
* @returns Success with array of mapped values, or first Failure
|
|
634
|
+
*/
|
|
635
|
+
traverse: <T, U>(arr: ReadonlyArray<T>, f: (value: T, index: number) => Try<U>) => Try<U[]>;
|
|
613
636
|
};
|
|
614
637
|
//#endregion
|
|
615
638
|
//#region src/reshapeable/Reshapeable.d.ts
|
|
@@ -666,7 +689,8 @@ interface Reshapeable<out T extends Type> {
|
|
|
666
689
|
* - Option: Some → Right, None → Left(leftValue)
|
|
667
690
|
* - Either: returns self
|
|
668
691
|
* - List: non-empty → Right(head), empty → Left(leftValue)
|
|
669
|
-
* - Try: Success → Right, Failure → Left(
|
|
692
|
+
* - Try: Success → Right, Failure → Left(leftValue). Try also accepts a builder
|
|
693
|
+
* `(err: Error) => E` to thread the underlying Error's context into the Left.
|
|
670
694
|
*
|
|
671
695
|
* @param leftValue - The value to use for the Left case when the source is empty/none/failure
|
|
672
696
|
* @returns An Either with the value as Right or the provided leftValue as Left
|
|
@@ -4629,6 +4653,22 @@ declare const Option: (<T extends Type>(value: T | null | undefined) => Option<T
|
|
|
4629
4653
|
* @returns Option instance
|
|
4630
4654
|
*/
|
|
4631
4655
|
fromBinary: <T>(binary: string) => Option<T>;
|
|
4656
|
+
/**
|
|
4657
|
+
* Combines an array of Options into a single Option containing an array.
|
|
4658
|
+
* Short-circuits on the first None.
|
|
4659
|
+
* @param options - Array of Option values
|
|
4660
|
+
* @returns Some with array of values, or None if any element is None
|
|
4661
|
+
*/
|
|
4662
|
+
sequence: <T extends Type>(options: Option<T>[]) => Option<T[]>;
|
|
4663
|
+
/**
|
|
4664
|
+
* Maps an array through a function returning Option, then sequences the results.
|
|
4665
|
+
* Short-circuits on the first None — `f` is not invoked for elements after the
|
|
4666
|
+
* first None result.
|
|
4667
|
+
* @param arr - Array of values
|
|
4668
|
+
* @param f - Function returning Option
|
|
4669
|
+
* @returns Some with array of mapped values, or None if any application returned None
|
|
4670
|
+
*/
|
|
4671
|
+
traverse: <T extends Type, U extends Type>(arr: ReadonlyArray<T>, f: (value: T, index: number) => Option<U>) => Option<U[]>;
|
|
4632
4672
|
};
|
|
4633
4673
|
//#endregion
|
|
4634
4674
|
//#region src/list/List.d.ts
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
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 Map, $n as reduceWiden, $t as TypedErrorContext, A as Collection, An as Cond, At as Task, B as SerializationResult, Bn as NonEmptyString, Bt as ContextServices, C as isRight, Cn as isTaggedThrowable, Ct as HttpClientConfig, D as Functype, Dn as Base, Dt as IO, E as FunctypeSum, En as ThrowableType, Et as TestContext, F as Some, Fn as BoundedNumber, Ft as LayerInput, G as fromJSON, Gn as UUID, Gt as FormValidation, H as createSerializationCompanion, Hn as PatternString, Ht as Tag, I as Stack, In as BoundedString, It as LayerOutput, J as Obj, Jn as ValidatedBrandCompanion, Jt as Validator, K as fromYAML, Kn as UrlString, Kt as Validation, L as Valuable, Ln as EmailAddress, Lt as Exit, M as None, Mn as InstanceType, Mt as UIO, N as Option, Nn as isCompanion, Nt as Layer, O as FunctypeBase, On as Match, Ot as InterruptedError, P as OptionConstructor, Pn as Companion, Pt as LayerError, Q as ESMapType, Qn as reduceRightWiden, Qt as TypedError, R as ValuableParams, Rn as ISO8601Date, Rt as ExitTag, S as isLeft, Sn as createCancellationTokenSource, St as HttpClient, T as tryCatchAsync, Tn as Throwable, Tt as TestClockTag, U as createSerializer, Un as PositiveInteger, Ut as TagService, V as createCustomSerializer, Vn as NonNegativeNumber, Vt as HasService, W as fromBinary, Wn as PositiveNumber, Wt as FieldValidation, X as MatchableUtils, Xn as TypeNames, Xt as ErrorMessage, Y as Matchable, Yn as Try, Yt as ErrorCode, Z as ESMap, Zn as Widen, Zt as ErrorStatus, _ as Right, _n as TaskMetadata, _t as DecodeError, a as EmptyListError, an as formatError, ar as CollectionOps, at as HKT, b as TypeCheckLeft, bn as TaskResult, bt as HttpStatusError, c as LeftError, cn as Async, cr as Extractable, ct as OptionKind, d as isDoCapable, dn as Err, dr as Doable, dt as FoldableUtils, en as ErrorChainElement, er as Promisable, et as KVTraversable, f as unwrap, fn as Ok, fr as ParseError, ft as Http, g as LeftOf, gn as TaskFailure, gt as ParseMode, h as Left, hn as Task$1, ht as HttpResponse, i as DoGenerator, in as createErrorSerializer, ir as Monad, it as EitherKind, j as List, jn as CompanionMethods, jt as TimeoutError, k as FunctypeCollection, kn as UntypedMatch, kt as RIO, l as LeftErrorType, ln as CancellationToken, lr as isExtractable, lt as TryKind, m as EitherBase, mn as TaggedThrowable, mt as HttpRequestOptions, n as Do, nn as ErrorWithTaskInfo, nr as AsyncMonad, nt as Lazy, o as FailureError, on as formatStackTrace, or as ContainerOps, ot as Kind, p as Either, pn as Sync, pt as HttpMethodOptions, q as Ref, qn as ValidatedBrand, qt as ValidationRule, r as DoAsync, rn as TaskErrorInfo, rr as Functor, rt as Identity, s as FailureErrorType, sn as safeStringify, sr as LazyList, st as ListKind, t as $, tn as ErrorFormatterOptions, tr as Applicative, tt as Traversable, u as NoneError, un as CancellationTokenSource, ur as DoResult, ut as UniversalContainer, v as RightOf, vn as TaskOutcome, vt as HttpError, w as tryCatch, wn as NAME, wt as TestClock, x as TypeCheckRight, xn as TaskSuccess, xt as NetworkError, y as TestEither, yn as TaskParams, yt as HttpMethod, z as Set, zn as IntegerNumber, zt as Context } from "./index-
|
|
2
|
+
import { $ as Map, $n as reduceWiden, $t as TypedErrorContext, A as Collection, An as Cond, At as Task, B as SerializationResult, Bn as NonEmptyString, Bt as ContextServices, C as isRight, Cn as isTaggedThrowable, Ct as HttpClientConfig, D as Functype, Dn as Base, Dt as IO, E as FunctypeSum, En as ThrowableType, Et as TestContext, F as Some, Fn as BoundedNumber, Ft as LayerInput, G as fromJSON, Gn as UUID, Gt as FormValidation, H as createSerializationCompanion, Hn as PatternString, Ht as Tag, I as Stack, In as BoundedString, It as LayerOutput, J as Obj, Jn as ValidatedBrandCompanion, Jt as Validator, K as fromYAML, Kn as UrlString, Kt as Validation, L as Valuable, Ln as EmailAddress, Lt as Exit, M as None, Mn as InstanceType, Mt as UIO, N as Option, Nn as isCompanion, Nt as Layer, O as FunctypeBase, On as Match, Ot as InterruptedError, P as OptionConstructor, Pn as Companion, Pt as LayerError, Q as ESMapType, Qn as reduceRightWiden, Qt as TypedError, R as ValuableParams, Rn as ISO8601Date, Rt as ExitTag, S as isLeft, Sn as createCancellationTokenSource, St as HttpClient, T as tryCatchAsync, Tn as Throwable, Tt as TestClockTag, U as createSerializer, Un as PositiveInteger, Ut as TagService, V as createCustomSerializer, Vn as NonNegativeNumber, Vt as HasService, W as fromBinary, Wn as PositiveNumber, Wt as FieldValidation, X as MatchableUtils, Xn as TypeNames, Xt as ErrorMessage, Y as Matchable, Yn as Try, Yt as ErrorCode, Z as ESMap, Zn as Widen, Zt as ErrorStatus, _ as Right, _n as TaskMetadata, _t as DecodeError, a as EmptyListError, an as formatError, ar as CollectionOps, at as HKT, b as TypeCheckLeft, bn as TaskResult, bt as HttpStatusError, c as LeftError, cn as Async, cr as Extractable, ct as OptionKind, d as isDoCapable, dn as Err, dr as Doable, dt as FoldableUtils, en as ErrorChainElement, er as Promisable, et as KVTraversable, f as unwrap, fn as Ok, fr as ParseError, ft as Http, g as LeftOf, gn as TaskFailure, gt as ParseMode, h as Left, hn as Task$1, ht as HttpResponse, i as DoGenerator, in as createErrorSerializer, ir as Monad, it as EitherKind, j as List, jn as CompanionMethods, jt as TimeoutError, k as FunctypeCollection, kn as UntypedMatch, kt as RIO, l as LeftErrorType, ln as CancellationToken, lr as isExtractable, lt as TryKind, m as EitherBase, mn as TaggedThrowable, mt as HttpRequestOptions, n as Do, nn as ErrorWithTaskInfo, nr as AsyncMonad, nt as Lazy, o as FailureError, on as formatStackTrace, or as ContainerOps, ot as Kind, p as Either, pn as Sync, pt as HttpMethodOptions, q as Ref, qn as ValidatedBrand, qt as ValidationRule, r as DoAsync, rn as TaskErrorInfo, rr as Functor, rt as Identity, s as FailureErrorType, sn as safeStringify, sr as LazyList, st as ListKind, t as $, tn as ErrorFormatterOptions, tr as Applicative, tt as Traversable, u as NoneError, un as CancellationTokenSource, ur as DoResult, ut as UniversalContainer, v as RightOf, vn as TaskOutcome, vt as HttpError, w as tryCatch, wn as NAME, wt as TestClock, x as TypeCheckRight, xn as TaskSuccess, xt as NetworkError, y as TestEither, yn as TaskParams, yt as HttpMethod, z as Set, zn as IntegerNumber, zt as Context } from "./index-P2ubIONw.js";
|
|
3
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-De-FhPDq.js";
|
|
4
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, DecodeError, Do, DoAsync, DoGenerator, DoResult, Doable, ESMap, ESMapType, Either, EitherBase, 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, FunctypeSum, HKT, HasService, Http, HttpClient, HttpClientConfig, HttpError, HttpError as HttpErrors, HttpMethod, HttpMethodOptions, HttpRequestOptions, HttpResponse, HttpStatusError, IO, IO as IOType, Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, KVTraversable, Kind, Layer, Layer as LayerType, LayerError, LayerInput, LayerOutput, Lazy, Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, Map, Match, Matchable, MatchableUtils, Monad, NAME, NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, Promisable, RIO, Ref, Ref as RefType, Right, RightOf, 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, Widen, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, reduceRightWiden, reduceWiden, 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,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 _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as V,U as H,V as U,W,X as G,Y as K,Z as q,_ as J,_t as Y,a as X,at as Z,b as Q,bt as $,c as ee,ct as te,d as ne,dt as re,et as ie,f as ae,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as fe,j as pe,jt as me,k as he,kt as ge,l as _e,lt as ve,m as ye,mt as be,n as xe,nt as Se,o as Ce,ot as we,p as Te,pt as Ee,q as De,r as Oe,rt as ke,s as Ae,st as je,t as Me,tt as Ne,u as Pe,ut as Fe,v as Ie,vt as Le,w as Re,wt as ze,x as Be,xt as Ve,y as He,yt as Ue,z as We}from"./src-
|
|
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 _,Ft as v,G as y,H as b,I as x,It as S,J as C,K as w,L as T,Lt as E,M as D,Mt as O,N as k,Nt as A,O as j,Ot as M,P as N,Pt as P,Q as F,R as I,Rt as L,S as R,St as z,T as B,Tt as V,U as H,V as U,W,X as G,Y as K,Z as q,_ as J,_t as Y,a as X,at as Z,b as Q,bt as $,c as ee,ct as te,d as ne,dt as re,et as ie,f as ae,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as fe,j as pe,jt as me,k as he,kt as ge,l as _e,lt as ve,m as ye,mt as be,n as xe,nt as Se,o as Ce,ot as we,p as Te,pt as Ee,q as De,r as Oe,rt as ke,s as Ae,st as je,t as Me,tt as Ne,u as Pe,ut as Fe,v as Ie,vt as Le,w as Re,wt as ze,x as Be,xt as Ve,y as He,yt as Ue,z as We}from"./src-DpQmW2iX.js";import{r as Ge,t as Ke}from"./Tuple-DY00RBep.js";export{pe as $,De as Base,q as BoundedNumber,F as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ge as Companion,K as Cond,d as Context,D as Do,k as DoAsync,Ce as ESMap,Fe as Either,s as EmailAddress,N as EmptyListError,u as Err,R as Exit,_ as FailureError,Pe as FoldableUtils,_e as HKT,ne as Http,Te as HttpClient,ae as HttpErrors,He as IO,ie as ISO8601Date,ee as Identity,Ne as IntegerNumber,Q as InterruptedError,Ie as Layer,Ae as Lazy,f as LazyList,re as Left,x as LeftError,Ue as List,X as Map,C as Match,de as MatchableUtils,y as NAME,Se as NonEmptyString,ke as NonNegativeNumber,M as None,T as NoneError,Oe as Obj,U as Ok,ge as Option,l as OptionConstructor,L as ParseError,fe as PatternString,Z as PositiveInteger,we as PositiveNumber,ze as Ref,oe as Right,V as Set,me as Some,xe as Stack,J as Tag,b as Task,ye as TestClock,le as TestClockTag,se as TestContext,w as Throwable,Be as TimeoutError,z as Try,Ke as Tuple,Ee as TypeCheckLeft,be as TypeCheckRight,$ as Typeable,h as TypedError,je as UUID,te as UrlString,ve as ValidatedBrand,B as Validation,Me as Valuable,i as createBrander,H as createCancellationTokenSource,O as createCustomSerializer,p as createErrorSerializer,A as createSerializationCompanion,P as createSerializer,j as formatError,he as formatStackTrace,v as fromBinary,S as fromJSON,E as fromYAML,a as hasBrand,G as isCompanion,I as isDoCapable,Re as isExtractable,ue as isLeft,ce as isRight,W as isTaggedThrowable,Ve as isTypeable,g as reduceRightWiden,m as reduceWiden,c as safeStringify,Y as tryCatch,Le as tryCatchAsync,We as unwrap,o as unwrapBrand};
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { j as List } from "../index-
|
|
1
|
+
import { j as List } from "../index-P2ubIONw.js";
|
|
2
2
|
export { List };
|
package/dist/list/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{yt as e}from"../src-
|
|
1
|
+
import{yt as e}from"../src-DpQmW2iX.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as Map } from "../index-
|
|
1
|
+
import { $ as Map } from "../index-P2ubIONw.js";
|
|
2
2
|
export { Map };
|
package/dist/map/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"../src-
|
|
1
|
+
import{a as e}from"../src-DpQmW2iX.js";export{e as Map};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-
|
|
1
|
+
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-P2ubIONw.js";
|
|
2
2
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{At as e,Ot as t,jt as n,kt as r}from"../src-
|
|
1
|
+
import{At as e,Ot as t,jt as n,kt as r}from"../src-DpQmW2iX.js";export{t as None,r as Option,e as OptionConstructor,n as Some};
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { z as Set } from "../index-
|
|
1
|
+
import { z as Set } from "../index-P2ubIONw.js";
|
|
2
2
|
export { Set };
|
package/dist/set/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Tt as e}from"../src-
|
|
1
|
+
import{Tt as e}from"../src-DpQmW2iX.js";export{e as Set};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import{Brand as e}from"./branded/index.js";import{i as t,n,r,t as i}from"./Tuple-DY00RBep.js";const a=e=>{let t=Error(e);return t.name=`ParseError`,t},o=(e,t)=>({toJSON:()=>JSON.stringify({_tag:e,value:t}),toYAML:()=>`_tag: ${e}\nvalue: ${n(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:e,value:t})).toString(`base64`)}),s=e=>({toJSON:()=>JSON.stringify(e),toYAML:()=>Object.entries(e).map(([e,t])=>`${e}: ${n(t)}`).join(`
|
|
2
2
|
`),toBinary:()=>Buffer.from(JSON.stringify(e)).toString(`base64`)}),c=(e,t)=>t(JSON.parse(e)),l=(e,t)=>{let n=e.split(`
|
|
3
3
|
`),r={};for(let e of n){let t=e.indexOf(`: `);if(t===-1)continue;let n=e.substring(0,t),i=e.substring(t+2);if(!i){r[n]=null;continue}try{r[n]=i===`null`?null:JSON.parse(i)}catch{r[n]=i}}return t(r)},u=(e,t)=>c(Buffer.from(e,`base64`).toString(),t),ee=e=>({fromJSON:t=>c(t,e),fromYAML:t=>l(t,e),fromBinary:t=>u(t,e)}),d=e=>({[Symbol.toStringTag]:`Option`,_tag:`Some`,value:e,isEmpty:!1,isSome(){return!0},isNone(){return!1},orElse:t=>e,orThrow:()=>e,or:t=>d(e),orNull:()=>e,orUndefined:()=>e,map:t=>d(t(e)),ap:t=>t._tag===`Some`&&t.value?d(t.value(e)):f,filter(t){return t(e)?d(e):f},count:t=>+!!t(e),find:t=>t(e)?d(e):f,exists:t=>t(e),forEach:t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Some(e),flatMap:t=>t(e),flatMapAsync:async t=>await t(e),reduce:t=>e,reduceRight:t=>e,foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),contains:t=>t===e,toList:()=>C([e]),size:1,toOption:()=>d(e),toEither:t=>w(e),toTry:()=>x(()=>e),toPromise:()=>Promise.resolve(e),toString:()=>`Some(${n(e)})`,toValue:()=>({_tag:`Some`,value:e}),pipe:t=>t(e),serialize:()=>o(`Some`,e),doUnwrap(){return{ok:!0,value:e}}}),f={[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=>f,ap:e=>f,filter(e){return f},count:e=>0,find:e=>f,exists:e=>!1,forEach:e=>{},flatMap:e=>f,flatMapAsync:e=>Promise.resolve(f),reduce:e=>{throw Error(`Cannot reduce an empty Option`)},reduceRight:e=>{throw Error(`Cannot reduceRight an empty Option`)},fold:(e,t)=>e(),foldAsync:async(e,t)=>e(),match:e=>e.None(),foldLeft:e=>()=>e,foldRight:e=>()=>e,contains:()=>!1,toList:()=>C([]),size:0,toOption:()=>f,toEither:e=>T(e),toTry:()=>x(()=>{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:()=>o(`None`,null),doUnwrap(){return{ok:!1,empty:!0}}},p=()=>f,te=e=>e==null?p():d(e),ne={from:e=>m(e),none:()=>p(),isSome:e=>e.isSome(),isNone:e=>e.isNone(),fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Some`?d(t.value):p()},fromYAML:e=>{let t=e.split(`
|
|
4
|
-
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return p();let i=r===`null`?null:JSON.parse(r);return n===`Some`?d(i):p()},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ne.fromJSON(t)}},m=r(te,ne),re=(e,t)=>e.reduce(t),ie=(e,t)=>e.reduceRight(t),h=globalThis.Set,g=e=>{let t=new h(e),n={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>t[Symbol.iterator](),add:e=>g([...t,e]),remove:e=>{let n=new h(t);return n.delete(e),g(n)},contains:e=>t.has(e),has:e=>t.has(e),map:e=>g(Array.from(t).map(e)),ap:e=>{let n=new h;for(let r of t)for(let t of e)n.add(t(r));return g(n)},flatMap:e=>{let n=new h;for(let r of t)for(let t of e(r))n.add(t);return g(n)},flatMapAsync:async e=>{let n=new h;for(let r of t){let t=await e(r);for(let e of t)n.add(e)}return g(n)},fold:(e,n)=>{let r=e;for(let e of t)r=n(r,e);return r},foldLeft:e=>n=>{let r=e;for(let e of t)r=n(r,e);return r},foldRight:e=>n=>Array.from(t).reduceRight((e,t)=>n(t,e),e),get size(){return t.size},get isEmpty(){return t.size===0},reduce:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduce empty Set`);return re(n,e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return ie(n,e)},count:e=>{let n=0;for(let r of t)e(r)&&n++;return n},find:e=>{for(let n of t)if(e(n))return m(n);return m(null)},exists:e=>{for(let n of t)if(e(n))return!0;return!1},forEach:e=>{t.forEach(e)},filter:e=>{let n=new h;for(let r of t)e(r)&&n.add(r);return g(n)},filterNot:e=>{let n=new h;for(let r of t)e(r)||n.add(r);return g(n)},drop:e=>g(Array.from(t).slice(e)),dropRight:e=>g(Array.from(t).slice(0,-e)),dropWhile:e=>{let n=Array.from(t),r=n.findIndex(t=>!e(t));return g(r===-1?[]:n.slice(r))},flatten:()=>{let e=new h;for(let n of t)if(Array.isArray(n))for(let t of n)e.add(t);else if(n&&typeof n==`object`&&Symbol.iterator in n)for(let t of n)e.add(t);else e.add(n);return g(e)},get head(){return Array.from(t)[0]},get headOption(){let e=Array.from(t)[0];return m(e)},take:e=>g(Array.from(t).slice(0,Math.max(0,e))),takeWhile:e=>{let n=Array.from(t),r=[];for(let t of n){if(!e(t))break;r.push(t)}return g(r)},takeRight:e=>{let n=Array.from(t);return g(e<=0?[]:n.slice(-e))},get last(){let e=Array.from(t);return e[e.length-1]},get lastOption(){let e=Array.from(t);return m(e[e.length-1])},get tail(){return g(Array.from(t).slice(1))},get init(){let e=Array.from(t);return g(e.length===0?[]:e.slice(0,-1))},toList:()=>C(Array.from(t)),toSet:()=>n,toArray:()=>Array.from(t),toString:()=>`Set(${Array.from(t).toString()})`,toValue:()=>({_tag:`Set`,value:Array.from(t)}),pipe:e=>e(Array.from(t)),serialize:()=>o(`Set`,Array.from(t))};return n},ae=e=>g(e),oe=g([]),se={empty:()=>oe,of:(...e)=>g(e),fromJSON:e=>ce(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
5
|
-
`)[1]?.split(`: `)[1];return ce(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return se.fromJSON(t)}},ce=r(ae,se),le=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e?(t=n,!0):!1},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(le,{of:e=>le(e)}),ue=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},de=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=ue(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=ue(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=ue(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=ue(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>{let t=Array.from(e);return{toJSON:()=>JSON.stringify({_tag:`LazyList`,value:t}),toYAML:()=>`_tag: LazyList\nvalue: ${n(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`LazyList`,value:t})).toString(`base64`)}},toString:()=>{let t=[],n=ue(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},fe=r(e=>v(e),{empty:()=>v([]),of:e=>v([e]),from:(...e)=>v(e),iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=ue(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${n(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toTry:()=>y(e),pipe:t=>t(e),serialize:()=>o(`Success`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t??e},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(e),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${n(e)}))`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toOption:()=>m(null),toList:()=>C([]),toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>s({_tag:`Failure`,error:e.message,stack:e.stack}),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),pe=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},me={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t._tag===`Success`)return y(t.value);{let e=Error(t.error);return t.stack&&(e.stack=t.stack),b(e)}},fromYAML:e=>{let t=e.split(`
|
|
6
|
-
`),n=t[0]?.split(`: `)[1];if(!n)return b(Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];return e?y(JSON.parse(e)):b(Error(`Invalid YAML format for Try Success`))}else{let e=t[1]?.split(`: `)[1];if(!e)return b(Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),b(i)}},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return me.fromJSON(t)}},x=r(pe,me);function he({_tag:e,impl:t}){return{...t,_tag:e}}function ge(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:t?e._tag===t:!0}const S=e=>{let t=Array.from(e??[]),r={[Symbol.toStringTag]:`List`,_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>S(t.map(e)),ap:e=>S(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>S(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async e=>S((await Promise.all(t.map(async t=>await e(t)))).flatMap(e=>Array.from(e))),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),filter:e=>S(t.filter(e)),filterNot:e=>S(t.filter(t=>!e(t))),filterType:e=>S(t.filter(t=>ge(t,e))),find:(e,n)=>m(t.find(t=>e(t)&&(n?ge(t,n):!0))),get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>re(t,e),reduceRight:e=>ie(t,e),fold:(e,n)=>t.reduce(n,e),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>S(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?r:S([...t.slice(0,e),...t.slice(e+1)]),add:e=>S([...t,e]),get:e=>m(t[e]),concat:e=>S([...t,...e.toArray()]),take:e=>S(t.slice(0,Math.max(0,e))),takeWhile:e=>{let n=[];for(let r of t){if(!e(r))break;n.push(r)}return S(n)},takeRight:e=>S(e<=0?[]:t.slice(-e)),get last(){return t[t.length-1]},get lastOption(){return t.length>0?m(t[t.length-1]):p()},get tail(){return S(t.slice(1))},get init(){return S(t.length===0?[]:t.slice(0,-1))},reverse:()=>S([...t].reverse()),indexOf:e=>t.indexOf(e),prepend:e=>S([e,...t]),distinct:()=>{let e=new globalThis.Set,n=[];for(let r of t)e.has(r)||(e.add(r),n.push(r));return S(n)},sorted:e=>S([...t].sort(e)),sortBy:(e,n)=>S([...t].sort((t,r)=>{let i=e(t),a=e(r);return n?n(i,a):i<a?-1:+(i>a)})),zip:e=>{let n=e.toArray(),r=Math.min(t.length,n.length),i=[];for(let e=0;e<r;e++)i.push([t[e],n[e]]);return S(i)},zipWithIndex:()=>S(t.map((e,t)=>[e,t])),groupBy:e=>{let n=new globalThis.Map;for(let r of t){let t=e(r),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new globalThis.Map;for(let[e,t]of n)r.set(e,S(t));return r},partition:e=>{let n=[],r=[];for(let i of t)e(i)?n.push(i):r.push(i);return[S(n),S(r)]},span:e=>{let n=t.findIndex(t=>!e(t));return n===-1?[S([...t]),S([])]:[S(t.slice(0,n)),S(t.slice(n))]},slice:(e,n)=>S(t.slice(e,n)),drop:e=>S(t.slice(e)),dropRight:e=>S(t.slice(0,-e)),dropWhile:e=>S(t.slice(t.findIndex(t=>!e(t)))),flatten:()=>S(t.flatMap(e=>Array.isArray(e)?e:[e])),toList:()=>r,toSet:()=>ce(t),toOption:()=>t.length>0?m(t[0]):p(),toEither:e=>t.length>0?w(t[0]):T(e),toTry:()=>t.length>0?x(()=>t[0]):x(()=>{throw Error(`Empty list`)}),toString:()=>`List(${n(t)})`,toValue:()=>({_tag:`List`,value:t}),pipe:e=>e([...t]),serialize:()=>o(`List`,t),doUnwrap(){return t.length===0?{ok:!1,empty:!0}:{ok:!0,value:t[0]}}};return r},_e=e=>S(e),ve=S([]),ye={empty:()=>ve,of:(...e)=>S(e),fromJSON:e=>C(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
4
|
+
`),n=t[0]?.split(`: `)[1],r=t[1]?.split(`: `)[1];if(!n||!r)return p();let i=r===`null`?null:JSON.parse(r);return n===`Some`?d(i):p()},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ne.fromJSON(t)},sequence:e=>e.reduce((e,t)=>e.isEmpty||t.isEmpty?p():d([...e.value,t.value]),d([])),traverse:(e,t)=>e.reduce((e,n,r)=>e.flatMap(e=>t(n,r).map(t=>[...e,t])),d([]))},m=r(te,ne),re=(e,t)=>e.reduce(t),ie=(e,t)=>e.reduceRight(t),h=globalThis.Set,g=e=>{let t=new h(e),n={[Symbol.toStringTag]:`FunctypeSet`,_tag:`Set`,[Symbol.iterator]:()=>t[Symbol.iterator](),add:e=>g([...t,e]),remove:e=>{let n=new h(t);return n.delete(e),g(n)},contains:e=>t.has(e),has:e=>t.has(e),map:e=>g(Array.from(t).map(e)),ap:e=>{let n=new h;for(let r of t)for(let t of e)n.add(t(r));return g(n)},flatMap:e=>{let n=new h;for(let r of t)for(let t of e(r))n.add(t);return g(n)},flatMapAsync:async e=>{let n=new h;for(let r of t){let t=await e(r);for(let e of t)n.add(e)}return g(n)},fold:(e,n)=>{let r=e;for(let e of t)r=n(r,e);return r},foldLeft:e=>n=>{let r=e;for(let e of t)r=n(r,e);return r},foldRight:e=>n=>Array.from(t).reduceRight((e,t)=>n(t,e),e),get size(){return t.size},get isEmpty(){return t.size===0},reduce:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduce empty Set`);return re(n,e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return ie(n,e)},count:e=>{let n=0;for(let r of t)e(r)&&n++;return n},find:e=>{for(let n of t)if(e(n))return m(n);return m(null)},exists:e=>{for(let n of t)if(e(n))return!0;return!1},forEach:e=>{t.forEach(e)},filter:e=>{let n=new h;for(let r of t)e(r)&&n.add(r);return g(n)},filterNot:e=>{let n=new h;for(let r of t)e(r)||n.add(r);return g(n)},drop:e=>g(Array.from(t).slice(e)),dropRight:e=>g(Array.from(t).slice(0,-e)),dropWhile:e=>{let n=Array.from(t),r=n.findIndex(t=>!e(t));return g(r===-1?[]:n.slice(r))},flatten:()=>{let e=new h;for(let n of t)if(Array.isArray(n))for(let t of n)e.add(t);else if(n&&typeof n==`object`&&Symbol.iterator in n)for(let t of n)e.add(t);else e.add(n);return g(e)},get head(){return Array.from(t)[0]},get headOption(){let e=Array.from(t)[0];return m(e)},take:e=>g(Array.from(t).slice(0,Math.max(0,e))),takeWhile:e=>{let n=Array.from(t),r=[];for(let t of n){if(!e(t))break;r.push(t)}return g(r)},takeRight:e=>{let n=Array.from(t);return g(e<=0?[]:n.slice(-e))},get last(){let e=Array.from(t);return e[e.length-1]},get lastOption(){let e=Array.from(t);return m(e[e.length-1])},get tail(){return g(Array.from(t).slice(1))},get init(){let e=Array.from(t);return g(e.length===0?[]:e.slice(0,-1))},toList:()=>C(Array.from(t)),toSet:()=>n,toArray:()=>Array.from(t),toString:()=>`Set(${Array.from(t).toString()})`,toValue:()=>({_tag:`Set`,value:Array.from(t)}),pipe:e=>e(Array.from(t)),serialize:()=>o(`Set`,Array.from(t))};return n},ae=e=>g(e),oe=g([]),se={empty:()=>oe,of:(...e)=>g(e),fromJSON:e=>ce(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
5
|
+
`)[1]?.split(`: `)[1];return ce(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return se.fromJSON(t)}},ce=r(ae,se),le=e=>{let t=e;return{get(){return t},set(e){t=e},update(e){t=e(t)},getAndSet(e){let n=t;return t=e,n},updateAndGet(e){return t=e(t),t},getAndUpdate(e){let n=t;return t=e(t),n},compareAndSet(e,n){return t===e?(t=n,!0):!1},modify(e){let[n,r]=e(t);return t=n,r}}},_=r(le,{of:e=>le(e)}),ue=(e=0)=>{let t=_(e),n=e;return{get:()=>t.get(),set:e=>t.set(e),increment:()=>t.updateAndGet(e=>e+1),decrement:()=>t.updateAndGet(e=>e-1),reset:()=>t.set(n),compareAndSet:(e,n)=>t.compareAndSet(e,n)}},de=()=>{let e=_([]);return{add:t=>e.update(e=>[...e,t]),addAll:t=>e.update(e=>[...e,...t]),build:()=>e.get(),clear:()=>e.set([]),size:()=>e.get().length}},v=e=>{let t={[Symbol.toStringTag]:`LazyList`,_tag:`LazyList`,[Symbol.iterator]:()=>e[Symbol.iterator](),map:t=>v((function*(){for(let n of e)yield t(n)})()),flatMap:t=>v((function*(){for(let n of e)yield*t(n)})()),filter:t=>v((function*(){for(let n of e)t(n)&&(yield n)})()),take:t=>v((function*(){let n=ue(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=ue(0);for(let r of e)n.get()>=t&&(yield r),n.increment()})()),takeWhile:t=>v((function*(){for(let n of e){if(!t(n))break;yield n}})()),dropWhile:t=>v((function*(){let n=_(!0);for(let r of e)n.get()&&t(r)||(n.set(!1),yield r)})()),concat:t=>v((function*(){yield*e,yield*t})()),zip:t=>v((function*(){let n=e[Symbol.iterator](),r=t[Symbol.iterator]();for(;;){let e=n.next(),t=r.next();if(e.done||t.done)break;yield[e.value,t.value]}})()),toList:()=>C(Array.from(e)),toArray:()=>Array.from(e),forEach:t=>{for(let n of e)t(n)},reduce:(t,n)=>{let r=_(n);for(let n of e)r.set(t(r.get(),n));return r.get()},find:t=>{for(let n of e)if(t(n))return m(n);return m.none()},some:t=>{for(let n of e)if(t(n))return!0;return!1},every:t=>{for(let n of e)if(!t(n))return!1;return!0},count:()=>{let t=ue(0);for(let n of e)t.increment();return t.get()},get head(){let t=e[Symbol.iterator]().next();return t.done?void 0:t.value},get headOption(){let t=e[Symbol.iterator]().next();return t.done?m.none():m(t.value)},get last(){let t;for(let n of e)t=n;return t},get lastOption(){let t=_(void 0),n=_(!1);for(let r of e)t.set(r),n.set(!0);return n.get()?m(t.get()):m.none()},get tail(){return v((function*(){let t=e[Symbol.iterator]();t.next();let n=t.next();for(;!n.done;)yield n.value,n=t.next()})())},get init(){let t=Array.from(e);return v(t.length===0?[]:t.slice(0,-1))},takeRight:t=>{let n=Array.from(e);return v(t<=0?[]:n.slice(-t))},reverse:()=>v(Array.from(e).reverse()),distinct:()=>v((function*(){let t=new globalThis.Set;for(let n of e)t.has(n)||(t.add(n),yield n)})()),zipWithIndex:()=>v((function*(){let t=ue(0);for(let n of e)yield[n,t.get()],t.increment()})()),fold:(t,n)=>{let r=t;for(let t of e)r=n(r,t);return r},foldLeft:t=>n=>{let r=_(t);for(let t of e)r.set(n(r.get(),t));return r.get()},foldRight:t=>n=>Array.from(e).reduceRight((e,t)=>n(t,e),t),pipe:e=>e(t),serialize:()=>{let t=Array.from(e);return{toJSON:()=>JSON.stringify({_tag:`LazyList`,value:t}),toYAML:()=>`_tag: LazyList\nvalue: ${n(t)}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`LazyList`,value:t})).toString(`base64`)}},toString:()=>{let t=[],n=ue(0),r=_(!1);for(let i of e)if(n.get()<10)t.push(i),n.increment();else{r.set(!0);break}let i=t.map(e=>String(e)).join(`, `);return r.get()?`LazyList(${i}, ...)`:`LazyList(${i})`}};return t},fe=r(e=>v(e),{empty:()=>v([]),of:e=>v([e]),from:(...e)=>v(e),iterate:(e,t)=>v((function*(){let n=_(e);for(;;)yield n.get(),n.set(t(n.get()))})()),generate:e=>v((function*(){for(;;)yield e()})()),range:(e,t,n=1)=>v((function*(){if(n===0)throw Error(`Step cannot be zero`);let r=_(e);if(n>0)for(;r.get()<t;)yield r.get(),r.set(r.get()+n);else for(;r.get()>t;)yield r.get(),r.set(r.get()+n)})()),repeat:(e,t)=>v((function*(){if(t===void 0)for(;;)yield e;else{let n=ue(0);for(;n.get()<t;)yield e,n.increment()}})()),cycle:e=>v((function*(){let t=Array.from(e);if(t.length!==0)for(;;)yield*t})())}),y=e=>({[Symbol.toStringTag]:`Try`,_tag:`Success`,error:void 0,isSuccess(){return!0},isFailure(){return!1},orElse:t=>e,orThrow:t=>e,or:t=>y(e),orNull:()=>e,orUndefined:()=>e,toEither:t=>w(e),map:t=>x(()=>t(e)),ap:t=>t.map(t=>t(e)),flatMap:t=>t(e),flatMapAsync:async t=>t(e),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),match:t=>t.Success(e),recover:t=>y(e),recoverWith:t=>y(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),toString:()=>`Success(${n(e)})`,toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Success`,value:e}),toOption:()=>d(e),toList:()=>C([e]),toTry:()=>y(e),pipe:t=>t(e),serialize:()=>o(`Success`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),b=e=>({[Symbol.toStringTag]:`Try`,_tag:`Failure`,error:e,isSuccess(){return!1},isFailure(){return!0},orElse:e=>e,orThrow:t=>{throw t??e},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:t=>T(typeof t==`function`?t(e):t),map:t=>b(e),ap:t=>b(e),flatMap:t=>b(e),flatMapAsync:t=>Promise.resolve(b(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),match:t=>t.Failure(e),recover:t=>x(()=>t(e)),recoverWith:t=>{try{return t(e)}catch(e){return b(e instanceof Error?e:Error(String(e)))}},foldLeft:e=>t=>e,foldRight:e=>t=>e,toString:()=>`Failure(${n(e)}))`,toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Failure`,value:e}),toOption:()=>m(null),toList:()=>C([]),toTry:()=>b(e),pipe:t=>{throw e},serialize:()=>s({_tag:`Failure`,error:e.message,stack:e.stack}),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),pe=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},me={success:e=>y(e),failure:e=>b(typeof e==`string`?Error(e):e),fromPromise:e=>e.then(e=>y(e)).catch(e=>b(e instanceof Error?e:Error(String(e)))),isSuccess:e=>e.isSuccess(),isFailure:e=>e.isFailure(),fromJSON:e=>{let t=JSON.parse(e);if(t._tag===`Success`)return y(t.value);{let e=Error(t.error);return t.stack&&(e.stack=t.stack),b(e)}},fromYAML:e=>{let t=e.split(`
|
|
6
|
+
`),n=t[0]?.split(`: `)[1];if(!n)return b(Error(`Invalid YAML format for Try`));if(n===`Success`){let e=t[1]?.split(`: `)[1];return e?y(JSON.parse(e)):b(Error(`Invalid YAML format for Try Success`))}else{let e=t[1]?.split(`: `)[1];if(!e)return b(Error(`Invalid YAML format for Try Failure`));let n=t[2]?.split(`: `),r=n&&n.length>1?n.slice(1).join(`: `):void 0,i=Error(e);return r&&(i.stack=r),b(i)}},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return me.fromJSON(t)},sequence:e=>x(()=>e.map(e=>e.orThrow())),traverse:(e,t)=>x(()=>e.map((e,n)=>t(e,n).orThrow()))},x=r(pe,me);function he({_tag:e,impl:t}){return{...t,_tag:e}}function ge(e,t){return!e||typeof e!=`object`||!(`_tag`in e)?!1:t?e._tag===t:!0}const S=e=>{let t=Array.from(e??[]),r={[Symbol.toStringTag]:`List`,_tag:`List`,[Symbol.iterator]:()=>t[Symbol.iterator](),get size(){return t.length},get length(){return t.length},map:e=>S(t.map(e)),ap:e=>S(t.flatMap(t=>Array.from(e).map(e=>e(t)))),flatMap:e=>S(t.flatMap(t=>Array.from(e(t)))),flatMapAsync:async e=>S((await Promise.all(t.map(async t=>await e(t)))).flatMap(e=>Array.from(e))),forEach:e=>t.forEach(e),contains:e=>t.includes(e),count:e=>t.filter(e).length,exists:e=>t.some(e),filter:e=>S(t.filter(e)),filterNot:e=>S(t.filter(t=>!e(t))),filterType:e=>S(t.filter(t=>ge(t,e))),find:(e,n)=>m(t.find(t=>e(t)&&(n?ge(t,n):!0))),get head(){return t[0]},get headOption(){return t.length>0?m(t[0]):p()},get isEmpty(){return t.length===0},toArray:()=>[...t],reduce:e=>re(t,e),reduceRight:e=>ie(t,e),fold:(e,n)=>t.reduce(n,e),foldLeft:e=>n=>t.reduce(n,e),foldRight:e=>n=>t.reduceRight((e,t)=>n(t,e),e),match:e=>t.length===0?e.Empty():e.NonEmpty([...t]),remove:e=>S(t.filter(t=>t!==e)),removeAt:e=>e<0||e>=t.length?r:S([...t.slice(0,e),...t.slice(e+1)]),add:e=>S([...t,e]),get:e=>m(t[e]),concat:e=>S([...t,...e.toArray()]),take:e=>S(t.slice(0,Math.max(0,e))),takeWhile:e=>{let n=[];for(let r of t){if(!e(r))break;n.push(r)}return S(n)},takeRight:e=>S(e<=0?[]:t.slice(-e)),get last(){return t[t.length-1]},get lastOption(){return t.length>0?m(t[t.length-1]):p()},get tail(){return S(t.slice(1))},get init(){return S(t.length===0?[]:t.slice(0,-1))},reverse:()=>S([...t].reverse()),indexOf:e=>t.indexOf(e),prepend:e=>S([e,...t]),distinct:()=>{let e=new globalThis.Set,n=[];for(let r of t)e.has(r)||(e.add(r),n.push(r));return S(n)},sorted:e=>S([...t].sort(e)),sortBy:(e,n)=>S([...t].sort((t,r)=>{let i=e(t),a=e(r);return n?n(i,a):i<a?-1:+(i>a)})),zip:e=>{let n=e.toArray(),r=Math.min(t.length,n.length),i=[];for(let e=0;e<r;e++)i.push([t[e],n[e]]);return S(i)},zipWithIndex:()=>S(t.map((e,t)=>[e,t])),groupBy:e=>{let n=new globalThis.Map;for(let r of t){let t=e(r),i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new globalThis.Map;for(let[e,t]of n)r.set(e,S(t));return r},partition:e=>{let n=[],r=[];for(let i of t)e(i)?n.push(i):r.push(i);return[S(n),S(r)]},span:e=>{let n=t.findIndex(t=>!e(t));return n===-1?[S([...t]),S([])]:[S(t.slice(0,n)),S(t.slice(n))]},slice:(e,n)=>S(t.slice(e,n)),drop:e=>S(t.slice(e)),dropRight:e=>S(t.slice(0,-e)),dropWhile:e=>S(t.slice(t.findIndex(t=>!e(t)))),flatten:()=>S(t.flatMap(e=>Array.isArray(e)?e:[e])),toList:()=>r,toSet:()=>ce(t),toOption:()=>t.length>0?m(t[0]):p(),toEither:e=>t.length>0?w(t[0]):T(e),toTry:()=>t.length>0?x(()=>t[0]):x(()=>{throw Error(`Empty list`)}),toString:()=>`List(${n(t)})`,toValue:()=>({_tag:`List`,value:t}),pipe:e=>e([...t]),serialize:()=>o(`List`,t),doUnwrap(){return t.length===0?{ok:!1,empty:!0}:{ok:!0,value:t[0]}}};return r},_e=e=>S(e),ve=S([]),ye={empty:()=>ve,of:(...e)=>S(e),fromJSON:e=>C(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
7
7
|
`)[1]?.split(`: `)[1];return C(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ye.fromJSON(t)}},C=r(_e,ye),be=e=>({[Symbol.toStringTag]:`Either`,_tag:`Right`,value:e,isLeft(){return!1},isRight(){return!0},orElse:t=>e,orThrow:()=>e,or:t=>w(e),orNull:()=>e,orUndefined:()=>e,map:t=>w(t(e)),ap:t=>t._tag===`Right`?w(t.value(e)):T(t.value),mapAsync:t=>t(e).then(e=>w(e)).catch(e=>Promise.resolve(T(e))),merge:t=>t.isLeft()?T(t.value):w([e,t.value]),flatMap:t=>t(e),flatMapAsync:t=>t(e).catch(e=>T(e)),toOption:()=>d(e),toList:()=>C([e]),toEither:t=>w(e),toTry:()=>x(()=>e),toJSON(){return{_tag:`Right`,value:e}},toString:()=>`Right(${n(e)})`,*[Symbol.iterator](){yield e},*yield(){yield e},traverse:t=>{let n=t(e);return n.isLeft()?T(n.value):w([n.value])},tap:t=>(t(e),w(e)),tapLeft:t=>w(e),mapLeft:t=>w(e),bimap:(t,n)=>w(n(e)),fold:(t,n)=>n(e),foldAsync:async(t,n)=>n(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),match:t=>t.Right(e),swap:()=>T(e),toPromise:()=>Promise.resolve(e),toValue:()=>({_tag:`Right`,value:e}),pipeEither:(t,n)=>n(e),pipe:t=>t(e),serialize:()=>o(`Right`,e),contains:t=>e===t,exists:t=>t(e),forEach:t=>t(e),doUnwrap(){return{ok:!0,value:e}}}),xe=e=>({[Symbol.toStringTag]:`Either`,_tag:`Left`,value:e,isLeft(){return!0},isRight(){return!1},orElse:e=>e,orThrow:t=>{throw t??e},or:e=>e,orNull:()=>null,orUndefined:()=>void 0,map:t=>T(e),ap:t=>T(e),mapAsync:t=>Promise.resolve(T(e)),merge:t=>T(e),flatMap:t=>T(e),flatMapAsync:t=>Promise.resolve(T(e)),toOption:()=>p(),toList:()=>C(),toEither:e=>T(e),toTry:()=>x(()=>{throw Error(String(e))}),toJSON(){return{_tag:`Left`,value:e}},toString:()=>`Left(${n(e)})`,*[Symbol.iterator](){},*yield(){},traverse:t=>T(e),tap:t=>T(e),tapLeft:t=>(t(e),T(e)),mapLeft:t=>T(t(e)),bimap:(t,n)=>T(t(e)),fold:(t,n)=>t(e),foldAsync:async(t,n)=>t(e),foldLeft:e=>t=>e,foldRight:e=>t=>e,match:t=>t.Left(e),swap:()=>w(e),toPromise:()=>Promise.reject(e),toValue:()=>({_tag:`Left`,value:e}),pipeEither:(t,n)=>t(e),pipe:t=>t(e),serialize:()=>o(`Left`,e),contains:e=>!1,exists:e=>!1,forEach:e=>{},doUnwrap(){return{ok:!1,empty:!1,error:e}}}),w=e=>be(e),T=e=>xe(e),Se=e=>e.isRight(),Ce=e=>e.isLeft(),we=(e,t)=>{try{return w(e())}catch(e){return T(t(e))}},Te=e=>be(e);console.assert(Te);const Ee=e=>xe(e);console.assert(Ee);const De=async(e,t)=>{try{return w(await e())}catch(e){return T(t(e))}},Oe=(e,t)=>t?w(e):T(e),ke={left:e=>T(e),right:e=>w(e),void:()=>w(void 0),isRight:e=>e.isRight(),isLeft:e=>e.isLeft(),sequence:e=>e.reduce((e,t)=>e.isLeft()?e:t.isLeft()?T(t.value):e.map(e=>[...e,t.value]),w([])),traverse:(e,t)=>ke.sequence(e.map(t)),fromNullable:(e,t)=>e==null?T(t):w(e),fromPredicate:(e,t,n)=>t(e)?w(e):T(n),ap:(e,t)=>e.flatMap(e=>t.map(e)),fromPromise:async(e,t)=>{try{return w(await e)}catch(e){return T(t(e))}},fromJSON:e=>{let t=JSON.parse(e);return t._tag===`Right`?w(t.value):T(t.value)},fromYAML:e=>{let t=e.split(`
|
|
8
8
|
`),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`?w(i):T(i)},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ke.fromJSON(t)}},Ae=r(Oe,ke);function E(t,n){return{brand:t,validate:n,of:r=>n(r)?m(e(t,r)):m.none(),from:r=>n(r)?w(e(t,r)):T(`Invalid ${t}: validation failed`),unsafeOf:r=>{if(!n(r))throw Error(`Invalid ${t}: validation failed`);return e(t,r)},is:e=>{try{return n(e)}catch{return!1}},unwrap:e=>e,refine:(e,t)=>E(e,e=>n(e)&&t(e))}}const je=E(`PositiveNumber`,e=>e>0),Me=E(`NonNegativeNumber`,e=>e>=0),Ne=E(`IntegerNumber`,e=>Number.isInteger(e)),Pe=je.refine(`PositiveInteger`,e=>Number.isInteger(e)),Fe=E(`NonEmptyString`,e=>e.length>0),Ie=E(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Le=E(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Re=E(`UUID`,e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e)),ze=E(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Be(e,t,n){return E(e,e=>e>=t&&e<=n)}function Ve(e,t,n){return E(e,e=>e.length>=t&&e.length<=n)}function He(e,t){return E(e,e=>t.test(e))}const Ue=e=>typeof e==`function`&&Object.keys(e).length>0,We=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?We({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?We({resolved:!0,value:t(i)}):n,else:n=>e.resolved?e.value:t(n),orThrow:()=>{if(!e.resolved)throw Error(`Conditional expression has no matching condition`);return e.value}};return n},Ge=()=>We({resolved:!1}),Ke=r(Ge,{of:()=>Ge(),match:e=>t=>{let n=t[e];if(n===void 0)throw Error(`No case defined for value: ${String(e)}`);return typeof n==`function`?n():n},lazy:()=>{let e={resolved:!1},t={when:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),elseWhen:(n,r)=>(e.resolved||n()&&(e.resolved=!0,e.value=r()),t),else:t=>e.resolved?e.value:t()};return t}}),qe=(e,t)=>t===e?!0:typeof t==`function`?t(e):t&&typeof t==`object`&&`_`in t?t._(e):typeof t==`object`&&t&&typeof e==`object`&&e?Object.entries(t).every(([t,n])=>{let r=e[t];return qe(r,n)}):!1,D=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(qe(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:qe(e.value,n)?D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):D({...e,patterns:[...e.patterns,{pattern:n,result:i}]}),caseValue:(t,n)=>{if(e.resolved)return r;if(e.value===t){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},caseValues:(t,n)=>{if(e.resolved)return r;if(t.includes(e.value)){let t=typeof n==`function`?n():n;return D({value:e.value,resolved:!0,result:t,patterns:[]})}return r},when:(e,t)=>r.case(e,t),caseAny:(n,i)=>{if(e.resolved)return r;for(let r of n)if(qe(e.value,r))return D({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return D({...e,patterns:[...e.patterns,...n.map(e=>({pattern:e,result:i}))]})},default:n=>e.resolved?e.result:t(n,e.value),exhaustive:()=>{if(e.resolved)return e.result;let t=n();if(!t.matched)throw Error(`Non-exhaustive match. No pattern matched value: ${JSON.stringify(e.value)}`);return t.result},orThrow:t=>{if(e.resolved)return e.result;let r=n();if(!r.matched)throw Error(t??`No matching pattern for value: ${JSON.stringify(e.value)}`);return r.result},toOption:()=>{if(e.resolved)return m(e.result);let t=n();return t.matched?m(t.result):m.none()}};return r},Je=e=>{let t=(e,t)=>typeof e==`function`?e(t):e;return{case:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return qe(e,n)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseValue:(t,n)=>D(e===t?{value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}:{value:e,resolved:!1,patterns:[]}),caseValues:(t,n)=>t.includes(e)?D({value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}):D({value:e,resolved:!1,patterns:[]}),when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?D({...i,resolved:!0,result:t(r,e)}):D(i)},caseAny:(n,r)=>{for(let i of n)if(qe(e,i))return D({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return D({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},Ye=r(e=>Je(e),{exhaustive:e=>t=>{let n=e[t];if(n===void 0)throw Error(`No case defined for value: ${String(t)}`);return n},partial:e=>({withDefault:t=>n=>{let r=e[n];return r===void 0?typeof t==`function`?t(n):t:typeof r==`function`?r(n):r}}),withGuards:e=>({withDefault:t=>n=>{for(let[t,r]of e)if(t(n))return typeof r==`function`?r(n):r;return typeof t==`function`?t(n):t}}),struct:()=>{let e=[],t={case:(n,r)=>(e.push({pattern:n,handler:r}),t),build:()=>t=>{for(let{pattern:n,handler:r}of e)if(qe(t,n))return r(t);throw Error(`No matching pattern for value: ${JSON.stringify(t)}`)}};return t},builder:()=>{let e=[],t,n={case:(t,r)=>(e.push({pattern:t,result:r}),n),when:(t,r)=>(e.push({pattern:t,result:r}),n),default:n=>(t=n,{build:()=>n=>{for(let{pattern:t,result:r}of e)if(qe(n,t))return typeof r==`function`?r(n):r;if(t!==void 0)return typeof t==`function`?t(n):t;throw Error(`No matching pattern for value: ${JSON.stringify(n)}`)}})};return n}});function Xe(e,t){return{...he({_tag:e,impl:t}),toString(){return`${e}()`},doUnwrap(){if(`isSome`in t&&`isNone`in t){if(typeof t.isSome==`function`&&t.isSome()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isNone==`function`&&t.isNone())return{ok:!1,empty:!0}}if(`isLeft`in t&&`isRight`in t){if(typeof t.isRight==`function`&&t.isRight()&&`value`in t)return{ok:!0,value:t.value};if(typeof t.isLeft==`function`&&t.isLeft()&&`value`in t)return{ok:!1,empty:!1,error:t.value}}if(`isSuccess`in t&&`isFailure`in t){if(typeof t.isSuccess==`function`&&t.isSuccess()&&`get`in t&&typeof t.get==`function`)return{ok:!0,value:t.get()};if(typeof t.isFailure==`function`&&t.isFailure()&&`getError`in t&&typeof t.getError==`function`)return{ok:!1,empty:!1,error:t.getError()}}if(`isEmpty`in t&&`head`in t){if(typeof t.isEmpty==`function`&&t.isEmpty())return{ok:!1,empty:!0};if(typeof t.head==`function`)return{ok:!0,value:t.head()};if(`head`in t)return{ok:!0,value:t.head}}return{ok:!0,value:t}}}}const Ze=`Throwable`;var Qe=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=Ze,this.name=t?.taskInfo?.name??`Throwable`,Object.defineProperties(this,{_tag:{value:Ze,writable:!1,configurable:!1},data:{value:t?.data,writable:!1,configurable:!1},taskInfo:{value:t?.taskInfo,writable:!1,configurable:!1},name:{value:t?.taskInfo?.name??`Throwable`,writable:!1,configurable:!1}}),t?.cause&&Object.defineProperty(this,`cause`,{value:t.cause,writable:!1,configurable:!1}),t?.stack?this.stack=t.stack:Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static apply(t,n,r){if(t instanceof Error){let i=new e(t.message,{data:n,cause:t.cause??void 0,stack:t.stack??void 0,taskInfo:r});for(let e of Object.keys(t))if(!(e in i)){let n=i;n[e]=t[e]}return i}if(t&&typeof t==`object`){let i=t,a=new e(typeof i.message==`string`?i.message:typeof i.error==`string`?i.error:`Object error: ${JSON.stringify(i,Object.getOwnPropertyNames(i).filter(e=>i[e]!==void 0))}`,{data:n??i,taskInfo:r});for(let e of Object.keys(i))if(!(e in a)){let t=a;t[e]=i[e]}return a}if(typeof t==`function`){let i=t.name??`anonymous function`,a=t.toString().substring(0,100)+(t.toString().length>100?`...`:``);return new e(`Function error: ${i}`,{data:n??{functionType:typeof t,functionName:i,functionString:a},taskInfo:r})}let i=typeof t,a=t===null?`null`:t===void 0?`undefined`:String(t);if(i===`number`){let a=t;return new e(Number.isNaN(a)?`Number error: NaN`:Number.isFinite(a)?`Number error: ${a}`:`Number error: ${a>0?`Infinity`:`-Infinity`}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}if(i===`bigint`)return new e(`BigInt error: ${t}n`,{data:n??{errorType:i,errorValue:String(t),originalError:t},taskInfo:r});if(i===`boolean`)return new e(`Boolean error: ${t}`,{data:n??{errorType:i,errorValue:t,originalError:t},taskInfo:r});if(i===`symbol`){let a=t.description??`unnamed symbol`;return new e(`Symbol error: Symbol(${a})`,{data:n??{errorType:i,symbolDescription:a,originalError:t},taskInfo:r})}return new e(typeof t==`string`?t:`${i.charAt(0).toUpperCase()+i.slice(1)} error: ${a}`,{data:n??{errorType:i,errorValue:a,originalError:t},taskInfo:r})}};function $e(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const et=(e,t)=>{if(e.isRight())return k(e.orThrow(),t);if(e.isLeft())return O(e.fold(e=>e,()=>Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},O=(e,t,r)=>{let i={name:r?.name??`Task`,description:r?.description??``},a=Qe.apply(e,t,i),o={...Xe(`Err`,{error:a,meta:i}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Err`,_meta:i,value:void 0,error:a,isSuccess(){return!1},isFailure(){return!0},isOk(){return!1},isErr(){return!0},map:e=>O(a,t,r),flatMap:e=>O(a,t,r),ap:e=>O(a,t,r),mapAsync:e=>Promise.resolve(O(a,t,r)),flatMapAsync:e=>Promise.resolve(O(a,t,r)),mapError:e=>O(e(a),t,r),recover:e=>k(e,r),recoverWith:e=>k(e(a),r),orThrow:e=>{throw e??a},orElse:e=>e,or:e=>e,orNull:()=>null,orUndefined:()=>void 0,toEither:()=>T(a),toTry:()=>x(()=>{throw a}),toOption:()=>p(),toList:()=>C([]),fold:(e,t)=>e(a),match:e=>e.Err(a),foldLeft:e=>t=>e,foldRight:e=>t=>e,size:0,isEmpty:!0,contains:e=>!1,reduce:e=>{throw Error(`Cannot reduce empty Err`)},reduceRight:e=>{throw Error(`Cannot reduceRight empty Err`)},count:e=>0,find:e=>p(),exists:e=>!1,forEach:e=>{},toPromise:()=>Promise.reject(a),doUnwrap(){return{ok:!1,empty:!1,error:a}},serialize:()=>({toJSON:()=>n({_tag:`Err`,error:a.message??a.toString()})??`{}`,toYAML:()=>`_tag: Err\nerror: ${a.message??a.toString()}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Err`,error:a.message??a.toString()})).toString(`base64`)}),pipe:e=>e(o)};return o},k=(e,t)=>{let r={name:t?.name??`Task`,description:t?.description??``},i={...Xe(`Ok`,{value:e,meta:r}),[Symbol.toStringTag]:`TaskOutcome`,_tag:`Ok`,_meta:r,value:e,error:void 0,isSuccess(){return!0},isFailure(){return!1},isOk(){return!0},isErr(){return!1},map:n=>k(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?et(r,t):r},ap:n=>n.isOk()?k(n.value(e),t):O(n.error,void 0,t),mapAsync:async n=>k(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>k(e,t),recover:n=>k(e,t),recoverWith:n=>k(e,t),orThrow:t=>e,orElse:t=>e,or:n=>k(e,t),orNull:()=>e,orUndefined:()=>e,toEither:()=>w(e),toTry:()=>x(()=>e),toOption:()=>d(e),toList:()=>C([e]),fold:(t,n)=>n(e),match:t=>t.Ok(e),foldLeft:t=>n=>n(t,e),foldRight:t=>n=>n(e,t),size:1,isEmpty:!1,contains:t=>e===t,reduce:t=>e,reduceRight:t=>e,count:t=>+!!t(e),find:t=>t(e)?d(e):p(),exists:t=>t(e),forEach:t=>t(e),toPromise:()=>Promise.resolve(e),doUnwrap(){return{ok:!0,value:e}},serialize:()=>({toJSON:()=>n({_tag:`Ok`,value:e})??`{}`,toYAML:()=>`_tag: Ok\nvalue: ${n(e)??`undefined`}`,toBinary:()=>Buffer.from(JSON.stringify({_tag:`Ok`,value:e})).toString(`base64`)}),pipe:e=>e(i)};return i},tt=()=>{let e=new AbortController,t=de();return{token:{get isCancelled(){return e.signal.aborted},get signal(){return e.signal},onCancel(n){e.signal.aborted?n():t.add(n)}},cancel(){e.signal.aborted||(e.abort(),t.build().forEach(e=>{try{e()}catch(e){console.error(`Error in cancellation callback:`,e)}}))}}},nt=e=>{let t=e?.name??`Task`,n=e?.description??``,r={Async:(e,r=e=>e,i=()=>{},a)=>new Promise(o=>{(async()=>{let s=_(!1),c=_(null),l=_(()=>{});if(a){if(a.isCancelled){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}o(O(Error(`Task was cancelled before execution started`),void 0,{name:t,description:n}));return}a.onCancel(()=>{s.set(!0),c.set(Error(`Task was cancelled during execution`))}),l.set(()=>{})}try{let r=await e();try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}if(r&&typeof r==`object`&&`_tag`in r){let e=r;e._tag===`Ok`||e._tag===`Err`?o(e):o(k(r,{name:t,description:n}))}else o(k(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(O(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(O(c.get(),void 0,{name:t,description:n})):o(O(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&$e(e)){let i=Error(`${t}: ${e.message}`),a=Qe.apply(i,void 0,{name:t,description:n});Object.defineProperty(a,`cause`,{value:e,writable:!1,configurable:!1}),Promise.resolve().then(()=>{try{r(e)}catch(e){console.error(`Error in error handler:`,e)}}),o(O(a,void 0,{name:t,description:n}))}else{let i=await r(e);if(i&&typeof i==`object`&&`_tag`in i){let e=i;e._tag===`Ok`||e._tag===`Err`?o(e):o(O(i,void 0,{name:t,description:n}))}else o(O(i,void 0,{name:t,description:n}))}}catch(e){o(O(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(O(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return k(e(),{name:t,description:n})}catch(e){return O(r(e),void 0,{name:t,description:n})}finally{i()}},AsyncWithProgress:(e,t,n=e=>e,i=()=>{},a)=>{let o=e=>{let n=Math.max(0,Math.min(100,e));n<=100&&t(n)};return r.Async(()=>e(o),n,i,a)}};return{...Xe(`Task`,r),_type:`Task`}},rt={success:(e,t)=>k(e,t),fail:(e,t,n)=>O(e,t,n),ok:(e,t)=>k(e,t),err:(e,t,n)=>O(e,t,n),fromEither:(e,t)=>et(e,t),fromTry:(e,t)=>e.isSuccess()?k(e.orThrow(),t):O(e.fold(e=>e,()=>Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=de();t.add(e);let n=_(e);for(;n.get()&&n.get().cause;){let{cause:e}=n.get();if(e)t.add(e),n.set(e);else break;if(t.size()>100)break}return t.build()},formatErrorChain:(e,t)=>{let n=rt.getErrorChain(e),r=t?.separator??`
|
|
9
9
|
`;return n.map((e,n)=>{if(!e)return`${n>0?`↳ `:``}Unknown error`;let{taskInfo:r}=e,i=t?.includeTasks&&r?.name?`[${r.name}] `:``,a=e.message??`No message`,o=_(`${n>0?`↳ `:``}${i}${a}`);return t?.includeStackTrace&&e.stack&&o.set(`${o.get()}\n${e.stack.split(`
|
package/dist/try/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Xn as TypeNames, Yn as Try } from "../index-
|
|
1
|
+
import { Xn as TypeNames, Yn as Try } from "../index-P2ubIONw.js";
|
|
2
2
|
export { Try, TypeNames };
|
package/dist/try/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{St as e}from"../src-
|
|
1
|
+
import{St as e}from"../src-DpQmW2iX.js";export{e as Try};
|
package/package.json
CHANGED
|
@@ -1,60 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"functype",
|
|
8
|
+
"functional",
|
|
9
|
+
"functional-programming",
|
|
10
|
+
"typescript",
|
|
11
|
+
"monad",
|
|
12
|
+
"adt",
|
|
13
|
+
"option",
|
|
14
|
+
"either",
|
|
15
|
+
"try",
|
|
16
|
+
"task",
|
|
17
|
+
"io",
|
|
18
|
+
"list",
|
|
19
|
+
"immutable",
|
|
20
|
+
"scala"
|
|
21
|
+
],
|
|
6
22
|
"author": "jordan.burke@gmail.com",
|
|
7
23
|
"license": "MIT",
|
|
8
24
|
"repository": {
|
|
9
25
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/jordanburke/functype.git"
|
|
26
|
+
"url": "git+https://github.com/jordanburke/functype.git",
|
|
27
|
+
"directory": "packages/functype"
|
|
11
28
|
},
|
|
12
29
|
"homepage": "https://functype.org/",
|
|
13
30
|
"url": "https://github.com/jordanburke/functype",
|
|
14
|
-
"scripts": {
|
|
15
|
-
"prevalidate": "bash scripts/version-check.sh",
|
|
16
|
-
"validate": "ts-builds validate",
|
|
17
|
-
"validate:core": "ts-builds validate:core",
|
|
18
|
-
"validate:site": "ts-builds validate:site",
|
|
19
|
-
"format": "ts-builds format",
|
|
20
|
-
"format:check": "ts-builds format:check",
|
|
21
|
-
"lint": "ts-builds lint",
|
|
22
|
-
"lint:check": "ts-builds lint:check",
|
|
23
|
-
"test": "ts-builds test",
|
|
24
|
-
"test:watch": "ts-builds test:watch",
|
|
25
|
-
"test:coverage": "ts-builds test:coverage",
|
|
26
|
-
"test:ui": "ts-builds test:ui",
|
|
27
|
-
"build": "ts-builds build",
|
|
28
|
-
"extract:interfaces": "ts-builds extract:interfaces",
|
|
29
|
-
"build:watch": "ts-builds dev",
|
|
30
|
-
"dev": "ts-builds dev",
|
|
31
|
-
"compile": "ts-builds compile",
|
|
32
|
-
"clean": "rimraf dist",
|
|
33
|
-
"prepublishOnly": "pnpm validate",
|
|
34
|
-
"bench": "vitest bench",
|
|
35
|
-
"bench:ui": "vitest bench --ui",
|
|
36
|
-
"docs:preprocess": "tsx scripts/preprocess-docs.ts",
|
|
37
|
-
"docs": "ts-builds docs",
|
|
38
|
-
"docs:watch": "typedoc --watch",
|
|
39
|
-
"docs:sync": "tsx scripts/sync-docs.ts",
|
|
40
|
-
"docs:validate": "ts-builds docs:validate",
|
|
41
|
-
"analyze:size": "pnpm build && node ./scripts/analyze-bundle-size.js",
|
|
42
|
-
"site:dev": "cd site && pnpm dev",
|
|
43
|
-
"site:build": "cd site && pnpm build",
|
|
44
|
-
"site:preview": "cd site && pnpm preview",
|
|
45
|
-
"cli-example": "npx . Option",
|
|
46
|
-
"version:bump": "bash scripts/version-bump.sh",
|
|
47
|
-
"version": "bash scripts/version-sync-satellites.sh"
|
|
48
|
-
},
|
|
49
31
|
"devDependencies": {
|
|
50
|
-
"@eslint/compat": "^2.0
|
|
32
|
+
"@eslint/compat": "^2.1.0",
|
|
51
33
|
"@types/node": "~24.10.15",
|
|
52
34
|
"eslint-config-functype": "2.3.0",
|
|
53
35
|
"eslint-plugin-functional": "^9.0.4",
|
|
54
36
|
"fast-check": "^4.7.0",
|
|
55
|
-
"globals": "^17.
|
|
56
|
-
"ts-builds": "^2.
|
|
57
|
-
"tsdown": "^0.
|
|
37
|
+
"globals": "^17.6.0",
|
|
38
|
+
"ts-builds": "^2.8.0",
|
|
39
|
+
"tsdown": "^0.22.0",
|
|
58
40
|
"tsx": "^4.21.0",
|
|
59
41
|
"typedoc": "^0.28.19"
|
|
60
42
|
},
|
|
@@ -179,5 +161,34 @@
|
|
|
179
161
|
"dist"
|
|
180
162
|
],
|
|
181
163
|
"sideEffects": false,
|
|
182
|
-
"
|
|
183
|
-
|
|
164
|
+
"publishConfig": {
|
|
165
|
+
"access": "public",
|
|
166
|
+
"provenance": true
|
|
167
|
+
},
|
|
168
|
+
"scripts": {
|
|
169
|
+
"validate": "ts-builds validate",
|
|
170
|
+
"format": "ts-builds format",
|
|
171
|
+
"format:check": "ts-builds format:check",
|
|
172
|
+
"lint": "ts-builds lint",
|
|
173
|
+
"lint:check": "ts-builds lint:check",
|
|
174
|
+
"test": "ts-builds test",
|
|
175
|
+
"test:watch": "ts-builds test:watch",
|
|
176
|
+
"test:coverage": "ts-builds test:coverage",
|
|
177
|
+
"test:ui": "ts-builds test:ui",
|
|
178
|
+
"build": "ts-builds build",
|
|
179
|
+
"extract:interfaces": "ts-builds extract:interfaces",
|
|
180
|
+
"build:watch": "ts-builds dev",
|
|
181
|
+
"dev": "ts-builds dev",
|
|
182
|
+
"compile": "ts-builds compile",
|
|
183
|
+
"clean": "rimraf dist",
|
|
184
|
+
"bench": "vitest bench",
|
|
185
|
+
"bench:ui": "vitest bench --ui",
|
|
186
|
+
"docs:preprocess": "tsx scripts/preprocess-docs.ts",
|
|
187
|
+
"docs": "ts-builds docs",
|
|
188
|
+
"docs:watch": "typedoc --watch",
|
|
189
|
+
"docs:sync": "tsx scripts/sync-docs.ts",
|
|
190
|
+
"docs:validate": "ts-builds docs:validate",
|
|
191
|
+
"analyze:size": "pnpm build && node ./scripts/analyze-bundle-size.js",
|
|
192
|
+
"cli-example": "npx . Option"
|
|
193
|
+
}
|
|
194
|
+
}
|