@dangayle/rustlike 0.1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["Ok","Err","toPanicString","Ok","Err","Ok","Err","Option","None"],"sources":["../src/async.ts","../src/match.ts","../src/types.ts","../src/interop.ts"],"sourcesContent":["/**\n * AsyncResult<T, E> - Handling asynchronous Results chaining\n */\n\nimport { Result, Ok, Err, Option } from \"./core\";\n\nexport class AsyncResult<T, E> implements PromiseLike<Result<T, E>> {\n constructor(private readonly promise: Promise<Result<T, E>>) {}\n\n /**\n * Create an AsyncResult from a Promise<Result<T, E>>\n */\n static fromPromise<T, E>(promise: Promise<Result<T, E>>): AsyncResult<T, E> {\n return new AsyncResult(promise);\n }\n\n /**\n * Create an AsyncResult that resolves to Ok(value)\n */\n static ok<T, E = never>(value: T): AsyncResult<T, E> {\n return new AsyncResult(Promise.resolve(Ok(value)));\n }\n\n /**\n * Create an AsyncResult that resolves to Err(error)\n */\n static err<E, T = never>(error: E): AsyncResult<T, E> {\n return new AsyncResult(Promise.resolve(Err(error)));\n }\n\n /**\n * Wrap an async function that might reject into an AsyncResult.\n * This is the async equivalent of Result.fromThrowable().\n *\n * @example\n * const result = await AsyncResult.fromThrowable(() => fetch('/api/users'));\n * // AsyncResult<Response, unknown>\n */\n static fromThrowable<T, E = unknown>(fn: () => Promise<T>): AsyncResult<T, E> {\n try {\n return new AsyncResult(\n fn()\n .then((value) => Ok(value) as Result<T, E>)\n // Cast: TypeScript catch blocks type errors as `unknown`. The caller\n // narrows via the E parameter (defaulting to `unknown`).\n .catch((error: unknown) => Err(error as E) as Result<T, E>),\n );\n } catch (e) {\n return new AsyncResult(Promise.resolve(Err(e as E) as Result<T, E>));\n }\n }\n\n /**\n * Map the inner Ok value using a synchronous or asynchronous function.\n * If the function returns a Promise, it is awaited.\n */\n map<U>(fn: (value: T) => U | Promise<U>): AsyncResult<U, E> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isErr()) return res as unknown as Result<U, E>;\n // If the mapping function throws, we let Promise rejection propagate\n // to stay consistent with sync map throwing (Rust panics on map errors).\n const value = await fn(res.value);\n return Ok(value);\n }),\n );\n }\n\n /**\n * Map the inner Err value using a synchronous or asynchronous function.\n */\n mapErr<F>(fn: (error: E) => F | Promise<F>): AsyncResult<T, F> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isOk()) return res as unknown as Result<T, F>;\n const error = await fn(res.error);\n return Err(error);\n }),\n );\n }\n\n /**\n * Chain another Result-returning operation (sync or async).\n * Supports returning: Result, AsyncResult, or Promise<Result>.\n */\n andThen<U>(\n fn: (value: T) => Result<U, E> | AsyncResult<U, E> | Promise<Result<U, E>>,\n ): AsyncResult<U, E> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isErr()) return res as unknown as Result<U, E>;\n\n const next = fn(res.value);\n if (next instanceof AsyncResult) {\n return await next.toPromise();\n }\n return await next;\n }),\n );\n }\n\n /**\n * Handle the error case with another Result-returning operation.\n */\n orElse<F>(\n fn: (error: E) => Result<T, F> | AsyncResult<T, F> | Promise<Result<T, F>>,\n ): AsyncResult<T, F> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isOk()) return res as unknown as Result<T, F>;\n\n const next = fn(res.error);\n if (next instanceof AsyncResult) {\n return await next.toPromise();\n }\n return await next;\n }),\n );\n }\n\n /**\n * Inspect the Ok value if present, without modifying it.\n * The callback can be synchronous or asynchronous.\n */\n inspect(fn: (value: T) => void | Promise<void>): AsyncResult<T, E> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isOk()) {\n await fn(res.value);\n }\n return res;\n }),\n );\n }\n\n /**\n * Inspect the Err value if present, without modifying it.\n * The callback can be synchronous or asynchronous.\n */\n inspectErr(fn: (error: E) => void | Promise<void>): AsyncResult<T, E> {\n return new AsyncResult(\n this.promise.then(async (res) => {\n if (res.isErr()) {\n await fn(res.error);\n }\n return res;\n }),\n );\n }\n\n /**\n * Pattern match on the result (async).\n */\n match<U>(handlers: {\n ok: (value: T) => U | Promise<U>;\n err: (error: E) => U | Promise<U>;\n }): Promise<U> {\n return this.promise.then((res) => res.match(handlers));\n }\n\n /**\n * Unwrap the value or throw (reject).\n */\n async unwrap(): Promise<T> {\n const res = await this.promise;\n return res.unwrap();\n }\n\n /**\n * Unwrap or return default.\n */\n async unwrapOr(defaultValue: T): Promise<T> {\n const res = await this.promise;\n return res.unwrapOr(defaultValue);\n }\n\n /**\n * Unwrap or compute default.\n */\n async unwrapOrElse(fn: (error: E) => T | Promise<T>): Promise<T> {\n const res = await this.promise;\n if (res.isOk()) return res.value;\n return await fn(res.error);\n }\n\n /**\n * Returns true if the result is Ok and contains the given value.\n */\n contains(value: T): Promise<boolean> {\n return this.promise.then((r) => r.contains(value));\n }\n\n /**\n * Returns true if the result is Err and contains the given error.\n */\n containsErr(error: E): Promise<boolean> {\n return this.promise.then((r) => r.containsErr(error));\n }\n\n /**\n * Returns `other` if the result is Ok, otherwise returns the Err value of self.\n */\n and<U>(other: AsyncResult<U, E>): AsyncResult<U, E> {\n return new AsyncResult(\n this.promise.then((r) =>\n r.isOk() ? other.promise : Promise.resolve(r as unknown as Result<U, E>),\n ),\n );\n }\n\n /**\n * Returns `other` if the result is Err, otherwise returns the Ok value of self.\n */\n or<F>(other: AsyncResult<T, F>): AsyncResult<T, F> {\n return new AsyncResult(\n this.promise.then((r) =>\n r.isErr() ? other.promise : Promise.resolve(r as unknown as Result<T, F>),\n ),\n );\n }\n\n /**\n * Converts from AsyncResult<Result<U, E>, E> to AsyncResult<U, E>.\n */\n flatten<U>(this: AsyncResult<Result<U, E>, E>): AsyncResult<U, E> {\n return new AsyncResult(this.promise.then((r) => r.flatten()));\n }\n\n /**\n * Converts from Result<T, E> to Option<T>, discarding the error if any.\n */\n toOption(): Promise<Option<T>> {\n return this.promise.then((r) => r.toOption());\n }\n\n /**\n * Converts from Result<T, E> to Option<E>, discarding the success value if any.\n */\n err(): Promise<Option<E>> {\n return this.promise.then((r) => r.err());\n }\n\n /**\n * Returns the contained Ok value, or throws with the provided message.\n */\n expect(message: string): Promise<T> {\n return this.promise.then((r) => r.expect(message));\n }\n\n /**\n * Returns the contained Err value, or throws if Ok.\n */\n unwrapErr(): Promise<E> {\n return this.promise.then((r) => r.unwrapErr());\n }\n\n /**\n * Returns the contained Err value, or throws with the provided message.\n */\n expectErr(message: string): Promise<E> {\n return this.promise.then((r) => r.expectErr(message));\n }\n\n /**\n * Get the underlying Promise<Result<T, E>>\n */\n toPromise(): Promise<Result<T, E>> {\n return this.promise;\n }\n\n /**\n * Implement PromiseLike to allow `await asyncResult`\n */\n then<TResult1 = Result<T, E>, TResult2 = never>(\n onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Required by PromiseLike interface\n onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null,\n ): PromiseLike<TResult1 | TResult2> {\n return this.promise.then(onfulfilled, onrejected);\n }\n}\n","/**\n * Exhaustive pattern matching utilities\n *\n * Ensures all cases are handled in discriminated unions.\n */\n\nimport { toPanicString } from \"./core\";\n\n/**\n * Use in the default case of a switch to ensure exhaustiveness.\n * If the switch is not exhaustive, TypeScript will error because\n * the unhandled case type cannot be assigned to 'never'.\n *\n * @example\n * type Shape = { kind: 'circle'; radius: number } | { kind: 'rect'; w: number; h: number };\n *\n * function area(s: Shape): number {\n * switch (s.kind) {\n * case 'circle': return Math.PI * s.radius ** 2;\n * case 'rect': return s.w * s.h;\n * default: return assertNever(s);\n * }\n * }\n */\nexport function assertNever(x: never, message?: string): never {\n if (message) {\n throw new Error(message);\n }\n throw new Error(`Unexpected value: ${toPanicString(x)}`);\n}\n\n/**\n * Type-safe exhaustive matching for discriminated unions.\n * Supports an optional catch-all '_' handler.\n *\n * @example\n * type Action =\n * | { type: 'increment'; amount: number }\n * | { type: 'decrement'; amount: number }\n * | { type: 'reset' };\n *\n * const result = match(action, 'type', {\n * increment: (a) => state + a.amount,\n * decrement: (a) => state - a.amount,\n * reset: () => 0,\n * });\n *\n * // With catch-all\n * const result = match(action, 'type', {\n * increment: (a) => state + a.amount,\n * _: () => state // catch-all\n * });\n */\nexport function match<T extends Record<K, string>, K extends keyof T, R>(\n value: T,\n discriminant: K,\n handlers:\n | { [P in T[K]]: (value: Extract<T, Record<K, P>>) => R }\n | ({ [P in T[K]]?: (value: Extract<T, Record<K, P>>) => R } & { _: (value: T) => R }),\n): R {\n const key = value[discriminant] as T[K];\n const handlersRecord = handlers as Record<PropertyKey, ((value: T) => R) | undefined>;\n const handler = handlersRecord[key];\n\n if (handler) {\n return handler(value);\n }\n\n const catchAll = handlersRecord._;\n if (catchAll) {\n return catchAll(value);\n }\n\n // This should be unreachable if types are correct\n return assertNever(value as never, `Unhandled variant: ${key}`);\n}\n\n/**\n * Match on a discriminated union using the 'kind' discriminant (common pattern).\n *\n * @example\n * type Shape =\n * | { kind: 'circle'; radius: number }\n * | { kind: 'rect'; w: number; h: number };\n *\n * const area = matchKind(shape, {\n * circle: (s) => Math.PI * s.radius ** 2,\n * rect: (s) => s.w * s.h,\n * });\n *\n * // With catch-all\n * const isCircle = matchKind(shape, {\n * circle: () => true,\n * _: () => false\n * });\n */\nexport function matchKind<T extends { kind: string }, R>(\n value: T,\n handlers:\n | { [P in T[\"kind\"]]: (value: Extract<T, { kind: P }>) => R }\n | ({ [P in T[\"kind\"]]?: (value: Extract<T, { kind: P }>) => R } & { _: (value: T) => R }),\n): R {\n return match(\n value,\n \"kind\",\n handlers as { [P in T[\"kind\"]]: (value: Extract<T, Record<\"kind\", P>>) => R },\n );\n}\n\n/**\n * Match on a discriminated union using the 'type' discriminant (common pattern).\n *\n * @example\n * type Action =\n * | { type: 'add'; item: string }\n * | { type: 'remove'; id: number };\n *\n * const result = matchType(action, {\n * add: (a) => [...items, a.item],\n * remove: (a) => items.filter((_, i) => i !== a.id),\n * });\n */\nexport function matchType<T extends { type: string }, R>(\n value: T,\n handlers:\n | { [P in T[\"type\"]]: (value: Extract<T, { type: P }>) => R }\n | ({ [P in T[\"type\"]]?: (value: Extract<T, { type: P }>) => R } & { _: (value: T) => R }),\n): R {\n return match(\n value,\n \"type\",\n handlers as { [P in T[\"type\"]]: (value: Extract<T, Record<\"type\", P>>) => R },\n );\n}\n","/**\n * Immutability and utility types for Rust-like TypeScript\n */\n\nimport { Result, Ok, Err } from \"./core\";\n\n/**\n * Recursively make all properties readonly (deep immutability)\n */\nexport type DeepReadonly<T> = T extends (infer U)[]\n ? readonly DeepReadonly<U>[]\n : T extends Map<infer K, infer V>\n ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>>\n : T extends Set<infer U>\n ? ReadonlySet<DeepReadonly<U>>\n : T extends object\n ? { readonly [P in keyof T]: DeepReadonly<T[P]> }\n : T;\n\n/**\n * Make specific properties readonly\n */\nexport type ReadonlyPick<T, K extends keyof T> = Omit<T, K> & Readonly<Pick<T, K>>;\n\n/**\n * Branded type for nominal typing (like Rust's newtype pattern)\n *\n * @example\n * type UserId = Brand<number, 'UserId'>;\n * type OrderId = Brand<number, 'OrderId'>;\n *\n * // These are now incompatible even though both are numbers\n * const userId: UserId = 1 as UserId;\n * const orderId: OrderId = userId; // Error!\n */\nexport type Brand<T, B> = T & { readonly __brand: B };\n\n/**\n * Create a branded type constructor\n *\n * @example\n * const UserId = brand<number, 'UserId'>();\n * const id = UserId(42); // type is Brand<number, 'UserId'>\n */\nexport const brand =\n <T, B>() =>\n (value: T): Brand<T, B> =>\n value as Brand<T, B>;\n\n/**\n * NonEmpty array type - guarantees at least one element\n */\nexport type NonEmptyArray<T> = readonly [T, ...T[]];\n\n/**\n * Check if array is non-empty (type guard)\n */\nexport const isNonEmpty = <T>(arr: readonly T[]): arr is NonEmptyArray<T> => arr.length > 0;\n\n/**\n * Create a non-empty array from values\n */\nexport const nonEmpty = <T>(first: T, ...rest: T[]): NonEmptyArray<T> => [first, ...rest];\n\n/**\n * Get the first element of a non-empty array (guaranteed to exist)\n */\nexport const head = <T>(arr: NonEmptyArray<T>): T => arr[0];\n\n/**\n * Create a newtype with validation (Rust's newtype pattern + smart constructor).\n * Implements the \"parse, don't validate\" pattern - make invalid states unrepresentable.\n *\n * @example\n * const EmailAddress = newtype<string, 'Email'>(\n * (s) => s.includes('@'),\n * \"Invalid email\"\n * );\n *\n * const email = EmailAddress.parse(userInput);\n * // Result<Brand<string, 'Email'>, string>\n *\n * @example\n * const PositiveNumber = newtype<number, 'Positive'>(\n * (n) => n > 0,\n * (n) => `Expected positive, got ${n}`\n * );\n */\nexport const newtype = <T, B, E = string>(\n validate: (value: T) => boolean,\n error: E | ((value: T) => E),\n): {\n parse: (value: T) => Result<Brand<T, B>, E>;\n unsafe: (value: T) => Brand<T, B>;\n} => {\n const getError = (value: T): E => {\n if (typeof error === \"function\") {\n return (error as (value: T) => E)(value);\n }\n return error;\n };\n\n return {\n /**\n * Parse and validate the input, returning a Result with the branded type on success.\n */\n parse: (value: T): Result<Brand<T, B>, E> => {\n if (validate(value)) {\n return Ok(value as Brand<T, B>);\n }\n return Err(getError(value));\n },\n\n /**\n * Unsafely cast a value to the branded type without validation.\n * Use only when you know the value is valid (e.g., from a trusted source).\n */\n unsafe: (value: T): Brand<T, B> => value as Brand<T, B>,\n };\n};\n","/**\n * Interop helpers for wrapping third-party and standard library code\n */\n\nimport { Option, None, Result, Ok, Err } from \"./core\";\n\n/**\n * One-shot: wrap a single throwing operation in a Result.\n * Use {@link safeTry} to create a reusable safe wrapper instead.\n *\n * @example\n * const result = tryCatch(() => JSON.parse(userInput));\n * // Result<unknown, unknown>\n */\nexport const tryCatch = <T, E = unknown>(fn: () => T): Result<T, E> => {\n try {\n return Ok(fn());\n } catch (e) {\n // Cast: TypeScript catch blocks type errors as `unknown`. The caller\n // narrows via the E parameter (defaulting to `unknown`). This is safe\n // because the caller opts into the cast by specifying E.\n return Err(e as E);\n }\n};\n\n/**\n * Wrap any async function that might reject to return Result\n *\n * @example\n * const result = await tryAsync(() => axios.get('/api/users'));\n * // Result<AxiosResponse, AxiosError>\n */\nexport const tryAsync = async <T, E = unknown>(fn: () => Promise<T>): Promise<Result<T, E>> => {\n try {\n return Ok(await fn());\n } catch (e) {\n // Cast: see tryCatch — caller narrows E via the type parameter.\n return Err(e as E);\n }\n};\n\n/**\n * Create a reusable Option-returning version of any function that may return\n * T | null | undefined or throw. Returns None on null, undefined, or throw.\n *\n * @example\n * const safeFind = safeCall((id: number) => users.find(u => u.id === id));\n * const user = safeFind(42); // Option<User>\n */\nexport const safeCall =\n <Args extends unknown[], T>(fn: (...args: Args) => T | null | undefined) =>\n (...args: Args): Option<T> => {\n try {\n return Option.from(fn(...args));\n } catch {\n return None;\n }\n };\n\n/**\n * Create a reusable Option-returning version of any async function that may return\n * T | null | undefined or reject. Returns None on null, undefined, or rejection.\n *\n * @example\n * const safeFetch = safeCallAsync((url: string) => fetch(url).then(r => r.ok ? r : null));\n * const response = await safeFetch('/api'); // Option<Response>\n */\nexport const safeCallAsync =\n <Args extends unknown[], T>(fn: (...args: Args) => Promise<T | null | undefined>) =>\n async (...args: Args): Promise<Option<T>> => {\n try {\n return Option.from(await fn(...args));\n } catch {\n return None;\n }\n };\n\n/**\n * Reusable: wrap a throwing function so every call returns a Result.\n * Use {@link tryCatch} for one-shot operations instead.\n *\n * @example\n * const safeJsonParse = safeTry(JSON.parse);\n * const data = safeJsonParse(input); // Result<unknown, unknown>\n */\nexport const safeTry =\n <Args extends unknown[], T, E = unknown>(fn: (...args: Args) => T) =>\n (...args: Args): Result<T, E> => {\n try {\n return Ok(fn(...args));\n } catch (e) {\n // Cast: see tryCatch — caller narrows E via the type parameter.\n return Err(e as E);\n }\n };\n"],"mappings":";;;;;;;AAMA,IAAa,cAAb,MAAa,YAAuD;CAClE,YAAY,AAAiB,SAAgC;EAAhC;;;;;CAK7B,OAAO,YAAkB,SAAmD;AAC1E,SAAO,IAAI,YAAY,QAA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GAAG,SAAgC,CAAC,OAAO,GAAG,KAAK;;;;AAKzF,MAAa,QAAW,QAA6B,IAAI;;;;;;;;;;;;;;;;;;;;AAqBzD,MAAa,WACX,UACA,UAIG;CACH,MAAM,YAAY,UAAgB;AAChC,MAAI,OAAO,UAAU,WACnB,QAAQ,MAA0B,MAAM;AAE1C,SAAO;;AAGT,QAAO;EAIL,QAAQ,UAAqC;AAC3C,OAAI,SAAS,MAAM,CACjB,QAAOC,sBAAG,MAAqB;AAEjC,UAAOC,uBAAI,SAAS,MAAM,CAAC;;EAO7B,SAAS,UAA0B;EACpC;;;;;;;;;;;;;;;;ACxGH,MAAa,YAA4B,OAA8B;AACrE,KAAI;AACF,SAAOC,sBAAG,IAAI,CAAC;UACR,GAAG;AAIV,SAAOC,uBAAI,EAAO;;;;;;;;;;AAWtB,MAAa,WAAW,OAAuB,OAAgD;AAC7F,KAAI;AACF,SAAOD,sBAAG,MAAM,IAAI,CAAC;UACd,GAAG;AAEV,SAAOC,uBAAI,EAAO;;;;;;;;;;;AAYtB,MAAa,YACiB,QAC3B,GAAG,SAA0B;AAC5B,KAAI;AACF,SAAOC,0BAAO,KAAK,GAAG,GAAG,KAAK,CAAC;SACzB;AACN,SAAOC;;;;;;;;;;;AAYb,MAAa,iBACiB,OAC5B,OAAO,GAAG,SAAmC;AAC3C,KAAI;AACF,SAAOD,0BAAO,KAAK,MAAM,GAAG,GAAG,KAAK,CAAC;SAC/B;AACN,SAAOC;;;;;;;;;;;AAYb,MAAa,WAC8B,QACxC,GAAG,SAA6B;AAC/B,KAAI;AACF,SAAOH,sBAAG,GAAG,GAAG,KAAK,CAAC;UACf,GAAG;AAEV,SAAOC,uBAAI,EAAO"}
@@ -0,0 +1,342 @@
1
+ import { _ as Some, a as asyncIterFromGenerator, b as isOk, c as PeekableIter, d as iterFromGenerator, f as Err, g as Result, h as Option, i as asyncIterFromArray, l as iter, m as Ok, n as PeekableAsyncIter, o as asyncIterFromIterable, p as None, r as asyncIter, s as Iter, t as AsyncIter, u as iterFromArray, v as isErr, x as isSome, y as isNone } from "./async-iter-D7Pj6knS.cjs";
2
+
3
+ //#region src/async.d.ts
4
+ declare class AsyncResult<T, E> implements PromiseLike<Result<T, E>> {
5
+ private readonly promise;
6
+ constructor(promise: Promise<Result<T, E>>);
7
+ /**
8
+ * Create an AsyncResult from a Promise<Result<T, E>>
9
+ */
10
+ static fromPromise<T, E>(promise: Promise<Result<T, E>>): AsyncResult<T, E>;
11
+ /**
12
+ * Create an AsyncResult that resolves to Ok(value)
13
+ */
14
+ static ok<T, E = never>(value: T): AsyncResult<T, E>;
15
+ /**
16
+ * Create an AsyncResult that resolves to Err(error)
17
+ */
18
+ static err<E, T = never>(error: E): AsyncResult<T, E>;
19
+ /**
20
+ * Wrap an async function that might reject into an AsyncResult.
21
+ * This is the async equivalent of Result.fromThrowable().
22
+ *
23
+ * @example
24
+ * const result = await AsyncResult.fromThrowable(() => fetch('/api/users'));
25
+ * // AsyncResult<Response, unknown>
26
+ */
27
+ static fromThrowable<T, E = unknown>(fn: () => Promise<T>): AsyncResult<T, E>;
28
+ /**
29
+ * Map the inner Ok value using a synchronous or asynchronous function.
30
+ * If the function returns a Promise, it is awaited.
31
+ */
32
+ map<U>(fn: (value: T) => U | Promise<U>): AsyncResult<U, E>;
33
+ /**
34
+ * Map the inner Err value using a synchronous or asynchronous function.
35
+ */
36
+ mapErr<F>(fn: (error: E) => F | Promise<F>): AsyncResult<T, F>;
37
+ /**
38
+ * Chain another Result-returning operation (sync or async).
39
+ * Supports returning: Result, AsyncResult, or Promise<Result>.
40
+ */
41
+ andThen<U>(fn: (value: T) => Result<U, E> | AsyncResult<U, E> | Promise<Result<U, E>>): AsyncResult<U, E>;
42
+ /**
43
+ * Handle the error case with another Result-returning operation.
44
+ */
45
+ orElse<F>(fn: (error: E) => Result<T, F> | AsyncResult<T, F> | Promise<Result<T, F>>): AsyncResult<T, F>;
46
+ /**
47
+ * Inspect the Ok value if present, without modifying it.
48
+ * The callback can be synchronous or asynchronous.
49
+ */
50
+ inspect(fn: (value: T) => void | Promise<void>): AsyncResult<T, E>;
51
+ /**
52
+ * Inspect the Err value if present, without modifying it.
53
+ * The callback can be synchronous or asynchronous.
54
+ */
55
+ inspectErr(fn: (error: E) => void | Promise<void>): AsyncResult<T, E>;
56
+ /**
57
+ * Pattern match on the result (async).
58
+ */
59
+ match<U>(handlers: {
60
+ ok: (value: T) => U | Promise<U>;
61
+ err: (error: E) => U | Promise<U>;
62
+ }): Promise<U>;
63
+ /**
64
+ * Unwrap the value or throw (reject).
65
+ */
66
+ unwrap(): Promise<T>;
67
+ /**
68
+ * Unwrap or return default.
69
+ */
70
+ unwrapOr(defaultValue: T): Promise<T>;
71
+ /**
72
+ * Unwrap or compute default.
73
+ */
74
+ unwrapOrElse(fn: (error: E) => T | Promise<T>): Promise<T>;
75
+ /**
76
+ * Returns true if the result is Ok and contains the given value.
77
+ */
78
+ contains(value: T): Promise<boolean>;
79
+ /**
80
+ * Returns true if the result is Err and contains the given error.
81
+ */
82
+ containsErr(error: E): Promise<boolean>;
83
+ /**
84
+ * Returns `other` if the result is Ok, otherwise returns the Err value of self.
85
+ */
86
+ and<U>(other: AsyncResult<U, E>): AsyncResult<U, E>;
87
+ /**
88
+ * Returns `other` if the result is Err, otherwise returns the Ok value of self.
89
+ */
90
+ or<F>(other: AsyncResult<T, F>): AsyncResult<T, F>;
91
+ /**
92
+ * Converts from AsyncResult<Result<U, E>, E> to AsyncResult<U, E>.
93
+ */
94
+ flatten<U>(this: AsyncResult<Result<U, E>, E>): AsyncResult<U, E>;
95
+ /**
96
+ * Converts from Result<T, E> to Option<T>, discarding the error if any.
97
+ */
98
+ toOption(): Promise<Option<T>>;
99
+ /**
100
+ * Converts from Result<T, E> to Option<E>, discarding the success value if any.
101
+ */
102
+ err(): Promise<Option<E>>;
103
+ /**
104
+ * Returns the contained Ok value, or throws with the provided message.
105
+ */
106
+ expect(message: string): Promise<T>;
107
+ /**
108
+ * Returns the contained Err value, or throws if Ok.
109
+ */
110
+ unwrapErr(): Promise<E>;
111
+ /**
112
+ * Returns the contained Err value, or throws with the provided message.
113
+ */
114
+ expectErr(message: string): Promise<E>;
115
+ /**
116
+ * Get the underlying Promise<Result<T, E>>
117
+ */
118
+ toPromise(): Promise<Result<T, E>>;
119
+ /**
120
+ * Implement PromiseLike to allow `await asyncResult`
121
+ */
122
+ then<TResult1 = Result<T, E>, TResult2 = never>(onfulfilled?: ((value: Result<T, E>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
123
+ }
124
+ //#endregion
125
+ //#region src/match.d.ts
126
+ /**
127
+ * Exhaustive pattern matching utilities
128
+ *
129
+ * Ensures all cases are handled in discriminated unions.
130
+ */
131
+ /**
132
+ * Use in the default case of a switch to ensure exhaustiveness.
133
+ * If the switch is not exhaustive, TypeScript will error because
134
+ * the unhandled case type cannot be assigned to 'never'.
135
+ *
136
+ * @example
137
+ * type Shape = { kind: 'circle'; radius: number } | { kind: 'rect'; w: number; h: number };
138
+ *
139
+ * function area(s: Shape): number {
140
+ * switch (s.kind) {
141
+ * case 'circle': return Math.PI * s.radius ** 2;
142
+ * case 'rect': return s.w * s.h;
143
+ * default: return assertNever(s);
144
+ * }
145
+ * }
146
+ */
147
+ declare function assertNever(x: never, message?: string): never;
148
+ /**
149
+ * Type-safe exhaustive matching for discriminated unions.
150
+ * Supports an optional catch-all '_' handler.
151
+ *
152
+ * @example
153
+ * type Action =
154
+ * | { type: 'increment'; amount: number }
155
+ * | { type: 'decrement'; amount: number }
156
+ * | { type: 'reset' };
157
+ *
158
+ * const result = match(action, 'type', {
159
+ * increment: (a) => state + a.amount,
160
+ * decrement: (a) => state - a.amount,
161
+ * reset: () => 0,
162
+ * });
163
+ *
164
+ * // With catch-all
165
+ * const result = match(action, 'type', {
166
+ * increment: (a) => state + a.amount,
167
+ * _: () => state // catch-all
168
+ * });
169
+ */
170
+ declare function match<T extends Record<K, string>, K extends keyof T, R>(value: T, discriminant: K, handlers: { [P in T[K]]: (value: Extract<T, Record<K, P>>) => R } | ({ [P in T[K]]?: (value: Extract<T, Record<K, P>>) => R } & {
171
+ _: (value: T) => R;
172
+ })): R;
173
+ /**
174
+ * Match on a discriminated union using the 'kind' discriminant (common pattern).
175
+ *
176
+ * @example
177
+ * type Shape =
178
+ * | { kind: 'circle'; radius: number }
179
+ * | { kind: 'rect'; w: number; h: number };
180
+ *
181
+ * const area = matchKind(shape, {
182
+ * circle: (s) => Math.PI * s.radius ** 2,
183
+ * rect: (s) => s.w * s.h,
184
+ * });
185
+ *
186
+ * // With catch-all
187
+ * const isCircle = matchKind(shape, {
188
+ * circle: () => true,
189
+ * _: () => false
190
+ * });
191
+ */
192
+ declare function matchKind<T extends {
193
+ kind: string;
194
+ }, R>(value: T, handlers: { [P in T["kind"]]: (value: Extract<T, {
195
+ kind: P;
196
+ }>) => R } | ({ [P in T["kind"]]?: (value: Extract<T, {
197
+ kind: P;
198
+ }>) => R } & {
199
+ _: (value: T) => R;
200
+ })): R;
201
+ /**
202
+ * Match on a discriminated union using the 'type' discriminant (common pattern).
203
+ *
204
+ * @example
205
+ * type Action =
206
+ * | { type: 'add'; item: string }
207
+ * | { type: 'remove'; id: number };
208
+ *
209
+ * const result = matchType(action, {
210
+ * add: (a) => [...items, a.item],
211
+ * remove: (a) => items.filter((_, i) => i !== a.id),
212
+ * });
213
+ */
214
+ declare function matchType<T extends {
215
+ type: string;
216
+ }, R>(value: T, handlers: { [P in T["type"]]: (value: Extract<T, {
217
+ type: P;
218
+ }>) => R } | ({ [P in T["type"]]?: (value: Extract<T, {
219
+ type: P;
220
+ }>) => R } & {
221
+ _: (value: T) => R;
222
+ })): R;
223
+ //#endregion
224
+ //#region src/types.d.ts
225
+ /**
226
+ * Recursively make all properties readonly (deep immutability)
227
+ */
228
+ type DeepReadonly<T> = T extends (infer U)[] ? readonly DeepReadonly<U>[] : T extends Map<infer K, infer V> ? ReadonlyMap<DeepReadonly<K>, DeepReadonly<V>> : T extends Set<infer U> ? ReadonlySet<DeepReadonly<U>> : T extends object ? { readonly [P in keyof T]: DeepReadonly<T[P]> } : T;
229
+ /**
230
+ * Make specific properties readonly
231
+ */
232
+ type ReadonlyPick<T, K extends keyof T> = Omit<T, K> & Readonly<Pick<T, K>>;
233
+ /**
234
+ * Branded type for nominal typing (like Rust's newtype pattern)
235
+ *
236
+ * @example
237
+ * type UserId = Brand<number, 'UserId'>;
238
+ * type OrderId = Brand<number, 'OrderId'>;
239
+ *
240
+ * // These are now incompatible even though both are numbers
241
+ * const userId: UserId = 1 as UserId;
242
+ * const orderId: OrderId = userId; // Error!
243
+ */
244
+ type Brand<T, B> = T & {
245
+ readonly __brand: B;
246
+ };
247
+ /**
248
+ * Create a branded type constructor
249
+ *
250
+ * @example
251
+ * const UserId = brand<number, 'UserId'>();
252
+ * const id = UserId(42); // type is Brand<number, 'UserId'>
253
+ */
254
+ declare const brand: <T, B>() => (value: T) => Brand<T, B>;
255
+ /**
256
+ * NonEmpty array type - guarantees at least one element
257
+ */
258
+ type NonEmptyArray<T> = readonly [T, ...T[]];
259
+ /**
260
+ * Check if array is non-empty (type guard)
261
+ */
262
+ declare const isNonEmpty: <T>(arr: readonly T[]) => arr is NonEmptyArray<T>;
263
+ /**
264
+ * Create a non-empty array from values
265
+ */
266
+ declare const nonEmpty: <T>(first: T, ...rest: T[]) => NonEmptyArray<T>;
267
+ /**
268
+ * Get the first element of a non-empty array (guaranteed to exist)
269
+ */
270
+ declare const head: <T>(arr: NonEmptyArray<T>) => T;
271
+ /**
272
+ * Create a newtype with validation (Rust's newtype pattern + smart constructor).
273
+ * Implements the "parse, don't validate" pattern - make invalid states unrepresentable.
274
+ *
275
+ * @example
276
+ * const EmailAddress = newtype<string, 'Email'>(
277
+ * (s) => s.includes('@'),
278
+ * "Invalid email"
279
+ * );
280
+ *
281
+ * const email = EmailAddress.parse(userInput);
282
+ * // Result<Brand<string, 'Email'>, string>
283
+ *
284
+ * @example
285
+ * const PositiveNumber = newtype<number, 'Positive'>(
286
+ * (n) => n > 0,
287
+ * (n) => `Expected positive, got ${n}`
288
+ * );
289
+ */
290
+ declare const newtype: <T, B, E = string>(validate: (value: T) => boolean, error: E | ((value: T) => E)) => {
291
+ parse: (value: T) => Result<Brand<T, B>, E>;
292
+ unsafe: (value: T) => Brand<T, B>;
293
+ };
294
+ //#endregion
295
+ //#region src/interop.d.ts
296
+ /**
297
+ * One-shot: wrap a single throwing operation in a Result.
298
+ * Use {@link safeTry} to create a reusable safe wrapper instead.
299
+ *
300
+ * @example
301
+ * const result = tryCatch(() => JSON.parse(userInput));
302
+ * // Result<unknown, unknown>
303
+ */
304
+ declare const tryCatch: <T, E = unknown>(fn: () => T) => Result<T, E>;
305
+ /**
306
+ * Wrap any async function that might reject to return Result
307
+ *
308
+ * @example
309
+ * const result = await tryAsync(() => axios.get('/api/users'));
310
+ * // Result<AxiosResponse, AxiosError>
311
+ */
312
+ declare const tryAsync: <T, E = unknown>(fn: () => Promise<T>) => Promise<Result<T, E>>;
313
+ /**
314
+ * Create a reusable Option-returning version of any function that may return
315
+ * T | null | undefined or throw. Returns None on null, undefined, or throw.
316
+ *
317
+ * @example
318
+ * const safeFind = safeCall((id: number) => users.find(u => u.id === id));
319
+ * const user = safeFind(42); // Option<User>
320
+ */
321
+ declare const safeCall: <Args extends unknown[], T>(fn: (...args: Args) => T | null | undefined) => (...args: Args) => Option<T>;
322
+ /**
323
+ * Create a reusable Option-returning version of any async function that may return
324
+ * T | null | undefined or reject. Returns None on null, undefined, or rejection.
325
+ *
326
+ * @example
327
+ * const safeFetch = safeCallAsync((url: string) => fetch(url).then(r => r.ok ? r : null));
328
+ * const response = await safeFetch('/api'); // Option<Response>
329
+ */
330
+ declare const safeCallAsync: <Args extends unknown[], T>(fn: (...args: Args) => Promise<T | null | undefined>) => (...args: Args) => Promise<Option<T>>;
331
+ /**
332
+ * Reusable: wrap a throwing function so every call returns a Result.
333
+ * Use {@link tryCatch} for one-shot operations instead.
334
+ *
335
+ * @example
336
+ * const safeJsonParse = safeTry(JSON.parse);
337
+ * const data = safeJsonParse(input); // Result<unknown, unknown>
338
+ */
339
+ declare const safeTry: <Args extends unknown[], T, E = unknown>(fn: (...args: Args) => T) => (...args: Args) => Result<T, E>;
340
+ //#endregion
341
+ export { AsyncIter, type AsyncIter as AsyncIterType, AsyncResult, type Brand, type DeepReadonly, Err, type Err as ErrType, Iter, type Iter as IterType, type NonEmptyArray, None, type None as NoneType, Ok, type Ok as OkType, Option, type Option as OptionType, type PeekableAsyncIter as PeekableAsyncIterType, type PeekableIter as PeekableIterType, type ReadonlyPick, Result, type Result as ResultType, Some, type Some as SomeType, assertNever, asyncIter, asyncIterFromArray, asyncIterFromGenerator, asyncIterFromIterable, brand, head, isErr, isNonEmpty, isNone, isOk, isSome, iter, iterFromArray, iterFromGenerator, match, matchKind, matchType, newtype, nonEmpty, safeCall, safeCallAsync, safeTry, tryAsync, tryCatch };
342
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/async.ts","../src/match.ts","../src/types.ts","../src/interop.ts"],"mappings":";;;cAMa,WAAA,kBAA6B,WAAA,CAAY,MAAA,CAAO,CAAA,EAAG,CAAA;EAAA,iBACjC,OAAA;cAAA,OAAA,EAAS,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA;EADM;;;EAAA,OAMvD,WAAA,MAAA,CAAkB,OAAA,EAAS,OAAA,CAAQ,MAAA,CAAO,CAAA,EAAG,CAAA,KAAM,WAAA,CAAY,CAAA,EAAG,CAAA;EAL3B;;;EAAA,OAYvC,EAAA,cAAA,CAAiB,KAAA,EAAO,CAAA,GAAI,WAAA,CAAY,CAAA,EAAG,CAAA;EAPR;;;EAAA,OAcnC,GAAA,cAAA,CAAkB,KAAA,EAAO,CAAA,GAAI,WAAA,CAAY,CAAA,EAAG,CAAA;EAdO;;;;;;;;EA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