functype 0.60.5 → 0.60.7
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 +2 -2
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/do/index.d.ts +2 -2
- 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-DT4nsgjh.js → full-interfaces-DP0MRmk5.js} +26 -1
- package/dist/{index-P2ubIONw.d.ts → index-DZR10yks.d.ts} +24 -0
- package/dist/index.d.ts +2 -2
- 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-DpQmW2iX.js → src-BxyCNnFT.js} +3 -3
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Functype
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/functype)
|
|
4
|
+
[](https://github.com/jordanburke/functype/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
6
|
## A Functional Programming Library for TypeScript
|
|
7
7
|
|
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-DP0MRmk5.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-BxyCNnFT.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-DP0MRmk5.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-
|
|
2
|
-
export { $, Do, DoAsync, DoGenerator, DoResult, Doable, EmptyListError, FailureError, FailureErrorType, LeftError, LeftErrorType, NoneError, isDoCapable, unwrap };
|
|
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-DZR10yks.js";
|
|
2
|
+
export { $, Do, DoAsync, DoGenerator, type DoResult, type 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-BxyCNnFT.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-DZR10yks.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-BxyCNnFT.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.7`,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()`,`.expect(() => never)`,`.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()`,`.expect((l) => never)`,`.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()`,`.expect((e) => never)`,`.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`,`.expect(handler: (e?) => never): 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
|
|
@@ -28,6 +28,14 @@ const e=`0.60.5`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
28
28
|
* @throws The specified error or a default error if the Option is None
|
|
29
29
|
*/
|
|
30
30
|
orThrow(error?: Error): T
|
|
31
|
+
/**
|
|
32
|
+
* Returns the contained value, or calls the never-returning handler if None.
|
|
33
|
+
* Use this when you have a helper like \`(msg) => fail(msg, 2)\` that terminates the
|
|
34
|
+
* program — the result type is unconditionally \`T\`, so you avoid the TypeScript
|
|
35
|
+
* narrowing trap where \`if (o.isNone()) fail(...)\` fails to narrow \`o.value\` when
|
|
36
|
+
* \`fail\` is an arrow function typed as \`(...): never\`.
|
|
37
|
+
*/
|
|
38
|
+
expect(handler: () => never): T
|
|
31
39
|
/**
|
|
32
40
|
* Returns this Option if it contains a value, otherwise returns the alternative container.
|
|
33
41
|
* The alternative may hold a different type; the result widens to \`Option<T | T2>\`.
|
|
@@ -150,6 +158,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
150
158
|
},
|
|
151
159
|
orElse: <R2 extends Type>(_defaultValue: R2): R | R2 => value,
|
|
152
160
|
orThrow: () => value,
|
|
161
|
+
expect: (_handler: (value: L) => never): R => value,
|
|
153
162
|
or: <L2 extends Type, R2 extends Type>(_alternative: Either<L2, R2>): Either<L | L2, R | R2> =>
|
|
154
163
|
Right<L | L2, R | R2>(value),
|
|
155
164
|
orNull: () => value,
|
|
@@ -229,6 +238,14 @@ export interface EitherBase<out L extends Type, out R extends Type>
|
|
|
229
238
|
isRight(): this is RightOf<L, R>
|
|
230
239
|
orElse<R2 extends Type>(defaultValue: R2): R | R2
|
|
231
240
|
orThrow: (error?: Error) => R
|
|
241
|
+
/**
|
|
242
|
+
* Returns the right value, or calls the never-returning handler with the Left's value.
|
|
243
|
+
* Use this when you have a helper like \`(msg) => fail(msg, 2)\` that terminates the
|
|
244
|
+
* program — the result type is unconditionally \`R\`, so you avoid the TypeScript
|
|
245
|
+
* narrowing trap where \`if (e.isLeft()) fail(...)\` fails to narrow \`e.value\` when
|
|
246
|
+
* \`fail\` is an arrow function typed as \`(...): never\`.
|
|
247
|
+
*/
|
|
248
|
+
expect: (handler: (value: L) => never) => R
|
|
232
249
|
or<L2 extends Type, R2 extends Type>(alternative: Either<L2, R2>): Either<L | L2, R | R2>
|
|
233
250
|
orNull: () => R | null
|
|
234
251
|
orUndefined: () => R | undefined
|
|
@@ -293,6 +310,14 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
293
310
|
isFailure(): this is Try<T> & { readonly _tag: "Failure"; error: Error }
|
|
294
311
|
orElse<T2 extends Type>(defaultValue: T2): T | T2
|
|
295
312
|
orThrow: (error?: Error) => T
|
|
313
|
+
/**
|
|
314
|
+
* Returns the success value, or calls the never-returning handler with the Failure's error.
|
|
315
|
+
* Use this when you have a helper like \`(msg) => fail(msg, 2)\` that terminates the program —
|
|
316
|
+
* the result type is unconditionally \`T\`, so you avoid the TypeScript narrowing trap where
|
|
317
|
+
* \`if (t.isFailure()) fail(...)\` fails to narrow \`t.value\` when \`fail\` is an arrow function
|
|
318
|
+
* typed as \`(...): never\`.
|
|
319
|
+
*/
|
|
320
|
+
expect: (handler: (error: Error) => never) => T
|
|
296
321
|
or<T2 extends Type>(alternative: Try<T2>): Try<T | T2>
|
|
297
322
|
orNull: () => T | null
|
|
298
323
|
orUndefined: () => T | undefined
|
|
@@ -507,6 +507,14 @@ interface Try<out T> extends FunctypeSum<T, TypeNames>, Extractable<T>, Pipe<T>,
|
|
|
507
507
|
};
|
|
508
508
|
orElse<T2 extends Type>(defaultValue: T2): T | T2;
|
|
509
509
|
orThrow: (error?: Error) => T;
|
|
510
|
+
/**
|
|
511
|
+
* Returns the success value, or calls the never-returning handler with the Failure's error.
|
|
512
|
+
* Use this when you have a helper like `(msg) => fail(msg, 2)` that terminates the program —
|
|
513
|
+
* the result type is unconditionally `T`, so you avoid the TypeScript narrowing trap where
|
|
514
|
+
* `if (t.isFailure()) fail(...)` fails to narrow `t.value` when `fail` is an arrow function
|
|
515
|
+
* typed as `(...): never`.
|
|
516
|
+
*/
|
|
517
|
+
expect: (handler: (error: Error) => never) => T;
|
|
510
518
|
or<T2 extends Type>(alternative: Try<T2>): Try<T | T2>;
|
|
511
519
|
orNull: () => T | null;
|
|
512
520
|
orUndefined: () => T | undefined;
|
|
@@ -4469,6 +4477,14 @@ interface Option<out T extends Type> extends Functype<T, "Some" | "None">, Promi
|
|
|
4469
4477
|
* @throws The specified error or a default error if the Option is None
|
|
4470
4478
|
*/
|
|
4471
4479
|
orThrow(error?: Error): T;
|
|
4480
|
+
/**
|
|
4481
|
+
* Returns the contained value, or calls the never-returning handler if None.
|
|
4482
|
+
* Use this when you have a helper like `(msg) => fail(msg, 2)` that terminates the
|
|
4483
|
+
* program — the result type is unconditionally `T`, so you avoid the TypeScript
|
|
4484
|
+
* narrowing trap where `if (o.isNone()) fail(...)` fails to narrow `o.value` when
|
|
4485
|
+
* `fail` is an arrow function typed as `(...): never`.
|
|
4486
|
+
*/
|
|
4487
|
+
expect(handler: () => never): T;
|
|
4472
4488
|
/**
|
|
4473
4489
|
* Returns this Option if it contains a value, otherwise returns the alternative container.
|
|
4474
4490
|
* The alternative may hold a different type; the result widens to `Option<T | T2>`.
|
|
@@ -4880,6 +4896,14 @@ interface EitherBase<out L extends Type, out R extends Type> extends FunctypeSum
|
|
|
4880
4896
|
isRight(): this is RightOf<L, R>;
|
|
4881
4897
|
orElse<R2 extends Type>(defaultValue: R2): R | R2;
|
|
4882
4898
|
orThrow: (error?: Error) => R;
|
|
4899
|
+
/**
|
|
4900
|
+
* Returns the right value, or calls the never-returning handler with the Left's value.
|
|
4901
|
+
* Use this when you have a helper like `(msg) => fail(msg, 2)` that terminates the
|
|
4902
|
+
* program — the result type is unconditionally `R`, so you avoid the TypeScript
|
|
4903
|
+
* narrowing trap where `if (e.isLeft()) fail(...)` fails to narrow `e.value` when
|
|
4904
|
+
* `fail` is an arrow function typed as `(...): never`.
|
|
4905
|
+
*/
|
|
4906
|
+
expect: (handler: (value: L) => never) => R;
|
|
4883
4907
|
or<L2 extends Type, R2 extends Type>(alternative: Either<L2, R2>): Either<L | L2, R | R2>;
|
|
4884
4908
|
orNull: () => R | null;
|
|
4885
4909
|
orUndefined: () => R | undefined;
|
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-DZR10yks.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
|
-
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 };
|
|
4
|
+
export { $, type Applicative, Async, type AsyncMonad, Base, BoundedNumber, BoundedString, Brand, BrandedBoolean, type BrandedBoolean as BrandedBooleanType, BrandedNumber, type BrandedNumber as BrandedNumberType, BrandedString, type BrandedString as BrandedStringType, CancellationToken, CancellationTokenSource, Collection, type CollectionOps, Companion, CompanionMethods, Cond, type ContainerOps, Context, type Context as ContextType, type ContextServices, type DecodeError, Do, DoAsync, DoGenerator, type DoResult, type Doable, ESMap, ESMapType, Either, EitherBase, EitherKind, EmailAddress, EmptyListError, Err, ErrorChainElement, ErrorCode, ErrorFormatterOptions, ErrorMessage, ErrorStatus, ErrorWithTaskInfo, Exit, type Exit as ExitType, type ExitTag, type ExtractBrand, ExtractTag, type Extractable, FailureError, FailureErrorType, FieldValidation, Foldable, FoldableUtils, FormValidation, type Functor, Functype, FunctypeBase, FunctypeCollection, FunctypeSum, HKT, type HasService, Http, HttpClient, type HttpClientConfig, type HttpError, HttpError as HttpErrors, type HttpMethod, type HttpMethodOptions, type HttpRequestOptions, type HttpResponse, type HttpStatusError, IO, type IO as IOType, type Task as IOTask, ISO8601Date, Identity, InstanceType, IntegerNumber, InterruptedError, KVTraversable, Kind, Layer, type Layer as LayerType, type LayerError, type LayerInput, type LayerOutput, Lazy, type Lazy as LazyType, LazyList, Left, LeftError, LeftErrorType, LeftOf, List, ListKind, Map, Match, type Matchable, MatchableUtils, type Monad, NAME, type NetworkError, NonEmptyString, NonNegativeNumber, None, NoneError, Obj, Ok, Option, OptionConstructor, OptionKind, ParseError, type ParseMode, PatternString, Pipe, PositiveInteger, PositiveNumber, type Promisable, type RIO, Ref, type Ref as RefType, Right, RightOf, Serializable, SerializationMethods, SerializationResult, Set, Some, Stack, Sync, Tag, type Tag as TagType, type TagService, TaggedThrowable, Task$1 as Task, TaskErrorInfo, TaskFailure, TaskMetadata, TaskOutcome, TaskParams, TaskResult, TaskSuccess, TestClock, type TestClock as TestClockType, TestClockTag, TestContext, type TestContext as TestContextType, TestEither, Throwable, ThrowableType, TimeoutError, Traversable, Try, TryKind, Tuple, Type, TypeCheckLeft, TypeCheckRight, TypeNames, Typeable, TypeableParams, TypedError, TypedErrorContext, type UIO, UUID, UniversalContainer, UntypedMatch, type Unwrap, UrlString, ValidatedBrand, type ValidatedBrand as ValidatedBrandType, type ValidatedBrandCompanion, Validation, ValidationRule, Validator, Valuable, ValuableParams, type 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-BxyCNnFT.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-DZR10yks.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-BxyCNnFT.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-DZR10yks.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-BxyCNnFT.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-DZR10yks.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-BxyCNnFT.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-DZR10yks.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-BxyCNnFT.js";export{e as Set};
|
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
`),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(`
|
|
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,expect:t=>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`)},expect(e){return e()},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
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(`
|
|
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,expect: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},expect:t=>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
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
|
-
`)[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(`
|
|
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,expect:t=>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},expect:t=>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(`
|
|
10
10
|
`).slice(1).join(`
|
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-DZR10yks.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-BxyCNnFT.js";export{e as Try};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype",
|
|
3
|
-
"version": "0.60.
|
|
3
|
+
"version": "0.60.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A functional programming library for TypeScript, using immutable data structures and type classes",
|
|
6
6
|
"keywords": [
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@eslint/compat": "^2.1.0",
|
|
33
33
|
"@types/node": "~24.10.15",
|
|
34
|
-
"eslint-config-functype": "2.3.0",
|
|
35
34
|
"eslint-plugin-functional": "^9.0.4",
|
|
36
|
-
"fast-check": "^4.
|
|
35
|
+
"fast-check": "^4.8.0",
|
|
37
36
|
"globals": "^17.6.0",
|
|
38
37
|
"ts-builds": "^2.8.0",
|
|
39
38
|
"tsdown": "^0.22.0",
|
|
40
|
-
"tsx": "^4.
|
|
41
|
-
"typedoc": "^0.28.19"
|
|
39
|
+
"tsx": "^4.22.2",
|
|
40
|
+
"typedoc": "^0.28.19",
|
|
41
|
+
"eslint-config-functype": "^2.60.7"
|
|
42
42
|
},
|
|
43
43
|
"types": "./dist/index.d.ts",
|
|
44
44
|
"module": "./dist/index.js",
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
"build:watch": "ts-builds dev",
|
|
181
181
|
"dev": "ts-builds dev",
|
|
182
182
|
"compile": "ts-builds compile",
|
|
183
|
-
"clean": "
|
|
183
|
+
"clean": "rm -rf dist",
|
|
184
184
|
"bench": "vitest bench",
|
|
185
185
|
"bench:ui": "vitest bench --ui",
|
|
186
186
|
"docs:preprocess": "tsx scripts/preprocess-docs.ts",
|