{"version":3,"file":"main.mjs","sources":["../src/core/option/symbols.ts","../src/core/option/guards.ts","../src/core/result/symbols.ts","../src/core/result/guards.ts","../src/core/prelude.ts","../src/core/option/extensions.ts","../src/core/result/constants.ts","../src/core/result/extensions.ts","../src/std/ops/symbols.ts","../src/std/ops/control_flow.ts","../src/std/ops/fn_once.ts","../src/std/ops/fn_once_async.ts","../src/std/ops/guards.ts","../src/std/sync/channel.ts","../src/std/sync/lazy.ts","../src/std/sync/lazy_async.ts","../src/std/sync/mutex.ts","../src/std/sync/once.ts","../src/std/sync/once_async.ts","../src/std/sync/rwlock.ts"],"sourcesContent":["/**\n * @module\n * Internal symbol used to identify `Option` type variants.\n *\n * This symbol is used as a property key to distinguish between `Some` and `None` variants.\n * It provides a reliable way to identify the variant of an `Option` instance without\n * relying on method calls or duck typing.\n *\n * Note: This symbol is an internal implementation detail and is not exported as part of the public API.\n * Use the `isOption` utility function for type checking instead.\n */\n\n/**\n * A unique symbol used as a property key to identify the variant of an `Option` instance.\n *\n * When accessed on an `Option`, returns `'Some'` if the Option contains a value,\n * or `'None'` if it represents the absence of a value.\n *\n * This symbol is used internally by the `isOption` utility function to verify\n * that an object is a valid `Option` instance.\n *\n * @internal\n */\nexport const OptionKindSymbol = Symbol('Option kind');\n","/**\n * @module\n * Type guard utility for checking if a value is an `Option` type.\n *\n * This function provides runtime type checking capability for the Option type.\n */\nimport type { Option } from './option.ts';\nimport { OptionKindSymbol } from './symbols.ts';\n\n/**\n * Checks if a value is an `Option`.\n *\n * @typeParam T - The expected type of the value contained within the `Option`.\n * @param o - The value to be checked as an `Option`.\n * @returns `true` if the value is an `Option`, otherwise `false`.\n * @since 1.2.0\n * @example\n * ```ts\n * const x = Some(5);\n * console.log(isOption(x)); // true\n * console.log(isOption(null)); // false\n * console.log(isOption({ value: 5 })); // false\n * ```\n */\nexport function isOption<T>(o: unknown): o is Option<T> {\n    // `Some` and `None` must be an object.\n    return o != null && typeof o === 'object' && OptionKindSymbol in o;\n}\n","/**\n * @module\n * Internal symbol used to identify `Result` type variants.\n *\n * This symbol is used as a property key to distinguish between `Ok` and `Err` variants.\n * It provides a reliable way to identify the variant of a `Result` instance without\n * relying on method calls or duck typing.\n *\n * Note: This symbol is an internal implementation detail and is not exported as part of the public API.\n * Use the `isResult` utility function for type checking instead.\n */\n\n/**\n * A unique symbol used as a property key to identify the variant of a `Result` instance.\n *\n * When accessed on a `Result`, returns `'Ok'` if the Result represents success,\n * or `'Err'` if it represents failure.\n *\n * This symbol is used internally by the `isResult` utility function to verify\n * that an object is a valid `Result` instance.\n *\n * @internal\n */\nexport const ResultKindSymbol = Symbol('Result kind');\n","/**\n * @module\n * Type guard utility for checking if a value is a `Result` type.\n *\n * This function provides runtime type checking capability for the Result type.\n */\nimport type { Result } from './result.ts';\nimport { ResultKindSymbol } from './symbols.ts';\n\n/**\n * Checks if a value is a `Result`.\n *\n * @typeParam T - The expected type of the success value contained within the `Result`.\n * @typeParam E - The expected type of the error value contained within the `Result`.\n * @param r - The value to be checked as a `Result`.\n * @returns `true` if the value is a `Result`, otherwise `false`.\n * @since 1.2.0\n * @example\n * ```ts\n * const x = Ok(5);\n * console.log(isResult(x)); // true\n * console.log(isResult(null)); // false\n * console.log(isResult({ value: 5 })); // false\n * ```\n */\nexport function isResult<T, E>(r: unknown): r is Result<T, E> {\n    // `Ok` and `Err` must be an object.\n    return r != null && typeof r === 'object' && ResultKindSymbol in r;\n}\n","/**\n * @module\n * Constructors and factory functions for creating `Option` and `Result` types.\n *\n * This module exports:\n * - `Some<T>(value)` - Creates an Option containing a value\n * - `None` - Constant representing absence of value\n * - `Ok<T, E>(value)` - Creates a successful Result\n * - `Err<T, E>(error)` - Creates a failed Result\n * - `None` interface - Type overrides for better type inference\n */\nimport { isOption } from './option/guards.ts';\nimport type { AsyncLikeOption, AsyncOption, Option } from './option/option.ts';\nimport { OptionKindSymbol } from './option/symbols.ts';\nimport { isResult } from './result/guards.ts';\nimport type { AsyncLikeResult, AsyncResult, Result } from './result/result.ts';\nimport { ResultKindSymbol } from './result/symbols.ts';\n\n// Internal cached Promise constants for runtime optimization\nconst ASYNC_TRUE: Promise<true> = Promise.resolve(true);\nconst ASYNC_FALSE: Promise<false> = Promise.resolve(false);\n\n/**\n * Represents the absence of a value, as a specialized `Option` type.\n * The type parameter is set to `never` because `None` does not hold a value.\n */\nexport interface None extends Option<never> {\n    /**\n     * When using `None` alone, the following overrides can make type inference more accurate.\n     */\n\n    readonly [OptionKindSymbol]: 'None';\n\n    isSome(): false;\n    isNone(): true;\n    isSomeAnd(predicate: (value: never) => boolean): false;\n    isSomeAndAsync(predicate: (value: never) => PromiseLike<boolean> | boolean): Promise<false>;\n    isNoneOr(predicate: (value: never) => boolean): true;\n    isNoneOrAsync(predicate: (value: never) => PromiseLike<boolean> | boolean): Promise<true>;\n\n    expect(msg: string): never;\n    unwrap(): never;\n    unwrapOr<T>(defaultValue: T): T;\n    unwrapOrElse<T>(fn: () => T): T;\n    unwrapOrElseAsync<T>(fn: () => PromiseLike<T> | T): Promise<Awaited<T>>;\n\n    okOr<E>(error: E): Result<never, E>;\n    okOrElse<E>(err: () => E): Result<never, E>;\n    transpose(): Result<this, never>;\n\n    filter(predicate: (value: never) => boolean): this;\n    flatten(): this;\n    map<U>(fn: (value: never) => U): this;\n    mapOr<U>(defaultValue: U, fn: (value: never) => U): U;\n    mapOrElse<U>(defaultFn: () => U, fn: (value: never) => U): U;\n\n    zip<U>(other: Option<U>): this;\n    zipWith<U, R>(other: Option<U>, fn: (value: never, otherValue: U) => R): this;\n    unzip(): [this, this];\n\n    and<U>(other: Option<U>): this;\n    andThen<U>(fn: (value: never) => Option<U>): this;\n    andThenAsync<U>(fn: (value: never) => AsyncLikeOption<U> | Option<U>): Promise<this>;\n    or<T>(other: Option<T>): Option<T>;\n    orElse<T>(fn: () => Option<T>): Option<T>;\n    orElseAsync<T>(fn: () => AsyncLikeOption<T> | Option<T>): AsyncOption<T>;\n    xor<T>(other: Option<T>): Option<T>;\n\n    inspect(fn: (value: never) => void): this;\n\n    eq<T>(other: Option<T>): boolean;\n}\n\n/**\n * Creates an `Option<T>` representing the presence of a value.\n * This function is typically used to construct an `Option` that contains a value, indicating that the operation yielding the value was successful.\n *\n * @typeParam T - The type of the value to be wrapped in a `Some`.\n * @param value - The value to wrap as a `Some` option.\n * @returns An `Option<T>` that contains the provided value, representing the `Some` case.\n * @since 1.0.0\n * @example\n * ```ts\n * const maybeValue = Some(1); // Option<number> with a value\n * if (maybeValue.isSome()) {\n *     console.log(maybeValue.unwrap()); // Outputs: 1\n * }\n * ```\n */\nexport function Some<T>(value: T): Option<T> {\n    const some: Option<T> = Object.freeze<Option<T>>({\n        [Symbol.toStringTag]: 'Option',\n        [OptionKindSymbol]: 'Some',\n\n        *[Symbol.iterator](): Iterator<T> {\n            yield value;\n        },\n        toString(): string {\n            return `Some(${ value })`;\n        },\n\n        isSome(): true {\n            return true;\n        },\n        isNone(): false {\n            return false;\n        },\n        isSomeAnd(predicate: (value: T) => boolean): boolean {\n            return predicate(value);\n        },\n        isSomeAndAsync(predicate: (value: T) => PromiseLike<boolean> | boolean): Promise<boolean> {\n            return Promise.resolve(predicate(value));\n        },\n        isNoneOr(predicate: (value: T) => boolean): boolean {\n            return predicate(value);\n        },\n        isNoneOrAsync(predicate: (value: T) => PromiseLike<boolean> | boolean): Promise<boolean> {\n            return Promise.resolve(predicate(value));\n        },\n\n        expect(_msg: string): T {\n            return value;\n        },\n        unwrap(): T {\n            return value;\n        },\n        unwrapOr(_defaultValue: T): T {\n            return value;\n        },\n        unwrapOrElse(_fn: () => T): T {\n            return value;\n        },\n        unwrapOrElseAsync(_fn: () => PromiseLike<T> | T): Promise<Awaited<T>> {\n            return Promise.resolve(value);\n        },\n\n        okOr<E>(_error: E): Result<T, E> {\n            return Ok(value);\n        },\n        okOrElse<E>(_err: () => E): Result<T, E> {\n            return Ok(value);\n        },\n        transpose<U, E>(): Result<Option<U>, E> {\n            assertResult<U, E>(value);\n            return value.isOk() ? Ok(Some(value.unwrap())) : Err(value.unwrapErr());\n        },\n\n        filter(predicate: (value: T) => boolean): Option<T> {\n            return predicate(value) ? some : None;\n        },\n        flatten<U>(): Option<U> {\n            assertOption<U>(value);\n            return value;\n        },\n        map<U>(fn: (value: T) => U): Option<U> {\n            return Some(fn(value));\n        },\n\n        mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n            return fn(value);\n        },\n        mapOrElse<U>(_defaultFn: () => U, fn: (value: T) => U): U {\n            return fn(value);\n        },\n\n        zip<U>(other: Option<U>): Option<[T, U]> {\n            assertOption<U>(other);\n            return other.isSome() ? Some([value, other.unwrap()]) : None;\n        },\n        zipWith<U, R>(other: Option<U>, fn: (value: T, otherValue: U) => R): Option<R> {\n            assertOption<U>(other);\n            return other.isSome() ? Some(fn(value, other.unwrap())) : None;\n        },\n        unzip<U, R>(): [Option<U>, Option<R>] {\n            const tuple = value as [U, R];\n\n            if (!Array.isArray(tuple) || tuple.length !== 2) {\n                throw new TypeError(`Option::unzip() requires a 2-element tuple, received ${ Array.isArray(tuple) ? `array with ${ tuple.length } elements` : typeof tuple }`);\n            }\n\n            const [a, b] = tuple;\n            return [Some(a), Some(b)];\n        },\n        reduce<U, R = T | U>(other: Option<U>, fn: (value: T, otherValue: U) => R): Option<T | U | R> {\n            assertOption<U>(other);\n            return other.isSome() ? Some(fn(value, other.unwrap())) : some as Option<T | U | R>;\n        },\n\n        and<U>(other: Option<U>): Option<U> {\n            assertOption<U>(other);\n            return other;\n        },\n        andThen<U>(fn: (value: T) => Option<U>): Option<U> {\n            return fn(value);\n        },\n        andThenAsync<U>(fn: (value: T) => AsyncLikeOption<U> | Option<U>): AsyncOption<U> {\n            return Promise.resolve(fn(value));\n        },\n        or(_other: Option<T>): Option<T> {\n            return some;\n        },\n        orElse(_fn: () => Option<T>): Option<T> {\n            return some;\n        },\n        orElseAsync(_fn: () => AsyncLikeOption<T> | Option<T>): AsyncOption<T> {\n            return Promise.resolve(some);\n        },\n        xor(other: Option<T>): Option<T> {\n            assertOption<T>(other);\n            return other.isSome() ? None : some;\n        },\n\n        inspect(fn: (value: T) => void): Option<T> {\n            fn(value);\n            return some;\n        },\n\n        eq(other: Option<T>): boolean {\n            assertOption<T>(other);\n            return other.isSome() && other.unwrap() === value;\n        },\n    } as const);\n\n    return some;\n}\n\n/**\n * A constant representing the `None` case of an `Option`, indicating the absence of a value.\n * This constant is frozen to ensure it is immutable and cannot be altered, preserving the integrity of `None` throughout the application.\n *\n * @since 1.0.0\n * @example\n * ```ts\n * // Use None to represent absence of a value\n * function findUser(id: number): Option<User> {\n *     const user = users.find(u => u.id === id);\n *     return user ? Some(user) : None;\n * }\n *\n * // None is a singleton, so you can compare by reference\n * const result = findUser(999);\n * if (result === None) {\n *     console.log('User not found');\n * }\n *\n * // Use with Option methods\n * const name = None.unwrapOr('Anonymous'); // 'Anonymous'\n * ```\n */\nexport const None: None = Object.freeze<None>({\n    [Symbol.toStringTag]: 'Option',\n    [OptionKindSymbol]: 'None',\n\n    *[Symbol.iterator](): Iterator<never> {\n        // Empty iterator - yields nothing\n    },\n    toString(): string {\n        return 'None';\n    },\n\n    isSome(): false {\n        return false;\n    },\n    isNone(): true {\n        return true;\n    },\n    isSomeAnd(_predicate: (value: never) => boolean): false {\n        return false;\n    },\n    isSomeAndAsync(_predicate: (value: never) => PromiseLike<boolean> | boolean): Promise<false> {\n        return ASYNC_FALSE;\n    },\n    isNoneOr(_predicate: (value: never) => boolean): true {\n        return true;\n    },\n    isNoneOrAsync(_predicate: (value: never) => PromiseLike<boolean> | boolean): Promise<true> {\n        return ASYNC_TRUE;\n    },\n\n    expect(msg: string): never {\n        throw new TypeError(msg);\n    },\n    unwrap(): never {\n        throw new TypeError('Option::unwrap() called on a `None` value');\n    },\n    unwrapOr<T>(defaultValue: T): T {\n        return defaultValue;\n    },\n    unwrapOrElse<T>(fn: () => T): T {\n        return fn();\n    },\n    unwrapOrElseAsync<T>(fn: () => PromiseLike<T> | T): Promise<Awaited<T>> {\n        return Promise.resolve(fn());\n    },\n\n    okOr<E>(error: E): Result<never, E> {\n        return Err(error);\n    },\n    okOrElse<E>(err: () => E): Result<never, E> {\n        return Err(err());\n    },\n    transpose(): Result<None, never> {\n        return Ok(None);\n    },\n\n    filter(_predicate: (value: never) => boolean): None {\n        return None;\n    },\n    flatten(): None {\n        return None;\n    },\n    map<U>(_fn: (value: never) => U): None {\n        return None;\n    },\n\n    mapOr<U>(defaultValue: U, _fn: (value: never) => U): U {\n        return defaultValue;\n    },\n    mapOrElse<U>(defaultFn: () => U, _fn: (value: never) => U): U {\n        return defaultFn();\n    },\n\n    zip<U>(_other: Option<U>): None {\n        return None;\n    },\n    zipWith<U, R>(_other: Option<U>, _fn: (value: never, otherValue: U) => R): None {\n        return None;\n    },\n    unzip(): [None, None] {\n        return [None, None];\n    },\n    reduce<U, R = U>(other: Option<U>, _fn: (value: never, otherValue: U) => R): Option<U | R> {\n        assertOption<U>(other);\n        return other as Option<U | R>;\n    },\n\n    and<U>(_other: Option<U>): None {\n        return None;\n    },\n    andThen<U>(_fn: (value: never) => Option<U>): None {\n        return None;\n    },\n    andThenAsync<U>(_fn: (value: never) => AsyncLikeOption<U> | Option<U>): Promise<None> {\n        return ASYNC_NONE;\n    },\n    or<T>(other: Option<T>): Option<T> {\n        assertOption<T>(other);\n        return other;\n    },\n    orElse<T>(fn: () => Option<T>): Option<T> {\n        return fn();\n    },\n    orElseAsync<T>(fn: () => AsyncLikeOption<T> | Option<T>): AsyncOption<T> {\n        return Promise.resolve(fn());\n    },\n    xor<T>(other: Option<T>): Option<T> {\n        assertOption<T>(other);\n        return other.isSome() ? other : None;\n    },\n\n    inspect(_fn: (value: never) => void): None {\n        return None;\n    },\n\n    eq<T>(other: Option<T>): boolean {\n        assertOption<T>(other);\n        return other === None;\n    },\n} as const);\n\n/**\n * Async Option constant for `None`.\n * A pre-resolved `Promise<None>` that can be reused to avoid creating\n * new Promise instances when returning `None` from async functions.\n *\n * Since `None extends Option<never>`, this constant can be assigned to any\n * `AsyncOption<T>` (i.e., `Promise<Option<T>>`) due to TypeScript's covariance.\n *\n * @since 1.8.0\n * @example\n * ```ts\n * async function findUser(id: number): AsyncOption<User> {\n *     if (id < 0) {\n *         return ASYNC_NONE;\n *     }\n *     const user = await db.findUser(id);\n *     return user ? Some(user) : ASYNC_NONE;\n * }\n * ```\n *\n * @example\n * ```ts\n * // Useful in conditional async returns\n * function maybeLoadAsync(shouldLoad: boolean): AsyncOption<Data> {\n *     if (!shouldLoad) {\n *         return ASYNC_NONE;\n *     }\n *     return loadDataAsync();\n * }\n * ```\n */\nexport const ASYNC_NONE: Promise<None> = Promise.resolve(None);\n\n/**\n * Creates a `Result<T, E>` representing a successful outcome containing a value.\n * This function is used to construct a `Result` that signifies the operation was successful by containing the value `T`.\n *\n * @typeParam T - The type of the value to be contained in the `Ok` result.\n * @typeParam E - The type of the error that the result could potentially contain (not used in this case).\n * @param value - The value to wrap as an `Ok` result.\n * @returns A `Result<T, E>` that contains the provided value, representing the `Ok` case.\n * @since 1.0.0\n * @example\n * ```ts\n * const goodResult = Ok<number, Error>(1); // Result<number, Error> with a value\n * if (goodResult.isOk()) {\n *   console.log(goodResult.unwrap()); // Outputs: 1\n * }\n * ```\n */\nexport function Ok<T, E = never>(value: T): Result<T, E>;\n/**\n * Creates a `Result<void, E>` representing a successful outcome with no value.\n * This overload is used when the operation succeeds but doesn't produce a meaningful value.\n *\n * In Rust, this would be `Ok(())` using the unit type `()`.\n * Since JavaScript doesn't have a unit type, we use `void` instead.\n *\n * @typeParam E - The type of the error that the result could potentially contain.\n * @returns A `Result<void, E>` representing a successful operation with no value.\n * @since 1.4.0\n * @example\n * ```ts\n * function saveToFile(path: string): Result<void, Error> {\n *     try {\n *         fs.writeFileSync(path, data);\n *         return Ok(); // Success with no return value\n *     } catch (e) {\n *         return Err(e as Error);\n *     }\n * }\n *\n * const result = saveToFile('/tmp/data.txt');\n * if (result.isOk()) {\n *     console.log('File saved successfully');\n * }\n * ```\n */\nexport function Ok<E = never>(): Result<void, E>;\nexport function Ok<T, E>(value?: T): Result<T, E> {\n    const ok: Result<T, E> = Object.freeze<Result<T, E>>({\n        [Symbol.toStringTag]: 'Result',\n        [ResultKindSymbol]: 'Ok',\n\n        *[Symbol.iterator](): Iterator<T> {\n            yield value as T;\n        },\n        toString(): string {\n            return `Ok(${ value })`;\n        },\n\n        isOk(): true {\n            return true;\n        },\n        isErr(): false {\n            return false;\n        },\n        isOkAnd(predicate: (value: T) => boolean): boolean {\n            return predicate(value as T);\n        },\n        isOkAndAsync(predicate: (value: T) => PromiseLike<boolean> | boolean): Promise<boolean> {\n            return Promise.resolve(predicate(value as T));\n        },\n        isErrAnd(_predicate: (error: E) => boolean): false {\n            return false;\n        },\n        isErrAndAsync(_predicate: (error: E) => PromiseLike<boolean> | boolean): Promise<false> {\n            return ASYNC_FALSE;\n        },\n\n        expect(_msg: string): T {\n            return value as T;\n        },\n        unwrap(): T {\n            return value as T;\n        },\n        unwrapOr(_defaultValue: T): T {\n            return value as T;\n        },\n        unwrapOrElse(_fn: (error: E) => T): T {\n            return value as T;\n        },\n        unwrapOrElseAsync(_fn: (error: E) => PromiseLike<T> | T): Promise<Awaited<T>> {\n            return Promise.resolve(value as T);\n        },\n\n        expectErr(msg: string): never {\n            throw new TypeError(`${ msg }: ${ value }`);\n        },\n        unwrapErr(): never {\n            throw new TypeError('Result::unwrapErr() called on an `Ok` value');\n        },\n\n        intoOk(): T {\n            return value as T;\n        },\n        intoErr(): never {\n            throw new TypeError('Result::intoErr() called on an `Ok` value');\n        },\n\n        ok(): Option<T> {\n            return Some(value as T);\n        },\n        err(): None {\n            return None;\n        },\n        transpose<U>(): Option<Result<U, E>> {\n            assertOption<U>(value);\n            return value.isSome() ? Some(Ok(value.unwrap())) : None;\n        },\n\n        map<U>(fn: (value: T) => U): Result<U, E> {\n            return Ok(fn(value as T));\n        },\n        mapErr<F>(_fn: (error: E) => F): Result<T, F> {\n            return ok as unknown as Result<T, F>;\n        },\n        mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n            return fn(value as T);\n        },\n        mapOrElse<U>(_defaultFn: (error: E) => U, fn: (value: T) => U): U {\n            return fn(value as T);\n        },\n        flatten<U>(): Result<U, E> {\n            assertResult<U, E>(value);\n            return value;\n        },\n\n        and<U>(other: Result<U, E>): Result<U, E> {\n            assertResult<T, E>(other);\n            return other;\n        },\n        or<F>(_other: Result<T, F>): Result<T, F> {\n            return ok as unknown as Result<T, F>;\n        },\n        andThen<U>(fn: (value: T) => Result<U, E>): Result<U, E> {\n            return fn(value as T);\n        },\n        andThenAsync<U>(fn: (value: T) => AsyncLikeResult<U, E> | Result<U, E>): AsyncResult<U, E> {\n            return Promise.resolve(fn(value as T));\n        },\n        orElse<F>(_fn: (error: E) => Result<T, F>): Result<T, F> {\n            return ok as unknown as Result<T, F>;\n        },\n        orElseAsync<F>(_fn: (error: E) => AsyncLikeResult<T, F> | Result<T, F>): AsyncResult<T, F> {\n            return Promise.resolve(ok as unknown as Result<T, F>);\n        },\n\n        inspect(fn: (value: T) => void): Result<T, E> {\n            fn(value as T);\n            return ok;\n        },\n        inspectErr(_fn: (error: E) => void): Result<T, E> {\n            return ok;\n        },\n\n        eq(other: Result<T, E>): boolean {\n            assertResult<T, E>(other);\n            return other.isOk() && other.unwrap() === value;\n        },\n\n        asOk<F>(): Result<T, F> {\n            return ok as unknown as Result<T, F>;\n        },\n        asErr(): never {\n            throw new TypeError('Result::asErr() called on an `Ok` value');\n        },\n\n        andTryAsync<U>(fn: (value: T) => PromiseLike<U> | U): AsyncResult<Awaited<U>, E> {\n            try {\n                const result = fn(value as T);\n                return Promise.resolve(result).then(\n                    Ok<Awaited<U>, E>,\n                    Err<Awaited<U>, E>,\n                );\n            } catch (e) {\n                return Promise.resolve(Err<Awaited<U>, E>(e as E));\n            }\n        },\n        orTryAsync<F>(_fn: (error: E) => PromiseLike<T> | T): AsyncResult<Awaited<T>, F> {\n            return Promise.resolve(ok as unknown as Result<Awaited<T>, F>);\n        },\n    } as const);\n\n    return ok;\n}\n\n/**\n * Creates a `Result<T, E>` representing a failed outcome containing an error.\n * This function is used to construct a `Result` that signifies the operation failed by containing the error `E`.\n *\n * @typeParam T - The type of the value that the result could potentially contain (not used in this case).\n * @typeParam E - The type of the error to be wrapped in the `Err` result.\n * @param error - The error to wrap as an `Err` result.\n * @returns A `Result<T, E>` that contains the provided error, representing the `Err` case.\n * @since 1.0.0\n * @example\n * ```ts\n * const badResult = Err<number, Error>(new Error('Something went wrong'));\n * if (badResult.isErr()) {\n *   console.error(badResult.unwrapErr()); // Outputs: Error: Something went wrong\n * }\n * ```\n */\nexport function Err<T = never, E = unknown>(error: E): Result<T, E> {\n    const err: Result<T, E> = Object.freeze<Result<T, E>>({\n        [Symbol.toStringTag]: 'Result',\n        [ResultKindSymbol]: 'Err',\n\n        *[Symbol.iterator](): Iterator<T> {\n            // Empty iterator - yields nothing for Err\n        },\n        toString(): string {\n            return `Err(${ error })`;\n        },\n\n        isOk(): false {\n            return false;\n        },\n        isErr(): true {\n            return true;\n        },\n        isOkAnd(_predicate: (value: T) => boolean): false {\n            return false;\n        },\n        isOkAndAsync(_predicate: (value: T) => PromiseLike<boolean> | boolean): Promise<boolean> {\n            return ASYNC_FALSE;\n        },\n        isErrAnd(predicate: (error: E) => boolean): boolean {\n            return predicate(error);\n        },\n        isErrAndAsync(predicate: (error: E) => PromiseLike<boolean> | boolean): Promise<boolean> {\n            return Promise.resolve(predicate(error));\n        },\n\n        expect(msg: string): never {\n            throw new TypeError(`${ msg }: ${ error }`);\n        },\n        unwrap(): never {\n            throw new TypeError('Result::unwrap() called on an `Err` value');\n        },\n        unwrapOr(defaultValue: T): T {\n            return defaultValue;\n        },\n        unwrapOrElse(fn: (error: E) => T): T {\n            return fn(error);\n        },\n        unwrapOrElseAsync(fn: (error: E) => PromiseLike<T> | T): Promise<Awaited<T>> {\n            return Promise.resolve(fn(error));\n        },\n\n        expectErr(_msg: string): E {\n            return error;\n        },\n        unwrapErr(): E {\n            return error;\n        },\n\n        intoOk(): never {\n            throw new TypeError('Result::intoOk() called on an `Err` value');\n        },\n        intoErr(): E {\n            return error;\n        },\n\n        ok(): None {\n            return None;\n        },\n        err(): Option<E> {\n            return Some(error);\n        },\n        transpose<U>(): Option<Result<U, E>> {\n            return Some(err as unknown as Result<U, E>);\n        },\n\n        map<U>(_fn: (value: T) => U): Result<U, E> {\n            return err as unknown as Result<U, E>;\n        },\n        mapErr<F>(fn: (error: E) => F): Result<T, F> {\n            return Err(fn(error));\n        },\n        mapOr<U>(defaultValue: U, _fn: (value: T) => U): U {\n            return defaultValue;\n        },\n        mapOrElse<U>(defaultFn: (error: E) => U, _fn: (value: T) => U): U {\n            return defaultFn(error);\n        },\n        flatten<U>(): Result<U, E> {\n            return err as unknown as Result<U, E>;\n        },\n\n        and<U>(_other: Result<U, E>): Result<U, E> {\n            return err as unknown as Result<U, E>;\n        },\n        or<F>(other: Result<T, F>): Result<T, F> {\n            assertResult<T, E>(other);\n            return other;\n        },\n        andThen<U>(_fn: (value: T) => Result<U, E>): Result<U, E> {\n            return err as unknown as Result<U, E>;\n        },\n        andThenAsync<U>(_fn: (value: T) => AsyncLikeResult<U, E> | Result<U, E>): AsyncResult<U, E> {\n            return Promise.resolve(err as unknown as Result<U, E>);\n        },\n        orElse<F>(fn: (error: E) => Result<T, F>): Result<T, F> {\n            return fn(error);\n        },\n        orElseAsync<F>(fn: (error: E) => AsyncLikeResult<T, F> | Result<T, F>): AsyncResult<T, F> {\n            return Promise.resolve(fn(error));\n        },\n\n        inspect(_fn: (value: T) => void): Result<T, E> {\n            return err;\n        },\n        inspectErr(fn: (error: E) => void): Result<T, E> {\n            fn(error);\n            return err;\n        },\n\n        eq(other: Result<T, E>): boolean {\n            assertResult<T, E>(other);\n            return other.isErr() && other.unwrapErr() === error;\n        },\n\n        asOk(): never {\n            throw new TypeError('Result::asOk() called on an `Err` value');\n        },\n        asErr<U>(): Result<U, E> {\n            return err as unknown as Result<U, E>;\n        },\n\n        andTryAsync<U>(_fn: (value: T) => PromiseLike<U> | U): AsyncResult<Awaited<U>, E> {\n            return Promise.resolve(err as unknown as Result<Awaited<U>, E>);\n        },\n        orTryAsync<F>(fn: (error: E) => PromiseLike<T> | T): AsyncResult<Awaited<T>, F> {\n            try {\n                const result = fn(error);\n                return Promise.resolve(result).then(\n                    Ok<Awaited<T>, F>,\n                    Err<Awaited<T>, F>,\n                );\n            } catch (e) {\n                return Promise.resolve(Err<Awaited<T>, F>(e as F));\n            }\n        },\n    } as const);\n\n    return err;\n}\n\n/**\n * Safely converts a value to a string representation for error messages.\n * Handles cases where `toString()` might throw or values are null/undefined.\n *\n * @param value - The value to stringify.\n * @returns A safe string representation of the value.\n */\nfunction safeStringify(value: unknown): string {\n    try {\n        if (value === null) {\n            return 'null';\n        }\n        if (value === undefined) {\n            return 'undefined';\n        }\n        if (typeof value === 'object') {\n            return Object.prototype.toString.call(value);\n        }\n        return String(value);\n    } catch {\n        return '[unable to stringify]';\n    }\n}\n\n/**\n * Asserts that a given value is an `Option`.\n *\n * @typeParam T - The expected type of the value contained within the `Option`.\n * @param o - The value to be checked as an `Option`.\n * @throws {TypeError} If the value is not an `Option`.\n * @see isOption\n */\nfunction assertOption<T>(o: unknown): asserts o is Option<T> {\n    if (!isOption(o)) {\n        throw new TypeError(`Expected an Option, but received: ${ safeStringify(o) }`);\n    }\n}\n\n/**\n * Asserts that a given value is a `Result`.\n *\n * @typeParam T - The expected type of the success value contained within the `Result`.\n * @typeParam E - The expected type of the error value contained within the `Result`.\n * @param r - The value to be checked as a `Result`.\n * @throws {TypeError} If the value is not a `Result`.\n * @see isResult\n */\nfunction assertResult<T, E>(r: unknown): asserts r is Result<T, E> {\n    if (!isResult(r)) {\n        throw new TypeError(`Expected a Result, but received: ${ safeStringify(r) }`);\n    }\n}\n","/**\n * @module\n * Extension functions for bridging standard JavaScript patterns with Option types.\n *\n * This module provides utilities for:\n * - Converting try-catch patterns to Option-based handling\n * - Integrating async/await patterns with Option types\n */\nimport { None, Some } from '../prelude.ts';\nimport type { AsyncOption, Option } from './option.ts';\n\n/**\n * Executes a function and returns `Some` with the result if successful, or `None` if it throws.\n *\n * This converts try-catch patterns to Option-based handling, where you only care\n * about success/failure, not the error details.\n *\n * Similar to `Promise.try`, this function accepts optional arguments that are passed to the function.\n *\n * @typeParam T - The type of the value returned by the function.\n * @typeParam Args - The types of the arguments to pass to the function.\n * @param fn - A function that may throw an exception.\n * @param args - Arguments to pass to the function.\n * @returns `Some<T>` if the function succeeds, or `None` if it throws.\n * @since 1.7.0\n * @example\n * ```ts\n * // Parse JSON, ignore error details\n * const data = tryOption(JSON.parse, jsonString);\n * console.log(data.unwrapOr(defaultData));\n * ```\n *\n * @example\n * ```ts\n * // Validate URL - using closure form\n * const url = tryOption(() => new URL(input));\n * url.inspect(u => console.log('Valid URL:', u.href));\n * ```\n *\n * @example\n * ```ts\n * // Decode URI component with arguments\n * const decoded = tryOption(decodeURIComponent, str);\n * ```\n */\nexport function tryOption<T, Args extends unknown[]>(fn: (...args: Args) => T, ...args: Args): Option<T> {\n    try {\n        return Some(fn(...args));\n    } catch {\n        return None;\n    }\n}\n\n/**\n * Executes an async operation and returns `Some` with the resolved value if successful, or `None` if it rejects.\n *\n * This overload accepts a Promise or PromiseLike object directly.\n * Use this when you already have a Promise and only care about success/failure, not the error details.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @param task - A promise or promise-like object to await.\n * @returns A promise that resolves to `Some<T>` if successful, or `None` if rejected.\n * @since 1.7.0\n * @example\n * ```ts\n * // Fetch data, ignore error details\n * const data = await tryAsyncOption(fetch('/api/data').then(r => r.json()));\n * console.log(data.unwrapOr(defaultData));\n * ```\n *\n * @example\n * ```ts\n * // With existing promise\n * const fileContent = await tryAsyncOption(fs.promises.readFile('config.json', 'utf-8'));\n * ```\n */\nexport function tryAsyncOption<T>(task: PromiseLike<T>): AsyncOption<Awaited<T>>;\n/**\n * Executes a function and returns `Some` with the result if successful, or `None` if it throws or rejects.\n *\n * This overload accepts a function that may return a sync value or a Promise.\n * It captures both synchronous exceptions (thrown before the Promise is created) and asynchronous rejections.\n *\n * Similar to `Promise.try`, you can pass arguments to the function.\n *\n * @typeParam T - The type of the value returned or resolved by the function.\n * @typeParam Args - The types of the arguments to pass to the function.\n * @param task - A function that returns a value or promise-like object.\n * @param args - Arguments to pass to the function.\n * @returns A promise that resolves to `Some<T>` if successful, or `None` if thrown or rejected.\n * @since 1.7.0\n * @example\n * ```ts\n * // Function with arguments\n * const result = await tryAsyncOption(fetch, '/api/data');\n * ```\n *\n * @example\n * ```ts\n * // Function can return sync or async value (like Promise.try)\n * const result = await tryAsyncOption((id) => {\n *     if (cache.has(id)) return cache.get(id);  // sync return\n *     return fetchFromServer(id);                // async return\n * }, 'user-123');\n * ```\n *\n * @example\n * ```ts\n * // Inline async function\n * const data = await tryAsyncOption(async () => {\n *     const response = await fetch('/api');\n *     return response.json();\n * });\n * ```\n */\nexport function tryAsyncOption<T, Args extends unknown[]>(task: (...args: Args) => PromiseLike<T> | T, ...args: Args): AsyncOption<Awaited<T>>;\nexport async function tryAsyncOption<T, Args extends unknown[]>(task: PromiseLike<T> | ((...args: Args) => PromiseLike<T> | T), ...args: Args): AsyncOption<Awaited<T>> {\n    try {\n        const result = typeof task === 'function' ? task(...args) : task;\n        return Some(await result);\n    } catch {\n        return None;\n    }\n}\n","/**\n * @module\n * Pre-defined Result constants for common return values.\n *\n * These immutable constants can be reused throughout the application to avoid\n * creating new Result instances for common values like `true`, `false`, `0`, and `void`.\n *\n * The error type is `never` because these are always `Ok` values that can never\n * contain an error. This allows them to be assigned to any `Result<T, E>` type.\n */\nimport { Ok } from '../prelude.ts';\nimport type { Result } from './result.ts';\n\n/**\n * Result constant for `true`.\n * Can be used anywhere due to immutability.\n * @since 1.3.0\n * @example\n * ```ts\n * function validate(): Result<boolean, Error> {\n *     return RESULT_TRUE;\n * }\n *\n * const result: Result<boolean, string> = RESULT_TRUE;\n * const value: boolean = RESULT_TRUE.intoOk(); // Safe extraction\n * ```\n */\nexport const RESULT_TRUE: Result<boolean, never> = Ok(true);\n\n/**\n * Result constant for `false`.\n * Can be used anywhere due to immutability.\n * @since 1.3.0\n * @example\n * ```ts\n * function validate(): Result<boolean, Error> {\n *     return RESULT_FALSE;\n * }\n *\n * const result: Result<boolean, string> = RESULT_FALSE;\n * const value: boolean = RESULT_FALSE.intoOk(); // Safe extraction\n * ```\n */\nexport const RESULT_FALSE: Result<boolean, never> = Ok(false);\n\n/**\n * Result constant for `0`.\n * Can be used anywhere due to immutability.\n * @since 1.3.0\n * @example\n * ```ts\n * function count(): Result<number, Error> {\n *     return RESULT_ZERO;\n * }\n *\n * const result: Result<number, string> = RESULT_ZERO;\n * const value: number = RESULT_ZERO.intoOk(); // Safe extraction\n * ```\n */\nexport const RESULT_ZERO: Result<number, never> = Ok(0);\n\n/**\n * Result constant for `void` or `()`.\n * Can be used anywhere due to immutability.\n * @since 1.4.0\n * @example\n * ```ts\n * function doSomething(): Result<void, Error> {\n *     return RESULT_VOID;\n * }\n *\n * const result: Result<void, string> = RESULT_VOID;\n * RESULT_VOID.intoOk(); // Safe extraction (returns undefined)\n * ```\n */\nexport const RESULT_VOID: Result<void, never> = Ok();\n","/**\n * @module\n * Extension functions for bridging standard JavaScript patterns with Result types.\n *\n * This module provides utilities for:\n * - Converting try-catch patterns to Result-based error handling\n * - Integrating async/await patterns with Result types\n */\nimport { Err, Ok } from '../prelude.ts';\nimport type { AsyncResult, Result } from './result.ts';\n\n/**\n * Executes a function and captures any thrown exception as an `Err`.\n * If the function executes successfully, returns `Ok` with the result.\n *\n * Use this to convert traditional try-catch error handling to Result-based handling.\n *\n * Similar to `Promise.try`, this function accepts optional arguments that are passed to the function.\n *\n * @typeParam T - The type of the value returned by the function.\n * @typeParam E - The type of the error that may be thrown, defaults to `Error`.\n * @typeParam Args - The types of the arguments to pass to the function.\n * @param fn - A function that may throw an exception.\n * @param args - Arguments to pass to the function.\n * @returns `Ok<T>` if the function succeeds, or `Err<E>` if it throws.\n * @since 1.7.0\n * @example\n * ```ts\n * // Parse JSON safely with arguments\n * const result = tryResult(JSON.parse, jsonString);\n * result.inspect(data => console.log('Parsed:', data))\n *       .inspectErr(err => console.error('Invalid JSON:', err));\n * ```\n *\n * @example\n * ```ts\n * // Validate URL - using closure form\n * const result = tryResult(() => new URL(input));\n * if (result.isOk()) {\n *     console.log('Valid URL:', result.unwrap().href);\n * }\n * ```\n *\n * @example\n * ```ts\n * // With custom error type\n * const result = tryResult<Config, ConfigError, [string]>(parseConfig, raw);\n * ```\n */\nexport function tryResult<T, E = Error, Args extends unknown[] = []>(fn: (...args: Args) => T, ...args: Args): Result<T, E> {\n    try {\n        return Ok(fn(...args));\n    } catch (err) {\n        return Err(err as E);\n    }\n}\n\n/**\n * Executes an async operation and captures any rejection as an `Err`.\n * If the operation succeeds, returns `Ok` with the resolved value.\n *\n * This overload accepts a Promise or PromiseLike object directly.\n * Use this to convert Promise-based error handling to Result-based handling.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @typeParam E - The type of the error that may be rejected, defaults to `Error`.\n * @param task - A promise or promise-like object to await.\n * @returns A promise that resolves to `Ok<T>` if successful, or `Err<E>` if rejected.\n * @since 1.7.0\n * @example\n * ```ts\n * // Fetch data safely\n * const result = await tryAsyncResult(fetch('/api/data'));\n * result.inspect(response => console.log('Status:', response.status))\n *       .inspectErr(err => console.error('Fetch failed:', err));\n * ```\n *\n * @example\n * ```ts\n * // With typed error\n * const result = await tryAsyncResult<User, ApiError>(api.getUser(id));\n * ```\n */\nexport function tryAsyncResult<T, E = Error>(task: PromiseLike<T>): AsyncResult<Awaited<T>, E>;\n/**\n * Executes a function and captures any thrown exception or rejection as an `Err`.\n * If the function succeeds, returns `Ok` with the result.\n *\n * This overload accepts a function that may return a sync value or a Promise.\n * It captures both synchronous exceptions (thrown before the Promise is created) and asynchronous rejections.\n *\n * Similar to `Promise.try`, you can pass arguments to the function.\n *\n * @typeParam T - The type of the value returned or resolved by the function.\n * @typeParam E - The type of the error that may be thrown or rejected, defaults to `Error`.\n * @typeParam Args - The types of the arguments to pass to the function.\n * @param task - A function that returns a value or promise-like object.\n * @param args - Arguments to pass to the function.\n * @returns A promise that resolves to `Ok<T>` if successful, or `Err<E>` if thrown or rejected.\n * @since 1.7.0\n * @example\n * ```ts\n * // Function with arguments\n * const result = await tryAsyncResult(fetch, '/api/data');\n * ```\n *\n * @example\n * ```ts\n * // Function can return sync or async value (like Promise.try)\n * const result = await tryAsyncResult((id) => {\n *     if (cache.has(id)) return cache.get(id);  // sync return\n *     return fetchFromServer(id);                // async return\n * }, 'user-123');\n * ```\n *\n * @example\n * ```ts\n * // Inline async function\n * const result = await tryAsyncResult(async () => {\n *     const response = await fetch('/api');\n *     return response.json();\n * });\n * ```\n *\n * @example\n * ```ts\n * // With custom error type\n * const result = await tryAsyncResult<Config, ConfigError, [string]>(loadConfig, 'app.json');\n * ```\n */\nexport function tryAsyncResult<T, E = Error, Args extends unknown[] = []>(task: (...args: Args) => PromiseLike<T> | T, ...args: Args): AsyncResult<Awaited<T>, E>;\nexport async function tryAsyncResult<T, E = Error, Args extends unknown[] = []>(task: PromiseLike<T> | ((...args: Args) => PromiseLike<T> | T), ...args: Args): AsyncResult<Awaited<T>, E> {\n    try {\n        const result = typeof task === 'function' ? task(...args) : task;\n        return Ok(await result);\n    } catch (err) {\n        return Err(err as E);\n    }\n}\n","/**\n * @module\n * Internal symbols used to identify `ControlFlow` type variants.\n *\n * These symbols are used as property keys to distinguish between `Break` and `Continue` variants.\n * They provide a reliable way to identify the variant of a `ControlFlow` instance without\n * relying on method calls or duck typing.\n *\n * Note: These symbols are internal implementation details and are not exported as part of the public API.\n * Use the `isControlFlow` utility function for type checking instead.\n */\n\n/**\n * A unique symbol used as a property key to identify the variant of a `ControlFlow` instance.\n *\n * When accessed on a `ControlFlow`, returns `'Break'` if the ControlFlow signals early exit,\n * or `'Continue'` if it signals to proceed as normal.\n *\n * This symbol is used internally by the `isControlFlow` utility function to verify\n * that an object is a valid `ControlFlow` instance.\n *\n * @internal\n */\nexport const ControlFlowKindSymbol = Symbol('ControlFlow kind');\n","/**\n * @module\n * Rust-inspired [ControlFlow](https://doc.rust-lang.org/std/ops/enum.ControlFlow.html) for control flow handling.\n */\n\nimport { Err, None, Ok, Some, type Option, type Result } from '../../core/mod.ts';\nimport { ControlFlowKindSymbol } from './symbols.ts';\n\n/**\n * Used to tell an operation whether it should exit early or go on as usual.\n *\n * This is the return type of `try_fold` and similar iterator methods that support\n * short-circuiting. It can also be used in custom control flow scenarios.\n *\n * **Use cases:**\n * - Short-circuiting iterators\n * - Signaling early termination in fold-like operations\n * - Implementing custom control flow patterns\n *\n * @typeParam B - The type of the value returned on `Break` (early exit).\n * @typeParam C - The type of the value returned on `Continue` (default: `void`).\n * @since 1.6.0\n * @see https://doc.rust-lang.org/std/ops/enum.ControlFlow.html\n * @example\n * ```ts\n * // Using ControlFlow to short-circuit a search\n * function findFirstNegative(numbers: number[]): Option<number> {\n *     let result: Option<number> = None;\n *\n *     for (const n of numbers) {\n *         const flow = n < 0 ? Break(n) : Continue();\n *         if (flow.isBreak()) {\n *             result = Some(flow.breakValue().unwrap());\n *             break;\n *         }\n *     }\n *\n *     return result;\n * }\n * ```\n *\n * @example\n * ```ts\n * // Using ControlFlow in a custom fold operation\n * function tryFold<T, Acc>(\n *     arr: T[],\n *     init: Acc,\n *     f: (acc: Acc, item: T) => ControlFlow<Acc, Acc>\n * ): ControlFlow<Acc, Acc> {\n *     let acc = init;\n *     for (const item of arr) {\n *         const flow = f(acc, item);\n *         if (flow.isBreak()) {\n *             return flow;\n *         }\n *         acc = flow.continueValue().unwrap();\n *     }\n *     return Continue(acc);\n * }\n * ```\n */\nexport interface ControlFlow<B, C = void> {\n    // #region Internal properties\n\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'ControlFlow'` so that `Object.prototype.toString.call(flow)` produces `'[object ControlFlow]'`.\n     *\n     * This enables reliable type identification even across different execution contexts (e.g., iframes, different module instances).\n     *\n     * @example\n     * ```ts\n     * const x = Break(5);\n     * console.log(Object.prototype.toString.call(x)); // '[object ControlFlow]'\n     * ```\n     */\n    readonly [Symbol.toStringTag]: 'ControlFlow';\n\n    /**\n     * A unique symbol property used to identify the variant of this `ControlFlow`.\n     * Returns `'Break'` if the ControlFlow signals early exit, or `'Continue'` if it signals to proceed as normal.\n     *\n     * This is used internally by the `isControlFlow` utility function to verify that an object is a valid `ControlFlow` instance,\n     * and to distinguish between `Break` and `Continue` variants without calling methods.\n     *\n     * Note: The symbol itself is not exported as part of the public API.\n     * Use the `isControlFlow` utility function or the `isBreak()`/`isContinue()` methods for type checking.\n     */\n    readonly [ControlFlowKindSymbol]: 'Break' | 'Continue';\n\n    // #endregion\n\n    /**\n     * Custom `toString` implementation that uses the `ControlFlow`'s contained value.\n     * @example\n     * ```ts\n     * console.log(Break(5).toString()); // 'Break(5)'\n     * console.log(Continue('ok').toString()); // 'Continue(ok)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Returns `true` if this is a `Break` variant.\n     *\n     * @example\n     * ```ts\n     * console.log(Break(3).isBreak()); // true\n     * console.log(Continue().isBreak()); // false\n     * ```\n     */\n    isBreak(): boolean;\n\n    /**\n     * Returns `true` if this is a `Continue` variant.\n     *\n     * @example\n     * ```ts\n     * console.log(Continue().isContinue()); // true\n     * console.log(Break(3).isContinue()); // false\n     * ```\n     */\n    isContinue(): boolean;\n\n    /**\n     * Converts the `ControlFlow` into an `Option` which is `Some` if the\n     * `ControlFlow` was `Break` and `None` otherwise.\n     *\n     * @returns `Some(value)` if `Break`, `None` if `Continue`.\n     * @example\n     * ```ts\n     * console.log(Break(3).breakValue()); // Some(3)\n     * console.log(Continue().breakValue()); // None\n     * ```\n     */\n    breakValue(): Option<B>;\n\n    /**\n     * Converts the `ControlFlow` into an `Option` which is `Some` if the\n     * `ControlFlow` was `Continue` and `None` otherwise.\n     *\n     * @returns `Some(value)` if `Continue`, `None` if `Break`.\n     * @example\n     * ```ts\n     * console.log(Continue(5).continueValue()); // Some(5)\n     * console.log(Break(3).continueValue()); // None\n     * ```\n     */\n    continueValue(): Option<C>;\n\n    /**\n     * Maps `ControlFlow<B, C>` to `ControlFlow<T, C>` by applying a function\n     * to the break value in case it exists.\n     *\n     * @typeParam T - The type of the new break value.\n     * @param fn - A function to apply to the break value.\n     * @returns A new `ControlFlow` with the mapped break value.\n     * @example\n     * ```ts\n     * const flow = Break(3);\n     * console.log(flow.mapBreak(v => v * 2).breakValue()); // Some(6)\n     * ```\n     */\n    mapBreak<T>(fn: (value: B) => T): ControlFlow<T, C>;\n\n    /**\n     * Maps `ControlFlow<B, C>` to `ControlFlow<B, T>` by applying a function\n     * to the continue value in case it exists.\n     *\n     * @typeParam T - The type of the new continue value.\n     * @param fn - A function to apply to the continue value.\n     * @returns A new `ControlFlow` with the mapped continue value.\n     * @example\n     * ```ts\n     * const flow = Continue(5);\n     * console.log(flow.mapContinue(v => v * 2).continueValue()); // Some(10)\n     * ```\n     */\n    mapContinue<T>(fn: (value: C) => T): ControlFlow<B, T>;\n\n    /**\n     * Converts the `ControlFlow` into a `Result` which is `Ok` if the\n     * `ControlFlow` was `Break` and `Err` otherwise.\n     *\n     * @returns `Ok(breakValue)` if `Break`, `Err(continueValue)` if `Continue`.\n     * @example\n     * ```ts\n     * console.log(Break(3).breakOk()); // Ok(3)\n     * console.log(Continue('still going').breakOk()); // Err('still going')\n     * ```\n     */\n    breakOk(): Result<B, C>;\n\n    /**\n     * Converts the `ControlFlow` into a `Result` which is `Ok` if the\n     * `ControlFlow` was `Continue` and `Err` otherwise.\n     *\n     * @returns `Ok(continueValue)` if `Continue`, `Err(breakValue)` if `Break`.\n     * @example\n     * ```ts\n     * console.log(Continue(5).continueOk()); // Ok(5)\n     * console.log(Break('stopped').continueOk()); // Err('stopped')\n     * ```\n     */\n    continueOk(): Result<C, B>;\n\n    /**\n     * Extracts the value from a `ControlFlow<T, T>` where both type parameters are the same.\n     *\n     * This method is only available when `B` and `C` are the same type.\n     * It returns the contained value regardless of whether this is a `Break` or `Continue`.\n     *\n     * @returns The contained value.\n     * @example\n     * ```ts\n     * const breakFlow: ControlFlow<number, number> = Break(5);\n     * console.log(breakFlow.intoValue()); // 5\n     *\n     * const continueFlow: ControlFlow<number, number> = Continue(10);\n     * console.log(continueFlow.intoValue()); // 10\n     * ```\n     */\n    intoValue(this: ControlFlow<B, B>): B;\n}\n\n/**\n * Creates a `Break` variant of `ControlFlow`.\n *\n * Use this to signal that an operation should exit early with the given value.\n *\n * @typeParam B - The type of the break value.\n * @typeParam C - The type of the continue value (defaults to `void` when a value is provided).\n * @param value - The value to return on break.\n * @returns A `ControlFlow` in the `Break` state.\n * @example\n * ```ts\n * const flow = Break('found it');\n * console.log(flow.isBreak()); // true\n * console.log(flow.breakValue().unwrap()); // 'found it'\n *\n * const voidFlow = Break();\n * console.log(voidFlow.isBreak()); // true\n * ```\n */\nexport function Break<B, C = never>(value: B): ControlFlow<B, C>;\n/**\n * Creates a `Break` variant of `ControlFlow` with no value.\n * This overload is used when the operation exits early but doesn't produce a meaningful value.\n *\n * @typeParam C - The type of the continue value (allows type specification when chaining with Continue).\n * @returns A `ControlFlow<void, C>` in the `Break` state.\n * @example\n * ```ts\n * const voidFlow = Break();\n * console.log(voidFlow.isBreak()); // true\n * console.log(voidFlow.breakValue()); // Some(undefined)\n *\n * // With explicit type parameter\n * const typedFlow = Break<number>();  // ControlFlow<void, number>\n * ```\n */\nexport function Break<C = never>(): ControlFlow<void, C>;\nexport function Break<B, C>(value?: B): ControlFlow<B, C> {\n    const brk: ControlFlow<B, C> = Object.freeze<ControlFlow<B, C>>({\n        [Symbol.toStringTag]: 'ControlFlow',\n        [ControlFlowKindSymbol]: 'Break',\n\n        toString(): string {\n            return `Break(${ value })`;\n        },\n\n        isBreak(): true {\n            return true;\n        },\n        isContinue(): false {\n            return false;\n        },\n        breakValue(): Option<B> {\n            return Some(value as B);\n        },\n        continueValue(): Option<C> {\n            return None;\n        },\n        mapBreak<T>(fn: (v: B) => T): ControlFlow<T, C> {\n            return Break(fn(value as B));\n        },\n        mapContinue<T>(_fn: (v: C) => T): ControlFlow<B, T> {\n            return brk as unknown as ControlFlow<B, T>;\n        },\n        breakOk(): Result<B, C> {\n            return Ok(value as B);\n        },\n        continueOk(): Result<C, B> {\n            return Err(value as B);\n        },\n        intoValue(): B {\n            return value as B;\n        },\n    } as const);\n\n    return brk;\n}\n\n/**\n * Creates a `Continue` variant of `ControlFlow`.\n *\n * Use this to signal that an operation should continue as normal.\n *\n * @typeParam B - The type of the break value (defaults to `void` when a value is provided).\n * @typeParam C - The type of the continue value.\n * @param value - The value to carry forward (optional, defaults to `undefined`).\n * @returns A `ControlFlow` in the `Continue` state.\n * @example\n * ```ts\n * const flow = Continue();\n * console.log(flow.isContinue()); // true\n *\n * const flowWithValue = Continue(42);\n * console.log(flowWithValue.continueValue().unwrap()); // 42\n * ```\n */\nexport function Continue<B = never, C = void>(value: C): ControlFlow<B, C>;\n/**\n * Creates a `Continue` variant of `ControlFlow` with no value.\n * This overload is used when the operation continues but doesn't carry a meaningful value.\n *\n * @typeParam B - The type of the break value (allows type specification when chaining with Break).\n * @returns A `ControlFlow<B, void>` in the `Continue` state.\n * @example\n * ```ts\n * const voidFlow = Continue();\n * console.log(voidFlow.isContinue()); // true\n * console.log(voidFlow.continueValue()); // Some(undefined)\n *\n * // With explicit type parameter\n * const typedFlow = Continue<string>();  // ControlFlow<string, void>\n * ```\n */\nexport function Continue<B = never>(): ControlFlow<B, void>;\nexport function Continue<B, C>(value?: C): ControlFlow<B, C> {\n    const cont: ControlFlow<B, C> = Object.freeze<ControlFlow<B, C>>({\n        [Symbol.toStringTag]: 'ControlFlow',\n        [ControlFlowKindSymbol]: 'Continue',\n\n        toString(): string {\n            return `Continue(${ value })`;\n        },\n\n        isBreak(): false {\n            return false;\n        },\n        isContinue(): true {\n            return true;\n        },\n        breakValue(): Option<B> {\n            return None;\n        },\n        continueValue(): Option<C> {\n            return Some(value as C);\n        },\n        mapBreak<T>(_fn: (v: B) => T): ControlFlow<T, C> {\n            return cont as unknown as ControlFlow<T, C>;\n        },\n        mapContinue<T>(fn: (v: C) => T): ControlFlow<B, T> {\n            return Continue(fn(value as C));\n        },\n        breakOk(): Result<B, C> {\n            return Err(value as C);\n        },\n        continueOk(): Result<C, B> {\n            return Ok(value as C);\n        },\n        intoValue(): B {\n            return value as unknown as B;\n        },\n    } as const);\n\n    return cont;\n}\n","/**\n * @module\n * Rust-inspired [FnOnce](https://doc.rust-lang.org/std/ops/trait.FnOnce.html) for one-time callable functions.\n *\n * **When to use `FnOnce` vs `FnOnceAsync`:**\n * - Use `FnOnce` for sync functions\n * - Use `FnOnceAsync` for async functions\n */\n\nimport { None, Some, type Option } from '../../core/mod.ts';\n\n/**\n * A function wrapper that can only be called once.\n *\n * After the first invocation, the function is consumed and cannot be called again.\n * This mirrors Rust's `FnOnce` trait, which represents closures that take ownership\n * of captured variables and can only be called once.\n *\n * **Use cases:**\n * - One-time callbacks (cleanup functions, event handlers)\n * - Ensuring certain operations execute exactly once\n * - Resource disposal patterns\n *\n * @typeParam A - Tuple type of the function arguments.\n * @typeParam R - Return type of the function.\n * @since 1.8.0\n * @see {@link FnOnceAsync} for async one-time callable functions\n * @see https://doc.rust-lang.org/std/ops/trait.FnOnce.html\n * @example\n * ```ts\n * // Basic usage\n * const greet = FnOnce((name: string) => `Hello, ${name}!`);\n * console.log(greet.call('World')); // 'Hello, World!'\n * // greet.call('Again'); // Throws Error: FnOnce has already been consumed\n *\n * // Safe call with tryCall\n * const cleanup = FnOnce(() => console.log('Cleaned up'));\n * cleanup.tryCall(); // Some(undefined), logs 'Cleaned up'\n * cleanup.tryCall(); // None, no effect\n * ```\n *\n * @example\n * ```ts\n * // One-time event handler\n * const onFirstClick = FnOnce((event: MouseEvent) => {\n *     console.log('First click at:', event.clientX, event.clientY);\n * });\n *\n * button.addEventListener('click', (e) => {\n *     onFirstClick.tryCall(e); // Only handles first click\n * });\n * ```\n *\n * @example\n * ```ts\n * // Resource cleanup pattern\n * function createConnection(): { close: FnOnce<[], void> } {\n *     const socket = new WebSocket('ws://example.com');\n *     return {\n *         close: FnOnce(() => {\n *             socket.close();\n *             console.log('Connection closed');\n *         })\n *     };\n * }\n *\n * const conn = createConnection();\n * conn.close.call();  // Closes connection\n * conn.close.call();  // Throws - already closed\n * ```\n */\nexport interface FnOnce<A extends unknown[], R> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'FnOnce'` so that `Object.prototype.toString.call(fn)` produces `'[object FnOnce]'`.\n     *\n     * @example\n     * ```ts\n     * const fn = FnOnce(() => 42);\n     * console.log(Object.prototype.toString.call(fn)); // '[object FnOnce]'\n     * ```\n     */\n    readonly [Symbol.toStringTag]: 'FnOnce';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const fn = FnOnce(() => 42);\n     * console.log(fn.toString()); // 'FnOnce(pending)' or 'FnOnce(consumed)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Calls the function with the provided arguments, consuming it.\n     *\n     * @param args - The arguments to pass to the function.\n     * @returns The return value of the function.\n     * @throws {Error} If the function has already been called.\n     * @example\n     * ```ts\n     * const add = FnOnce((a: number, b: number) => a + b);\n     * console.log(add.call(2, 3)); // 5\n     * // add.call(1, 1); // Throws Error\n     * ```\n     */\n    call(...args: A): R;\n\n    /**\n     * Attempts to call the function, returning `Some(result)` if successful\n     * or `None` if the function has already been consumed.\n     *\n     * This is the safe alternative to `call()` that never throws.\n     *\n     * @param args - The arguments to pass to the function.\n     * @returns `Some(result)` if the function was called, `None` if already consumed.\n     * @example\n     * ```ts\n     * const greet = FnOnce((name: string) => `Hi, ${name}`);\n     * console.log(greet.tryCall('Alice')); // Some('Hi, Alice')\n     * console.log(greet.tryCall('Bob'));   // None\n     * ```\n     */\n    tryCall(...args: A): Option<R>;\n\n    /**\n     * Returns `true` if the function has been consumed (called).\n     *\n     * @example\n     * ```ts\n     * const fn = FnOnce(() => 'done');\n     * console.log(fn.isConsumed()); // false\n     * fn.call();\n     * console.log(fn.isConsumed()); // true\n     * ```\n     */\n    isConsumed(): boolean;\n}\n\n/**\n * Creates a `FnOnce` wrapper around a function, making it callable only once.\n *\n * @typeParam A - Tuple type of the function arguments.\n * @typeParam R - Return type of the function.\n * @param fn - The function to wrap.\n * @returns A `FnOnce` instance that wraps the function.\n * @example\n * ```ts\n * const initialize = FnOnce(() => {\n *     console.log('Initializing...');\n *     return { ready: true };\n * });\n *\n * const result = initialize.call(); // Logs 'Initializing...', returns { ready: true }\n * // initialize.call(); // Throws Error: FnOnce has already been consumed\n * ```\n */\nexport function FnOnce<A extends unknown[], R>(fn: (...args: A) => R): FnOnce<A, R> {\n    let consumed = false;\n\n    return Object.freeze<FnOnce<A, R>>({\n        [Symbol.toStringTag]: 'FnOnce',\n\n        toString(): string {\n            return `FnOnce(${ consumed ? 'consumed' : 'pending' })`;\n        },\n\n        call(...args: A): R {\n            if (consumed) {\n                throw new Error('FnOnce has already been consumed');\n            }\n            consumed = true;\n            return fn(...args);\n        },\n\n        tryCall(...args: A): Option<R> {\n            if (consumed) {\n                return None;\n            }\n            consumed = true;\n            return Some(fn(...args));\n        },\n\n        isConsumed(): boolean {\n            return consumed;\n        },\n    } as const);\n}\n","/**\n * @module\n * Rust-inspired [AsyncFnOnce](https://doc.rust-lang.org/std/ops/trait.AsyncFnOnce.html) for one-time callable async functions.\n *\n * **When to use `FnOnce` vs `FnOnceAsync`:**\n * - Use `FnOnce` for sync functions\n * - Use `FnOnceAsync` for async functions\n */\n\nimport { ASYNC_NONE, Some, type AsyncOption } from '../../core/mod.ts';\n\n/**\n * An async function wrapper that can only be called once.\n *\n * After the first invocation, the function is consumed and cannot be called again.\n * This mirrors Rust's `AsyncFnOnce` trait (stabilized in Rust 1.85), which represents\n * async closures that take ownership of captured variables and can only be called once.\n *\n * **Use cases:**\n * - One-time async callbacks (cleanup functions, initialization)\n * - Ensuring certain async operations execute exactly once\n * - Async resource disposal patterns\n *\n * @typeParam A - Tuple type of the function arguments.\n * @typeParam R - The resolved type of the Promise returned by the async function.\n * @since 1.8.0\n * @see {@link FnOnce} for sync one-time callable functions\n * @example\n * ```ts\n * // Basic usage\n * const fetchData = FnOnceAsync(async (id: number) => {\n *     const response = await fetch(`/api/data/${id}`);\n *     return response.json();\n * });\n *\n * const data = await fetchData.call(1);\n * // fetchData.call(2); // Throws Error: FnOnceAsync has already been consumed\n * ```\n *\n * @example\n * ```ts\n * // Safe call with tryCall\n * const initOnce = FnOnceAsync(async () => {\n *     await someAsyncSetup();\n *     return { initialized: true };\n * });\n *\n * const result1 = await initOnce.tryCall(); // Some({ initialized: true })\n * const result2 = await initOnce.tryCall(); // None\n * ```\n *\n * @example\n * ```ts\n * // One-time async resource cleanup\n * const cleanup = FnOnceAsync(async () => {\n *     await closeConnections();\n *     await flushLogs();\n * });\n *\n * await cleanup.tryCall(); // Performs cleanup\n * await cleanup.tryCall(); // Returns None, no effect\n * ```\n */\nexport interface FnOnceAsync<A extends unknown[], R> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'FnOnceAsync'` so that `Object.prototype.toString.call(fn)` produces `'[object FnOnceAsync]'`.\n     *\n     * @example\n     * ```ts\n     * const fn = FnOnceAsync(async () => 42);\n     * console.log(Object.prototype.toString.call(fn)); // '[object FnOnceAsync]'\n     * ```\n     */\n    readonly [Symbol.toStringTag]: 'FnOnceAsync';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const fn = FnOnceAsync(async () => 42);\n     * console.log(fn.toString()); // 'FnOnceAsync(pending)' or 'FnOnceAsync(consumed)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Calls the async function with the provided arguments, consuming it.\n     *\n     * @param args - The arguments to pass to the function.\n     * @returns A Promise that resolves to the return value of the function.\n     * @throws {Error} If the function has already been called.\n     * @example\n     * ```ts\n     * const fetchUser = FnOnceAsync(async (id: number) => {\n     *     const response = await fetch(`/api/users/${id}`);\n     *     return response.json();\n     * });\n     *\n     * const user = await fetchUser.call(1);\n     * // await fetchUser.call(2); // Throws Error\n     * ```\n     */\n    call(...args: A): Promise<Awaited<R>>;\n\n    /**\n     * Attempts to call the async function, returning `Some(result)` if successful\n     * or `None` if the function has already been consumed.\n     *\n     * This is the safe alternative to `call()` that never throws due to consumption.\n     * The returned Promise may still reject if the underlying async function throws.\n     *\n     * @param args - The arguments to pass to the function.\n     * @returns A Promise that resolves to `Some(result)` if the function was called, `None` if already consumed.\n     * @example\n     * ```ts\n     * const fetchData = FnOnceAsync(async (id: number) => {\n     *     const response = await fetch(`/api/data/${id}`);\n     *     return response.json();\n     * });\n     *\n     * const result1 = await fetchData.tryCall(1); // Some(data)\n     * const result2 = await fetchData.tryCall(2); // None\n     * ```\n     */\n    tryCall(...args: A): AsyncOption<Awaited<R>>;\n\n    /**\n     * Returns `true` if the function has been consumed (called).\n     *\n     * @example\n     * ```ts\n     * const fn = FnOnceAsync(async () => 'done');\n     * console.log(fn.isConsumed()); // false\n     * await fn.call();\n     * console.log(fn.isConsumed()); // true\n     * ```\n     */\n    isConsumed(): boolean;\n}\n\n/**\n * Creates a `FnOnceAsync` wrapper around an async function, making it callable only once.\n *\n * @typeParam A - Tuple type of the function arguments.\n * @typeParam R - The resolved type of the Promise returned by the async function.\n * @param fn - A function that returns `PromiseLike<R>` or `R`.\n * @returns A `FnOnceAsync` instance that wraps the function.\n * @example\n * ```ts\n * const initialize = FnOnceAsync(async () => {\n *     console.log('Initializing...');\n *     await loadResources();\n *     return { ready: true };\n * });\n *\n * const result = await initialize.call(); // Logs 'Initializing...', returns { ready: true }\n * // await initialize.call(); // Throws Error: FnOnceAsync has already been consumed\n * ```\n */\nexport function FnOnceAsync<A extends unknown[], R>(fn: (...args: A) => PromiseLike<R> | R): FnOnceAsync<A, R> {\n    let consumed = false;\n\n    return Object.freeze<FnOnceAsync<A, R>>({\n        [Symbol.toStringTag]: 'FnOnceAsync',\n\n        toString(): string {\n            return `FnOnceAsync(${ consumed ? 'consumed' : 'pending' })`;\n        },\n\n        call(...args: A): Promise<Awaited<R>> {\n            if (consumed) {\n                throw new Error('FnOnceAsync has already been consumed');\n            }\n            consumed = true;\n            return Promise.resolve(fn(...args));\n        },\n\n        // Use `Promise.resolve(fn())` instead of `async` to preserve sync error behavior:\n        // sync throws propagate directly, async errors become rejected Promises.\n        tryCall(...args: A): AsyncOption<Awaited<R>> {\n            if (consumed) {\n                return ASYNC_NONE;\n            }\n            consumed = true;\n            return Promise.resolve(fn(...args)).then(Some);\n        },\n\n        isConsumed(): boolean {\n            return consumed;\n        },\n    } as const);\n}\n","/**\n * @module\n * Type guard utilities for checking if values are `ControlFlow` types.\n *\n * These functions provide runtime type checking capabilities for the ControlFlow type.\n */\nimport type { ControlFlow } from './control_flow.ts';\nimport { ControlFlowKindSymbol } from './symbols.ts';\n\n/**\n * Checks if a value is a `ControlFlow`.\n *\n * @typeParam B - The expected type of the break value contained within the `ControlFlow`.\n * @typeParam C - The expected type of the continue value contained within the `ControlFlow`.\n * @param cf - The value to be checked as a `ControlFlow`.\n * @returns `true` if the value is a `ControlFlow`, otherwise `false`.\n * @since 1.6.0\n * @example\n * ```ts\n * const x = Break(5);\n * console.log(isControlFlow(x)); // true\n * console.log(isControlFlow(null)); // false\n * console.log(isControlFlow({ isBreak: () => true })); // false\n * ```\n */\nexport function isControlFlow<B, C>(cf: unknown): cf is ControlFlow<B, C> {\n    // `Break` and `Continue` must be an object.\n    return cf != null && typeof cf === 'object' && ControlFlowKindSymbol in cf;\n}\n","/**\n * @module\n * Rust-inspired MPMC (multi-producer multi-consumer) channel for async message passing.\n *\n * Provides a type-safe channel with optional bounded capacity and backpressure support.\n * Supports rendezvous (capacity=0) for synchronous handoff between sender and receiver.\n *\n */\n\nimport { ASYNC_NONE, None, Some, type AsyncOption, type Option } from '../../core/mod.ts';\n\n// Internal cached Promise constants for runtime optimization\nconst ASYNC_TRUE = Promise.resolve(true);\nconst ASYNC_FALSE = Promise.resolve(false);\n\n/**\n * A sender view of a channel that can only send values.\n *\n * Created by calling `channel.sender()`. Shares state with the parent channel.\n *\n * @typeParam T - The type of values that can be sent.\n * @see https://doc.rust-lang.org/std/sync/mpmc/struct.Sender.html\n */\nexport interface Sender<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Sender'` so that `Object.prototype.toString.call(sender)` produces `'[object Sender]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Sender';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const sender = Channel<number>(10).sender;\n     * console.log(sender.toString()); // 'Sender(0/10)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * The maximum number of values that can be buffered.\n     * `0` for rendezvous channels, `Infinity` for unbounded channels.\n     *\n     * @see {@link Channel.capacity}\n     */\n    readonly capacity: number;\n\n    /**\n     * The current number of values in the buffer.\n     *\n     * Note: This does **not** count waiting senders/receivers; it only counts buffered items.\n     *\n     * @see {@link Channel.length}\n     */\n    readonly length: number;\n\n    /**\n     * Returns `true` if the channel has been closed.\n     */\n    readonly isClosed: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is empty.\n     * Note: A rendezvous channel (capacity=0) is always empty.\n     *\n     * @see {@link Channel.isEmpty}\n     */\n    readonly isEmpty: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is full.\n     * Note: A rendezvous channel (capacity=0) is always full.\n     *\n     * @see {@link Channel.isFull}\n     */\n    readonly isFull: boolean;\n\n    /**\n     * Sends a value into the channel, waiting if necessary.\n     *\n     * - If there are waiting receivers, delivers directly to one of them.\n     * - If the buffer has space, adds to the buffer and returns immediately.\n     * - If the buffer is full (or capacity is 0), waits until space is available.\n     * - If the channel is closed, returns `false` immediately.\n     *\n     * @param value - The value to send.\n     * @returns A promise that resolves to `true` if sent successfully, `false` if the channel is closed.\n     * @see {@link Channel.send}\n     * @example\n     * ```ts\n     * const success = await sender.send(42);\n     * if (!success) {\n     *     console.log('Channel was closed');\n     * }\n     * ```\n     */\n    send(value: T): Promise<boolean>;\n\n    /**\n     * Attempts to send a value without waiting.\n     *\n     * - If there are waiting receivers, delivers directly and returns `true`.\n     * - If the buffer has space, adds to the buffer and returns `true`.\n     * - If the buffer is full or the channel is closed, returns `false`.\n     *\n     * @param value - The value to send.\n     * @returns `true` if sent successfully, `false` if full or closed.\n     * @see {@link Channel.trySend}\n     * @example\n     * ```ts\n     * if (!sender.trySend(42)) {\n     *     console.log('Channel is full or closed');\n     * }\n     * ```\n     */\n    trySend(value: T): boolean;\n\n    /**\n     * Sends a value into the channel with a timeout.\n     *\n     * Like `send()`, but returns `false` if the operation cannot complete\n     * within the specified timeout.\n     *\n     * @param value - The value to send.\n     * @param ms - Timeout in milliseconds.\n     * @returns A promise that resolves to `true` if sent successfully,\n     *          `false` if timed out, channel is full, or closed.\n     *\n     * @see {@link Channel.sendTimeout}\n     * @example\n     * ```ts\n     * const success = await sender.sendTimeout(42, 1000);\n     * if (!success) {\n     *     console.log('Send timed out or channel closed');\n     * }\n     * ```\n     */\n    sendTimeout(value: T, ms: number): Promise<boolean>;\n}\n\n/**\n * A receiver view of a channel that can only receive values.\n *\n * Created by calling `channel.receiver()`. Shares state with the parent channel.\n * Implements `AsyncIterable` for use with `for await...of`.\n *\n * @typeParam T - The type of values that can be received.\n * @see https://doc.rust-lang.org/std/sync/mpmc/struct.Receiver.html\n */\nexport interface Receiver<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Receiver'` so that `Object.prototype.toString.call(receiver)` produces `'[object Receiver]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Receiver';\n\n    /**\n     * Returns an async iterator that yields values until the channel is closed.\n     *\n     * @example\n     * ```ts\n     * for await (const msg of receiver) {\n     *     console.log('Message:', msg);\n     * }\n     * console.log('Channel closed');\n     * ```\n     */\n    [Symbol.asyncIterator](): AsyncIterator<T>;\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const receiver = Channel<number>(10).receiver;\n     * console.log(receiver.toString()); // 'Receiver(0/10)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * The maximum number of values that can be buffered.\n     * `0` for rendezvous channels, `Infinity` for unbounded channels.\n     *\n     * @see {@link Channel.capacity}\n     */\n    readonly capacity: number;\n\n    /**\n     * The current number of values in the buffer.\n     *\n     * Note: This does **not** count waiting senders/receivers; it only counts buffered items.\n     *\n     * @see {@link Channel.length}\n     */\n    readonly length: number;\n\n    /**\n     * Returns `true` if the channel has been closed.\n     */\n    readonly isClosed: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is empty.\n     * Note: A rendezvous channel (capacity=0) is always empty.\n     *\n     * @see {@link Channel.isEmpty}\n     */\n    readonly isEmpty: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is full.\n     * Note: A rendezvous channel (capacity=0) is always full.\n     *\n     * @see {@link Channel.isFull}\n     */\n    readonly isFull: boolean;\n\n    /**\n     * Receives a value from the channel, waiting if necessary.\n     *\n     * - If the buffer has values, returns `Some(value)` immediately.\n     * - If senders are waiting (rendezvous), receives directly from one.\n     * - If the buffer is empty and not closed, waits for a value.\n     * - If the channel is closed and empty, returns `None`.\n     *\n     * @returns A promise that resolves to `Some(value)` or `None` if closed and empty.\n     * @see {@link Channel.receive}\n     * @example\n     * ```ts\n     * const result = await receiver.receive();\n     * if (result.isSome()) {\n     *     console.log('Received:', result.unwrap());\n     * } else {\n     *     console.log('Channel closed');\n     * }\n     * ```\n     */\n    receive(): AsyncOption<T>;\n\n    /**\n     * Attempts to receive a value without waiting.\n     *\n     * - If the buffer has values, returns `Some(value)`.\n     * - If senders are waiting (rendezvous), receives directly from one.\n     * - Otherwise returns `None`.\n     *\n     * @returns `Some(value)` if available, `None` if empty.\n     * @see {@link Channel.tryReceive}\n     * @example\n     * ```ts\n     * const result = receiver.tryReceive();\n     * result.inspect((v) => console.log('Got:', v));\n     * ```\n     */\n    tryReceive(): Option<T>;\n\n    /**\n     * Receives a value from the channel with a timeout.\n     *\n     * Like `receive()`, but returns `None` if the operation cannot complete\n     * within the specified timeout.\n     *\n     * @param ms - Timeout in milliseconds.\n     * @returns A promise that resolves to `Some(value)` or `None` if timed out,\n     *          empty, or closed.\n     *\n     * @see {@link Channel.receiveTimeout}\n     * @example\n     * ```ts\n     * const result = await receiver.receiveTimeout(1000);\n     * if (result.isNone()) {\n     *     console.log('Receive timed out or channel closed');\n     * }\n     * ```\n     */\n    receiveTimeout(ms: number): AsyncOption<T>;\n}\n\n/**\n * An MPMC (multi-producer multi-consumer) channel for async message passing.\n *\n * Channels allow multiple async tasks to communicate by sending and receiving\n * typed values. Values are delivered in FIFO order.\n *\n * @typeParam T - The type of values that can be sent through the channel.\n * @since 1.8.0\n * @see https://doc.rust-lang.org/std/sync/mpmc/fn.channel.html\n * @example\n * ```ts\n * // Create a bounded channel with capacity 10\n * const channel = Channel<string>(10);\n *\n * // Producer\n * await channel.send('hello');\n * await channel.send('world');\n * channel.close();\n *\n * // Consumer\n * for await (const msg of channel) {\n *     console.log(msg);\n * }\n * ```\n *\n * @example\n * ```ts\n * // Rendezvous channel (direct handoff)\n * const channel = Channel<number>(0);\n *\n * // This will block until someone receives\n * const sendPromise = channel.send(42);\n *\n * // This unblocks the sender\n * const value = await channel.receive(); // Some(42)\n * await sendPromise; // Now completes\n * ```\n */\nexport interface Channel<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Channel'` so that `Object.prototype.toString.call(channel)` produces `'[object Channel]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Channel';\n\n    /**\n     * Returns an async iterator that yields values until the channel is closed.\n     *\n     * @example\n     * ```ts\n     * for await (const msg of channel) {\n     *     console.log('Message:', msg);\n     * }\n     * ```\n     */\n    [Symbol.asyncIterator](): AsyncIterator<T>;\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * console.log(ch.toString()); // 'Channel(0/10)'\n     *\n     * ch.send(1);\n     * console.log(ch.toString()); // 'Channel(1/10)'\n     *\n     * ch.close();\n     * console.log(ch.toString()); // 'Channel(<closed>)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * The maximum number of values that can be buffered.\n     * `0` for rendezvous channels, `Infinity` for unbounded channels.\n     *\n     * @example\n     * ```ts\n     * const rendezvous = Channel<number>(0);\n     * console.log(rendezvous.capacity); // 0\n     *\n     * const unbounded = Channel<number>();\n     * console.log(unbounded.capacity); // Infinity\n     * ```\n     */\n    readonly capacity: number;\n\n    /**\n     * The current number of values in the buffer.\n     *\n     * Note: This does **not** count waiting senders/receivers; it only counts buffered items.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(0);\n     * const sendP = ch.send(1);\n     * const recvP = ch.receive();\n     *\n     * // Rendezvous channels don't buffer values.\n     * console.log(ch.length); // 0\n     *\n     * await recvP;\n     * await sendP;\n     * ```\n     */\n    readonly length: number;\n\n    /**\n     * Returns `true` if the channel has been closed.\n     */\n    readonly isClosed: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is empty.\n     * Note: A rendezvous channel (capacity=0) is always empty.\n     *\n     * @example\n     * ```ts\n     * const rendezvous = Channel<number>(0);\n     * console.log(rendezvous.isEmpty); // true\n     *\n     * const bounded = Channel<number>(1);\n     * console.log(bounded.isEmpty); // true\n     * await bounded.send(1);\n     * console.log(bounded.isEmpty); // false\n     * ```\n     */\n    readonly isEmpty: boolean;\n\n    /**\n     * Returns `true` if the channel buffer is full.\n     * Note: A rendezvous channel (capacity=0) is always full.\n     *\n     * @example\n     * ```ts\n     * const rendezvous = Channel<number>(0);\n     * console.log(rendezvous.isFull); // true\n     *\n     * const bounded = Channel<number>(1);\n     * console.log(bounded.isFull); // false\n     * await bounded.send(1);\n     * console.log(bounded.isFull); // true\n     * ```\n     */\n    readonly isFull: boolean;\n\n    /**\n     * A sender-only view of this channel.\n     *\n     * The `Sender` shares state with this channel but only exposes\n     * send-related methods. Useful for type-safe producer/consumer separation.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * const sender = ch.sender;\n     *\n     * // Pass to producer - they can only send\n     * await sender.send(42);\n     * // sender.receive() // Type error!\n     * ```\n     */\n    readonly sender: Sender<T>;\n\n    /**\n     * A receiver-only view of this channel.\n     *\n     * The `Receiver` shares state with this channel but only exposes\n     * receive-related methods. Useful for type-safe producer/consumer separation.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * const receiver = ch.receiver;\n     *\n     * // Pass to consumer - they can only receive\n     * for await (const msg of receiver) {\n     *     console.log(msg);\n     * }\n     * // receiver.send(1) // Type error!\n     * ```\n     */\n    readonly receiver: Receiver<T>;\n\n    /**\n     * Sends a value into the channel, waiting if necessary.\n     *\n     * - If there are waiting receivers, delivers directly to one of them.\n     * - If the buffer has space, adds to the buffer and returns immediately.\n     * - If the buffer is full (or capacity is 0), waits until space is available.\n     * - If the channel is closed, returns `false` immediately.\n     *\n     * @param value - The value to send.\n     * @returns A promise that resolves to `true` if sent successfully, `false` if the channel is closed.\n     * @example\n     * ```ts\n     * const ch = Channel<number>(1);\n     *\n     * const ok1 = await ch.send(1); // true\n     * ch.close();\n     * const ok2 = await ch.send(2); // false\n     * ```\n     */\n    send(value: T): Promise<boolean>;\n\n    /**\n     * Attempts to send a value without waiting.\n     *\n     * - If there are waiting receivers, delivers directly and returns `true`.\n     * - If the buffer has space, adds to the buffer and returns `true`.\n     * - If the buffer is full or the channel is closed, returns `false`.\n     *\n     * @param value - The value to send.\n     * @returns `true` if sent successfully, `false` if full or closed.\n     * @example\n     * ```ts\n     * const ch = Channel<number>(0);\n     *\n     * // Rendezvous channels are always \"full\" unless a receiver is waiting\n     * const ok = ch.trySend(1); // usually false\n     * ```\n     */\n    trySend(value: T): boolean;\n\n    /**\n     * Sends a value into the channel with a timeout.\n     *\n     * Like `send()`, but returns `false` if the operation cannot complete\n     * within the specified timeout.\n     *\n     * @param value - The value to send.\n     * @param ms - Timeout in milliseconds.\n     * @returns A promise that resolves to `true` if sent successfully,\n     *          `false` if timed out, channel is full, or closed.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(0);\n     *\n     * // No receiver arrives within 10ms\n     * const ok = await ch.sendTimeout(123, 10); // false\n     * ```\n     */\n    sendTimeout(value: T, ms: number): Promise<boolean>;\n\n    /**\n     * Receives a value from the channel, waiting if necessary.\n     *\n     * - If the buffer has values, returns `Some(value)` immediately.\n     * - If senders are waiting (rendezvous), receives directly from one.\n     * - If the buffer is empty and not closed, waits for a value.\n     * - If the channel is closed and empty, returns `None`.\n     *\n     * @returns A promise that resolves to `Some(value)` or `None` if closed and empty.\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * void ch.send(1);\n     *\n     * const v1 = await ch.receive(); // Some(1)\n     * ch.close();\n     * const v2 = await ch.receive(); // None\n     * ```\n     */\n    receive(): AsyncOption<T>;\n\n    /**\n     * Attempts to receive a value without waiting.\n     *\n     * - If the buffer has values, returns `Some(value)`.\n     * - If senders are waiting (rendezvous), receives directly from one.\n     * - Otherwise returns `None`.\n     *\n     * @returns `Some(value)` if available, `None` if empty.\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * console.log(ch.tryReceive().isNone()); // true\n     * ```\n     */\n    tryReceive(): Option<T>;\n\n    /**\n     * Receives a value from the channel with a timeout.\n     *\n     * Like `receive()`, but returns `None` if the operation cannot complete\n     * within the specified timeout.\n     *\n     * @param ms - Timeout in milliseconds.\n     * @returns A promise that resolves to `Some(value)` or `None` if timed out,\n     *          empty, or closed.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * const v = await ch.receiveTimeout(5);\n     * console.log(v.isNone()); // true\n     * ```\n     */\n    receiveTimeout(ms: number): AsyncOption<T>;\n\n    /**\n     * Closes the channel.\n     *\n     * After closing:\n     * - `send()` and `trySend()` will return `false`.\n     * - Pending senders will receive `false`.\n     * - `receive()` will drain remaining buffered values, then return `None`.\n     * - Pending receivers will receive `None` after the buffer is drained.\n     *\n     * Closing is idempotent - calling `close()` multiple times has no effect.\n     *\n     * @example\n     * ```ts\n     * const ch = Channel<number>(10);\n     * ch.send(1);\n     * ch.send(2);\n     * ch.close();\n     *\n     * // Can still receive buffered values\n     * await ch.receive(); // Some(1)\n     * await ch.receive(); // Some(2)\n     * await ch.receive(); // None\n     * ```\n     */\n    close(): void;\n}\n\n/**\n * Creates a new MPMC channel with the specified capacity.\n *\n * @typeParam T - The type of values that can be sent through the channel.\n * @param capacity - Maximum buffer size. Defaults to `Infinity` (unbounded).\n *                   Use `0` for a rendezvous channel (direct handoff).\n * @returns A new `Channel<T>` instance.\n * @throws {RangeError} If capacity is negative or not an integer (except Infinity).\n * @example\n * ```ts\n * // Unbounded channel (default)\n * const unbounded = Channel<string>();\n *\n * // Bounded channel with backpressure\n * const bounded = Channel<string>(100);\n *\n * // Rendezvous channel (synchronous handoff)\n * const rendezvous = Channel<string>(0);\n * ```\n *\n * @example\n * ```ts\n * // Task queue with backpressure\n * const taskQueue = Channel<() => Promise<void>>(10);\n *\n * // Worker\n * (async () => {\n *     for await (const task of taskQueue) {\n *         await task();\n *     }\n * })();\n *\n * // Producer - will wait if queue is full\n * await taskQueue.send(async () => {\n *     console.log('Processing...');\n * });\n * ```\n *\n * @example\n * ```ts\n * // Log aggregation with multiple producers\n * const logs = Channel<string>(1000);\n *\n * // Multiple producers\n * async function logFromService(name: string) {\n *     const sender = logs.sender();\n *     await sender.send(`[${ name }] Started`);\n *     // ... do work ...\n *     await sender.send(`[${ name }] Finished`);\n * }\n *\n * // Single consumer writing to file\n * async function writeLogsToFile() {\n *     const receiver = logs.receiver();\n *     for await (const log of receiver) {\n *         await fs.appendFile('app.log', log + '\\n');\n *     }\n * }\n * ```\n */\nexport function Channel<T>(capacity = Infinity): Channel<T> {\n    interface SendWaiter { value: T; resolve: (success: boolean) => void; }\n    type ReceiveWaiter = (value: Option<T>) => void;\n\n    if (capacity < 0 || !Number.isInteger(capacity) && capacity !== Infinity) {\n        throw new RangeError('Channel capacity must be a non-negative integer or Infinity');\n    }\n\n    const buffer = new Queue<T>();\n    let closed = false;\n\n    // Senders waiting for space (or for a receiver in rendezvous mode)\n    const sendWaitQueue: SendWaiter[] = [];\n\n    // Receivers waiting for values\n    const receiveWaitQueue: ReceiveWaiter[] = [];\n\n    // Cache for sender/receiver views\n    let cachedSender: Sender<T> | undefined;\n    let cachedReceiver: Receiver<T> | undefined;\n\n    function send(value: T): Promise<boolean> {\n        if (closed) {\n            return ASYNC_FALSE;\n        }\n\n        if (trySend(value)) {\n            return ASYNC_TRUE;\n        }\n\n        // Buffer is full (or capacity is 0), wait for space\n        return new Promise<boolean>((resolve) => {\n            sendWaitQueue.push({ value, resolve });\n        });\n    }\n\n    function trySend(value: T): boolean {\n        if (closed) {\n            return false;\n        }\n\n        // If there are waiting receivers, deliver directly\n        if (receiveWaitQueue.length > 0) {\n            const receiver = receiveWaitQueue.shift() as ReceiveWaiter;\n            receiver(Some(value));\n            return true;\n        }\n\n        // If buffer has space, add to buffer\n        if (buffer.length < capacity) {\n            buffer.push(value);\n            return true;\n        }\n\n        return false;\n    }\n\n    function receive(): AsyncOption<T> {\n        const result = tryReceive();\n        if (result.isSome()) {\n            return Promise.resolve(result);\n        }\n\n        if (closed) {\n            return ASYNC_NONE;\n        }\n\n        // Wait for a value\n        return new Promise<Option<T>>((resolve) => {\n            receiveWaitQueue.push(resolve);\n        });\n    }\n\n    function tryReceive(): Option<T> {\n        // If buffer has items, return one\n        if (buffer.length > 0) {\n            const value = buffer.shift() as T;\n\n            // Wake up a waiting sender if any\n            if (sendWaitQueue.length > 0) {\n                const sender = sendWaitQueue.shift() as SendWaiter;\n                buffer.push(sender.value);\n                sender.resolve(true);\n            }\n\n            return Some(value);\n        }\n\n        // Buffer is empty, check for waiting senders (rendezvous)\n        if (sendWaitQueue.length > 0) {\n            const sender = sendWaitQueue.shift() as SendWaiter;\n            sender.resolve(true);\n            return Some(sender.value);\n        }\n\n        return None;\n    }\n\n    function close(): void {\n        if (closed) {\n            return;\n        }\n        closed = true;\n\n        // Wake all waiting senders with false\n        while (sendWaitQueue.length > 0) {\n            const sender = sendWaitQueue.shift() as SendWaiter;\n            sender.resolve(false);\n        }\n\n        // Wake all waiting receivers with None\n        while (receiveWaitQueue.length > 0) {\n            const receiver = receiveWaitQueue.shift() as ReceiveWaiter;\n            receiver(None);\n        }\n    }\n\n    function sendTimeout(value: T, ms: number): Promise<boolean> {\n        if (closed) {\n            return ASYNC_FALSE;\n        }\n\n        if (trySend(value)) {\n            return ASYNC_TRUE;\n        }\n\n        // Buffer is full, wait with timeout\n        return new Promise<boolean>((resolve) => {\n            const waiter: SendWaiter = { value, resolve };\n            sendWaitQueue.push(waiter);\n\n            const timeoutId = setTimeout(() => {\n                const index = sendWaitQueue.indexOf(waiter);\n                sendWaitQueue.splice(index, 1);\n                resolve(false);\n            }, ms);\n\n            // Wrap the original resolve to clear the timeout\n            const originalResolve = waiter.resolve;\n            waiter.resolve = (success: boolean) => {\n                clearTimeout(timeoutId);\n                originalResolve(success);\n            };\n        });\n    }\n\n    function receiveTimeout(ms: number): AsyncOption<T> {\n        const result = tryReceive();\n        if (result.isSome()) {\n            return Promise.resolve(result);\n        }\n\n        if (closed) {\n            return ASYNC_NONE;\n        }\n\n        // Wait with timeout\n        return new Promise<Option<T>>((resolve) => {\n            const wrappedWaiter: ReceiveWaiter = (value) => {\n                clearTimeout(timeoutId);\n                resolve(value);\n            };\n\n            receiveWaitQueue.push(wrappedWaiter);\n\n            const timeoutId = setTimeout(() => {\n                const index = receiveWaitQueue.indexOf(wrappedWaiter);\n                receiveWaitQueue.splice(index, 1);\n                resolve(None);\n            }, ms);\n        });\n    }\n\n    function asyncIterator(): AsyncIterator<T> {\n        return {\n            async next(): Promise<IteratorResult<T>> {\n                const result = await receive();\n                if (result.isNone()) {\n                    return { done: true, value: undefined };\n                }\n                return { done: false, value: result.unwrap() };\n            },\n        };\n    }\n\n    function createSender(): Sender<T> {\n        return Object.freeze<Sender<T>>({\n            [Symbol.toStringTag]: 'Sender',\n\n            toString(): string {\n                if (closed) {\n                    return 'Sender(<closed>)';\n                }\n                if (capacity === Infinity) {\n                    return `Sender(${ buffer.length }/∞)`;\n                }\n                return `Sender(${ buffer.length }/${ capacity })`;\n            },\n\n            get capacity(): number {\n                return capacity;\n            },\n\n            get length(): number {\n                return buffer.length;\n            },\n\n            get isClosed(): boolean {\n                return closed;\n            },\n\n            get isEmpty(): boolean {\n                return buffer.length === 0;\n            },\n\n            get isFull(): boolean {\n                return buffer.length >= capacity;\n            },\n\n            send,\n            trySend,\n            sendTimeout,\n        });\n    }\n\n    function createReceiver(): Receiver<T> {\n        return Object.freeze<Receiver<T>>({\n            [Symbol.toStringTag]: 'Receiver',\n            [Symbol.asyncIterator]: asyncIterator,\n\n            toString(): string {\n                if (closed) {\n                    return 'Receiver(<closed>)';\n                }\n                if (capacity === Infinity) {\n                    return `Receiver(${ buffer.length }/∞)`;\n                }\n                return `Receiver(${ buffer.length }/${ capacity })`;\n            },\n\n            get capacity(): number {\n                return capacity;\n            },\n\n            get length(): number {\n                return buffer.length;\n            },\n\n            get isClosed(): boolean {\n                return closed;\n            },\n\n            get isEmpty(): boolean {\n                return buffer.length === 0;\n            },\n\n            get isFull(): boolean {\n                return buffer.length >= capacity;\n            },\n\n            receive,\n            tryReceive,\n            receiveTimeout,\n        });\n    }\n\n    return Object.freeze<Channel<T>>({\n        [Symbol.toStringTag]: 'Channel',\n        [Symbol.asyncIterator]: asyncIterator,\n\n        toString(): string {\n            if (closed) {\n                return 'Channel(<closed>)';\n            }\n            if (capacity === Infinity) {\n                return `Channel(${ buffer.length }/∞)`;\n            }\n            return `Channel(${ buffer.length }/${ capacity })`;\n        },\n\n        get capacity(): number {\n            return capacity;\n        },\n\n        get length(): number {\n            return buffer.length;\n        },\n\n        get isClosed(): boolean {\n            return closed;\n        },\n\n        get isEmpty(): boolean {\n            return buffer.length === 0;\n        },\n\n        get isFull(): boolean {\n            return buffer.length >= capacity;\n        },\n\n        get sender(): Sender<T> {\n            return cachedSender ??= createSender();\n        },\n\n        get receiver(): Receiver<T> {\n            return cachedReceiver ??= createReceiver();\n        },\n\n        send,\n        trySend,\n        sendTimeout,\n        receive,\n        tryReceive,\n        receiveTimeout,\n        close,\n    } as const);\n}\n\n\n// #region Internal helpers\n\n/**\n * A fast FIFO queue implementation using an array and an offset pointer.\n * This avoids the O(n) overhead of Array.shift() by simply incrementing the offset.\n *\n * When the offset exceeds a threshold (1024) and more than half the array is empty,\n * the array is compacted by slicing. The threshold 1024 was chosen empirically:\n * - Too small: frequent compaction overhead\n * - Too large: excessive memory waste\n * - 1024 balances compaction frequency and memory usage across typical workloads\n *\n * Benchmark results show minimal performance difference between thresholds (64-16384),\n * so 1024 is a reasonable default that works well for most Channel use cases.\n */\nclass Queue<T> {\n    private data: (T | undefined)[] = [];\n    private offset = 0;\n\n    get length(): number {\n        return this.data.length - this.offset;\n    }\n\n    push(item: T): void {\n        this.data.push(item);\n    }\n\n    shift(): T | undefined {\n        const item = this.data[this.offset];\n        this.data[this.offset] = undefined;\n        this.offset++;\n\n        // Compact the array if the empty space is too large\n        if (this.offset > 1024 && this.offset * 2 > this.data.length) {\n            this.data = this.data.slice(this.offset);\n            this.offset = 0;\n        }\n\n        return item as T;\n    }\n}\n\n// #endregion\n","/**\n * @module\n * Rust-inspired [LazyLock](https://doc.rust-lang.org/std/sync/struct.LazyLock.html) for lazy initialization.\n *\n * Unlike `Once<T>`, which allows setting values manually or with different\n * initializers, `Lazy<T>` binds the initializer at creation time.\n *\n * **When to use `Lazy<T>` vs `LazyAsync<T>`:**\n * - Use `Lazy<T>` for sync-only initialization\n * - Use `LazyAsync<T>` for async initialization with concurrent call handling\n */\n\nimport { None, Some, type Option } from '../../core/mod.ts';\n\n/**\n * A value which is initialized on the first access.\n *\n * The initialization function is provided at construction time and executed\n * on first access. Subsequent accesses return the cached value.\n *\n * @typeParam T - The type of the value stored.\n * @since 1.6.0\n * @see {@link LazyAsync} for async lazy initialization\n * @see https://doc.rust-lang.org/std/sync/struct.LazyLock.html\n * @example\n * ```ts\n * const expensive = Lazy(() => {\n *     console.log('Computing...');\n *     return heavyComputation();\n * });\n *\n * // Nothing computed yet\n * console.log(expensive.isInitialized()); // false\n *\n * // First access triggers computation\n * const value = expensive.force(); // logs \"Computing...\"\n *\n * // Subsequent access returns cached value\n * const same = expensive.force(); // no log, returns cached value\n * ```\n */\nexport interface Lazy<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Lazy'` so that `Object.prototype.toString.call(lazy)` produces `'[object Lazy]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Lazy';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const lazy = Lazy(() => 42);\n     * console.log(lazy.toString()); // 'Lazy(<uninitialized>)'\n     *\n     * lazy.force();\n     * console.log(lazy.toString()); // 'Lazy(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Forces the evaluation of this lazy value and returns the result.\n     *\n     * If the value has already been initialized, returns the cached value.\n     * Otherwise, executes the initialization function, caches the result,\n     * and returns it.\n     *\n     * @returns The initialized value.\n     * @throws Rethrows any exception thrown by the initialization function.\n     * @example\n     * ```ts\n     * const lazy = Lazy(() => 42);\n     * console.log(lazy.force()); // 42\n     * console.log(lazy.force()); // 42 (cached)\n     * ```\n     */\n    force(): T;\n\n    /**\n     * Gets the value if it has been initialized.\n     *\n     * Unlike `force()`, this does not trigger initialization.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const lazy = Lazy(() => 42);\n     * console.log(lazy.get()); // None\n     *\n     * lazy.force();\n     * console.log(lazy.get()); // Some(42)\n     * ```\n     */\n    get(): Option<T>;\n\n    /**\n     * Returns `true` if the value has been initialized.\n     *\n     * @example\n     * ```ts\n     * const lazy = Lazy(() => 42);\n     * console.log(lazy.isInitialized()); // false\n     *\n     * lazy.force();\n     * console.log(lazy.isInitialized()); // true\n     * ```\n     */\n    isInitialized(): boolean;\n}\n\n/**\n * Creates a new `Lazy<T>` with the given synchronous initialization function.\n *\n * The function is called at most once, on first access via `force()`.\n *\n * @typeParam T - The type of value to store.\n * @param fn - The initialization function that produces the value.\n * @returns A new `Lazy<T>` instance.\n * @example\n * ```ts\n * // Basic usage\n * const lazy = Lazy(() => {\n *     console.log('Initializing');\n *     return 42;\n * });\n *\n * console.log(lazy.isInitialized()); // false\n * console.log(lazy.force()); // logs \"Initializing\", returns 42\n * console.log(lazy.isInitialized()); // true\n * console.log(lazy.force()); // returns 42 (no log)\n * ```\n *\n * @example\n * ```ts\n * // Lazy singleton pattern\n * const logger = Lazy(() => new Logger('app'));\n *\n * function getLogger(): Logger {\n *     return logger.force();\n * }\n * ```\n *\n * @example\n * ```ts\n * // Expensive computation\n * const fibonacci = Lazy(() => {\n *     function fib(n: number): number {\n *         if (n <= 1) return n;\n *         return fib(n - 1) + fib(n - 2);\n *     }\n *     return fib(40); // Only computed once\n * });\n * ```\n */\nexport function Lazy<T>(fn: () => T): Lazy<T> {\n    let value: T | undefined;\n    let initialized = false;\n\n    return Object.freeze<Lazy<T>>({\n        [Symbol.toStringTag]: 'Lazy',\n\n        toString(): string {\n            return initialized ? `Lazy(${ value })` : 'Lazy(<uninitialized>)';\n        },\n\n        force(): T {\n            if (!initialized) {\n                value = fn();\n                initialized = true;\n            }\n            return value as T;\n        },\n\n        get(): Option<T> {\n            return initialized ? Some(value as T) : None;\n        },\n\n        isInitialized(): boolean {\n            return initialized;\n        },\n    } as const);\n}\n","/**\n * @module\n * Rust-inspired [LazyLock](https://doc.rust-lang.org/std/sync/struct.LazyLock.html) for async lazy initialization.\n *\n * **When to use `Lazy<T>` vs `LazyAsync<T>`:**\n * - Use `Lazy<T>` for sync-only initialization\n * - Use `LazyAsync<T>` for async initialization with concurrent call handling\n */\n\nimport { None, Some, type Option } from '../../core/mod.ts';\n\n/**\n * A value which is initialized asynchronously on the first access.\n *\n * The initialization function can return `PromiseLike<T>` or `T`.\n * If multiple calls to `force()` occur concurrently before initialization\n * completes, only one initialization will run.\n *\n * @typeParam T - The type of the value stored.\n * @since 1.6.0\n * @see {@link Lazy} for sync-only lazy initialization\n * @example\n * ```ts\n * const db = LazyAsync(async () => {\n *     console.log('Connecting...');\n *     return await Database.connect(url);\n * });\n *\n * // Multiple concurrent accesses - only one connection\n * const [db1, db2] = await Promise.all([\n *     db.force(),\n *     db.force(),\n * ]);\n * // db1 === db2\n * ```\n */\nexport interface LazyAsync<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'LazyAsync'` so that `Object.prototype.toString.call(lazy)` produces `'[object LazyAsync]'`.\n     */\n    readonly [Symbol.toStringTag]: 'LazyAsync';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const lazy = LazyAsync(async () => 42);\n     * console.log(lazy.toString()); // 'LazyAsync(<uninitialized>)'\n     *\n     * await lazy.force();\n     * console.log(lazy.toString()); // 'LazyAsync(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Forces the evaluation of this lazy value and returns a promise to the result.\n     *\n     * If the value has already been initialized, returns the cached value.\n     * If initialization is in progress, waits for it to complete.\n     * Otherwise, starts initialization.\n     *\n     * @returns A promise that resolves to the initialized value.\n     * @throws Rejects with any error thrown or rejected by the initialization function.\n     * @example\n     * ```ts\n     * const lazy = LazyAsync(async () => {\n     *     await delay(100);\n     *     return 42;\n     * });\n     * console.log(await lazy.force()); // 42\n     * ```\n     */\n    force(): Promise<Awaited<T>>;\n\n    /**\n     * Gets the value if it has been initialized.\n     *\n     * Unlike `force()`, this does not trigger initialization.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const lazy = LazyAsync(async () => 42);\n     * console.log(lazy.get()); // None\n     *\n     * await lazy.force();\n     * console.log(lazy.get()); // Some(42)\n     * ```\n     */\n    get(): Option<Awaited<T>>;\n\n    /**\n     * Returns `true` if the value has been initialized.\n     *\n     * Note: Returns `false` while initialization is in progress.\n     *\n     * @example\n     * ```ts\n     * const lazy = LazyAsync(async () => 42);\n     * console.log(lazy.isInitialized()); // false\n     *\n     * await lazy.force();\n     * console.log(lazy.isInitialized()); // true\n     * ```\n     */\n    isInitialized(): boolean;\n}\n\n/**\n * Creates a new `LazyAsync<T>` with the given async initialization function.\n *\n * The function is called at most once, on first access via `force()`.\n * Concurrent calls to `force()` before initialization completes will\n * wait for the single initialization to finish.\n *\n * @typeParam T - The type of value to store.\n * @param fn - A function that returns `PromiseLike<T>` or `T` to initialize.\n * @returns A new `LazyAsync<T>` instance.\n * @example\n * ```ts\n * // Basic usage\n * const lazy = LazyAsync(async () => {\n *     const response = await fetch('/api/data');\n *     return await response.json();\n * });\n *\n * const data = await lazy.force();\n * ```\n *\n * @example\n * ```ts\n * // Database connection singleton\n * const db = LazyAsync(async () => {\n *     console.log('Connecting to database...');\n *     return await Database.connect(connectionString);\n * });\n *\n * async function getDb(): Promise<Database> {\n *     return await db.force();\n * }\n *\n * // Multiple calls - connection happens only once\n * const [db1, db2] = await Promise.all([getDb(), getDb()]);\n * console.log(db1 === db2); // true\n * ```\n *\n * @example\n * ```ts\n * // Configuration loader\n * const config = LazyAsync(async () => {\n *     const response = await fetch('/api/config');\n *     if (!response.ok) {\n *         throw new Error(`Failed to load config: ${response.status}`);\n *     }\n *     return await response.json() as Config;\n * });\n *\n * // Used throughout the app\n * async function getApiEndpoint(): Promise<string> {\n *     const cfg = await config.force();\n *     return cfg.apiEndpoint;\n * }\n * ```\n */\nexport function LazyAsync<T>(fn: () => PromiseLike<T> | T): LazyAsync<T> {\n    let value: Awaited<T> | undefined;\n    let initialized = false;\n    let pendingPromise: Promise<Awaited<T>> | undefined;\n\n    return Object.freeze<LazyAsync<T>>({\n        [Symbol.toStringTag]: 'LazyAsync',\n\n        toString(): string {\n            return initialized ? `LazyAsync(${ value })` : 'LazyAsync(<uninitialized>)';\n        },\n\n        // Use `Promise.resolve(fn())` instead of `async` to preserve sync error behavior:\n        // sync throws propagate directly, async errors become rejected Promises.\n        force(): Promise<Awaited<T>> {\n            if (initialized) {\n                // Reuse cached promise to avoid creating new Promise on each call\n                return pendingPromise ??= Promise.resolve(value as Awaited<T>);\n            }\n\n            if (pendingPromise) {\n                return pendingPromise;\n            }\n\n            pendingPromise = Promise.resolve(fn()).then(\n                (result) => {\n                    value = result;\n                    initialized = true;\n                    return result;\n                },\n            ).catch((err) => {\n                // Only clear on failure to allow retry\n                pendingPromise = undefined;\n                throw err;\n            });\n\n            return pendingPromise;\n        },\n\n        get(): Option<Awaited<T>> {\n            return initialized ? Some(value as Awaited<T>) : None;\n        },\n\n        isInitialized(): boolean {\n            return initialized;\n        },\n    } as const);\n}\n","/**\n * @module\n * Rust-inspired [Mutex](https://doc.rust-lang.org/std/sync/struct.Mutex.html) for async mutual exclusion.\n *\n * In JavaScript's single-threaded environment, `Mutex<T>` is used to serialize\n * async operations, ensuring only one async task accesses the protected resource at a time.\n */\n\nimport { None, Some, type Option } from '../../core/mod.ts';\n\n/**\n * A guard that provides access to the mutex-protected value.\n *\n * The guard must be released after use by calling `unlock()`.\n * Failure to unlock will cause deadlock for subsequent lock attempts.\n *\n * @typeParam T - The type of the protected value.\n */\nexport interface MutexGuard<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'MutexGuard'` so that `Object.prototype.toString.call(guard)` produces `'[object MutexGuard]'`.\n     */\n    readonly [Symbol.toStringTag]: 'MutexGuard';\n\n    /**\n     * The protected value. Can be read or modified while the guard is held.\n     *\n     * @example\n     * ```ts\n     * const guard = await mutex.lock();\n     * console.log(guard.value); // Read value\n     * guard.value = newValue;   // Modify value\n     * guard.unlock();\n     * ```\n     */\n    value: T;\n\n    /**\n     * Custom `toString` implementation.\n     *\n     * @returns A string representation of the guard.\n     * @example\n     * ```ts\n     * const guard = await mutex.lock();\n     * console.log(guard.toString()); // 'MutexGuard(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Releases the lock, allowing other waiters to acquire it.\n     *\n     * Must be called when done with the protected value.\n     * After calling `unlock()`, the guard should not be used.\n     *\n     * @example\n     * ```ts\n     * const guard = await mutex.lock();\n     * try {\n     *     guard.value.push('item');\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    unlock(): void;\n}\n\n/**\n * An async mutual exclusion primitive for protecting shared data.\n *\n * This mutex provides exclusive access to the contained value, ensuring\n * that only one async operation can access it at a time. This is useful\n * for preventing race conditions in async code.\n *\n * Unlike Rust's Mutex which is for multi-threading, this JavaScript version\n * serializes async operations in the single-threaded event loop.\n *\n * @typeParam T - The type of the protected value.\n * @since 1.6.0\n * @see https://doc.rust-lang.org/std/sync/struct.Mutex.html\n * @example\n * ```ts\n * const mutex = Mutex({ balance: 100 });\n *\n * // Safe concurrent updates\n * await Promise.all([\n *     mutex.withLock(async (account) => {\n *         account.balance -= 50;\n *     }),\n *     mutex.withLock(async (account) => {\n *         account.balance += 30;\n *     }),\n * ]);\n * ```\n */\nexport interface Mutex<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Mutex'` so that `Object.prototype.toString.call(mutex)` produces `'[object Mutex]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Mutex';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const mutex = Mutex(42);\n     * console.log(mutex.toString()); // 'Mutex(<unlocked>)'\n     *\n     * const guard = await mutex.lock();\n     * console.log(mutex.toString()); // 'Mutex(<locked>)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Acquires the lock and executes the callback with the protected value.\n     *\n     * This is the recommended way to use the mutex as it automatically\n     * releases the lock when the callback completes (or throws).\n     *\n     * @typeParam U - The return type of the callback.\n     * @param fn - The callback that receives the protected value.\n     * @returns A promise that resolves to the callback's return value.\n     * @example\n     * ```ts\n     * const mutex = Mutex<number[]>([]);\n     *\n     * await mutex.withLock(async (arr) => {\n     *     arr.push(await fetchItem());\n     * });\n     * ```\n     */\n    withLock<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>>;\n\n    /**\n     * Acquires the lock and returns a guard for manual control.\n     *\n     * Use this when you need more control over when to release the lock.\n     * **Important:** Always release the lock in a `finally` block to prevent deadlocks.\n     *\n     * @returns A promise that resolves to a guard providing access to the value.\n     * @example\n     * ```ts\n     * const guard = await mutex.lock();\n     * try {\n     *     // Long-running operation with the protected value\n     *     await processData(guard.value);\n     *     guard.value = transformedData;\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    lock(): Promise<MutexGuard<T>>;\n\n    /**\n     * Attempts to acquire the lock without waiting.\n     *\n     * Returns immediately with `Some(guard)` if the lock is available,\n     * or `None` if it's currently held by another operation.\n     *\n     * @returns `Some(guard)` if acquired, `None` if locked.\n     * @example\n     * ```ts\n     * const maybeGuard = mutex.tryLock();\n     * if (maybeGuard.isSome()) {\n     *     const guard = maybeGuard.unwrap();\n     *     try {\n     *         // Use the value\n     *     } finally {\n     *         guard.unlock();\n     *     }\n     * } else {\n     *     console.log('Mutex is busy');\n     * }\n     * ```\n     */\n    tryLock(): Option<MutexGuard<T>>;\n\n    /**\n     * Returns `true` if the mutex is currently locked.\n     *\n     * Note: This is a snapshot and may change immediately after the call.\n     *\n     * @example\n     * ```ts\n     * console.log(mutex.isLocked()); // false\n     * const guard = await mutex.lock();\n     * console.log(mutex.isLocked()); // true\n     * guard.unlock();\n     * console.log(mutex.isLocked()); // false\n     * ```\n     */\n    isLocked(): boolean;\n\n    /**\n     * Acquires the lock and returns a copy of the protected value.\n     *\n     * This is a convenience method equivalent to `withLock(v => v)`.\n     *\n     * @returns A promise that resolves to a copy of the value.\n     * @example\n     * ```ts\n     * const mutex = Mutex(42);\n     * const value = await mutex.get();\n     * console.log(value); // 42\n     * ```\n     */\n    get(): Promise<Awaited<T>>;\n\n    /**\n     * Acquires the lock and sets a new value.\n     *\n     * This is a convenience method equivalent to `withLock(() => { value = newValue; })`.\n     *\n     * @param value - The new value to set.\n     * @returns A promise that resolves when the value has been set.\n     * @example\n     * ```ts\n     * const mutex = Mutex(42);\n     * await mutex.set(100);\n     * console.log(await mutex.get()); // 100\n     * ```\n     */\n    set(value: T): Promise<void>;\n\n    /**\n     * Acquires the lock, sets a new value, and returns the old value.\n     *\n     * This is a convenience method equivalent to:\n     * ```ts\n     * withLock(old => { value = newValue; return old; })\n     * ```\n     *\n     * @param value - The new value to set.\n     * @returns A promise that resolves to the old value.\n     * @example\n     * ```ts\n     * const mutex = Mutex(42);\n     * const old = await mutex.replace(100);\n     * console.log(old); // 42\n     * console.log(await mutex.get()); // 100\n     * ```\n     */\n    replace(value: T): Promise<Awaited<T>>;\n}\n\n/**\n * Creates a new `Mutex<T>` protecting the given value.\n *\n * @typeParam T - The type of the protected value.\n * @param value - The initial value to protect.\n * @returns A new `Mutex<T>` instance.\n * @example\n * ```ts\n * // Protect a simple value\n * const counter = Mutex(0);\n *\n * // Protect an object\n * const state = Mutex({ users: [], lastUpdate: Date.now() });\n *\n * // Protect a resource\n * const db = Mutex(await createConnection());\n * ```\n *\n * @example\n * ```ts\n * // Database transaction safety\n * const connection = Mutex(db);\n *\n * async function transfer(from: string, to: string, amount: number) {\n *     await connection.withLock(async (conn) => {\n *         await conn.beginTransaction();\n *         try {\n *             const balance = await conn.query('SELECT balance FROM accounts WHERE id = ?', [from]);\n *             if (balance < amount) {\n *                 throw new Error('Insufficient funds');\n *             }\n *             await conn.query('UPDATE accounts SET balance = balance - ? WHERE id = ?', [amount, from]);\n *             await conn.query('UPDATE accounts SET balance = balance + ? WHERE id = ?', [amount, to]);\n *             await conn.commit();\n *         } catch (e) {\n *             await conn.rollback();\n *             throw e;\n *         }\n *     });\n * }\n * ```\n *\n * @example\n * ```ts\n * // Token refresh with mutex\n * const authState = Mutex({ token: '', expiresAt: 0 });\n *\n * async function getToken(): Promise<string> {\n *     return await authState.withLock(async (state) => {\n *         if (Date.now() > state.expiresAt) {\n *             const response = await fetch('/api/refresh');\n *             const data = await response.json();\n *             state.token = data.token;\n *             state.expiresAt = Date.now() + data.expiresIn * 1000;\n *         }\n *         return state.token;\n *     });\n * }\n * ```\n *\n * @example\n * ```ts\n * // File write serialization\n * const fileLock = Mutex('/path/to/file.json');\n *\n * async function appendToFile(data: string) {\n *     await fileLock.withLock(async (path) => {\n *         const content = await fs.readFile(path, 'utf-8');\n *         const json = JSON.parse(content);\n *         json.entries.push(data);\n *         await fs.writeFile(path, JSON.stringify(json, null, 2));\n *     });\n * }\n * ```\n */\nexport function Mutex<T>(value: T): Mutex<T> {\n    let currentValue = value;\n    let locked = false;\n    const waitQueue: (() => void)[] = [];\n\n    function unlock(): void {\n        if (waitQueue.length > 0) {\n            // Wake up the next waiter\n            const next = waitQueue.shift() as () => void;\n            next();\n        } else {\n            locked = false;\n        }\n    }\n\n    function createGuard(): MutexGuard<T> {\n        let released = false;\n\n        return Object.freeze<MutexGuard<T>>({\n            [Symbol.toStringTag]: 'MutexGuard',\n\n            toString(): string {\n                if (released) {\n                    return 'MutexGuard(<released>)';\n                }\n                return `MutexGuard(${ currentValue })`;\n            },\n\n            get value(): T {\n                if (released) {\n                    throw new Error('MutexGuard has been released');\n                }\n                return currentValue;\n            },\n            set value(newValue: T) {\n                if (released) {\n                    throw new Error('MutexGuard has been released');\n                }\n                currentValue = newValue;\n            },\n            unlock(): void {\n                if (released) {\n                    return; // Already released, ignore\n                }\n                released = true;\n                unlock();\n            },\n        } as const);\n    }\n\n    function lock(): Promise<MutexGuard<T>> {\n        if (!locked) {\n            locked = true;\n            return Promise.resolve(createGuard());\n        }\n\n        return new Promise<MutexGuard<T>>((resolve) => {\n            waitQueue.push(() => {\n                resolve(createGuard());\n            });\n        });\n    }\n\n    return Object.freeze<Mutex<T>>({\n        [Symbol.toStringTag]: 'Mutex',\n\n        toString(): string {\n            return locked ? 'Mutex(<locked>)' : 'Mutex(<unlocked>)';\n        },\n\n        async withLock<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>> {\n            const guard = await lock();\n            try {\n                return await fn(guard.value);\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        lock,\n\n        tryLock(): Option<MutexGuard<T>> {\n            if (locked) {\n                return None;\n            }\n            locked = true;\n            return Some(createGuard());\n        },\n\n        isLocked(): boolean {\n            return locked;\n        },\n\n        async get(): Promise<Awaited<T>> {\n            const guard = await lock();\n            try {\n                return guard.value as Awaited<T>;\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        async set(value: T): Promise<void> {\n            const guard = await lock();\n            try {\n                guard.value = value;\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        async replace(value: T): Promise<Awaited<T>> {\n            const guard = await lock();\n            try {\n                const old = guard.value;\n                guard.value = value;\n                return old as Awaited<T>;\n            } finally {\n                guard.unlock();\n            }\n        },\n    } as const);\n}\n","/**\n * @module\n * Rust-inspired [OnceLock](https://doc.rust-lang.org/std/sync/struct.OnceLock.html) for one-time initialization.\n *\n * `Once<T>` is a container which can be written to only once. It provides safe access\n * to lazily initialized data with synchronous initialization.\n *\n * **When to use `Once<T>` vs `OnceAsync<T>`:**\n * - Use `Once<T>` for sync-only initialization\n * - Use `OnceAsync<T>` for async initialization with concurrent call handling\n */\n\nimport { Err, None, Ok, RESULT_VOID, Some, type Option, type Result, type VoidResult } from '../../core/mod.ts';\n\n/**\n * A container which can be written to only once.\n *\n * Useful for lazy initialization of global data or expensive computations\n * that should only happen once.\n *\n * @typeParam T - The type of the value stored.\n * @since 1.6.0\n * @see {@link OnceAsync} for async one-time initialization\n * @see https://doc.rust-lang.org/std/sync/struct.OnceLock.html\n * @example\n * ```ts\n * const once = Once<number>();\n *\n * // Set value (only works once)\n * once.set(42); // Ok(undefined)\n * once.set(100); // Err(100) - already set\n *\n * // Get value\n * console.log(once.get()); // Some(42)\n * ```\n *\n * @example\n * ```ts\n * // Sync lazy initialization\n * const config = Once<Config>();\n * const cfg = config.getOrInit(() => loadConfigFromFile());\n * ```\n */\nexport interface Once<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'Once'` so that `Object.prototype.toString.call(once)` produces `'[object Once]'`.\n     */\n    readonly [Symbol.toStringTag]: 'Once';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     * console.log(once.toString()); // 'Once(<uninitialized>)'\n     *\n     * once.set(42);\n     * console.log(once.toString()); // 'Once(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Gets the reference to the underlying value.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     * console.log(once.get()); // None\n     *\n     * once.set(42);\n     * console.log(once.get()); // Some(42)\n     * ```\n     */\n    get(): Option<T>;\n\n    /**\n     * Sets the contents to `value`.\n     *\n     * @param value - The value to store.\n     * @returns `Ok(undefined)` if empty, `Err(value)` if already initialized.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     *\n     * console.log(once.set(42)); // Ok(undefined)\n     * console.log(once.set(100)); // Err(100) - value returned back\n     * console.log(once.get()); // Some(42)\n     * ```\n     */\n    set(value: T): VoidResult<T>;\n\n    /**\n     * Sets the contents to `value` if empty, returning a reference to the value.\n     *\n     * Unlike `set()`, this method returns the stored value on success,\n     * and returns both the current and passed values on failure.\n     *\n     * @param value - The value to store.\n     * @returns `Ok(value)` if empty, `Err([currentValue, passedValue])` if already initialized.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     *\n     * // First insert succeeds, returns the stored value\n     * const result1 = once.tryInsert(42);\n     * console.log(result1.unwrap()); // 42\n     *\n     * // Second insert fails, returns [current, passed]\n     * const result2 = once.tryInsert(100);\n     * console.log(result2.unwrapErr()); // [42, 100]\n     * ```\n     */\n    tryInsert(value: T): Result<T, [T, T]>;\n\n    /**\n     * Gets the contents, initializing it with `fn` if empty.\n     *\n     * @param fn - The synchronous initialization function, called only if empty.\n     * @returns The stored value.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     *\n     * const value = once.getOrInit(() => {\n     *     console.log('Initializing...');\n     *     return 42;\n     * });\n     * console.log(value); // 42\n     *\n     * // Second call - fn is not called\n     * const value2 = once.getOrInit(() => 100);\n     * console.log(value2); // 42\n     * ```\n     */\n    getOrInit(fn: () => T): T;\n\n    /**\n     * Gets the contents, initializing it with `fn` if empty.\n     * If `fn` returns `Err`, remains uninitialized.\n     *\n     * @typeParam E - The error type.\n     * @param fn - The initialization function that may fail.\n     * @returns `Ok(value)` if initialized, `Err(error)` if initialization failed.\n     * @example\n     * ```ts\n     * const once = Once<Config>();\n     *\n     * const result = once.getOrTryInit(() => {\n     *     const config = parseConfig(rawData);\n     *     return config ? Ok(config) : Err(new Error('Invalid config'));\n     * });\n     *\n     * if (result.isOk()) {\n     *     console.log('Config loaded:', result.unwrap());\n     * }\n     * ```\n     */\n    getOrTryInit<E>(fn: () => Result<T, E>): Result<T, E>;\n\n    /**\n     * Takes the value out, leaving it uninitialized.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     * once.set(42);\n     *\n     * console.log(once.take()); // Some(42)\n     * console.log(once.get()); // None - now empty\n     * console.log(once.take()); // None\n     * ```\n     */\n    take(): Option<T>;\n\n    /**\n     * Returns `true` if initialized.\n     *\n     * @example\n     * ```ts\n     * const once = Once<number>();\n     * console.log(once.isInitialized()); // false\n     *\n     * once.set(42);\n     * console.log(once.isInitialized()); // true\n     * ```\n     */\n    isInitialized(): boolean;\n}\n\n/**\n * Creates a new empty `Once<T>`.\n *\n * @typeParam T - The type of value to store.\n * @returns A new uninitialized `Once`.\n * @example\n * ```ts\n * // Basic usage\n * const once = Once<string>();\n * once.set('hello');\n * console.log(once.get().unwrap()); // 'hello'\n * ```\n *\n * @example\n * ```ts\n * // Sync lazy singleton pattern\n * const logger = Once<Logger>();\n *\n * function getLogger(): Logger {\n *     return logger.getOrInit(() => new Logger('app'));\n * }\n * ```\n *\n * @example\n * ```ts\n * // Fallible sync initialization\n * const config = Once<Config>();\n *\n * function loadConfig(): Result<Config, Error> {\n *     return config.getOrTryInit(() => {\n *         const data = readFileSync('config.json');\n *         return data ? Ok(JSON.parse(data)) : Err(new Error('Config not found'));\n *     });\n * }\n * ```\n */\nexport function Once<T>(): Once<T> {\n    let value: T | undefined;\n    let initialized = false;\n\n    /**\n     * Sets the value and marks as initialized.\n     */\n    function setValue(val: T): void {\n        value = val;\n        initialized = true;\n    }\n\n    return Object.freeze<Once<T>>({\n        [Symbol.toStringTag]: 'Once',\n\n        toString(): string {\n            return initialized ? `Once(${ value })` : 'Once(<uninitialized>)';\n        },\n\n        get(): Option<T> {\n            return initialized ? Some(value as T) : None;\n        },\n\n        set(newValue: T): VoidResult<T> {\n            if (initialized) {\n                return Err(newValue);\n            }\n            setValue(newValue);\n            return RESULT_VOID;\n        },\n\n        tryInsert(newValue: T): Result<T, [T, T]> {\n            if (initialized) {\n                return Err([value as T, newValue]);\n            }\n            setValue(newValue);\n            return Ok(newValue);\n        },\n\n        getOrInit(fn: () => T): T {\n            if (!initialized) {\n                setValue(fn());\n            }\n            return value as T;\n        },\n\n        getOrTryInit<E>(fn: () => Result<T, E>): Result<T, E> {\n            if (initialized) {\n                return Ok(value as T);\n            }\n\n            const result = fn();\n            if (result.isOk()) {\n                setValue(result.unwrap());\n            }\n            return result;\n        },\n\n        take(): Option<T> {\n            if (!initialized) {\n                return None;\n            }\n            const taken = value as T;\n            value = undefined;\n            initialized = false;\n            return Some(taken);\n        },\n\n        isInitialized(): boolean {\n            return initialized;\n        },\n    } as const);\n}\n","/**\n * @module\n * Async-first one-time initialization container.\n *\n * `OnceAsync<T>` is designed for async initialization where the stored value\n * is always `Awaited<T>`, matching JavaScript's Promise flattening behavior.\n *\n * **When to use `OnceAsync<T>` vs `Once<T>`:**\n * - Use `Once<T>` for sync-only initialization\n * - Use `OnceAsync<T>` for async initialization with concurrent call handling\n */\n\nimport { Err, None, Ok, RESULT_VOID, Some, type AsyncLikeResult, type AsyncResult, type Option, type Result, type VoidResult } from '../../core/mod.ts';\n\n/**\n * An async-first container which can be written to only once.\n *\n * `OnceAsync<T>` stores `Awaited<T>`, matching JavaScript's Promise flattening behavior.\n * This means `OnceAsync<Promise<number>>` and `OnceAsync<number>` behave identically,\n * both storing `number`.\n *\n * **Key difference from `Once<T>`:**\n * - `Once<T>` with sync methods stores `T` as-is (including Promise values)\n * - `OnceAsync<T>` always stores `Awaited<T>` (flattened value)\n *\n * @typeParam T - The type parameter. The actual stored type is `Awaited<T>`.\n * @since 1.8.0\n * @see {@link Once} for sync-only one-time initialization\n * @example\n * ```ts\n * const db = OnceAsync<Database>();\n *\n * // Initialize with async function - stores the resolved Database\n * const conn = await db.getOrInit(async () => Database.connect(url));\n *\n * // Get the stored value\n * console.log(db.get()); // Some(Database)\n * ```\n *\n * @example\n * ```ts\n * // Fallible async initialization\n * const config = OnceAsync<Config>();\n *\n * const result = await config.getOrTryInit(async () => {\n *     try {\n *         const response = await fetch('/api/config');\n *         return Ok(await response.json());\n *     } catch (e) {\n *         return Err(e as Error);\n *     }\n * });\n * ```\n */\nexport interface OnceAsync<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     * Returns `'OnceAsync'` so that `Object.prototype.toString.call(once)` produces `'[object OnceAsync]'`.\n     */\n    readonly [Symbol.toStringTag]: 'OnceAsync';\n\n    /**\n     * Custom `toString` implementation.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     * console.log(once.toString()); // 'OnceAsync(<uninitialized>)'\n     *\n     * await once.getOrInit(async () => 42);\n     * console.log(once.toString()); // 'OnceAsync(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Gets the reference to the underlying value.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     * console.log(once.get()); // None\n     *\n     * await once.getOrInit(async () => 42);\n     * console.log(once.get()); // Some(42)\n     * ```\n     */\n    get(): Option<Awaited<T>>;\n\n    /**\n     * Sets the contents to `value`.\n     *\n     * @param value - The value to store.\n     * @returns `Ok(undefined)` if empty, `Err(value)` if already initialized.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     *\n     * console.log(once.set(42)); // Ok(undefined)\n     * console.log(once.set(100)); // Err(100) - value returned back\n     * console.log(once.get()); // Some(42)\n     * ```\n     */\n    set(value: Awaited<T>): VoidResult<Awaited<T>>;\n\n    /**\n     * Sets the contents to `value` if empty, returning a reference to the value.\n     *\n     * Unlike `set()`, this method returns the stored value on success,\n     * and returns both the current and passed values on failure.\n     *\n     * @param value - The value to store.\n     * @returns `Ok(value)` if empty, `Err([currentValue, passedValue])` if already initialized.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     *\n     * // First insert succeeds, returns the stored value\n     * const result1 = once.tryInsert(42);\n     * console.log(result1.unwrap()); // 42\n     *\n     * // Second insert fails, returns [current, passed]\n     * const result2 = once.tryInsert(100);\n     * console.log(result2.unwrapErr()); // [42, 100]\n     * ```\n     */\n    tryInsert(value: Awaited<T>): Result<Awaited<T>, [Awaited<T>, Awaited<T>]>;\n\n    /**\n     * Gets the contents, initializing it with async `fn` if empty.\n     *\n     * If multiple calls occur concurrently, only the first one will run the\n     * initialization function. Other calls will wait for it to complete.\n     *\n     * @param fn - A function that returns `PromiseLike<Awaited<T>>` or `Awaited<T>` to initialize.\n     * @returns A promise that resolves to the stored value (`Awaited<T>`).\n     * @example\n     * ```ts\n     * const db = OnceAsync<Database>();\n     *\n     * // Multiple concurrent calls - only one connection happens\n     * const [db1, db2, db3] = await Promise.all([\n     *     db.getOrInit(() => Database.connect(url)),\n     *     db.getOrInit(() => Database.connect(url)),\n     *     db.getOrInit(() => Database.connect(url)),\n     * ]);\n     * // db1 === db2 === db3\n     * ```\n     */\n    getOrInit(fn: () => PromiseLike<Awaited<T>> | Awaited<T>): Promise<Awaited<T>>;\n\n    /**\n     * Gets the contents, initializing it with async `fn` if empty.\n     * If `fn` returns `Err`, remains uninitialized.\n     *\n     * If multiple calls occur concurrently, only the first one will run the\n     * initialization function. Other calls will wait for it to complete.\n     *\n     * @typeParam E - The error type.\n     * @param fn - A function that returns `PromiseLike<Result<Awaited<T>, E>>` or `Result<Awaited<T>, E>`.\n     * @returns A promise that resolves to `Ok(value)` or `Err(error)`.\n     * @example\n     * ```ts\n     * const config = OnceAsync<Config>();\n     *\n     * const result = await config.getOrTryInit(async () => {\n     *     try {\n     *         const response = await fetch('/api/config');\n     *         return Ok(await response.json());\n     *     } catch (e) {\n     *         return Err(e as Error);\n     *     }\n     * });\n     * ```\n     */\n    getOrTryInit<E>(fn: () => AsyncLikeResult<Awaited<T>, E> | Result<Awaited<T>, E>): AsyncResult<Awaited<T>, E>;\n\n    /**\n     * Takes the value out, leaving it uninitialized.\n     *\n     * @returns `Some(value)` if initialized, `None` otherwise.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     * await once.getOrInit(async () => 42);\n     *\n     * console.log(once.take()); // Some(42)\n     * console.log(once.get()); // None - now empty\n     * console.log(once.take()); // None\n     * ```\n     */\n    take(): Option<Awaited<T>>;\n\n    /**\n     * Returns `true` if initialized.\n     *\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     * console.log(once.isInitialized()); // false\n     *\n     * await once.getOrInit(async () => 42);\n     * console.log(once.isInitialized()); // true\n     * ```\n     */\n    isInitialized(): boolean;\n\n    /**\n     * Waits for the cell to be initialized, then returns the value.\n     *\n     * If the cell is already initialized, returns immediately.\n     * If initialization is in progress, waits for it to complete.\n     * If the cell is uninitialized and no initialization is in progress,\n     * the returned promise will resolve when another caller initializes the cell.\n     *\n     * @returns A promise that resolves to the stored value once initialized.\n     * @example\n     * ```ts\n     * const once = OnceAsync<number>();\n     *\n     * // Start waiting in background\n     * const waitPromise = once.wait();\n     *\n     * // Later, initialize the value\n     * once.set(42);\n     *\n     * // waitPromise resolves with 42\n     * console.log(await waitPromise); // 42\n     * ```\n     */\n    wait(): Promise<Awaited<T>>;\n}\n\n/**\n * Creates a new empty `OnceAsync<T>`.\n *\n * `OnceAsync<T>` stores `Awaited<T>`, matching JavaScript's Promise flattening behavior.\n * This means `OnceAsync<Promise<number>>` and `OnceAsync<number>` behave identically.\n *\n * @typeParam T - The type parameter. The actual stored type is `Awaited<T>`.\n * @returns A new uninitialized `OnceAsync`.\n * @example\n * ```ts\n * // Basic usage\n * const once = OnceAsync<string>();\n * await once.getOrInit(async () => 'hello');\n * console.log(once.get().unwrap()); // 'hello'\n * ```\n *\n * @example\n * ```ts\n * // Async lazy singleton pattern\n * const db = OnceAsync<Database>();\n *\n * async function getDb(): Promise<Database> {\n *     return await db.getOrInit(async () => {\n *         console.log('Connecting to database...');\n *         return await Database.connect(connectionString);\n *     });\n * }\n *\n * // Multiple calls - connection happens only once\n * const [db1, db2] = await Promise.all([getDb(), getDb()]);\n * console.log(db1 === db2); // true\n * ```\n *\n * @example\n * ```ts\n * // Fallible async initialization\n * const config = OnceAsync<Config>();\n *\n * async function loadConfig(): Promise<Result<Config, Error>> {\n *     return await config.getOrTryInit(async () => {\n *         try {\n *             const response = await fetch('/api/config');\n *             if (!response.ok) {\n *                 return Err(new Error(`HTTP ${response.status}`));\n *             }\n *             return Ok(await response.json());\n *         } catch (e) {\n *             return Err(e as Error);\n *         }\n *     });\n * }\n * ```\n */\nexport function OnceAsync<T>(): OnceAsync<T> {\n    /** Internal alias to reduce repetition of `Awaited<T>` */\n    type Value = Awaited<T>;\n    /** Callback type for waiters waiting for initialization */\n    type Waiter = (value: Value) => void;\n\n    let value: Value | undefined;\n    let initialized = false;\n    let pendingPromise: Promise<Value> | undefined;\n    let resolvedPromise: Promise<Value> | undefined;\n    let resolvedResultPromise: AsyncResult<Value, unknown> | undefined;\n    let waiters: Waiter[] = [];\n\n    /**\n     * Sets the value, marks as initialized, and notifies all waiters.\n     */\n    function setValue(val: Value): void {\n        value = val;\n        initialized = true;\n        for (const waiter of waiters) {\n            waiter(val);\n        }\n        waiters = [];\n    }\n\n    // Use `Promise.resolve(fn())` instead of `async` to preserve sync error behavior:\n    // sync throws propagate directly, async errors become rejected Promises.\n    function getOrTryInit<E>(fn: () => AsyncLikeResult<Value, E> | Result<Value, E>): AsyncResult<Value, E> {\n        if (initialized) {\n            // Reuse cached promise to avoid creating new Promise on each call\n            return (resolvedResultPromise ??= Promise.resolve(Ok(value as Value))) as AsyncResult<Value, E>;\n        }\n\n        // If already initializing, wait for it\n        if (pendingPromise) {\n            return pendingPromise.then(\n                () => Ok(value as Value),\n                // Previous initialization failed via Err result, let this call try again.\n                // Note: fn's sync errors won't throw here since we're inside a .then() callback,\n                // they will be caught and converted to rejected Promise by Promise.resolve(fn()).\n                () => getOrTryInit(fn),\n            );\n        }\n\n        // Create a new pending promise for this initialization attempt\n        // fn() is called synchronously here - sync throws propagate directly\n        // Store the Result separately to preserve the original Result\n        const resultPromise = Promise.resolve(fn());\n\n        pendingPromise = resultPromise.then(\n            (result) => {\n                if (result.isOk()) {\n                    const val = result.unwrap();\n                    setValue(val);\n                    return val;\n                }\n                // If Err, throw to signal failure (waiters will retry)\n                throw result;\n            },\n        ).finally(() => {\n            pendingPromise = undefined;\n        });\n\n        // Wait for pendingPromise to complete (success or failure), then return original Result\n        return pendingPromise.then(\n            () => resultPromise,\n            () => resultPromise,\n        );\n    }\n\n    return Object.freeze<OnceAsync<T>>({\n        [Symbol.toStringTag]: 'OnceAsync',\n\n        toString(): string {\n            return initialized ? `OnceAsync(${ value })` : 'OnceAsync(<uninitialized>)';\n        },\n\n        get(): Option<Value> {\n            return initialized ? Some(value as Value) : None;\n        },\n\n        set(newValue: Value): VoidResult<Value> {\n            if (initialized) {\n                return Err(newValue);\n            }\n            setValue(newValue);\n            return RESULT_VOID;\n        },\n\n        tryInsert(newValue: Value): Result<Value, [Value, Value]> {\n            if (initialized) {\n                return Err([value as Value, newValue]);\n            }\n            setValue(newValue);\n            return Ok(newValue);\n        },\n\n        // Use `Promise.resolve(fn())` instead of `async` to preserve sync error behavior:\n        // sync throws propagate directly, async errors become rejected Promises.\n        getOrInit(fn: () => PromiseLike<Value> | Value): Promise<Value> {\n            if (initialized) {\n                // Reuse cached promise to avoid creating new Promise on each call\n                return (resolvedPromise ??= Promise.resolve(value as Value));\n            }\n\n            // If already initializing, wait for the pending promise\n            if (pendingPromise) {\n                return pendingPromise;\n            }\n\n            pendingPromise = Promise.resolve(fn()).then(\n                (result) => {\n                    setValue(result);\n                    return result;\n                },\n            ).finally(() => {\n                pendingPromise = undefined;\n            });\n\n            return pendingPromise;\n        },\n\n        getOrTryInit,\n\n        take(): Option<Value> {\n            if (!initialized) {\n                return None;\n            }\n            const taken = value as Value;\n            value = undefined;\n            initialized = false;\n            resolvedPromise = undefined;  // Clear cached promise\n            resolvedResultPromise = undefined;  // Clear cached result promise\n            return Some(taken);\n        },\n\n        isInitialized(): boolean {\n            return initialized;\n        },\n\n        wait(): Promise<Value> {\n            // If already initialized, return immediately\n            if (initialized) {\n                // Reuse cached promise to avoid creating new Promise on each call\n                return (resolvedPromise ??= Promise.resolve(value as Value));\n            }\n\n            // If initialization is in progress, wait for it\n            if (pendingPromise) {\n                return pendingPromise;\n            }\n\n            // Otherwise, add to waiters and wait for someone to initialize\n            return new Promise<Value>((resolve) => {\n                waiters.push(resolve);\n            });\n        },\n    } as const);\n}\n","/**\n * @module\n * Rust-inspired [RwLock](https://doc.rust-lang.org/std/sync/struct.RwLock.html) for async read-write locking.\n *\n * In JavaScript's single-threaded environment, `RwLock<T>` allows multiple\n * concurrent readers or a single exclusive writer. This is useful when\n * read operations are frequent and write operations are rare.\n *\n * **When to use RwLock vs Mutex:**\n * - Use `RwLock` when reads are frequent, writes are rare, and read operations\n *   contain `await` statements that could benefit from concurrent access.\n * - Use `Mutex` for simpler cases or when read/write frequency is balanced.\n *\n * **Important:** In JS, the benefit of RwLock is limited because:\n * - JS is single-threaded, so \"parallel reads\" don't truly execute simultaneously\n * - If read operations don't contain `await`, there's no opportunity for concurrency\n * - RwLock adds complexity over Mutex with marginal performance benefit\n */\n\nimport { None, Some, type Option } from '../../core/mod.ts';\n\n/**\n * A guard that provides shared read access to the RwLock-protected value.\n *\n * Multiple read guards can exist simultaneously, but no write guards\n * can be acquired while any read guard is held.\n *\n * @typeParam T - The type of the protected value.\n */\nexport interface RwLockReadGuard<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     */\n    readonly [Symbol.toStringTag]: 'RwLockReadGuard';\n\n    /**\n     * The protected value (read-only access).\n     *\n     * @example\n     * ```ts\n     * const guard = await rwlock.read();\n     * console.log(guard.value); // Read the value\n     * guard.unlock();\n     * ```\n     */\n    readonly value: T;\n\n    /**\n     * Custom `toString` implementation.\n     *\n     * @returns A string representation of the guard.\n     * @example\n     * ```ts\n     * const guard = await rwlock.read();\n     * console.log(guard.toString()); // 'RwLockReadGuard(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Releases the read lock.\n     *\n     * After calling `unlock()`, the guard should not be used.\n     *\n     * @example\n     * ```ts\n     * const guard = await rwlock.read();\n     * try {\n     *     console.log(guard.value);\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    unlock(): void;\n}\n\n/**\n * A guard that provides exclusive write access to the RwLock-protected value.\n *\n * Only one write guard can exist at a time, and no read guards can be\n * acquired while a write guard is held.\n *\n * @typeParam T - The type of the protected value.\n */\nexport interface RwLockWriteGuard<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     */\n    readonly [Symbol.toStringTag]: 'RwLockWriteGuard';\n\n    /**\n     * The protected value (read-write access).\n     *\n     * @example\n     * ```ts\n     * const guard = await rwlock.write();\n     * console.log(guard.value); // Read the value\n     * guard.value = newValue;   // Modify the value\n     * guard.unlock();\n     * ```\n     */\n    value: T;\n\n    /**\n     * Custom `toString` implementation.\n     *\n     * @returns A string representation of the guard.\n     * @example\n     * ```ts\n     * const guard = await rwlock.write();\n     * console.log(guard.toString()); // 'RwLockWriteGuard(42)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Releases the write lock.\n     *\n     * After calling `unlock()`, the guard should not be used.\n     *\n     * @example\n     * ```ts\n     * const guard = await rwlock.write();\n     * try {\n     *     guard.value = newValue;\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    unlock(): void;\n}\n\n/**\n * An async read-write lock for protecting shared data.\n *\n * This lock allows multiple concurrent readers or a single exclusive writer.\n * Writers are given priority to prevent writer starvation.\n *\n * @typeParam T - The type of the protected value.\n * @since 1.8.0\n * @see https://doc.rust-lang.org/std/sync/struct.RwLock.html\n * @example\n * ```ts\n * const config = RwLock({ apiUrl: 'https://api.example.com', timeout: 5000 });\n *\n * // Multiple readers can access simultaneously\n * async function getConfig() {\n *     const guard = await config.read();\n *     try {\n *         return { ...guard.value };\n *     } finally {\n *         guard.unlock();\n *     }\n * }\n *\n * // Writers get exclusive access\n * async function updateConfig(newConfig: Partial<Config>) {\n *     const guard = await config.write();\n *     try {\n *         Object.assign(guard.value, newConfig);\n *     } finally {\n *         guard.unlock();\n *     }\n * }\n * ```\n */\nexport interface RwLock<T> {\n    /**\n     * The well-known symbol `Symbol.toStringTag` used by `Object.prototype.toString()`.\n     */\n    readonly [Symbol.toStringTag]: 'RwLock';\n\n    /**\n     * Custom `toString` implementation.\n     *\n     * @example\n     * ```ts\n     * const rwlock = RwLock(42);\n     * console.log(rwlock.toString()); // 'RwLock(<unlocked>)'\n     * ```\n     */\n    toString(): string;\n\n    /**\n     * Acquires a read lock and executes the callback with the protected value.\n     *\n     * Multiple read operations can execute concurrently.\n     *\n     * @typeParam U - The return type of the callback.\n     * @param fn - The callback that receives the protected value (read-only).\n     * @returns A promise that resolves to the callback's return value.\n     * @example\n     * ```ts\n     * const data = await rwlock.withRead(async (value) => {\n     *     return value.items.filter(item => item.active);\n     * });\n     * ```\n     */\n    withRead<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>>;\n\n    /**\n     * Acquires a write lock and executes the callback with the protected value.\n     *\n     * Write operations are exclusive - no other reads or writes can proceed.\n     *\n     * @typeParam U - The return type of the callback.\n     * @param fn - The callback that receives the protected value (read-write).\n     * @returns A promise that resolves to the callback's return value.\n     * @example\n     * ```ts\n     * await rwlock.withWrite(async (value) => {\n     *     value.items.push(await fetchNewItem());\n     * });\n     * ```\n     */\n    withWrite<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>>;\n\n    /**\n     * Acquires a read lock and returns a guard for manual control.\n     *\n     * @returns A promise that resolves to a read guard.\n     * @example\n     * ```ts\n     * const guard = await rwlock.read();\n     * try {\n     *     console.log(guard.value);\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    read(): Promise<RwLockReadGuard<T>>;\n\n    /**\n     * Acquires a write lock and returns a guard for manual control.\n     *\n     * @returns A promise that resolves to a write guard.\n     * @example\n     * ```ts\n     * const guard = await rwlock.write();\n     * try {\n     *     guard.value = newValue;\n     * } finally {\n     *     guard.unlock();\n     * }\n     * ```\n     */\n    write(): Promise<RwLockWriteGuard<T>>;\n\n    /**\n     * Attempts to acquire a read lock without waiting.\n     *\n     * Returns `None` if a write lock is currently held.\n     *\n     * @returns `Some(guard)` if acquired, `None` if a writer holds the lock.\n     * @example\n     * ```ts\n     * const maybeGuard = rwlock.tryRead();\n     * if (maybeGuard.isSome()) {\n     *     const guard = maybeGuard.unwrap();\n     *     try {\n     *         console.log(guard.value);\n     *     } finally {\n     *         guard.unlock();\n     *     }\n     * }\n     * ```\n     */\n    tryRead(): Option<RwLockReadGuard<T>>;\n\n    /**\n     * Attempts to acquire a write lock without waiting.\n     *\n     * Returns `None` if any read or write lock is currently held.\n     *\n     * @returns `Some(guard)` if acquired, `None` if any lock is held.\n     * @example\n     * ```ts\n     * const maybeGuard = rwlock.tryWrite();\n     * if (maybeGuard.isSome()) {\n     *     const guard = maybeGuard.unwrap();\n     *     try {\n     *         guard.value = newValue;\n     *     } finally {\n     *         guard.unlock();\n     *     }\n     * }\n     * ```\n     */\n    tryWrite(): Option<RwLockWriteGuard<T>>;\n\n    /**\n     * Returns the number of active readers.\n     *\n     * @example\n     * ```ts\n     * console.log(rwlock.readerCount()); // 0\n     * const guard = await rwlock.read();\n     * console.log(rwlock.readerCount()); // 1\n     * ```\n     */\n    readerCount(): number;\n\n    /**\n     * Returns `true` if a writer currently holds the lock.\n     *\n     * @example\n     * ```ts\n     * console.log(rwlock.isWriteLocked()); // false\n     * const guard = await rwlock.write();\n     * console.log(rwlock.isWriteLocked()); // true\n     * ```\n     */\n    isWriteLocked(): boolean;\n\n    /**\n     * Acquires a read lock and returns a copy of the protected value.\n     *\n     * @returns A promise that resolves to a copy of the value.\n     * @example\n     * ```ts\n     * const value = await rwlock.get();\n     * ```\n     */\n    get(): Promise<Awaited<T>>;\n\n    /**\n     * Acquires a write lock and sets a new value.\n     *\n     * @param value - The new value to set.\n     * @returns A promise that resolves when the value has been set.\n     * @example\n     * ```ts\n     * await rwlock.set(newValue);\n     * ```\n     */\n    set(value: T): Promise<void>;\n\n    /**\n     * Acquires a write lock, sets a new value, and returns the old value.\n     *\n     * @param value - The new value to set.\n     * @returns A promise that resolves to the old value.\n     * @example\n     * ```ts\n     * const rwlock = RwLock(42);\n     * const old = await rwlock.replace(100);\n     * console.log(old); // 42\n     * console.log(await rwlock.get()); // 100\n     * ```\n     */\n    replace(value: T): Promise<Awaited<T>>;\n}\n\n/**\n * Creates a new `RwLock<T>` protecting the given value.\n *\n * @typeParam T - The type of the protected value.\n * @param value - The initial value to protect.\n * @returns A new `RwLock<T>` instance.\n * @example\n * ```ts\n * // Basic usage\n * const counter = RwLock(0);\n *\n * // Read (multiple can proceed)\n * const value = await counter.withRead(v => v);\n *\n * // Write (exclusive)\n * await counter.withWrite(v => v + 1);\n * ```\n *\n * @example\n * ```ts\n * // Cache with read-heavy workload\n * const cache = RwLock(new Map<string, Data>());\n *\n * // Many concurrent reads\n * async function get(key: string): Promise<Data | undefined> {\n *     return cache.withRead(map => map.get(key));\n * }\n *\n * // Occasional writes\n * async function set(key: string, value: Data): Promise<void> {\n *     await cache.withWrite(map => { map.set(key, value); });\n * }\n * ```\n *\n * @example\n * ```ts\n * // Configuration that's read frequently, updated rarely\n * interface AppConfig {\n *     apiUrl: string;\n *     timeout: number;\n *     features: string[];\n * }\n *\n * const config = RwLock<AppConfig>({\n *     apiUrl: 'https://api.example.com',\n *     timeout: 5000,\n *     features: ['feature-a', 'feature-b'],\n * });\n *\n * // Read config (concurrent)\n * async function isFeatureEnabled(feature: string): Promise<boolean> {\n *     return config.withRead(cfg => cfg.features.includes(feature));\n * }\n *\n * // Update config (exclusive)\n * async function enableFeature(feature: string): Promise<void> {\n *     await config.withWrite(cfg => {\n *         if (!cfg.features.includes(feature)) {\n *             cfg.features.push(feature);\n *         }\n *     });\n * }\n * ```\n */\nexport function RwLock<T>(value: T): RwLock<T> {\n    let currentValue = value;\n    let readers = 0;\n    let writer = false;\n    let pendingWriters = 0;\n\n    const readWaitQueue: (() => void)[] = [];\n    const writeWaitQueue: (() => void)[] = [];\n\n    function tryAcquireRead(): boolean {\n        // Can read if no writer and no pending writers (writer priority)\n        if (!writer && pendingWriters === 0) {\n            readers++;\n            return true;\n        }\n        return false;\n    }\n\n    function tryAcquireWrite(): boolean {\n        // Can write if no readers and no writer\n        if (readers === 0 && !writer) {\n            writer = true;\n            return true;\n        }\n        return false;\n    }\n\n    function releaseRead(): void {\n        readers--;\n\n        // If no more readers, try to wake a writer\n        if (readers === 0 && writeWaitQueue.length > 0) {\n            const next = writeWaitQueue.shift() as () => void;\n            writer = true;\n            pendingWriters--;\n            next();\n        }\n    }\n\n    function releaseWrite(): void {\n        writer = false;\n\n        // Writers have priority, but if no writers waiting, wake all readers\n        if (writeWaitQueue.length > 0) {\n            const next = writeWaitQueue.shift() as () => void;\n            writer = true;\n            pendingWriters--;\n            next();\n        } else {\n            // Wake all pending readers\n            while (readWaitQueue.length > 0) {\n                readers++;\n                const next = readWaitQueue.shift() as () => void;\n                next();\n            }\n        }\n    }\n\n    function createReadGuard(): RwLockReadGuard<T> {\n        let released = false;\n\n        return Object.freeze<RwLockReadGuard<T>>({\n            [Symbol.toStringTag]: 'RwLockReadGuard',\n\n            toString(): string {\n                if (released) {\n                    return 'RwLockReadGuard(<released>)';\n                }\n                return `RwLockReadGuard(${ currentValue })`;\n            },\n\n            get value(): T {\n                if (released) {\n                    throw new Error('RwLockReadGuard has been released');\n                }\n                return currentValue;\n            },\n\n            unlock(): void {\n                if (released) {\n                    return;\n                }\n                released = true;\n                releaseRead();\n            },\n        });\n    }\n\n    function createWriteGuard(): RwLockWriteGuard<T> {\n        let released = false;\n\n        return Object.freeze<RwLockWriteGuard<T>>({\n            [Symbol.toStringTag]: 'RwLockWriteGuard',\n\n            toString(): string {\n                if (released) {\n                    return 'RwLockWriteGuard(<released>)';\n                }\n                return `RwLockWriteGuard(${ currentValue })`;\n            },\n\n            get value(): T {\n                if (released) {\n                    throw new Error('RwLockWriteGuard has been released');\n                }\n                return currentValue;\n            },\n\n            set value(newValue: T) {\n                if (released) {\n                    throw new Error('RwLockWriteGuard has been released');\n                }\n                currentValue = newValue;\n            },\n\n            unlock(): void {\n                if (released) {\n                    return;\n                }\n                released = true;\n                releaseWrite();\n            },\n        } as const);\n    }\n\n    function read(): Promise<RwLockReadGuard<T>> {\n        if (tryAcquireRead()) {\n            return Promise.resolve(createReadGuard());\n        }\n\n        return new Promise<RwLockReadGuard<T>>((resolve) => {\n            readWaitQueue.push(() => {\n                resolve(createReadGuard());\n            });\n        });\n    }\n\n    function write(): Promise<RwLockWriteGuard<T>> {\n        if (tryAcquireWrite()) {\n            return Promise.resolve(createWriteGuard());\n        }\n\n        pendingWriters++;\n        return new Promise<RwLockWriteGuard<T>>((resolve) => {\n            writeWaitQueue.push(() => {\n                resolve(createWriteGuard());\n            });\n        });\n    }\n\n    return Object.freeze<RwLock<T>>({\n        [Symbol.toStringTag]: 'RwLock',\n\n        toString(): string {\n            if (writer) {\n                return 'RwLock(<write-locked>)';\n            }\n            if (readers > 0) {\n                return `RwLock(<read-locked:${ readers }>)`;\n            }\n            return 'RwLock(<unlocked>)';\n        },\n\n        async withRead<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>> {\n            const guard = await read();\n            try {\n                return await fn(guard.value);\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        async withWrite<U>(fn: (value: T) => PromiseLike<U> | U): Promise<Awaited<U>> {\n            const guard = await write();\n            try {\n                return await fn(guard.value);\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        read,\n\n        write,\n\n        tryRead(): Option<RwLockReadGuard<T>> {\n            if (tryAcquireRead()) {\n                return Some(createReadGuard());\n            }\n            return None;\n        },\n\n        tryWrite(): Option<RwLockWriteGuard<T>> {\n            if (tryAcquireWrite()) {\n                return Some(createWriteGuard());\n            }\n            return None;\n        },\n\n        readerCount(): number {\n            return readers;\n        },\n\n        isWriteLocked(): boolean {\n            return writer;\n        },\n\n        async get(): Promise<Awaited<T>> {\n            const guard = await read();\n            try {\n                return guard.value as Awaited<T>;\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        async set(value: T): Promise<void> {\n            const guard = await write();\n            try {\n                guard.value = value;\n            } finally {\n                guard.unlock();\n            }\n        },\n\n        async replace(value: T): Promise<Awaited<T>> {\n            const guard = await write();\n            try {\n                const old = guard.value;\n                guard.value = value;\n                return old as Awaited<T>;\n            } finally {\n                guard.unlock();\n            }\n        },\n    } as const);\n}\n"],"names":["ASYNC_TRUE","ASYNC_FALSE","value"],"mappings":"AAuBO,MAAM,gBAAA,0BAA0B,aAAa,CAAA;;ACC7C,SAAS,SAAY,CAAA,EAA4B;AAEpD,EAAA,OAAO,CAAA,IAAK,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAA,IAAoB,CAAA;AACrE;;ACJO,MAAM,gBA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