functype 0.51.0 → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- 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-CbBWKnyv.js → full-interfaces-DXMfSObi.js} +10 -3
- package/dist/{index-B5zYifBQ.d.ts → index-Di7IFeuy.d.ts} +432 -141
- 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 +2 -2
- 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-DagovFT3.js +19 -0
- package/dist/try/index.d.ts +1 -1
- package/dist/try/index.js +1 -1
- package/package.json +16 -6
- package/dist/src-3rbFE_vI.js +0 -19
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ npx functype --json # JSON output for programmatic use
|
|
|
37
37
|
- **Try Type**: Safely execute operations that might throw exceptions
|
|
38
38
|
- **Do-notation**: Scala-like for-comprehensions with **optimized List performance** (up to 12x faster than traditional flatMap)
|
|
39
39
|
- **Task**: Handle synchronous and asynchronous operations with error handling
|
|
40
|
+
- **Http**: Typed HTTP fetch wrapper returning IO effects with HttpError ADT, auto content-type detection, and configurable clients
|
|
40
41
|
- **Lazy**: Deferred computation with memoization
|
|
41
42
|
- **Tuple**: Type-safe fixed-length arrays
|
|
42
43
|
- **Typeable**: Runtime type identification with compile-time safety
|
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-DXMfSObi.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{
|
|
2
|
+
import{Dt as e,J as t,yt as n}from"../src-DagovFT3.js";import{a as r,i,n as a,r as o,t as s}from"../full-interfaces-DXMfSObi.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 {
|
|
1
|
+
import { a as EmptyListError, c as LeftError, d as isDoCapable, f as unwrap, i as DoGenerator, ir as Doable, l as LeftErrorType, n as Do, o as FailureError, r as DoAsync, rr as DoResult, s as FailureErrorType, t as $, u as NoneError } from "../index-Di7IFeuy.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{
|
|
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-DagovFT3.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 { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-
|
|
1
|
+
import { S as tryCatchAsync, _ as TypeCheckLeft, b as isRight, g as TestEither, h as Right, m as Left, p as Either, v as TypeCheckRight, x as tryCatch, y as isLeft } from "../index-Di7IFeuy.js";
|
|
2
2
|
export { Either, Left, Right, TestEither, TypeCheckLeft, TypeCheckRight, isLeft, isRight, tryCatch, tryCatchAsync };
|
package/dist/either/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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-DagovFT3.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.53.0`,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)`,`.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)`],transform:[`.map(f)`,`.flatMap(f)`,`.mapLeft(f)`,`.swap()`],extract:[`.fold(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)`,`.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<T>> with typed errors and auto content-type detection`,interfaces:[],methods:{create:[`Http.get<T>(url)`,`Http.post<T>(url, opts)`,`Http.put<T>(url, opts)`,`Http.patch<T>(url, opts)`,`Http.delete<T>(url, opts)`,`Http.request<T>(opts)`,`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<T extends Type> extends Functype<T, "Some" | "None">, Promisable<T>, Doable<T>, Reshapeable<T> {
|
|
2
2
|
/** The contained value (undefined for None) */
|
|
3
3
|
readonly value: T | undefined
|
|
4
4
|
/** Whether this Option contains no value */
|
|
@@ -303,7 +303,7 @@ const e=`0.51.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
303
303
|
toString: () => string
|
|
304
304
|
}`,Map:`export interface Map<K, V>
|
|
305
305
|
extends
|
|
306
|
-
|
|
306
|
+
KVTraversable<Tuple<[K, V]>>,
|
|
307
307
|
Collection<Tuple<[K, V]>>,
|
|
308
308
|
Typeable<"Map">,
|
|
309
309
|
Serializable<[K, V][]>,
|
|
@@ -661,4 +661,11 @@ const e=`0.51.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
661
661
|
* @returns The result of applying the matching handler function
|
|
662
662
|
*/
|
|
663
663
|
match<R>(patterns: { Empty: () => R; NonEmpty: (values: A[]) => R }): R
|
|
664
|
-
} & Traversable<A>
|
|
664
|
+
} & Traversable<A> &`,HttpError:`export type HttpError = NetworkError | HttpStatusError | DecodeError
|
|
665
|
+
|
|
666
|
+
const networkError = (url: string, method: HttpMethod, cause: unknown): NetworkError => ({
|
|
667
|
+
_tag: "NetworkError",
|
|
668
|
+
url,
|
|
669
|
+
method,
|
|
670
|
+
cause,
|
|
671
|
+
})`};export{e as a,t as i,r as n,n as r,i as t};
|