functype 0.58.1 → 0.59.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/{Tuple-DwyoW0ZP.d.ts → Tuple-De-FhPDq.d.ts} +4 -4
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +4 -4
- 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-CFgKdoOy.js → full-interfaces-B4FY6xGA.js} +21 -52
- package/dist/{index-VSAy-IRN.d.ts → index-BPe5pcCH.d.ts} +137 -70
- package/dist/index.d.ts +3 -3
- 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-Co3npRp-.js +19 -0
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/dist/tuple/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/src-CmTVH4Yo.js +0 -19
|
@@ -15,7 +15,7 @@ type Type = unknown;
|
|
|
15
15
|
*
|
|
16
16
|
* @typeParam A - The type of elements in the data structure
|
|
17
17
|
*/
|
|
18
|
-
interface Foldable<A> {
|
|
18
|
+
interface Foldable<out A> {
|
|
19
19
|
/**
|
|
20
20
|
* Left-associative fold using the provided zero value and operation
|
|
21
21
|
* @param z - Zero/identity value
|
|
@@ -35,7 +35,7 @@ interface Foldable<A> {
|
|
|
35
35
|
* Pipe interface for functional data structures
|
|
36
36
|
* @typeParam T - The type of value to pipe
|
|
37
37
|
*/
|
|
38
|
-
interface Pipe<T extends Type> {
|
|
38
|
+
interface Pipe<out T extends Type> {
|
|
39
39
|
/**
|
|
40
40
|
* Pipes the value through the provided function
|
|
41
41
|
* @param f - The function to apply to the value
|
|
@@ -54,7 +54,7 @@ interface SerializationMethods<T> {
|
|
|
54
54
|
toYAML(): string;
|
|
55
55
|
toBinary(): string;
|
|
56
56
|
}
|
|
57
|
-
interface Serializable<T> {
|
|
57
|
+
interface Serializable<out T> {
|
|
58
58
|
serialize(): SerializationMethods<T>;
|
|
59
59
|
}
|
|
60
60
|
//#endregion
|
|
@@ -103,7 +103,7 @@ declare function Typeable<Tag extends string, T>({
|
|
|
103
103
|
declare function isTypeable<T>(value: unknown, tag: string): value is T;
|
|
104
104
|
//#endregion
|
|
105
105
|
//#region src/tuple/Tuple.d.ts
|
|
106
|
-
interface Tuple<T extends Type[]> extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
|
|
106
|
+
interface Tuple<out T extends Type[]> extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
|
|
107
107
|
readonly [Symbol.toStringTag]: string;
|
|
108
108
|
get<K extends number>(index: K): T[K];
|
|
109
109
|
fold<B>(initial: B, fn: (acc: B, a: T[number]) => B): B;
|
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-B4FY6xGA.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,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
`)},l=(
|
|
2
|
+
import{J as e,kt as t,yt as n}from"../src-Co3npRp-.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-B4FY6xGA.js";const c=()=>{let e=n([`functype ${r} - Scala-inspired FP for TypeScript`,``]);return n(Object.entries(a)).foldLeft(e)((e,[r,a])=>{let o=e.add(r.toUpperCase());return n(a).foldLeft(o)((e,n)=>t(i[n]).fold(()=>e,t=>{let r=t.interfaces.length>0?` [${t.interfaces.join(`, `)}]`:``;return e.add(` ${n}${r}`).add(` ${t.description}`)})).add(``)}).concat(n([`Use: npx functype <Type> for details`,`Use: npx functype interfaces for interface reference`])).toArray().join(`
|
|
3
|
+
`)},l=(e,r)=>{let i=r.interfaces.length>0?` [${r.interfaces.join(`, `)}]`:``,a=n([`create`,`transform`,`extract`,`check`,`other`]),o=n([`${e}<T>${i}`,``,r.description,``]);return a.foldLeft(o)((e,i)=>t(r.methods[i]).filter(e=>e.length>0).fold(()=>e,t=>{let r=e.add(i.toUpperCase());return n(t).foldLeft(r)((e,t)=>e.add(` ${t}`)).add(``)})).toArray().join(`
|
|
4
4
|
`).trimEnd()},u=()=>{let e=n([`INTERFACES`,``]);return n(Object.entries(o)).foldLeft(e)((e,[t,r])=>{let i=r.extends?` extends ${r.extends}`:``,a=e.add(`${t}<A>${i}`).add(` ${r.description}`);return n(r.methods).foldLeft(a)((e,t)=>e.add(` ${t}`)).add(``)}).toArray().join(`
|
|
5
|
-
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=t
|
|
5
|
+
`).trimEnd()},d=e=>JSON.stringify(e,null,2),f=()=>({version:r,categories:a,types:i}),p=e=>t(i[e]).map(t=>({name:e,data:t})).or(n(Object.entries(i)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([e,t])=>({name:e,data:t}))).orUndefined(),m=()=>Object.keys(i),h=()=>o,g=e=>{let t=n(e.slice(2));return{flags:{json:t.contains(`--json`),full:t.contains(`--full`),help:t.exists(e=>e===`--help`||e===`-h`)},args:t.filter(e=>!e.startsWith(`--`)&&e!==`-h`)}},_=e=>t(s[e]).or(n(Object.entries(s)).find(([t])=>t.toLowerCase()===e.toLowerCase()).map(([,e])=>e)),v=()=>{let e=n([`FULL INTERFACE DEFINITIONS`,`=`.repeat(60),``]);return n(Object.entries(s)).foldLeft(e)((e,[t,r])=>e.concat(n([`// ${t}`,r,``,`-`.repeat(60),``]))).toArray().join(`
|
|
6
6
|
`).trimEnd()},y=()=>{console.log(`functype - API documentation for LLMs
|
|
7
7
|
|
|
8
8
|
USAGE
|
|
@@ -24,4 +24,4 @@ EXAMPLES
|
|
|
24
24
|
npx functype Option --json # Option as JSON
|
|
25
25
|
npx functype Option --full # Full TypeScript interface
|
|
26
26
|
npx functype --full # All full interfaces (large output!)
|
|
27
|
-
`)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${m().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(
|
|
27
|
+
`)},b=e=>{console.error(`Unknown type: ${e}`),console.error(``),console.error(`Available types: ${m().join(`, `)}`),console.error(``),console.error(`Use: npx functype interfaces - for interface reference`),process.exit(1)},x=e=>console.log(e),S=(e,n)=>t(p(e)).fold(()=>b(e),e=>{n.full?_(e.name).fold(()=>x(n.json?d({[e.name]:e.data}):l(e.name,e.data)),t=>x(n.json?d({[e.name]:{...e.data,fullInterface:t}}):t)):x(n.json?d({[e.name]:e.data}):l(e.name,e.data))});(()=>{let{flags:t,args:n}=g(process.argv);e(!0).when(()=>t.help,()=>y()).when(()=>n.isEmpty,()=>t.full?x(t.json?d(s):v()):x(t.json?d(f()):c())).when(()=>n.headOption.contains(`interfaces`),()=>x(t.json?d(h()):u())).default(()=>n.headOption.fold(()=>x(t.json?d(f()):c()),e=>S(e,t)))})();
|
package/dist/do/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as EmptyListError, c as LeftError,
|
|
1
|
+
import { a as EmptyListError, c as LeftError, d as isDoCapable, dr as Doable, f as unwrap, i as DoGenerator, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, s as FailureErrorType, t as $, u as NoneError, ur as DoResult } from "../index-BPe5pcCH.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-Co3npRp-.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-BPe5pcCH.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-Co3npRp-.js";export{s as Either,t as Left,n as Right,o as TypeCheckLeft,a as TypeCheckRight,i as isLeft,r as isRight,e as tryCatch,c as tryCatchAsync};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=`0.
|
|
1
|
+
const e=`0.59.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
2
|
extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
3
3
|
/** The contained value (undefined for None) */
|
|
4
4
|
readonly value: T | undefined
|
|
@@ -75,18 +75,6 @@ const e=`0.58.1`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
75
75
|
* @returns Promise of the result of applying f to the contained value, or None if this Option is None
|
|
76
76
|
*/
|
|
77
77
|
flatMapAsync<U extends Type>(f: (value: T) => Promise<Option<U>>): Promise<Option<U>>
|
|
78
|
-
/**
|
|
79
|
-
* Applies a binary operator to a start value and the contained value
|
|
80
|
-
* @param f - The binary operator
|
|
81
|
-
* @returns The result of the reduction
|
|
82
|
-
*/
|
|
83
|
-
reduce<U>(f: (acc: U, value: T) => U): U
|
|
84
|
-
/**
|
|
85
|
-
* Applies a binary operator to the contained value and a start value
|
|
86
|
-
* @param f - The binary operator
|
|
87
|
-
* @returns The result of the reduction
|
|
88
|
-
*/
|
|
89
|
-
reduceRight<U>(f: (acc: U, value: T) => U): U
|
|
90
78
|
/**
|
|
91
79
|
* Pattern matches over the Option, applying onNone if None and onSome if Some
|
|
92
80
|
* @param onNone - Function to apply if the Option is None
|
|
@@ -236,12 +224,7 @@ const RightConstructor = <L extends Type, R extends Type>(value: R): RightOf<L,
|
|
|
236
224
|
})
|
|
237
225
|
|
|
238
226
|
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"> {
|
|
227
|
+
extends FunctypeSum<R, "Left" | "Right">, Promisable<R>, Doable<R>, Reshapeable<R>, Extractable<R> {
|
|
245
228
|
isLeft(): this is LeftOf<L, R>
|
|
246
229
|
isRight(): this is RightOf<L, R>
|
|
247
230
|
orElse<R2 extends Type>(defaultValue: R2): R | R2
|
|
@@ -303,13 +286,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
303
286
|
readonly _tag: "Right"
|
|
304
287
|
readonly value: R
|
|
305
288
|
}`,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> {
|
|
289
|
+
extends FunctypeSum<T, TypeNames>, Extractable<T>, Pipe<T>, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
313
290
|
readonly _tag: TypeNames
|
|
314
291
|
readonly error: Error | undefined
|
|
315
292
|
isSuccess(): this is Try<T> & { readonly _tag: "Success"; error: undefined }
|
|
@@ -404,11 +381,6 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
404
381
|
partition: (p: (a: A) => boolean) => [List<A>, List<A>]
|
|
405
382
|
span: (p: (a: A) => boolean) => [List<A>, List<A>]
|
|
406
383
|
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
|
|
412
384
|
/**
|
|
413
385
|
* Pattern matches over the List, applying a handler function based on whether it's empty
|
|
414
386
|
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|
|
@@ -418,20 +390,17 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
418
390
|
}`,Set:`export interface Set<out A> extends FunctypeCollection<A, "Set">, Collection<A> {
|
|
419
391
|
add<B>(value: B): Set<A | B>
|
|
420
392
|
remove: (value: unknown) => Set<A>
|
|
421
|
-
contains(value: unknown): boolean
|
|
422
393
|
has(value: unknown): boolean
|
|
423
394
|
map: <B>(f: (a: A) => B) => Set<B>
|
|
424
395
|
flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>
|
|
425
396
|
filter: (p: (a: A) => boolean) => Set<A>
|
|
426
397
|
filterNot: (p: (a: A) => boolean) => Set<A>
|
|
427
398
|
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
|
|
430
399
|
toList: () => List<A>
|
|
431
400
|
toSet: () => Set<A>
|
|
432
401
|
toArray: <B = A>() => B[]
|
|
433
402
|
toString: () => string
|
|
434
|
-
}`,Map:`export interface Map<K, V>
|
|
403
|
+
}`,Map:`export interface Map<K, out V>
|
|
435
404
|
extends
|
|
436
405
|
KVTraversable<Tuple<[K, V]>>,
|
|
437
406
|
Collection<Tuple<[K, V]>>,
|
|
@@ -461,17 +430,16 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
461
430
|
*/
|
|
462
431
|
match<R>(patterns: { Empty: () => R; NonEmpty: (entries: Array<Tuple<[K, V]>>) => R }): R
|
|
463
432
|
toValue(): { _tag: "Map"; value: [K, V][] }
|
|
464
|
-
}`,Lazy:`export interface Lazy<T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>, Pipe<T> {
|
|
433
|
+
}`,Lazy:`export interface Lazy<out T extends Type> extends FunctypeBase<T, "Lazy">, Extractable<T>, Pipe<T> {
|
|
465
434
|
/** Tag identifying this as a Lazy type */
|
|
466
435
|
readonly _tag: "Lazy"
|
|
467
436
|
/** Whether the computation has been evaluated */
|
|
468
437
|
readonly isEvaluated: boolean
|
|
469
438
|
/**
|
|
470
|
-
* Returns the computed value or a default value if computation fails
|
|
471
|
-
*
|
|
472
|
-
* @returns The computed value or defaultValue
|
|
439
|
+
* Returns the computed value or a default value if computation fails.
|
|
440
|
+
* Result widens to \`T | T2\` (Scala: \`getOrElse[B >: A](default: B): B\`).
|
|
473
441
|
*/
|
|
474
|
-
orElse(defaultValue:
|
|
442
|
+
orElse<T2 extends Type>(defaultValue: T2): T | T2
|
|
475
443
|
/**
|
|
476
444
|
* Returns the computed value or null if computation fails
|
|
477
445
|
* @returns The computed value or null
|
|
@@ -485,11 +453,10 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
485
453
|
*/
|
|
486
454
|
orThrow(error?: Error): T
|
|
487
455
|
/**
|
|
488
|
-
* Returns this Lazy if computation succeeds, otherwise returns the alternative Lazy
|
|
489
|
-
*
|
|
490
|
-
* @returns This Lazy or the alternative
|
|
456
|
+
* Returns this Lazy if computation succeeds, otherwise returns the alternative Lazy.
|
|
457
|
+
* The alternative may carry a different type; result is \`Lazy<T | T2>\`.
|
|
491
458
|
*/
|
|
492
|
-
or(alternative: Lazy<
|
|
459
|
+
or<T2 extends Type>(alternative: Lazy<T2>): Lazy<T | T2>
|
|
493
460
|
/**
|
|
494
461
|
* Maps the value inside the Lazy using the provided function
|
|
495
462
|
* @param f - The mapping function
|
|
@@ -612,7 +579,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
612
579
|
* @returns Object representation of the Lazy with evaluation state
|
|
613
580
|
*/
|
|
614
581
|
toValue(): { _tag: "Lazy"; evaluated: boolean; value?: T }
|
|
615
|
-
}`,LazyList:`export interface LazyList<A extends Type>
|
|
582
|
+
}`,LazyList:`export interface LazyList<out A extends Type>
|
|
616
583
|
extends Foldable<A>, Pipe<LazyList<A>>, Serializable<LazyList<A>>, Typeable<"LazyList"> {
|
|
617
584
|
readonly [Symbol.toStringTag]: string
|
|
618
585
|
// Iterator protocol
|
|
@@ -626,7 +593,8 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
626
593
|
drop(n: number): LazyList<A>
|
|
627
594
|
takeWhile(predicate: (a: A) => boolean): LazyList<A>
|
|
628
595
|
dropWhile(predicate: (a: A) => boolean): LazyList<A>
|
|
629
|
-
|
|
596
|
+
/** Concatenate with another lazy list, possibly widening (Scala: \`++[B >: A]\`). */
|
|
597
|
+
concat<B extends Type>(other: LazyList<B>): LazyList<A | B>
|
|
630
598
|
zip<B extends Type>(other: LazyList<B>): LazyList<[A, B]>
|
|
631
599
|
|
|
632
600
|
takeRight(n: number): LazyList<A>
|
|
@@ -657,7 +625,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
657
625
|
|
|
658
626
|
// Additional methods for clarity
|
|
659
627
|
toString(): string
|
|
660
|
-
}`,TaskOutcome:`export interface TaskOutcome<T>
|
|
628
|
+
}`,TaskOutcome:`export interface TaskOutcome<out T>
|
|
661
629
|
extends FunctypeBase<T, "Ok" | "Err">, Extractable<T>, AsyncMonad<T>, Promisable<T>, Doable<T> {
|
|
662
630
|
readonly _tag: "Ok" | "Err"
|
|
663
631
|
readonly _meta: TaskMetadata
|
|
@@ -675,8 +643,8 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
675
643
|
|
|
676
644
|
// Error handling methods
|
|
677
645
|
readonly mapError: (f: (error: Throwable) => Throwable) => TaskOutcome<T>
|
|
678
|
-
|
|
679
|
-
|
|
646
|
+
recover<U extends Type>(value: U): Ok<T | U>
|
|
647
|
+
recoverWith<U extends Type>(f: (error: Throwable) => U): Ok<T | U>
|
|
680
648
|
|
|
681
649
|
// Type guards
|
|
682
650
|
readonly isSuccess: () => this is Ok<T>
|
|
@@ -693,7 +661,7 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
693
661
|
// Pattern matching
|
|
694
662
|
readonly fold: <U>(onErr: (error: Throwable) => U, onOk: (value: T) => U) => U
|
|
695
663
|
readonly match: <U>(patterns: { Ok: (value: T) => U; Err: (error: Throwable) => U }) => U
|
|
696
|
-
}`,Tuple:`export interface Tuple<T extends Type[]>
|
|
664
|
+
}`,Tuple:`export interface Tuple<out T extends Type[]>
|
|
697
665
|
extends Foldable<T[number]>, Pipe<Tuple<T>>, Serializable<Tuple<T>>, Typeable<"Tuple"> {
|
|
698
666
|
readonly [Symbol.toStringTag]: string
|
|
699
667
|
get<K extends number>(index: K): T[K]
|
|
@@ -716,11 +684,12 @@ export interface RightOf<out L extends Type, out R extends Type> extends EitherB
|
|
|
716
684
|
}`,Stack:`export type Stack<A extends Type> = {
|
|
717
685
|
readonly [Symbol.toStringTag]: string
|
|
718
686
|
/**
|
|
719
|
-
* Push a value onto the top of the stack
|
|
687
|
+
* Push a value onto the top of the stack. The value may be a wider type;
|
|
688
|
+
* the result widens to \`Stack<A | B>\` (Scala: \`:+[B >: A]\`).
|
|
720
689
|
* @param value - The value to push
|
|
721
690
|
* @returns A new Stack with the value added
|
|
722
691
|
*/
|
|
723
|
-
push(value:
|
|
692
|
+
push<B extends Type>(value: B): Stack<A | B>
|
|
724
693
|
|
|
725
694
|
/**
|
|
726
695
|
* Remove and return the top value from the stack
|