functype 0.57.3 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-vTMoBp4S.js → full-interfaces-CFgKdoOy.js} +69 -59
- package/dist/{index-CPGqLMJY.d.ts → index-VSAy-IRN.d.ts} +106 -44
- 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-C7PxhgcS.js → src-CmTVH4Yo.js} +3 -3
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +1 -1
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-CFgKdoOy.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{Dt as e,J as t,yt as n}from"../src-
|
|
2
|
+
import{Dt as e,J as t,yt as n}from"../src-CmTVH4Yo.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-CFgKdoOy.js";const c=()=>{let t=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(t)((t,[r,a])=>{let o=t.add(r.toUpperCase());return n(a).foldLeft(o)((t,n)=>e(i[n]).fold(()=>t,e=>{let r=e.interfaces.length>0?` [${e.interfaces.join(`, `)}]`:``;return t.add(` ${n}${r}`).add(` ${e.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
3
|
`)},l=(t,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${t}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((t,i)=>e(r.methods[i]).filter(e=>e.length>0).fold(()=>t,e=>{let r=t.add(i.toUpperCase());return n(e).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=t=>e(i[t]).map(e=>({name:t,data:e})).or(n(Object.entries(i)).find(([e])=>e.toLowerCase()===t.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`)}},_=t=>e(s[t]).or(n(Object.entries(s)).find(([e])=>e.toLowerCase()===t.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, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError,
|
|
1
|
+
import { a as EmptyListError, c as LeftError, cr as Doable, d as isDoCapable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, sr as DoResult, t as $, u as NoneError } from "../index-VSAy-IRN.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-CmTVH4Yo.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-VSAy-IRN.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-CmTVH4Yo.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,5 @@
|
|
|
1
|
-
const e=`0.
|
|
1
|
+
const e=`0.58.1`,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`]}},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`]}},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`]}},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
|
+
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
2
3
|
/** The contained value (undefined for None) */
|
|
3
4
|
readonly value: T | undefined
|
|
4
5
|
/** Whether this Option contains no value */
|
|
@@ -14,11 +15,12 @@ const e=`0.57.3`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
14
15
|
*/
|
|
15
16
|
isNone(): this is Option<T> & { value: undefined; isEmpty: true }
|
|
16
17
|
/**
|
|
17
|
-
* Returns the contained value or a default value if None
|
|
18
|
+
* Returns the contained value or a default value if None. The default may be of a
|
|
19
|
+
* different type; the result widens to \`T | T2\` so Option stays covariant in T.
|
|
18
20
|
* @param defaultValue - The value to return if this Option is None
|
|
19
|
-
* @returns The contained value or defaultValue
|
|
21
|
+
* @returns The contained value or defaultValue, typed as \`T | T2\`
|
|
20
22
|
*/
|
|
21
|
-
orElse(defaultValue:
|
|
23
|
+
orElse<T2 extends Type>(defaultValue: T2): T | T2
|
|
22
24
|
/**
|
|
23
25
|
* Returns the contained value or throws an error if None
|
|
24
26
|
* @param error - Optional custom error to throw. If not provided, throws a default error
|
|
@@ -27,11 +29,12 @@ const e=`0.57.3`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
27
29
|
*/
|
|
28
30
|
orThrow(error?: Error): T
|
|
29
31
|
/**
|
|
30
|
-
* Returns this Option if it contains a value, otherwise returns the alternative container
|
|
32
|
+
* Returns this Option if it contains a value, otherwise returns the alternative container.
|
|
33
|
+
* The alternative may hold a different type; the result widens to \`Option<T | T2>\`.
|
|
31
34
|
* @param alternative - The alternative Option to return if this is None
|
|
32
|
-
* @returns This Option or the alternative
|
|
35
|
+
* @returns This Option or the alternative, typed as \`Option<T | T2>\`
|
|
33
36
|
*/
|
|
34
|
-
or(alternative: Option<
|
|
37
|
+
or<T2 extends Type>(alternative: Option<T2>): Option<T | T2>
|
|
35
38
|
/**
|
|
36
39
|
* Returns the contained value or null if None
|
|
37
40
|
* @returns The contained value or null
|
|
@@ -108,17 +111,17 @@ const e=`0.57.3`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
108
111
|
* @returns A function that takes an operation to apply
|
|
109
112
|
*/
|
|
110
113
|
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B
|
|
111
|
-
/**
|
|
112
|
-
* Converts this Option to a List
|
|
113
|
-
* @returns A List containing the value if Some, or empty List if None
|
|
114
|
-
*/
|
|
115
|
-
toList(): List<T>
|
|
116
114
|
/**
|
|
117
115
|
* Checks if this Option contains the specified value
|
|
118
116
|
* @param value - The value to check for
|
|
119
117
|
* @returns true if this Option contains the value, false otherwise
|
|
120
118
|
*/
|
|
121
119
|
contains(value: T): boolean
|
|
120
|
+
/**
|
|
121
|
+
* Converts this Option to a List.
|
|
122
|
+
* @returns A List containing the value if Some, or empty List if None
|
|
123
|
+
*/
|
|
124
|
+
toList(): List<T>
|
|
122
125
|
/** The number of elements in this Option (0 or 1) */
|
|
123
126
|
size: number
|
|
124
127
|
/**
|
|
@@ -157,9 +160,10 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
157
160
|
isRight(): this is RightOf<L, R> {
|
|
158
161
|
return true
|
|
159
162
|
},
|
|
160
|
-
orElse: (_defaultValue:
|
|
163
|
+
orElse: <R2 extends Type>(_defaultValue: R2): R | R2 => value,
|
|
161
164
|
orThrow: () => value,
|
|
162
|
-
or: <L2 extends Type>(_alternative: Either<L2,
|
|
165
|
+
or: <L2 extends Type, R2 extends Type>(_alternative: Either<L2, R2>): Either<L | L2, R | R2> =>
|
|
166
|
+
Right<L | L2, R | R2>(value),
|
|
163
167
|
orNull: () => value,
|
|
164
168
|
orUndefined: () => value,
|
|
165
169
|
map: <U extends Type>(f: (value: R) => U): Either<L, U> => Right(f(value)),
|
|
@@ -197,9 +201,6 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
197
201
|
const result = f(value)
|
|
198
202
|
return result.isLeft() ? Left<L | L2, U[]>(result.value as L2) : Right<L | L2, U[]>([result.value as U])
|
|
199
203
|
},
|
|
200
|
-
*lazyMap<U extends Type>(f: (value: R) => U) {
|
|
201
|
-
yield Right<L, U>(f(value))
|
|
202
|
-
},
|
|
203
204
|
tap: (f: (value: R) => void) => {
|
|
204
205
|
f(value)
|
|
205
206
|
return Right<L, R>(value)
|
|
@@ -225,17 +226,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
225
226
|
pipeEither: <U extends Type>(_onLeft: (value: L) => U, onRight: (value: R) => U) => onRight(value),
|
|
226
227
|
pipe: <U extends Type>(f: (value: L | R) => U) => f(value),
|
|
227
228
|
serialize: () => createSerializer("Right", value),
|
|
228
|
-
get size() {
|
|
229
|
-
return 1
|
|
230
|
-
},
|
|
231
|
-
get isEmpty() {
|
|
232
|
-
return false
|
|
233
|
-
},
|
|
234
229
|
contains: (v: R) => value === v,
|
|
235
|
-
reduce: (_f: (b: R, a: R) => R) => value,
|
|
236
|
-
reduceRight: (_f: (b: R, a: R) => R) => value,
|
|
237
|
-
count: (p: (x: R) => boolean) => (p(value) ? 1 : 0),
|
|
238
|
-
find: (p: (a: R) => boolean) => (p(value) ? Some(value) : None<R>()),
|
|
239
230
|
exists: (p: (a: R) => boolean) => p(value),
|
|
240
231
|
forEach: (f: (a: R) => void) => f(value),
|
|
241
232
|
// Implement Doable interface for Do-notation
|
|
@@ -244,13 +235,18 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
244
235
|
},
|
|
245
236
|
})
|
|
246
237
|
|
|
247
|
-
export interface EitherBase<L extends Type, R extends Type>
|
|
248
|
-
extends
|
|
238
|
+
export interface EitherBase<out L extends Type, out R extends Type>
|
|
239
|
+
extends
|
|
240
|
+
FunctypeSum<R, "Left" | "Right">,
|
|
241
|
+
Promisable<R>,
|
|
242
|
+
Doable<R>,
|
|
243
|
+
Reshapeable<R>,
|
|
244
|
+
Omit<Extractable<R>, "or" | "orElse"> {
|
|
249
245
|
isLeft(): this is LeftOf<L, R>
|
|
250
246
|
isRight(): this is RightOf<L, R>
|
|
251
|
-
orElse
|
|
247
|
+
orElse<R2 extends Type>(defaultValue: R2): R | R2
|
|
252
248
|
orThrow: (error?: Error) => R
|
|
253
|
-
or<L2 extends Type>(alternative: Either<L2,
|
|
249
|
+
or<L2 extends Type, R2 extends Type>(alternative: Either<L2, R2>): Either<L | L2, R | R2>
|
|
254
250
|
orNull: () => R | null
|
|
255
251
|
orUndefined: () => R | undefined
|
|
256
252
|
readonly map: <U extends Type>(f: (value: R) => U) => Either<L, U>
|
|
@@ -260,12 +256,10 @@ export interface EitherBase<L extends Type, R extends Type>
|
|
|
260
256
|
flatMap: <L2 extends Type, U extends Type>(f: (value: R) => Either<L2, U>) => Either<L | L2, U>
|
|
261
257
|
flatMapAsync: <L2 extends Type, U extends Type>(f: (value: R) => Promise<Either<L2, U>>) => Promise<Either<L | L2, U>>
|
|
262
258
|
toOption: () => Option<R>
|
|
263
|
-
toList: () => List<R>
|
|
264
259
|
toString: () => string
|
|
265
260
|
[Symbol.iterator]: () => Iterator<R>
|
|
266
261
|
yield: () => Generator<R, void, unknown>
|
|
267
262
|
traverse: <L2 extends Type, U extends Type>(f: (value: R) => Either<L2, U>) => Either<L | L2, U[]>
|
|
268
|
-
lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>
|
|
269
263
|
tap: (f: (value: R) => void) => Either<L, R>
|
|
270
264
|
tapLeft: (f: (value: L) => void) => Either<L, R>
|
|
271
265
|
mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>
|
|
@@ -300,28 +294,33 @@ export interface EitherBase<L extends Type, R extends Type>
|
|
|
300
294
|
toJSON(): { _tag: "Left" | "Right"; value: L | R }
|
|
301
295
|
}
|
|
302
296
|
|
|
303
|
-
export interface LeftOf<L extends Type, R extends Type> extends EitherBase<L, R> {
|
|
297
|
+
export interface LeftOf<out L extends Type, out R extends Type> extends EitherBase<L, R> {
|
|
304
298
|
readonly _tag: "Left"
|
|
305
299
|
readonly value: L
|
|
306
300
|
}
|
|
307
301
|
|
|
308
|
-
export interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R> {
|
|
302
|
+
export interface RightOf<out L extends Type, out R extends Type> extends EitherBase<L, R> {
|
|
309
303
|
readonly _tag: "Right"
|
|
310
304
|
readonly value: R
|
|
311
|
-
}`,Try:`export interface Try<T>
|
|
312
|
-
extends
|
|
305
|
+
}`,Try:`export interface Try<out T>
|
|
306
|
+
extends
|
|
307
|
+
FunctypeSum<T, TypeNames>,
|
|
308
|
+
Omit<Extractable<T>, "or" | "orElse">,
|
|
309
|
+
Pipe<T>,
|
|
310
|
+
Promisable<T>,
|
|
311
|
+
Doable<T>,
|
|
312
|
+
Reshapeable<T> {
|
|
313
313
|
readonly _tag: TypeNames
|
|
314
314
|
readonly error: Error | undefined
|
|
315
315
|
isSuccess(): this is Try<T> & { readonly _tag: "Success"; error: undefined }
|
|
316
316
|
isFailure(): this is Try<T> & { readonly _tag: "Failure"; error: Error }
|
|
317
|
-
orElse
|
|
317
|
+
orElse<T2 extends Type>(defaultValue: T2): T | T2
|
|
318
318
|
orThrow: (error?: Error) => T
|
|
319
|
-
or
|
|
319
|
+
or<T2 extends Type>(alternative: Try<T2>): Try<T | T2>
|
|
320
320
|
orNull: () => T | null
|
|
321
321
|
orUndefined: () => T | undefined
|
|
322
322
|
toOption: () => Option<T>
|
|
323
323
|
toEither: <E extends Type>(leftValue: E) => Either<E, T>
|
|
324
|
-
toList: () => List<T>
|
|
325
324
|
toTry: () => Try<T>
|
|
326
325
|
map: <U>(f: (value: T) => U) => Try<U>
|
|
327
326
|
ap: <U>(ff: Try<(value: T) => U>) => Try<U>
|
|
@@ -350,19 +349,18 @@ export interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R
|
|
|
350
349
|
*/
|
|
351
350
|
match<R>(patterns: { Success: (value: T) => R; Failure: (error: Error) => R }): R
|
|
352
351
|
/**
|
|
353
|
-
* Recovers from a Failure by applying a function to the error, returning a new Try
|
|
354
|
-
*
|
|
355
|
-
*
|
|
352
|
+
* Recovers from a Failure by applying a function to the error, returning a new Try.
|
|
353
|
+
* The recovery value may be a wider type; the result is \`Try<T | U>\`, matching
|
|
354
|
+
* Scala's \`recover[U >: T]\` shape so Try stays covariant in T.
|
|
356
355
|
*/
|
|
357
|
-
recover
|
|
356
|
+
recover<U extends Type>(f: (error: Error) => U): Try<T | U>
|
|
358
357
|
/**
|
|
359
|
-
* Recovers from a Failure by applying a function that returns a new Try
|
|
360
|
-
*
|
|
361
|
-
* @returns The result of f if Failure, otherwise this
|
|
358
|
+
* Recovers from a Failure by applying a function that returns a new Try.
|
|
359
|
+
* As with \`recover\`, the recovery Try may carry a wider type; the result widens accordingly.
|
|
362
360
|
*/
|
|
363
|
-
recoverWith
|
|
361
|
+
recoverWith<U extends Type>(f: (error: Error) => Try<U>): Try<T | U>
|
|
364
362
|
toValue(): { _tag: TypeNames; value: T | Error }
|
|
365
|
-
}`,List:`export interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
|
|
363
|
+
}`,List:`export interface List<out A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
|
|
366
364
|
readonly length: number
|
|
367
365
|
readonly [Symbol.iterator]: () => Iterator<A>
|
|
368
366
|
// Override these to return List instead of FunctypeCollection
|
|
@@ -377,11 +375,14 @@ export interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R
|
|
|
377
375
|
// List-specific methods
|
|
378
376
|
/** @internal */
|
|
379
377
|
filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>
|
|
380
|
-
|
|
378
|
+
/** Remove a value. Accepts \`unknown\` so an unrelated-type arg is a safe no-op (Scala: \`-(elem: Any)\`). */
|
|
379
|
+
remove: (value: unknown) => List<A>
|
|
381
380
|
removeAt: (index: number) => List<A>
|
|
382
|
-
|
|
381
|
+
/** Add a value, possibly widening the element type (Scala: \`:+[B >: A]\`). */
|
|
382
|
+
add<B>(item: B): List<A | B>
|
|
383
383
|
get: (index: number) => Option<A>
|
|
384
|
-
|
|
384
|
+
/** Concatenate with another list, possibly widening (Scala: \`++[B >: A]\`). */
|
|
385
|
+
concat<B>(other: List<B>): List<A | B>
|
|
385
386
|
take: (n: number) => List<A>
|
|
386
387
|
takeWhile: (p: (a: A) => boolean) => List<A>
|
|
387
388
|
takeRight: (n: number) => List<A>
|
|
@@ -390,8 +391,10 @@ export interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R
|
|
|
390
391
|
get tail(): List<A>
|
|
391
392
|
get init(): List<A>
|
|
392
393
|
reverse: () => List<A>
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
/** Find the index of a value. Accepts \`unknown\` (Scala: \`indexOf(elem: Any)\`). */
|
|
395
|
+
indexOf: (value: unknown) => number
|
|
396
|
+
/** Prepend a value, possibly widening (Scala: \`+:[B >: A]\`). */
|
|
397
|
+
prepend<B>(item: B): List<A | B>
|
|
395
398
|
distinct: () => List<A>
|
|
396
399
|
sorted: (compareFn?: (a: A, b: A) => number) => List<A>
|
|
397
400
|
sortBy: <B>(f: (a: A) => B, compareFn?: (a: B, b: B) => number) => List<A>
|
|
@@ -401,22 +404,29 @@ export interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R
|
|
|
401
404
|
partition: (p: (a: A) => boolean) => [List<A>, List<A>]
|
|
402
405
|
span: (p: (a: A) => boolean) => [List<A>, List<A>]
|
|
403
406
|
slice: (start: number, end: number) => List<A>
|
|
407
|
+
/** Contains check. Accepts \`unknown\` (Scala: \`contains(elem: Any)\`). */
|
|
408
|
+
contains(value: unknown): boolean
|
|
409
|
+
/** Reduce with a possibly-wider accumulator type (Scala: \`reduce[B >: A]\`). Defaults to \`B = A\`. */
|
|
410
|
+
reduce<B = A>(op: (b: B, a: B) => B): B
|
|
411
|
+
reduceRight<B = A>(op: (b: B, a: B) => B): B
|
|
404
412
|
/**
|
|
405
413
|
* Pattern matches over the List, applying a handler function based on whether it's empty
|
|
406
414
|
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|
|
407
415
|
* @returns The result of applying the matching handler function
|
|
408
416
|
*/
|
|
409
417
|
match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R
|
|
410
|
-
}`,Set:`export interface Set<A> extends FunctypeCollection<A, "Set">, Collection<A> {
|
|
411
|
-
add
|
|
412
|
-
remove: (value:
|
|
413
|
-
contains
|
|
414
|
-
has
|
|
418
|
+
}`,Set:`export interface Set<out A> extends FunctypeCollection<A, "Set">, Collection<A> {
|
|
419
|
+
add<B>(value: B): Set<A | B>
|
|
420
|
+
remove: (value: unknown) => Set<A>
|
|
421
|
+
contains(value: unknown): boolean
|
|
422
|
+
has(value: unknown): boolean
|
|
415
423
|
map: <B>(f: (a: A) => B) => Set<B>
|
|
416
424
|
flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>
|
|
417
425
|
filter: (p: (a: A) => boolean) => Set<A>
|
|
418
426
|
filterNot: (p: (a: A) => boolean) => Set<A>
|
|
419
427
|
fold: <B>(initial: B, fn: (acc: B, a: A) => B) => B
|
|
428
|
+
reduce<B = A>(op: (b: B, a: B) => B): B
|
|
429
|
+
reduceRight<B = A>(op: (b: B, a: B) => B): B
|
|
420
430
|
toList: () => List<A>
|
|
421
431
|
toSet: () => Set<A>
|
|
422
432
|
toArray: <B = A>() => B[]
|
|
@@ -431,7 +431,7 @@ interface Promisable<A extends Type> {
|
|
|
431
431
|
* Possible types of Try instances
|
|
432
432
|
*/
|
|
433
433
|
type TypeNames = "Success" | "Failure";
|
|
434
|
-
interface Try<T> extends
|
|
434
|
+
interface Try<out T> extends FunctypeSum<T, TypeNames>, Omit<Extractable<T>, "or" | "orElse">, Pipe<T>, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
435
435
|
readonly _tag: TypeNames;
|
|
436
436
|
readonly error: Error | undefined;
|
|
437
437
|
isSuccess(): this is Try<T> & {
|
|
@@ -442,14 +442,13 @@ interface Try<T> extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T>, Pr
|
|
|
442
442
|
readonly _tag: "Failure";
|
|
443
443
|
error: Error;
|
|
444
444
|
};
|
|
445
|
-
orElse
|
|
445
|
+
orElse<T2 extends Type>(defaultValue: T2): T | T2;
|
|
446
446
|
orThrow: (error?: Error) => T;
|
|
447
|
-
or
|
|
447
|
+
or<T2 extends Type>(alternative: Try<T2>): Try<T | T2>;
|
|
448
448
|
orNull: () => T | null;
|
|
449
449
|
orUndefined: () => T | undefined;
|
|
450
450
|
toOption: () => Option<T>;
|
|
451
451
|
toEither: <E extends Type>(leftValue: E) => Either<E, T>;
|
|
452
|
-
toList: () => List<T>;
|
|
453
452
|
toTry: () => Try<T>;
|
|
454
453
|
map: <U>(f: (value: T) => U) => Try<U>;
|
|
455
454
|
ap: <U>(ff: Try<(value: T) => U>) => Try<U>;
|
|
@@ -478,17 +477,16 @@ interface Try<T> extends FunctypeBase<T, TypeNames>, Extractable<T>, Pipe<T>, Pr
|
|
|
478
477
|
Failure: (error: Error) => R;
|
|
479
478
|
}): R;
|
|
480
479
|
/**
|
|
481
|
-
* Recovers from a Failure by applying a function to the error, returning a new Try
|
|
482
|
-
*
|
|
483
|
-
*
|
|
480
|
+
* Recovers from a Failure by applying a function to the error, returning a new Try.
|
|
481
|
+
* The recovery value may be a wider type; the result is `Try<T | U>`, matching
|
|
482
|
+
* Scala's `recover[U >: T]` shape so Try stays covariant in T.
|
|
484
483
|
*/
|
|
485
|
-
recover
|
|
484
|
+
recover<U extends Type>(f: (error: Error) => U): Try<T | U>;
|
|
486
485
|
/**
|
|
487
|
-
* Recovers from a Failure by applying a function that returns a new Try
|
|
488
|
-
*
|
|
489
|
-
* @returns The result of f if Failure, otherwise this
|
|
486
|
+
* Recovers from a Failure by applying a function that returns a new Try.
|
|
487
|
+
* As with `recover`, the recovery Try may carry a wider type; the result widens accordingly.
|
|
490
488
|
*/
|
|
491
|
-
recoverWith
|
|
489
|
+
recoverWith<U extends Type>(f: (error: Error) => Try<U>): Try<T | U>;
|
|
492
490
|
toValue(): {
|
|
493
491
|
_tag: TypeNames;
|
|
494
492
|
value: T | Error;
|
|
@@ -4124,16 +4122,24 @@ declare const createSerializationCompanion: <T>(reconstructor: (parsed: {
|
|
|
4124
4122
|
};
|
|
4125
4123
|
//#endregion
|
|
4126
4124
|
//#region src/set/Set.d.ts
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4125
|
+
/**
|
|
4126
|
+
* Immutable Set. Covariant in A (`<out A>`) — while Scala's `Set[A]` is nominally invariant,
|
|
4127
|
+
* functype's Set follows the same pragmatic covariance pattern as List: element-query methods
|
|
4128
|
+
* (`contains`, `has`, `remove`) accept `unknown`, and additions widen via `<B>(B) => Set<A | B>`.
|
|
4129
|
+
* `reduce`/`reduceRight` follow Scala's `reduce[B >: A]` pattern with a default `B = A`.
|
|
4130
|
+
*/
|
|
4131
|
+
interface Set<out A> extends FunctypeCollection<A, "Set">, Collection<A> {
|
|
4132
|
+
add<B>(value: B): Set<A | B>;
|
|
4133
|
+
remove: (value: unknown) => Set<A>;
|
|
4134
|
+
contains(value: unknown): boolean;
|
|
4135
|
+
has(value: unknown): boolean;
|
|
4132
4136
|
map: <B>(f: (a: A) => B) => Set<B>;
|
|
4133
4137
|
flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>;
|
|
4134
4138
|
filter: (p: (a: A) => boolean) => Set<A>;
|
|
4135
4139
|
filterNot: (p: (a: A) => boolean) => Set<A>;
|
|
4136
4140
|
fold: <B>(initial: B, fn: (acc: B, a: A) => B) => B;
|
|
4141
|
+
reduce<B = A>(op: (b: B, a: B) => B): B;
|
|
4142
|
+
reduceRight<B = A>(op: (b: B, a: B) => B): B;
|
|
4137
4143
|
toList: () => List<A>;
|
|
4138
4144
|
toSet: () => Set<A>;
|
|
4139
4145
|
toArray: <B = A>() => B[];
|
|
@@ -4320,7 +4326,7 @@ declare const Stack: (<A extends Type>(values?: A[]) => Stack<A>) & {
|
|
|
4320
4326
|
* It's used to handle potentially null or undefined values in a type-safe way.
|
|
4321
4327
|
* @typeParam T - The type of the value contained in the Option
|
|
4322
4328
|
*/
|
|
4323
|
-
interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
4329
|
+
interface Option<out T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
4324
4330
|
/** The contained value (undefined for None) */
|
|
4325
4331
|
readonly value: T | undefined;
|
|
4326
4332
|
/** Whether this Option contains no value */
|
|
@@ -4342,11 +4348,12 @@ interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisabl
|
|
|
4342
4348
|
isEmpty: true;
|
|
4343
4349
|
};
|
|
4344
4350
|
/**
|
|
4345
|
-
* Returns the contained value or a default value if None
|
|
4351
|
+
* Returns the contained value or a default value if None. The default may be of a
|
|
4352
|
+
* different type; the result widens to `T | T2` so Option stays covariant in T.
|
|
4346
4353
|
* @param defaultValue - The value to return if this Option is None
|
|
4347
|
-
* @returns The contained value or defaultValue
|
|
4354
|
+
* @returns The contained value or defaultValue, typed as `T | T2`
|
|
4348
4355
|
*/
|
|
4349
|
-
orElse(defaultValue:
|
|
4356
|
+
orElse<T2 extends Type>(defaultValue: T2): T | T2;
|
|
4350
4357
|
/**
|
|
4351
4358
|
* Returns the contained value or throws an error if None
|
|
4352
4359
|
* @param error - Optional custom error to throw. If not provided, throws a default error
|
|
@@ -4355,11 +4362,12 @@ interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisabl
|
|
|
4355
4362
|
*/
|
|
4356
4363
|
orThrow(error?: Error): T;
|
|
4357
4364
|
/**
|
|
4358
|
-
* Returns this Option if it contains a value, otherwise returns the alternative container
|
|
4365
|
+
* Returns this Option if it contains a value, otherwise returns the alternative container.
|
|
4366
|
+
* The alternative may hold a different type; the result widens to `Option<T | T2>`.
|
|
4359
4367
|
* @param alternative - The alternative Option to return if this is None
|
|
4360
|
-
* @returns This Option or the alternative
|
|
4368
|
+
* @returns This Option or the alternative, typed as `Option<T | T2>`
|
|
4361
4369
|
*/
|
|
4362
|
-
or(alternative: Option<
|
|
4370
|
+
or<T2 extends Type>(alternative: Option<T2>): Option<T | T2>;
|
|
4363
4371
|
/**
|
|
4364
4372
|
* Returns the contained value or null if None
|
|
4365
4373
|
* @returns The contained value or null
|
|
@@ -4436,17 +4444,17 @@ interface Option<T extends Type> extends Functype<T, "Some" | "None">, Promisabl
|
|
|
4436
4444
|
* @returns A function that takes an operation to apply
|
|
4437
4445
|
*/
|
|
4438
4446
|
foldRight<B>(z: B): (op: (a: T, b: B) => B) => B;
|
|
4439
|
-
/**
|
|
4440
|
-
* Converts this Option to a List
|
|
4441
|
-
* @returns A List containing the value if Some, or empty List if None
|
|
4442
|
-
*/
|
|
4443
|
-
toList(): List<T>;
|
|
4444
4447
|
/**
|
|
4445
4448
|
* Checks if this Option contains the specified value
|
|
4446
4449
|
* @param value - The value to check for
|
|
4447
4450
|
* @returns true if this Option contains the value, false otherwise
|
|
4448
4451
|
*/
|
|
4449
4452
|
contains(value: T): boolean;
|
|
4453
|
+
/**
|
|
4454
|
+
* Converts this Option to a List.
|
|
4455
|
+
* @returns A List containing the value if Some, or empty List if None
|
|
4456
|
+
*/
|
|
4457
|
+
toList(): List<T>;
|
|
4450
4458
|
/** The number of elements in this Option (0 or 1) */
|
|
4451
4459
|
size: number;
|
|
4452
4460
|
/**
|
|
@@ -4552,7 +4560,20 @@ declare const Option: (<T extends Type>(value: T | null | undefined) => Option<T
|
|
|
4552
4560
|
};
|
|
4553
4561
|
//#endregion
|
|
4554
4562
|
//#region src/list/List.d.ts
|
|
4555
|
-
|
|
4563
|
+
/**
|
|
4564
|
+
* Immutable List. Covariant in A (`<out A>`) — mirrors Scala's `List[+A]`.
|
|
4565
|
+
*
|
|
4566
|
+
* Methods that would otherwise force A-invariance use TS equivalents of Scala's
|
|
4567
|
+
* co-variance patterns:
|
|
4568
|
+
* - query/removal ops (`contains`, `indexOf`, `remove`) take `unknown`, matching
|
|
4569
|
+
* Scala's `-(elem: Any)` / `contains(elem: Any)` — if the value can't possibly
|
|
4570
|
+
* be in the list, it's a no-op, not a type error.
|
|
4571
|
+
* - additive ops (`add`, `prepend`, `concat`) widen the element type, matching
|
|
4572
|
+
* Scala's `::[B >: A]` / `++[B >: A]` — `List<A> + B` produces `List<A | B>`.
|
|
4573
|
+
* - `reduce` / `reduceRight` accept a wider accumulator type, matching Scala's
|
|
4574
|
+
* `reduce[B >: A]`.
|
|
4575
|
+
*/
|
|
4576
|
+
interface List<out A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
|
|
4556
4577
|
readonly length: number;
|
|
4557
4578
|
readonly [Symbol.iterator]: () => Iterator<A>;
|
|
4558
4579
|
map: <B>(f: (a: A) => B) => List<B>;
|
|
@@ -4564,11 +4585,14 @@ interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<
|
|
|
4564
4585
|
filterNot: (p: (a: A) => boolean) => List<A>;
|
|
4565
4586
|
/** @internal */
|
|
4566
4587
|
filterType: <T extends Typeable<string, unknown>>(tag: string) => List<T & A>;
|
|
4567
|
-
|
|
4588
|
+
/** Remove a value. Accepts `unknown` so an unrelated-type arg is a safe no-op (Scala: `-(elem: Any)`). */
|
|
4589
|
+
remove: (value: unknown) => List<A>;
|
|
4568
4590
|
removeAt: (index: number) => List<A>;
|
|
4569
|
-
|
|
4591
|
+
/** Add a value, possibly widening the element type (Scala: `:+[B >: A]`). */
|
|
4592
|
+
add<B>(item: B): List<A | B>;
|
|
4570
4593
|
get: (index: number) => Option<A>;
|
|
4571
|
-
|
|
4594
|
+
/** Concatenate with another list, possibly widening (Scala: `++[B >: A]`). */
|
|
4595
|
+
concat<B>(other: List<B>): List<A | B>;
|
|
4572
4596
|
take: (n: number) => List<A>;
|
|
4573
4597
|
takeWhile: (p: (a: A) => boolean) => List<A>;
|
|
4574
4598
|
takeRight: (n: number) => List<A>;
|
|
@@ -4577,8 +4601,10 @@ interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<
|
|
|
4577
4601
|
get tail(): List<A>;
|
|
4578
4602
|
get init(): List<A>;
|
|
4579
4603
|
reverse: () => List<A>;
|
|
4580
|
-
|
|
4581
|
-
|
|
4604
|
+
/** Find the index of a value. Accepts `unknown` (Scala: `indexOf(elem: Any)`). */
|
|
4605
|
+
indexOf: (value: unknown) => number;
|
|
4606
|
+
/** Prepend a value, possibly widening (Scala: `+:[B >: A]`). */
|
|
4607
|
+
prepend<B>(item: B): List<A | B>;
|
|
4582
4608
|
distinct: () => List<A>;
|
|
4583
4609
|
sorted: (compareFn?: (a: A, b: A) => number) => List<A>;
|
|
4584
4610
|
sortBy: <B>(f: (a: A) => B, compareFn?: (a: B, b: B) => number) => List<A>;
|
|
@@ -4588,6 +4614,11 @@ interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<
|
|
|
4588
4614
|
partition: (p: (a: A) => boolean) => [List<A>, List<A>];
|
|
4589
4615
|
span: (p: (a: A) => boolean) => [List<A>, List<A>];
|
|
4590
4616
|
slice: (start: number, end: number) => List<A>;
|
|
4617
|
+
/** Contains check. Accepts `unknown` (Scala: `contains(elem: Any)`). */
|
|
4618
|
+
contains(value: unknown): boolean;
|
|
4619
|
+
/** Reduce with a possibly-wider accumulator type (Scala: `reduce[B >: A]`). Defaults to `B = A`. */
|
|
4620
|
+
reduce<B = A>(op: (b: B, a: B) => B): B;
|
|
4621
|
+
reduceRight<B = A>(op: (b: B, a: B) => B): B;
|
|
4591
4622
|
/**
|
|
4592
4623
|
* Pattern matches over the List, applying a handler function based on whether it's empty
|
|
4593
4624
|
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|
|
@@ -4693,6 +4724,37 @@ interface FunctypeCollection<A, Tag extends string = string> extends Omit<Functy
|
|
|
4693
4724
|
flatMapAsync<B extends Type>(f: (value: A) => PromiseLike<Iterable<B>>): PromiseLike<FunctypeCollection<B, Tag>>;
|
|
4694
4725
|
}
|
|
4695
4726
|
//#endregion
|
|
4727
|
+
//#region src/functype/FunctypeSum.d.ts
|
|
4728
|
+
/**
|
|
4729
|
+
* Base interface for sum-type containers (Either, Try, etc.) that are NOT iterables.
|
|
4730
|
+
*
|
|
4731
|
+
* Unlike `FunctypeBase`, this base deliberately excludes `Traversable` — which bundles
|
|
4732
|
+
* `reduce` / `reduceRight` / `size` / `isEmpty`. Those methods force A-invariance on their
|
|
4733
|
+
* containers (signature `(f: (A, A) => A) => A` puts A in both contravariant and covariant
|
|
4734
|
+
* positions) and have no semantic meaning for disjoint-union types where the "success"
|
|
4735
|
+
* branch is 0-or-1, not a collection.
|
|
4736
|
+
*
|
|
4737
|
+
* Sum types that extend `FunctypeSum` can be declared covariant in their type parameter
|
|
4738
|
+
* (`interface Foo<out A>`) without structural check failures. This mirrors Scala's model:
|
|
4739
|
+
* `Either[+L, +R]` and `Try[+T]` do not extend `Iterable`; only `Option[+A]` extends the
|
|
4740
|
+
* lighter `IterableOnce[+A]`.
|
|
4741
|
+
*
|
|
4742
|
+
* Only the covariance-safe subset of `ContainerOps` is included inline: `contains`,
|
|
4743
|
+
* `exists`, and `forEach` all place A only in contravariant (callback input) position.
|
|
4744
|
+
* `find` (returns `Option<A>`) and `count` are intentionally omitted — if a sum type
|
|
4745
|
+
* needs them it can declare them directly.
|
|
4746
|
+
*
|
|
4747
|
+
* @typeParam A - the type of the "success" branch value
|
|
4748
|
+
* @typeParam Tag - the discriminant tag (e.g., `"Left" | "Right"`, `"Success" | "Failure"`)
|
|
4749
|
+
*/
|
|
4750
|
+
interface FunctypeSum<A extends Type, Tag extends string = string> extends AsyncMonad<A>, Foldable<A>, Serializable<A>, Typeable<Tag> {
|
|
4751
|
+
readonly _tag: Tag;
|
|
4752
|
+
readonly [Symbol.toStringTag]: string;
|
|
4753
|
+
contains(value: A): boolean;
|
|
4754
|
+
exists(p: (a: A) => boolean): boolean;
|
|
4755
|
+
forEach(f: (a: A) => void): void;
|
|
4756
|
+
}
|
|
4757
|
+
//#endregion
|
|
4696
4758
|
//#region src/either/Either.d.ts
|
|
4697
4759
|
/**
|
|
4698
4760
|
* Either type module
|
|
@@ -4706,12 +4768,12 @@ interface FunctypeCollection<A, Tag extends string = string> extends Omit<Functy
|
|
|
4706
4768
|
* union. After `if (e.isLeft())`, the else branch narrows `e` to RightOf<L,R> and
|
|
4707
4769
|
* `e.value` narrows to R without a cast.
|
|
4708
4770
|
*/
|
|
4709
|
-
interface EitherBase<L extends Type, R extends Type> extends
|
|
4771
|
+
interface EitherBase<out L extends Type, out R extends Type> extends FunctypeSum<R, "Left" | "Right">, Promisable<R>, Doable<R>, Reshapeable<R>, Omit<Extractable<R>, "or" | "orElse"> {
|
|
4710
4772
|
isLeft(): this is LeftOf<L, R>;
|
|
4711
4773
|
isRight(): this is RightOf<L, R>;
|
|
4712
|
-
orElse
|
|
4774
|
+
orElse<R2 extends Type>(defaultValue: R2): R | R2;
|
|
4713
4775
|
orThrow: (error?: Error) => R;
|
|
4714
|
-
or<L2 extends Type>(alternative: Either<L2,
|
|
4776
|
+
or<L2 extends Type, R2 extends Type>(alternative: Either<L2, R2>): Either<L | L2, R | R2>;
|
|
4715
4777
|
orNull: () => R | null;
|
|
4716
4778
|
orUndefined: () => R | undefined;
|
|
4717
4779
|
readonly map: <U extends Type>(f: (value: R) => U) => Either<L, U>;
|
|
@@ -4721,12 +4783,10 @@ interface EitherBase<L extends Type, R extends Type> extends FunctypeBase<R, "Le
|
|
|
4721
4783
|
flatMap: <L2 extends Type, U extends Type>(f: (value: R) => Either<L2, U>) => Either<L | L2, U>;
|
|
4722
4784
|
flatMapAsync: <L2 extends Type, U extends Type>(f: (value: R) => Promise<Either<L2, U>>) => Promise<Either<L | L2, U>>;
|
|
4723
4785
|
toOption: () => Option<R>;
|
|
4724
|
-
toList: () => List<R>;
|
|
4725
4786
|
toString: () => string;
|
|
4726
4787
|
[Symbol.iterator]: () => Iterator<R>;
|
|
4727
4788
|
yield: () => Generator<R, void, unknown>;
|
|
4728
4789
|
traverse: <L2 extends Type, U extends Type>(f: (value: R) => Either<L2, U>) => Either<L | L2, U[]>;
|
|
4729
|
-
lazyMap: <U extends Type>(f: (value: R) => U) => Generator<Either<L, U>, void, unknown>;
|
|
4730
4790
|
tap: (f: (value: R) => void) => Either<L, R>;
|
|
4731
4791
|
tapLeft: (f: (value: L) => void) => Either<L, R>;
|
|
4732
4792
|
mapLeft: <L2 extends Type>(f: (value: L) => L2) => Either<L2, R>;
|
|
@@ -4771,20 +4831,22 @@ interface EitherBase<L extends Type, R extends Type> extends FunctypeBase<R, "Le
|
|
|
4771
4831
|
/**
|
|
4772
4832
|
* Left variant of Either. Discriminated by `_tag: "Left"` with `value: L`.
|
|
4773
4833
|
*/
|
|
4774
|
-
interface LeftOf<L extends Type, R extends Type> extends EitherBase<L, R> {
|
|
4834
|
+
interface LeftOf<out L extends Type, out R extends Type> extends EitherBase<L, R> {
|
|
4775
4835
|
readonly _tag: "Left";
|
|
4776
4836
|
readonly value: L;
|
|
4777
4837
|
}
|
|
4778
4838
|
/**
|
|
4779
4839
|
* Right variant of Either. Discriminated by `_tag: "Right"` with `value: R`.
|
|
4780
4840
|
*/
|
|
4781
|
-
interface RightOf<L extends Type, R extends Type> extends EitherBase<L, R> {
|
|
4841
|
+
interface RightOf<out L extends Type, out R extends Type> extends EitherBase<L, R> {
|
|
4782
4842
|
readonly _tag: "Right";
|
|
4783
4843
|
readonly value: R;
|
|
4784
4844
|
}
|
|
4785
4845
|
/**
|
|
4786
4846
|
* Either is a discriminated union of LeftOf and RightOf. TypeScript narrows
|
|
4787
|
-
* across both branches of `isLeft()` / `isRight()` and `_tag` checks.
|
|
4847
|
+
* across both branches of `isLeft()` / `isRight()` and `_tag` checks. Variance
|
|
4848
|
+
* is inherited from LeftOf/RightOf (both covariant in L and R) — union type
|
|
4849
|
+
* aliases cannot carry their own variance annotations in TS.
|
|
4788
4850
|
*/
|
|
4789
4851
|
type Either<L extends Type, R extends Type> = LeftOf<L, R> | RightOf<L, R>;
|
|
4790
4852
|
type TestEither<L extends Type, R extends Type> = Either<L, R> & AsyncMonad<R>;
|
|
@@ -5066,4 +5128,4 @@ interface FailureErrorType extends Error {
|
|
|
5066
5128
|
}
|
|
5067
5129
|
declare const FailureError: (cause: Error, message?: string) => FailureErrorType;
|
|
5068
5130
|
//#endregion
|
|
5069
|
-
export {
|
|
5131
|
+
export { Map$1 as $, AsyncMonad as $n, TypedErrorContext as $t, Collection as A, Cond as An, Task as At, SerializationResult as B, NonEmptyString as Bn, ContextServices as Bt, isRight as C, isTaggedThrowable as Cn, HttpClientConfig as Ct, Functype as D, Base as Dn, IO as Dt, FunctypeSum as E, ThrowableType as En, TestContext as Et, Some as F, BoundedNumber as Fn, LayerInput as Ft, fromJSON as G, UUID as Gn, FormValidation as Gt, createSerializationCompanion as H, PatternString as Hn, Tag as Ht, Stack as I, BoundedString as In, LayerOutput as It, Obj as J, ValidatedBrandCompanion as Jn, Validator as Jt, fromYAML as K, UrlString as Kn, Validation as Kt, Valuable as L, EmailAddress as Ln, Exit as Lt, None as M, InstanceType as Mn, UIO as Mt, Option as N, isCompanion as Nn, Layer as Nt, FunctypeBase as O, Match as On, InterruptedError as Ot, OptionConstructor as P, Companion as Pn, LayerError as Pt, ESMapType as Q, Applicative as Qn, TypedError as Qt, ValuableParams as R, ISO8601Date as Rn, ExitTag as Rt, isLeft as S, createCancellationTokenSource as Sn, HttpClient as St, tryCatchAsync as T, Throwable as Tn, TestClockTag as Tt, createSerializer as U, PositiveInteger as Un, TagService as Ut, createCustomSerializer as V, NonNegativeNumber as Vn, HasService as Vt, fromBinary as W, PositiveNumber as Wn, FieldValidation as Wt, MatchableUtils as X, TypeNames as Xn, ErrorMessage as Xt, Matchable as Y, Try as Yn, ErrorCode as Yt, ESMap as Z, Promisable as Zn, ErrorStatus as Zt, Right as _, TaskMetadata as _n, DecodeError as _t, EmptyListError as a, formatError as an, Extractable as ar, HKT as at, TypeCheckLeft as b, TaskResult as bn, HttpStatusError as bt, LeftError as c, Async as cn, Doable as cr, OptionKind as ct, isDoCapable as d, Err as dn, FoldableUtils as dt, ErrorChainElement as en, Functor as er, KVTraversable as et, unwrap as f, Ok as fn, Http as ft, LeftOf as g, TaskFailure as gn, ParseMode as gt, Left as h, Task$1 as hn, HttpResponse as ht, DoGenerator as i, createErrorSerializer as in, LazyList as ir, EitherKind as it, List as j, CompanionMethods as jn, TimeoutError as jt, FunctypeCollection as k, UntypedMatch as kn, RIO as kt, LeftErrorType as l, CancellationToken as ln, ParseError as lr, TryKind as lt, EitherBase as m, TaggedThrowable as mn, HttpRequestOptions as mt, Do as n, ErrorWithTaskInfo as nn, CollectionOps as nr, Lazy as nt, FailureError as o, formatStackTrace as on, isExtractable as or, Kind as ot, Either as p, Sync as pn, HttpMethodOptions as pt, Ref as q, ValidatedBrand as qn, ValidationRule as qt, DoAsync as r, TaskErrorInfo as rn, ContainerOps as rr, Identity as rt, FailureErrorType as s, safeStringify as sn, DoResult as sr, ListKind as st, $ as t, ErrorFormatterOptions as tn, Monad as tr, Traversable as tt, NoneError as u, CancellationTokenSource as un, UniversalContainer as ut, RightOf as v, TaskOutcome as vn, HttpError as vt, tryCatch as w, NAME as wn, TestClock as wt, TypeCheckRight as x, TaskSuccess as xn, NetworkError as xt, TestEither as y, TaskParams as yn, HttpMethod as yt, Set as z, IntegerNumber as zn, Context as zt };
|
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
|
|
2
|
+
import { $ as Map, $n as AsyncMonad, $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 Applicative, 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 Promisable, Zt as ErrorStatus, _ as Right, _n as TaskMetadata, _t as DecodeError, a as EmptyListError, an as formatError, ar as Extractable, at as HKT, b as TypeCheckLeft, bn as TaskResult, bt as HttpStatusError, c as LeftError, cn as Async, cr as Doable, ct as OptionKind, d as isDoCapable, dn as Err, dt as FoldableUtils, en as ErrorChainElement, er as Functor, et as KVTraversable, f as unwrap, fn as Ok, 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 LazyList, 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 ParseError, lt as TryKind, m as EitherBase, mn as TaggedThrowable, mt as HttpRequestOptions, n as Do, nn as ErrorWithTaskInfo, nr as CollectionOps, nt as Lazy, o as FailureError, on as formatStackTrace, or as isExtractable, 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 ContainerOps, rt as Identity, s as FailureErrorType, sn as safeStringify, sr as DoResult, st as ListKind, t as $, tn as ErrorFormatterOptions, tr as Monad, tt as Traversable, u as NoneError, un as CancellationTokenSource, 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-VSAy-IRN.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-DwyoW0ZP.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, 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, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
|
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, createBrander, createCancellationTokenSource, createCustomSerializer, createErrorSerializer, createSerializationCompanion, createSerializer, formatError, formatStackTrace, fromBinary, fromJSON, fromYAML, hasBrand, isCompanion, isDoCapable, isExtractable, isLeft, isRight, isTaggedThrowable, isTypeable, safeStringify, tryCatch, tryCatchAsync, unwrap, unwrapBrand };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Brand as e,BrandedBoolean as t,BrandedNumber as n,BrandedString as r,createBrander as i,hasBrand as a,unwrap as o}from"./branded/index.js";import{$ as s,A as c,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,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}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,M as E,Mt as D,N as O,Nt as k,O as A,Ot as j,P as M,Pt as N,Q as P,R as F,S as I,St as L,T as R,Tt as z,U as B,V,W as H,X as U,Y as W,Z as G,_ as K,_t as q,a as J,at as Y,b as X,bt as Z,c as Q,ct as $,d as ee,dt as te,et as ne,f as re,ft as ie,g as ae,gt as oe,h as se,ht as ce,i as le,it as ue,j as de,jt as fe,k as pe,kt as me,l as he,lt as ge,m as _e,mt as ve,n as ye,nt as be,o as xe,ot as Se,p as Ce,pt as we,q as Te,r as Ee,rt as De,s as Oe,st as ke,t as Ae,tt as je,u as Me,ut as Ne,v as Pe,vt as Fe,w as Ie,wt as Le,x as Re,xt as ze,y as Be,yt as Ve,z as He}from"./src-CmTVH4Yo.js";import{r as Ue,t as We}from"./Tuple-DY00RBep.js";export{de as $,Te as Base,G as BoundedNumber,P as BoundedString,e as Brand,t as BrandedBoolean,n as BrandedNumber,r as BrandedString,Ue as Companion,W as Cond,d as Context,E as Do,O as DoAsync,xe as ESMap,Ne as Either,s as EmailAddress,M as EmptyListError,u as Err,I as Exit,_ as FailureError,Me as FoldableUtils,he as HKT,ee as Http,Ce as HttpClient,re as HttpErrors,Be as IO,ne as ISO8601Date,Q as Identity,je as IntegerNumber,X as InterruptedError,Pe as Layer,Oe as Lazy,f as LazyList,te as Left,x as LeftError,Ve as List,J as Map,C as Match,le as MatchableUtils,y as NAME,be as NonEmptyString,De as NonNegativeNumber,g as None,T as NoneError,Ee as Obj,V as Ok,m as Option,j as OptionConstructor,S as ParseError,ue as PatternString,Y as PositiveInteger,Se as PositiveNumber,Le as Ref,ie as Right,z as Set,me as Some,ye as Stack,K as Tag,b as Task,_e as TestClock,se as TestClockTag,ae as TestContext,w as Throwable,Re as TimeoutError,L as Try,We as Tuple,we as TypeCheckLeft,ve as TypeCheckRight,Z as Typeable,h as TypedError,ke as UUID,$ as UrlString,ge as ValidatedBrand,R as Validation,Ae as Valuable,i as createBrander,B as createCancellationTokenSource,l as createCustomSerializer,p as createErrorSerializer,fe as createSerializationCompanion,D as createSerializer,A as formatError,pe as formatStackTrace,k as fromBinary,N as fromJSON,v as fromYAML,a as hasBrand,U as isCompanion,F as isDoCapable,Ie as isExtractable,ce as isLeft,oe as isRight,H as isTaggedThrowable,ze as isTypeable,c as safeStringify,q as tryCatch,Fe as tryCatchAsync,He as unwrap,o as unwrapBrand};
|
package/dist/list/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as List } from "../index-VSAy-IRN.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-CmTVH4Yo.js";export{e as List};
|
package/dist/map/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as Map } from "../index-VSAy-IRN.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-CmTVH4Yo.js";export{e as Map};
|
package/dist/option/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as Some, M as None, N as Option, P as OptionConstructor } from "../index-VSAy-IRN.js";
|
|
2
2
|
export { None, Option, OptionConstructor, Some };
|
package/dist/option/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Dt as e,Et as t,Ot as n,kt as r}from"../src-
|
|
1
|
+
import{Dt as e,Et as t,Ot as n,kt as r}from"../src-CmTVH4Yo.js";export{t as None,e as Option,n as OptionConstructor,r as Some};
|
package/dist/set/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z as Set } from "../index-VSAy-IRN.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-CmTVH4Yo.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:
|
|
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=>t(void 0,e),reduceRight:t=>t(void 0,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:()=>void 0,reduceRight:()=>void 0,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)}},m=r(te,ne),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 n.reduce(e)},reduceRight:e=>{let n=Array.from(t);if(n.length===0)throw Error(`Cannot reduceRight empty Set`);return n.reduceRight(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},re=e=>g(e),ie=g([]),ae={empty:()=>ie,of:(...e)=>g(e),fromJSON:e=>oe(JSON.parse(e).value),fromYAML:e=>{let t=e.split(`
|
|
5
|
-
`)[1]?.split(`: `)[1];return oe(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ae.fromJSON(t)}},oe=r(re,ae),se=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(se,{of:e=>se(e)}),ce=(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)}},le=()=>{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=ce(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=ce(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=ce(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=ce(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=ce(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},ue=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=ce(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),
|
|
5
|
+
`)[1]?.split(`: `)[1];return oe(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return ae.fromJSON(t)}},oe=r(re,ae),se=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(se,{of:e=>se(e)}),ce=(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)}},le=()=>{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=ce(0);for(let r of e){if(n.get()>=t)break;yield r,n.increment()}})()),drop:t=>v((function*(){let n=ce(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=ce(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=ce(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=ce(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},ue=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=ce(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}}}),de=e=>{try{return y(e())}catch(e){return b(e instanceof Error?e:Error(String(e)))}},fe={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 fe.fromJSON(t)}},x=r(de,fe);function pe({_tag:e,impl:t}){return{...t,_tag:e}}function me(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=>me(t,e))),find:(e,n)=>m(t.find(t=>e(t)&&(n?me(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=>t.reduce(e),reduceRight:e=>t.reduceRight(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:()=>oe(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},he=e=>S(e),ge=S([]),_e={empty:()=>ge,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 _e.fromJSON(t)}},C=r(he,_e),ve=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])}
|
|
7
|
+
`)[1]?.split(`: `)[1];return C(t?JSON.parse(t):[])},fromBinary:e=>{let t=Buffer.from(e,`base64`).toString();return _e.fromJSON(t)}},C=r(he,_e),ve=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}}}),ye=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=>ve(e),T=e=>ye(e),be=e=>e.isRight(),xe=e=>e.isLeft(),Se=(e,t)=>{try{return w(e())}catch(e){return T(t(e))}},Ce=e=>ve(e);console.assert(Ce);const we=e=>ye(e);console.assert(we);const Te=async(e,t)=>{try{return w(await e())}catch(e){return T(t(e))}},Ee=(e,t)=>t?w(e):T(e),De={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)=>De.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 De.fromJSON(t)}},Oe=r(Ee,De);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 ke=E(`PositiveNumber`,e=>e>0),Ae=E(`NonNegativeNumber`,e=>e>=0),je=E(`IntegerNumber`,e=>Number.isInteger(e)),Me=ke.refine(`PositiveInteger`,e=>Number.isInteger(e)),Ne=E(`NonEmptyString`,e=>e.length>0),Pe=E(`EmailAddress`,e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)),Fe=E(`UrlString`,e=>{try{return new URL(e),!0}catch{return!1}}),Ie=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)),Le=E(`ISO8601Date`,e=>!isNaN(Date.parse(e))&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(e));function Re(e,t,n){return E(e,e=>e>=t&&e<=n)}function ze(e,t,n){return E(e,e=>e.length>=t&&e.length<=n)}function Be(e,t){return E(e,e=>t.test(e))}const Ve=e=>typeof e==`function`&&Object.keys(e).length>0,He=e=>{let t=e=>typeof e==`function`?e():e,n={when:(r,i)=>e.resolved?n:r?He({resolved:!0,value:t(i)}):n,elseWhen:(r,i)=>e.resolved?n:r?He({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},Ue=()=>He({resolved:!1}),We=r(Ue,{of:()=>Ue(),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}}),D=(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 D(r,n)}):!1,O=e=>{let t=(e,t)=>typeof e==`function`?e(t):e,n=()=>{for(let{pattern:n,result:r}of e.patterns)if(D(e.value,n))return{matched:!0,result:t(r,e.value)};return{matched:!1}},r={case:(n,i)=>e.resolved?r:D(e.value,n)?O({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]}):O({...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 O({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 O({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(D(e.value,r))return O({value:e.value,resolved:!0,result:t(i,e.value),patterns:[]});return O({...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},Ge=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 D(e,n)?O({...i,resolved:!0,result:t(r,e)}):O(i)},caseValue:(t,n)=>O(e===t?{value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}:{value:e,resolved:!1,patterns:[]}),caseValues:(t,n)=>t.includes(e)?O({value:e,resolved:!0,result:typeof n==`function`?n():n,patterns:[]}):O({value:e,resolved:!1,patterns:[]}),when:(n,r)=>{let i={value:e,resolved:!1,patterns:[{pattern:n,result:r}]};return n(e)?O({...i,resolved:!0,result:t(r,e)}):O(i)},caseAny:(n,r)=>{for(let i of n)if(D(e,i))return O({value:e,resolved:!0,result:t(r,e),patterns:n.map(e=>({pattern:e,result:r}))});return O({value:e,resolved:!1,patterns:n.map(e=>({pattern:e,result:r}))})}}},Ke=r(e=>Ge(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(D(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(D(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 qe(e,t){return{...pe({_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 Je=`Throwable`;var Ye=class e extends Error{constructor(e,t){super(e,{cause:t?.cause}),this._tag=Je,this.name=t?.taskInfo?.name??`Throwable`,Object.defineProperties(this,{_tag:{value:Je,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 Xe(e){return e instanceof Error&&typeof e==`object`&&e._tag===`Throwable`}const Ze=(e,t)=>{if(e.isRight())return A(e.orThrow(),t);if(e.isLeft())return k(e.fold(e=>e,()=>Error(`Unexpected right value`)),void 0,t);throw Error(`Unrecognized task outcome`)},k=(e,t,r)=>{let i={name:r?.name??`Task`,description:r?.description??``},a=Ye.apply(e,t,i),o={...qe(`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=>k(a,t,r),flatMap:e=>k(a,t,r),ap:e=>k(a,t,r),mapAsync:e=>Promise.resolve(k(a,t,r)),flatMapAsync:e=>Promise.resolve(k(a,t,r)),mapError:e=>k(e(a),t,r),recover:e=>A(e,r),recoverWith:e=>A(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},A=(e,t)=>{let r={name:t?.name??`Task`,description:t?.description??``},i={...qe(`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=>A(n(e),t),flatMap:n=>{let r=n(e);return r&&typeof r==`object`&&`isLeft`in r&&`isRight`in r?Ze(r,t):r},ap:n=>n.isOk()?A(n.value(e),t):k(n.error,void 0,t),mapAsync:async n=>A(await n(e),t),flatMapAsync:async t=>await t(e),mapError:n=>A(e,t),recover:n=>A(e,t),recoverWith:n=>A(e,t),orThrow:t=>e,orElse:t=>e,or:n=>A(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},Qe=()=>{let e=new AbortController,t=le();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)}}))}}},$e=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(k(e,void 0,{name:t,description:n}));return}o(k(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(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(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(A(r,{name:t,description:n}))}else o(A(r,{name:t,description:n}))}catch(e){try{await i()}catch(e){o(k(e,void 0,{name:t,description:n}));return}if(s.get()){c.get()?o(k(c.get(),void 0,{name:t,description:n})):o(k(Error(`Task was cancelled during execution`),void 0,{name:t,description:n}));return}try{if(e instanceof Error&&Xe(e)){let i=Error(`${t}: ${e.message}`),a=Ye.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(k(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(k(i,void 0,{name:t,description:n}))}else o(k(i,void 0,{name:t,description:n}))}}catch(e){o(k(e,void 0,{name:t,description:n}))}}finally{l.get()()}})().catch(e=>o(k(e,void 0,{name:t,description:n})))}),Sync:(e,r=e=>e,i=()=>{})=>{try{return A(e(),{name:t,description:n})}catch(e){return k(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{...qe(`Task`,r),_type:`Task`}},et={success:(e,t)=>A(e,t),fail:(e,t,n)=>k(e,t,n),ok:(e,t)=>A(e,t),err:(e,t,n)=>k(e,t,n),fromEither:(e,t)=>Ze(e,t),fromTry:(e,t)=>e.isSuccess()?A(e.orThrow(),t):k(e.fold(e=>e,()=>Error(`Unexpected success`)),void 0,t),getErrorChain:e=>{if(!e)return[];let t=le();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=et.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 {
|
|
1
|
+
import { Xn as TypeNames, Yn as Try } from "../index-VSAy-IRN.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-CmTVH4Yo.js";export{e as Try};
|
package/package.json
CHANGED