functype 0.49.0 → 0.51.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/dist/Brand-BJIRbUKB.d.ts +54 -0
- package/dist/Tuple-DY00RBep.js +1 -0
- package/dist/{Typeable-lfO2nRVW.d.ts → Tuple-DwyoW0ZP.d.ts} +84 -8
- package/dist/branded/index.d.ts +1 -53
- package/dist/cli/exports.js +1 -1
- package/dist/cli/index.js +4 -4
- package/dist/do/index.d.ts +2 -184
- package/dist/do/index.js +1 -1
- package/dist/either/index.d.ts +1 -187
- package/dist/either/index.js +1 -2
- package/dist/{full-interfaces-DzRVS-A-.js → full-interfaces-CbBWKnyv.js} +25 -3
- package/dist/{Functype-rgysbeU6.d.ts → index-B5zYifBQ.d.ts} +960 -25
- package/dist/index.d.ts +4 -12
- package/dist/index.js +1 -1
- package/dist/list/index.d.ts +1 -84
- package/dist/list/index.js +1 -2
- package/dist/map/index.d.ts +1 -72
- package/dist/map/index.js +1 -2
- package/dist/option/index.d.ts +1 -242
- package/dist/option/index.js +1 -2
- package/dist/set/index.d.ts +1 -53
- package/dist/set/index.js +1 -2
- package/dist/src-3rbFE_vI.js +19 -0
- package/dist/try/index.d.ts +1 -96
- package/dist/try/index.js +1 -2
- package/dist/tuple/index.d.ts +1 -76
- package/dist/tuple/index.js +1 -1
- package/package.json +7 -7
- package/dist/Valuable-GZAXcYok.js +0 -13
- package/dist/stringify-DepodSy0.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=`0.
|
|
1
|
+
const e=`0.51.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`]}},Map:{description:`Immutable key-value store`,interfaces:[`SafeTraversable`,`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`]}}},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`],Collection:[`List`,`Set`,`Map`,`LazyList`,`Tuple`,`Stack`],Effect:[`IO`,`Task`],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 */
|
|
@@ -229,6 +229,18 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
229
229
|
* @returns The result of applying the matching handler function
|
|
230
230
|
*/
|
|
231
231
|
match<R>(patterns: { Success: (value: T) => R; Failure: (error: Error) => R }): R
|
|
232
|
+
/**
|
|
233
|
+
* Recovers from a Failure by applying a function to the error, returning a new Try
|
|
234
|
+
* @param f - Function to apply to the error to produce a recovery value
|
|
235
|
+
* @returns Success with the recovery value if Failure, otherwise this
|
|
236
|
+
*/
|
|
237
|
+
recover: (f: (error: Error) => T) => Try<T>
|
|
238
|
+
/**
|
|
239
|
+
* Recovers from a Failure by applying a function that returns a new Try
|
|
240
|
+
* @param f - Function to apply to the error to produce a new Try
|
|
241
|
+
* @returns The result of f if Failure, otherwise this
|
|
242
|
+
*/
|
|
243
|
+
recoverWith: (f: (error: Error) => Try<T>) => Try<T>
|
|
232
244
|
toValue(): { _tag: TypeNames; value: T | Error }
|
|
233
245
|
}`,List:`export interface List<A> extends FunctypeCollection<A, "List">, Doable<A>, Reshapeable<A> {
|
|
234
246
|
readonly length: number
|
|
@@ -284,7 +296,7 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
284
296
|
flatMap: <B>(f: (a: A) => Iterable<B>) => Set<B>
|
|
285
297
|
filter: (p: (a: A) => boolean) => Set<A>
|
|
286
298
|
filterNot: (p: (a: A) => boolean) => Set<A>
|
|
287
|
-
fold: <
|
|
299
|
+
fold: <B>(initial: B, fn: (acc: B, a: A) => B) => B
|
|
288
300
|
toList: () => List<A>
|
|
289
301
|
toSet: () => Set<A>
|
|
290
302
|
toArray: <B = A>() => B[]
|
|
@@ -309,7 +321,7 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
309
321
|
get(key: K): Option<V>
|
|
310
322
|
getOrElse(key: K, defaultValue: V): V
|
|
311
323
|
orElse(key: K, alternative: Option<V>): Option<V>
|
|
312
|
-
fold<
|
|
324
|
+
fold<B>(initial: B, fn: (acc: B, a: Tuple<[K, V]>) => B): B
|
|
313
325
|
foldLeft<B>(z: B): (op: (b: B, a: Tuple<[K, V]>) => B) => B
|
|
314
326
|
foldRight<B>(z: B): (op: (a: Tuple<[K, V]>, b: B) => B) => B
|
|
315
327
|
/**
|
|
@@ -500,6 +512,9 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
500
512
|
get tail(): LazyList<A>
|
|
501
513
|
get init(): LazyList<A>
|
|
502
514
|
|
|
515
|
+
// Foldable
|
|
516
|
+
fold<B>(initial: B, fn: (acc: B, a: A) => B): B
|
|
517
|
+
|
|
503
518
|
// Terminal operations (force evaluation)
|
|
504
519
|
toList(): List<A>
|
|
505
520
|
toArray(): A[]
|
|
@@ -553,6 +568,8 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
553
568
|
readonly [Symbol.toStringTag]: string
|
|
554
569
|
get<K extends number>(index: K): T[K]
|
|
555
570
|
|
|
571
|
+
fold<B>(initial: B, fn: (acc: B, a: T[number]) => B): B
|
|
572
|
+
|
|
556
573
|
map<U extends Type[]>(f: (value: T) => U): Tuple<U>
|
|
557
574
|
|
|
558
575
|
flatMap<U extends Type[]>(f: (value: T) => Tuple<U>): Tuple<U>
|
|
@@ -633,6 +650,11 @@ const e=`0.49.0`,t={Option:{description:`Safe nullable handling - Some<T> or Non
|
|
|
633
650
|
*/
|
|
634
651
|
toString(): string
|
|
635
652
|
|
|
653
|
+
/**
|
|
654
|
+
* Left-associative fold over all elements using an initial value and combining function.
|
|
655
|
+
*/
|
|
656
|
+
fold<B>(initial: B, fn: (acc: B, a: A) => B): B
|
|
657
|
+
|
|
636
658
|
/**
|
|
637
659
|
* Pattern matches over the Stack, applying a handler function based on whether it's empty
|
|
638
660
|
* @param patterns - Object with handler functions for Empty and NonEmpty variants
|