@carbonteq/fp 0.9.1 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +326 -97
- package/dist/errors.cjs +2 -3
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +2 -5
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +2 -5
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -2
- package/dist/errors.mjs.map +1 -1
- package/dist/flow-experimental.cjs +332 -0
- package/dist/flow-experimental.cjs.map +1 -0
- package/dist/flow-experimental.d.cts +69 -0
- package/dist/flow-experimental.d.cts.map +1 -0
- package/dist/flow-experimental.d.mts +69 -0
- package/dist/flow-experimental.d.mts.map +1 -0
- package/dist/flow-experimental.mjs +330 -0
- package/dist/flow-experimental.mjs.map +1 -0
- package/dist/flow.cjs +340 -0
- package/dist/flow.cjs.map +1 -0
- package/dist/flow.d.cts +77 -0
- package/dist/flow.d.cts.map +1 -0
- package/dist/flow.d.mts +77 -0
- package/dist/flow.d.mts.map +1 -0
- package/dist/flow.mjs +338 -0
- package/dist/flow.mjs.map +1 -0
- package/dist/index.cjs +29 -14
- package/dist/index.d.cts +10 -5
- package/dist/index.d.mts +10 -5
- package/dist/index.mjs +10 -5
- package/dist/match.cjs +376 -3
- package/dist/match.cjs.map +1 -1
- package/dist/match.d.cts +467 -8
- package/dist/match.d.cts.map +1 -1
- package/dist/match.d.mts +467 -8
- package/dist/match.d.mts.map +1 -1
- package/dist/match.mjs +371 -3
- package/dist/match.mjs.map +1 -1
- package/dist/option-experimental.cjs +1547 -0
- package/dist/option-experimental.cjs.map +1 -0
- package/dist/option-experimental.d.cts +1380 -0
- package/dist/option-experimental.d.cts.map +1 -0
- package/dist/option-experimental.d.mts +1380 -0
- package/dist/option-experimental.d.mts.map +1 -0
- package/dist/option-experimental.mjs +1545 -0
- package/dist/option-experimental.mjs.map +1 -0
- package/dist/option.cjs +650 -71
- package/dist/option.cjs.map +1 -1
- package/dist/option.d.cts +528 -39
- package/dist/option.d.cts.map +1 -1
- package/dist/option.d.mts +528 -39
- package/dist/option.d.mts.map +1 -1
- package/dist/option.mjs +648 -70
- package/dist/option.mjs.map +1 -1
- package/dist/result-experimental.cjs +1346 -0
- package/dist/result-experimental.cjs.map +1 -0
- package/dist/result-experimental.d.cts +1127 -0
- package/dist/result-experimental.d.cts.map +1 -0
- package/dist/result-experimental.d.mts +1127 -0
- package/dist/result-experimental.d.mts.map +1 -0
- package/dist/result-experimental.mjs +1345 -0
- package/dist/result-experimental.mjs.map +1 -0
- package/dist/result.cjs +746 -81
- package/dist/result.cjs.map +1 -1
- package/dist/result.d.cts +799 -104
- package/dist/result.d.cts.map +1 -1
- package/dist/result.d.mts +799 -104
- package/dist/result.d.mts.map +1 -1
- package/dist/result.mjs +742 -73
- package/dist/result.mjs.map +1 -1
- package/dist/tuple.cjs +5 -4
- package/dist/tuple.cjs.map +1 -1
- package/dist/tuple.d.cts +9 -7
- package/dist/tuple.d.cts.map +1 -1
- package/dist/tuple.d.mts +9 -7
- package/dist/tuple.d.mts.map +1 -1
- package/dist/tuple.mjs +4 -3
- package/dist/tuple.mjs.map +1 -1
- package/dist/unit.cjs +3 -3
- package/dist/unit.cjs.map +1 -1
- package/dist/unit.d.cts +4 -5
- package/dist/unit.d.cts.map +1 -1
- package/dist/unit.d.mts +4 -5
- package/dist/unit.d.mts.map +1 -1
- package/dist/unit.mjs +2 -2
- package/dist/unit.mjs.map +1 -1
- package/dist/utils.cjs +50 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +14 -4
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +14 -4
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +46 -3
- package/dist/utils.mjs.map +1 -1
- package/examples/README.md +60 -0
- package/examples/flow/01-basics.ts +74 -0
- package/examples/flow/02-async.ts +73 -0
- package/examples/flow/03-recovery.ts +60 -0
- package/examples/flow/04-complex-backend.ts +240 -0
- package/examples/flow/05-complex-backend-asyncGen.ts +224 -0
- package/examples/flow/index.ts +13 -0
- package/examples/flow-experimental/01-basics.ts +78 -0
- package/examples/flow-experimental/02-async.ts +77 -0
- package/examples/flow-experimental/03-recovery.ts +93 -0
- package/examples/flow-experimental/04-complex-backend.ts +244 -0
- package/examples/flow-experimental/05-complex-backend-asyncGen.ts +229 -0
- package/examples/flow-experimental/index.ts +14 -0
- package/examples/match/01-stable-match.ts +154 -0
- package/examples/match/index.ts +19 -0
- package/examples/match-experimental/01-experimental-match.ts +157 -0
- package/examples/match-experimental/index.ts +18 -0
- package/examples/option/01-basics.ts +16 -0
- package/examples/option/02-map-flatMap.ts +36 -0
- package/examples/option/03-zip-flatZip.ts +23 -0
- package/examples/option/04-constructors.ts +21 -0
- package/examples/option/05-transform.ts +15 -0
- package/examples/option/06-aggregation.ts +14 -0
- package/examples/option/index.ts +49 -0
- package/examples/option-experimental/01-map.ts +109 -0
- package/examples/option-experimental/02-flatMap.ts +234 -0
- package/examples/option-experimental/03-zip.ts +197 -0
- package/examples/option-experimental/04-flatZip.ts +251 -0
- package/examples/option-experimental/05-gen.ts +360 -0
- package/examples/option-experimental/06-genAdapter.ts +463 -0
- package/examples/option-experimental/07-asyncGen.ts +353 -0
- package/examples/option-experimental/08-asyncGenAdapter.ts +514 -0
- package/examples/option-experimental/09-workflow-simple-sync.ts +321 -0
- package/examples/option-experimental/10-workflow-async.ts +378 -0
- package/examples/option-experimental/index.ts +341 -0
- package/examples/option-experimental/shared-domain.ts +325 -0
- package/examples/result/01-basics.ts +16 -0
- package/examples/result/02-map-flatMap.ts +34 -0
- package/examples/result/03-zip-flatZip.ts +23 -0
- package/examples/result/04-validation.ts +44 -0
- package/examples/result/05-constructors.ts +30 -0
- package/examples/result/06-utilities.ts +36 -0
- package/examples/result/index.ts +53 -0
- package/examples/result-experimental/01-map.ts +60 -0
- package/examples/result-experimental/02-flatMap.ts +169 -0
- package/examples/result-experimental/03-zip.ts +145 -0
- package/examples/result-experimental/04-flatZip.ts +252 -0
- package/examples/result-experimental/05-gen.ts +293 -0
- package/examples/result-experimental/06-genAdapter.ts +396 -0
- package/examples/result-experimental/07-asyncGen.ts +379 -0
- package/examples/result-experimental/08-asyncGenAdapter.ts +553 -0
- package/examples/result-experimental/09-workflow-simple-sync.ts +304 -0
- package/examples/result-experimental/10-workflow-async.ts +356 -0
- package/examples/result-experimental/index.ts +312 -0
- package/examples/result-experimental/shared-domain.ts +263 -0
- package/package.json +54 -31
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"option-experimental.cjs","names":["isPromiseLike","UNIT","ExperimentalResult","CapturedTrace","isCapturedTrace","closeGenerator","closeAsyncGenerator"],"sources":["../src/option-experimental.ts"],"sourcesContent":["import { ExperimentalResult } from \"./result-experimental.js\"\nimport { UNIT } from \"./unit.js\"\nimport {\n CapturedTrace,\n closeAsyncGenerator,\n closeGenerator,\n isCapturedTrace,\n isPromiseLike,\n} from \"./utils.js\"\n\ntype Predicate<T> = (val: T) => boolean\ntype Falsy = false | 0 | \"\" | null | undefined\n\n/**\n * Error thrown when attempting to unwrap a `None` value.\n *\n * This exception is thrown by {@link ExperimentalOption.unwrap} when called on a `None`.\n * It represents a programmer error - you should only call `unwrap()` when\n * you are certain the ExperimentalOption contains a value, or use safe alternatives\n * like {@link ExperimentalOption.unwrapOr} or {@link ExperimentalOption.safeUnwrap}.\n *\n * @example\n * ```ts\n * try {\n * ExperimentalOption.None.unwrap();\n * } catch (e) {\n * e instanceof UnwrappedNone // true\n * e.name // \"UnwrapError\"\n * }\n * ```\n */\nexport class UnwrappedNone extends Error {\n readonly name = \"UnwrapError\"\n\n constructor() {\n super(\"Attempted to unwrap ExperimentalOption::None\")\n }\n}\n\nconst UNWRAPPED_NONE_ERR = new UnwrappedNone()\n\nconst NONE_VAL = Symbol(\"ExperimentalOption::None\")\n\n/** ExperimentalOption alias for presence-without-payload values. */\nexport type UnitOption = ExperimentalOption<UNIT>\n/** Extracts the contained value type from an ExperimentalOption type. */\nexport type UnwrapOption<T> = T extends ExperimentalOption<infer R> ? R : never\n\ntype CombinedOptions<T extends ExperimentalOption<unknown>[]> = {\n [K in keyof T]: UnwrapOption<T[K]>\n}\n\ninterface MatchCases<T, U> {\n Some: (val: T) => U\n None: () => U\n}\n\n/**\n * Wrapper that makes ExperimentalOption yieldable with proper type tracking.\n *\n * @internal\n */\nclass OptionYieldWrap<T> {\n constructor(readonly option: ExperimentalOption<T>) {}\n\n *[Symbol.iterator](): Generator<OptionYieldWrap<T>, T, unknown> {\n return (yield this) as T\n }\n}\n\n/**\n * Wrapper that makes ExperimentalOption yieldable in async generators with proper type tracking.\n *\n * @internal\n */\nclass AsyncOptionYieldWrap<T> {\n readonly option: Promise<ExperimentalOption<T>>\n\n constructor(option: ExperimentalOption<T> | Promise<ExperimentalOption<T>>) {\n this.option = (\n isPromiseLike(option) ? option : Promise.resolve(option)\n ) as Promise<ExperimentalOption<T>>\n }\n\n async *[Symbol.asyncIterator](): AsyncGenerator<\n AsyncOptionYieldWrap<T>,\n Awaited<T>,\n unknown\n > {\n return (yield this) as Awaited<T>\n }\n}\n\n/**\n * A type-safe container for optional values.\n *\n * `ExperimentalOption<T>` represents a value that may or may not be present. It eliminates the\n * need for `null` and `undefined` checks by making absence explicit through the\n * type system.\n *\n * ## States\n *\n * - **Some\\<T\\>**: Contains a value of type `T`\n * - **None**: Represents absence of a value (singleton)\n *\n * ## Basic Usage\n *\n * ```ts\n * import { ExperimentalOption } from \"@carbonteq/fp\";\n *\n * // Creating ExperimentalOptions\n * const some: ExperimentalOption<number> = ExperimentalOption.Some(42);\n * const none: ExperimentalOption<number> = ExperimentalOption.None;\n *\n * // From nullable values\n * const fromNull = ExperimentalOption.fromNullable(null); // None\n * const fromValue = ExperimentalOption.fromNullable(\"hello\"); // Some(\"hello\")\n *\n * // Checking and extracting\n * if (some.isSome()) {\n * console.log(some.unwrap()); // 42\n * }\n *\n * // Chaining operations\n * const result = ExperimentalOption.Some(5)\n * .map(x => x * 2)\n * .flatMap(x => ExperimentalOption.Some(x + 1));\n * // Some(11)\n * ```\n *\n * ## Async Variants\n *\n * For operations that return Promises, use `*Async` methods:\n *\n * ```ts\n * // Sync\n * ExperimentalOption.Some(5).map(x => x * 2); // ExperimentalOption<number>\n *\n * // Async\n * ExperimentalOption.Some(5).mapAsync(async x => x * 2); // Promise<ExperimentalOption<number>>\n * ```\n *\n * @template T - The type of the contained value\n *\n * @see {@link https://carbonteq.github.io/ct-fp/option | ExperimentalOption Documentation}\n */\nexport class ExperimentalOption<T> {\n /** Discriminant tag for type-level identification */\n readonly _tag: \"Some\" | \"None\"\n\n readonly #val: T\n\n private constructor(val: T, tag: \"Some\" | \"None\") {\n this.#val = val\n this._tag = tag\n }\n\n /**\n * Singleton `None` instance representing absence of a value.\n *\n * This is a shared instance - all `None` values reference the same object.\n *\n * @example\n * ```ts\n * const none1 = ExperimentalOption.None;\n * const none2 = ExperimentalOption.None;\n * none1 === none2 // true\n * ```\n */\n static readonly None: ExperimentalOption<never> = new ExperimentalOption(\n NONE_VAL as never,\n \"None\",\n )\n\n /**\n * Creates a `Some` variant containing the provided value.\n *\n * @template Inner - The type of value to wrap\n * @param val - The value to wrap in a Some\n * @returns An `ExperimentalOption<Inner>` in the Some state\n *\n * @example\n * ```ts\n * const opt = ExperimentalOption.Some(42); // ExperimentalOption<number>\n * const str = ExperimentalOption.Some(\"hello\"); // ExperimentalOption<string>\n * const obj = ExperimentalOption.Some({ id: 1 }); // ExperimentalOption<{ id: number }>\n * ```\n */\n static Some<Inner>(this: void, val: Inner): ExperimentalOption<Inner> {\n return new ExperimentalOption(val, \"Some\")\n }\n\n /**\n * Creates an `ExperimentalOption` from a nullable value, returning `None` for `null` or `undefined`.\n *\n * Unlike {@link fromFalsy}, this only treats `null` and `undefined` as absence.\n * Values like `0`, `\"\"`, and `false` are considered valid and wrapped in `Some`.\n *\n * @template T - The input type which may include null/undefined\n * @param val - The value to convert to an ExperimentalOption\n * @returns `Some<NonNullable<T>>` if value is non-nullish, else `None`\n *\n * @example\n * ```ts\n * ExperimentalOption.fromNullable(\"hello\") // Some(\"hello\")\n * ExperimentalOption.fromNullable(null) // None\n * ExperimentalOption.fromNullable(undefined) // None\n * ExperimentalOption.fromNullable(0) // Some(0) - 0 is not nullish\n * ExperimentalOption.fromNullable(\"\") // Some(\"\") - empty string is not nullish\n * ExperimentalOption.fromNullable(false) // Some(false) - false is not nullish\n *\n * // With user input\n * function findUser(id: string): User | null {\n * return database.getUser(id) ?? null;\n * }\n * const user = ExperimentalOption.fromNullable(findUser(\"123\"));\n * // ExperimentalOption<User>\n * ```\n */\n static fromNullable<T>(val: T): ExperimentalOption<NonNullable<T>> {\n return val === null || val === undefined\n ? ExperimentalOption.None\n : ExperimentalOption.Some(val as NonNullable<T>)\n }\n\n /**\n * Creates an `ExperimentalOption` from a value that may be falsy, returning `None` for falsy values.\n *\n * Treats `false`, `0`, `\"\"`, `null`, and `undefined` as absence.\n * Use {@link fromNullable} if you only want to exclude `null`/`undefined`.\n *\n * @template T - The type of value to wrap\n * @param val - The value to convert to an ExperimentalOption\n * @returns `Some<T>` if value is truthy, else `None`\n *\n * @example\n * ```ts\n * ExperimentalOption.fromFalsy(\"hello\") // Some(\"hello\")\n * ExperimentalOption.fromFalsy(\"\") // None\n * ExperimentalOption.fromFalsy(0) // None\n * ExperimentalOption.fromFalsy(false) // None\n * ExperimentalOption.fromFalsy(null) // None\n * ExperimentalOption.fromFalsy(undefined) // None\n *\n * // Useful for validation\n * const isValid = ExperimentalOption.fromFalsy(getConfigValue(\"API_KEY\"));\n * ```\n */\n static fromFalsy<T>(val: T | Falsy): ExperimentalOption<T> {\n return val ? ExperimentalOption.Some(val as T) : ExperimentalOption.None\n }\n\n /**\n * Creates an `ExperimentalOption` based on a predicate function result.\n *\n * Returns `Some` if the predicate returns `true`, otherwise `None`.\n *\n * @template T - The type of value to test\n * @param val - The value to test\n * @param pred - A predicate function that returns true if value should be wrapped\n * @returns `Some<T>` if predicate returns true, else `None`\n *\n * @example\n * ```ts\n * const age = 25;\n * ExperimentalOption.fromPredicate(age, a => a >= 18) // Some(25)\n * ExperimentalOption.fromPredicate(15, a => a >= 18) // None\n *\n * // Can be used for validation\n * const isValidEmail = (email: string) => /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(email);\n * ExperimentalOption.fromPredicate(user.email, isValidEmail)\n *\n * // With complex predicates\n * const isValidPassword = (pw: string) =>\n * pw.length >= 8 && /[A-Z]/.test(pw) && /[0-9]/.test(pw);\n * ExperimentalOption.fromPredicate(password, isValidPassword)\n * ```\n */\n static fromPredicate<T>(val: T, pred: Predicate<T>): ExperimentalOption<T> {\n return pred(val) ? ExperimentalOption.Some(val) : ExperimentalOption.None\n }\n\n /**\n * Combines multiple ExperimentalOptions into a single ExperimentalOption of an array.\n *\n * Returns `Some` containing an array of all unwrapped values if ALL inputs are `Some`.\n * Returns `None` if ANY input is `None`.\n *\n * @template T - Variadic tuple of ExperimentalOption types\n * @param options - Variable number of ExperimentalOptions to combine\n * @returns `ExperimentalOption<[T1, T2, ...]>` with array of values, or `None`\n *\n * @example\n * ```ts\n * // All Some -> array of values\n * const all = ExperimentalOption.all(\n * ExperimentalOption.Some(1),\n * ExperimentalOption.Some(2),\n * ExperimentalOption.Some(3)\n * );\n * // Some([1, 2, 3])\n *\n * // Any None -> None\n * const withNone = ExperimentalOption.all(\n * ExperimentalOption.Some(1),\n * ExperimentalOption.None,\n * ExperimentalOption.Some(3)\n * );\n * // None\n *\n * // Empty -> Some([])\n * const empty = ExperimentalOption.all();\n * // Some([])\n *\n * // Practical example: combine multiple validations\n * const name = ExperimentalOption.fromNullable(user.name);\n * const email = ExperimentalOption.fromNullable(user.email);\n * const age = ExperimentalOption.fromNullable(user.age);\n *\n * const complete = ExperimentalOption.all(name, email, age);\n * // ExperimentalOption<[string, string, number]>\n * ```\n */\n static all<T extends ExperimentalOption<unknown>[]>(\n ...options: T\n ): ExperimentalOption<CombinedOptions<T>> {\n const vals = [] as CombinedOptions<T>\n\n for (const opt of options) {\n if (opt.isNone()) return ExperimentalOption.None\n vals.push(opt.#val)\n }\n\n return ExperimentalOption.Some(vals)\n }\n\n /**\n * Returns the first `Some` from a list of ExperimentalOptions, or `None` if all are `None`.\n *\n * Short-circuits on the first `Some` found, evaluating subsequent options lazily.\n *\n * @template T - The type of values in the ExperimentalOptions\n * @param options - Variable number of ExperimentalOptions to check\n * @returns The first `Some<T>` found, or `None`\n *\n * @example\n * ```ts\n * // Returns first Some\n * const first = ExperimentalOption.any(\n * ExperimentalOption.None,\n * ExperimentalOption.Some(\"First value\"),\n * ExperimentalOption.Some(\"Second value\")\n * );\n * // Some(\"First value\")\n *\n * // All None -> None\n * const allNone = ExperimentalOption.any(\n * ExperimentalOption.None,\n * ExperimentalOption.None,\n * ExperimentalOption.None\n * );\n * // None\n *\n * // Practical: Try multiple fallback sources\n * const config = ExperimentalOption.any(\n * ExperimentalOption.fromNullable(process.env.API_KEY),\n * ExperimentalOption.fromNullable(getEnvVar(\"API_KEY\")),\n * ExperimentalOption.fromNullable(readConfigFile(\"API_KEY\"))\n * );\n *\n * // Empty -> None\n * const empty = ExperimentalOption.any();\n * // None\n * ```\n */\n static any<T>(...options: ExperimentalOption<T>[]): ExperimentalOption<T> {\n for (const opt of options) {\n if (opt.isSome()) return opt\n }\n return ExperimentalOption.None\n }\n\n /**\n * Type guard that narrows the type to `Some`.\n *\n * Returns `true` if this ExperimentalOption is in the `Some` state, containing a value.\n *\n * @returns `true` if this is a `Some`, `false` if `None`\n *\n * @example\n * ```ts\n * const opt: ExperimentalOption<number> = ExperimentalOption.Some(42);\n *\n * if (opt.isSome()) {\n * // TypeScript knows opt is ExperimentalOption<number> & { _tag: \"Some\" }\n * console.log(opt.unwrap()); // 42\n * }\n * ```\n */\n isSome(): this is ExperimentalOption<T> & { readonly _tag: \"Some\" } {\n return this._tag === \"Some\" && this.#val !== NONE_VAL\n }\n\n /**\n * Type guard that narrows the type to `None`.\n *\n * Returns `true` if this ExperimentalOption is in the `None` state (absence of value).\n *\n * @returns `true` if this is `None`, `false` if `Some`\n *\n * @example\n * ```ts\n * const opt: ExperimentalOption<number> = ExperimentalOption.None;\n *\n * if (opt.isNone()) {\n * // TypeScript knows opt is ExperimentalOption<never> & { _tag: \"None\" }\n * console.log(\"No value present\");\n * }\n * ```\n */\n isNone(): this is ExperimentalOption<never> & { readonly _tag: \"None\" } {\n return this._tag === \"None\" || this.#val === NONE_VAL\n }\n\n /**\n * Type guard that checks if the contained value is the `Unit` type.\n *\n * Returns `true` if this ExperimentalOption contains the special `UNIT` value,\n * used to represent operations that produce no meaningful output.\n *\n * @returns `true` if this contains `UNIT`, `false` otherwise\n *\n * @example\n * ```ts\n * const unitOpt: ExperimentalOption<UNIT> = ExperimentalOption.Some(UNIT);\n * unitOpt.isUnit(); // true\n *\n * const normalOpt: ExperimentalOption<number> = ExperimentalOption.Some(42);\n * normalOpt.isUnit(); // false\n * ```\n */\n isUnit(): this is ExperimentalOption<UNIT> {\n return this.#val === UNIT\n }\n\n /**\n * Returns the contained value or throws {@link UnwrappedNone} if `None`.\n *\n * This is an unsafe operation that throws on `None`. Use only when you are\n * certain the ExperimentalOption contains a value, or use safe alternatives like\n * {@link unwrapOr} or {@link safeUnwrap}.\n *\n * @throws {@link UnwrappedNone} if this is `None`\n * @returns The contained value\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(42).unwrap(); // 42\n * ExperimentalOption.None.unwrap(); // throws UnwrappedNone\n *\n * // Safe usage pattern\n * const opt = ExperimentalOption.Some(42);\n * if (opt.isSome()) {\n * const value = opt.unwrap(); // Safe: we checked isSome()\n * }\n * ```\n *\n * @see {@link unwrapOr} for safe unwrapping with a default value\n * @see {@link unwrapOrElse} for lazy default computation\n * @see {@link safeUnwrap} for null-returning safe unwrap\n */\n unwrap(): T {\n if (this.isNone()) {\n throw UNWRAPPED_NONE_ERR\n }\n return this.#val\n }\n\n /**\n * Returns the contained value, or the provided default value if `None`.\n *\n * A safe alternative to {@link unwrap} that doesn't throw.\n *\n * @param defaultValue - The value to return if this is `None`\n * @returns The contained value, or the default\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(42).unwrapOr(0); // 42\n * ExperimentalOption.None.unwrapOr(0); // 0\n *\n * // With user input\n * const age = ExperimentalOption.fromNullable(user.age).unwrapOr(18);\n *\n * // With complex defaults\n * const config = ExperimentalOption.fromNullable(getConfig())\n * .unwrapOr({ port: 3000, host: \"localhost\" });\n * ```\n *\n * @see {@link unwrapOrElse} for lazy default computation\n * @see {@link safeUnwrap} for null-returning safe unwrap\n */\n unwrapOr(defaultValue: T): T {\n if (this.isNone()) return defaultValue\n return this.#val\n }\n\n /**\n * Returns the contained value, or computes a default via a function if `None`.\n *\n * Unlike {@link unwrapOr}, the default is computed lazily - only if this is `None`.\n * Use this when the default value is expensive to compute.\n *\n * @param fn - A factory function that produces the default value\n * @returns The contained value, or the computed default\n *\n * @example\n * ```ts\n * // Lazy default - only computed if needed\n * const value = ExperimentalOption.None.unwrapOrElse(() => {\n * console.log(\"Computing expensive default...\");\n * return expensivelyComputeDefault();\n * });\n * // Prints \"Computing expensive default...\"\n *\n * // Not computed when Some\n * const some = ExperimentalOption.Some(42).unwrapOrElse(() => {\n * console.log(\"This won't print\");\n * return expensivelyComputeDefault();\n * });\n * // Returns 42 without printing\n *\n * // Practical: cache lookup with fallback\n * const cached = ExperimentalOption.fromNullable(cache.get(key))\n * .unwrapOrElse(() => {\n * const value = fetchFromDatabase(key);\n * cache.set(key, value);\n * return value;\n * });\n * ```\n *\n * @see {@link unwrapOr} for simple default values\n * @see {@link unwrap} for unsafe unwrapping\n */\n unwrapOrElse(fn: () => T): T {\n if (this.isNone()) return fn()\n return this.#val\n }\n\n /**\n * Returns the contained value, or `null` if `None`.\n *\n * Provides a safe way to extract values that integrates with TypeScript's\n * null checking while maintaining the ExperimentalOption semantics.\n *\n * @returns The contained value, or `null`\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(42).safeUnwrap(); // 42\n * ExperimentalOption.None.safeUnwrap(); // null\n *\n * // Integration with existing null-handling code\n * const value = ExperimentalOption.fromNullable(user.name).safeUnwrap();\n * if (value !== null) {\n * console.log(value.toUpperCase());\n * }\n *\n * // With nullish coalescing\n * const displayName = ExperimentalOption.fromNullable(user.displayName)\n * .safeUnwrap() ?? user.email;\n * ```\n *\n * @see {@link unwrapOr} for typed defaults\n * @see {@link unwrapOrElse} for lazy defaults\n */\n safeUnwrap(): T | null {\n if (this.isNone()) return null\n return this.#val\n }\n\n /**\n * Pattern matches on both states of the ExperimentalOption, providing exhaustive handling.\n *\n * This is the most explicit way to handle ExperimentalOptions, ensuring both `Some` and `None`\n * cases are handled at compile time.\n *\n * @template U - The result type of both branches\n * @param cases - Object containing handlers for both states\n * @returns The result of calling the appropriate handler\n *\n * @example\n * ```ts\n * const result = ExperimentalOption.Some(42).match({\n * Some: (value) => `Got: ${value}`,\n * None: () => \"Got nothing\"\n * });\n * // \"Got: 42\"\n *\n * const noneResult = ExperimentalOption.None.match({\n * Some: (value) => `Got: ${value}`,\n * None: () => \"Got nothing\"\n * });\n * // \"Got nothing\"\n *\n * // Practical: user lookup\n * const message = findUser(userId).match({\n * Some: (user) => `Welcome, ${user.name}!`,\n * None: () => \"User not found\"\n * });\n * ```\n *\n * @see {@link isSome} and {@link isNone} for conditional handling\n */\n match<U>(cases: MatchCases<T, U>): U {\n if (this.isNone()) {\n return cases.None()\n }\n return cases.Some(this.#val)\n }\n\n /**\n * Pattern matches using positional arguments (FP convention alias for `match`).\n *\n * This is a more concise alternative to `match` using positional arguments\n * instead of an object. Familiar to developers from Scala, Haskell, and other FP languages.\n *\n * @template U - The result type of both branches\n * @param onSome - Handler called with the value if `Some`\n * @param onNone - Handler called if `None`\n * @returns The result of calling the appropriate handler\n *\n * @example\n * ```ts\n * const result = ExperimentalOption.Some(42).fold(\n * (value) => `Got: ${value}`,\n * () => \"Got nothing\"\n * );\n * // \"Got: 42\"\n *\n * const noneResult = ExperimentalOption.None.fold(\n * (value) => `Got: ${value}`,\n * () => \"Got nothing\"\n * );\n * // \"Got nothing\"\n *\n * // Equivalent to match:\n * experimentalOption.fold(onSome, onNone);\n * experimentalOption.match({ Some: onSome, None: onNone });\n * ```\n *\n * @see {@link match} for object-based pattern matching\n * @see {@link foldAsync} for async handlers\n */\n fold<U>(onSome: (val: T) => U, onNone: () => U): U {\n if (this.isNone()) {\n return onNone()\n }\n return onSome(this.#val)\n }\n\n /**\n * Async pattern matching using positional arguments.\n *\n * Async variant of `fold` for when handlers return Promises.\n * Rejections from `onSome` are propagated (not converted to `None`).\n *\n * @template U - The result type of both branches\n * @param onSome - Async handler called with the value if `Some`\n * @param onNone - Async handler called if `None`\n * @returns Promise resolving to the result of the appropriate handler\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.Some(userId).foldAsync(\n * async (id) => await fetchUser(id),\n * async () => await getDefaultUser()\n * );\n *\n * // With database lookup\n * const user = await ExperimentalOption.fromNullable(sessionUserId).foldAsync(\n * async (id) => await db.users.findById(id),\n * async () => ({ id: 0, name: \"Guest\" })\n * );\n * ```\n *\n * @see {@link fold} for synchronous handlers\n * @see {@link matchAsync} for object-based async pattern matching\n */\n async foldAsync<U>(\n onSome: (val: T) => Promise<U>,\n onNone: () => Promise<U>,\n ): Promise<U> {\n if (this.isNone()) {\n return onNone()\n }\n\n return onSome(this.#val)\n }\n\n /**\n * Async pattern matching on both states of the ExperimentalOption.\n *\n * Async variant of `match` for when handlers return Promises.\n * Rejections from `Some` handler are propagated (not converted to `None`).\n *\n * @template U - The result type of both branches\n * @param cases - Object containing async handlers for both states\n * @returns Promise resolving to the result of the appropriate handler\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.Some(userId).matchAsync({\n * Some: async (id) => await fetchUser(id),\n * None: async () => await getDefaultUser()\n * });\n *\n * // With API calls\n * const data = await maybeConfig.matchAsync({\n * Some: async (config) => await loadWithConfig(config),\n * None: async () => await loadDefaults()\n * });\n * ```\n *\n * @see {@link match} for synchronous pattern matching\n * @see {@link foldAsync} for positional-argument async matching\n */\n async matchAsync<U>(cases: {\n Some: (val: T) => Promise<U>\n None: () => Promise<U>\n }): Promise<U> {\n if (this.isNone()) {\n return cases.None()\n }\n return cases.Some(this.#val)\n }\n\n /**\n * Pattern matches with a subset of cases, using a default for unhandled cases.\n *\n * Unlike `match` which requires all cases, `matchPartial` allows handling\n * only specific cases with a fallback default function.\n *\n * @template U - The result type\n * @param cases - Partial object with optional `Some` and `None` handlers\n * @param getDefault - Lazy default function for unhandled cases\n * @returns The result of the matching handler or the default\n *\n * @example\n * ```ts\n * // Only handle Some, default for None\n * ExperimentalOption.Some(42).matchPartial({ Some: (v) => v * 2 }, () => 0); // 84\n * ExperimentalOption.None.matchPartial({ Some: (v) => v * 2 }, () => 0); // 0\n *\n * // Only handle None\n * ExperimentalOption.Some(42).matchPartial({ None: () => -1 }, () => 100); // 100\n * ExperimentalOption.None.matchPartial({ None: () => -1 }, () => 100); // -1\n *\n * // Lazy default with function\n * experimentalOption.matchPartial(\n * { Some: (v) => process(v) },\n * () => computeExpensiveDefault()\n * );\n * ```\n *\n * @see {@link match} for exhaustive pattern matching\n */\n\n matchPartial<U>(\n cases: {\n Some?: (val: T) => NoInfer<U>\n None?: () => NoInfer<U>\n },\n getDefault: () => U,\n ): U {\n if (this.isNone()) {\n return cases.None ? cases.None() : getDefault()\n }\n\n return cases.Some ? cases.Some(this.#val) : getDefault()\n }\n\n /**\n * Transforms the contained value using the provided function.\n *\n * If `Some`, applies the function and wraps the result in a new `Some`.\n * If `None`, returns `None` without calling the function.\n *\n * This method rejects async mappers at compile time - use {@link mapAsync} for those.\n *\n * @template U - The type of the transformed value\n * @param fn - A function that transforms the contained value\n * @returns `Some<U>` with the transformed value, or `None`\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(5).map(x => x * 2); // Some(10)\n * ExperimentalOption.None.map(x => x * 2); // None\n *\n * // Chaining transforms\n * ExperimentalOption.Some(\"hello\")\n * .map(s => s.toUpperCase())\n * .map(s => `${s}!`)\n * .map(s => s.length);\n * // Some(6)\n *\n * // Type transformation\n * ExperimentalOption.Some(\"123\")\n * .map(s => parseInt(s, 10));\n * // Some(123)\n * ```\n *\n * @see {@link mapAsync} for async transformations\n * @see {@link flatMap} for chaining operations that return ExperimentalOptions\n * @see {@link mapOr} for unwrapping with transformation\n */\n map<U>(fn: (val: T) => Promise<U>): never\n map<U>(fn: (val: T) => U): ExperimentalOption<U>\n map<U>(fn: (val: T) => U): ExperimentalOption<U> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n return ExperimentalOption.Some(fn(this.#val))\n }\n\n /**\n * Transforms the contained value using an async function.\n *\n * If `Some`, awaits the async function and wraps the result in a new `Some`.\n * If `None`, returns a resolved `None` Promise without calling the function.\n *\n * @template U - The type of the transformed value\n * @param fn - An async function that transforms the contained value\n * @returns `Promise<Some<U>>` with the transformed value, or `Promise<None>`\n *\n * @example\n * ```ts\n * // Simple async transform\n * const result = await ExperimentalOption.Some(5).mapAsync(async x => {\n * return x * 2;\n * });\n * // Some(10)\n *\n * // Chaining with .then()\n * ExperimentalOption.Some(5)\n * .map(x => x * 2) // Some(10)\n * .mapAsync(async x => {\n * return await fetchData(x); // Some<Data>\n * })\n * .then(o => o.map(d => d.name)); // Promise<Some<string>>\n *\n * // Practical: API call after validation\n * const userData = await ExperimentalOption.Some(userId)\n * .mapAsync(async id => await fetchUser(id))\n * .then(o => o.mapAsync(async user => await fetchProfile(user.id)));\n * // Promise<ExperimentalOption<Profile>>\n * ```\n *\n * @see {@link map} for synchronous transformations\n */\n async mapAsync<U>(\n fn: (val: T) => Promise<U>,\n ): Promise<ExperimentalOption<U>> {\n if (this.isNone()) {\n return Promise.resolve(ExperimentalOption.None)\n }\n\n return fn(this.#val).then((u) => ExperimentalOption.Some(u))\n }\n\n /**\n * Maps the value or returns a default value (unwrapped).\n *\n * Unlike {@link map}, this returns the value directly (not wrapped in ExperimentalOption).\n * If `Some`, applies the function and returns the result.\n * If `None`, returns the default value without calling the function.\n *\n * @template U - The type of the result\n * @param defaultValue - The value to return if `None`\n * @param fn - A function to apply if `Some`\n * @returns The mapped value or the default\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(5).mapOr(0, x => x * 2); // 10\n * ExperimentalOption.None.mapOr(0, x => x * 2); // 0\n *\n * // Practical: formatting with fallback\n * const displayName = ExperimentalOption.fromNullable(user.name)\n * .mapOr(\"Anonymous\", name => name.toUpperCase());\n * // \"JOHN\" or \"Anonymous\"\n *\n * // With complex defaults\n * const balance = ExperimentalOption.fromNullable(account?.balance)\n * .mapOr(0, b => b.toFixed(2));\n * ```\n *\n * @see {@link map} for wrapped results\n * @see {@link mapOrAsync} for async transformations\n */\n mapOr<U>(defaultValue: U, fn: (val: T) => U): U {\n if (this.isNone()) {\n return defaultValue\n }\n\n return fn(this.#val)\n }\n\n /**\n * Maps the value using an async function or returns a default value.\n *\n * @template U - The type of the result\n * @param defaultValue - The value to return if `None`\n * @param fn - An async function to apply if `Some`\n * @returns `Promise<U>` with the mapped value or the default\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.Some(5).mapOrAsync(0, async x => {\n * return x * 2;\n * });\n * // 10\n *\n * const noneResult = await ExperimentalOption.None.mapOrAsync(0, async x => {\n * return x * 2;\n * });\n * // 0\n *\n * // Practical: async fetch with fallback\n * const balance = await ExperimentalOption.fromNullable(userId)\n * .mapOrAsync(0, async id => await getAccountBalance(id));\n * ```\n *\n * @see {@link mapOr} for synchronous transformations\n */\n async mapOrAsync<U>(defaultValue: U, fn: (val: T) => Promise<U>): Promise<U> {\n if (this.isNone()) {\n return defaultValue\n }\n\n return fn(this.#val)\n }\n\n /**\n * Chains operations that return ExperimentalOptions, flattening nested ExperimentalOptions.\n *\n * Also known as `bind` or `chain`. Use this to sequence operations where\n * each step depends on the previous value and may fail.\n *\n * If `Some`, applies the function and returns its result directly.\n * If `None`, returns `None` without calling the function.\n *\n * @template U - The type of the value in the returned ExperimentalOption\n * @param fn - A function that returns an ExperimentalOption\n * @returns The result of the function, or `None`\n *\n * @example\n * ```ts\n * // Basic chaining\n * ExperimentalOption.Some(5).flatMap(x => ExperimentalOption.Some(x + 1)); // Some(6)\n * ExperimentalOption.Some(5).flatMap(x => ExperimentalOption.None); // None\n * ExperimentalOption.None.flatMap(x => ExperimentalOption.Some(x + 1)); // None\n *\n * // Chaining optional operations\n * const email = findUser(userId)\n * .flatMap(user => ExperimentalOption.fromNullable(user.profile))\n * .flatMap(profile => ExperimentalOption.fromNullable(profile.avatar))\n * .flatMap(avatar => ExperimentalOption.fromNullable(avatar.url));\n *\n * // Practical: multi-step validation\n * const valid = ExperimentalOption.Some(input)\n * .flatMap(s => parseEmail(s))\n * .flatMap(email => checkDomain(email))\n * .flatMap(domain => resolveDomain(domain));\n * ```\n *\n * @see {@link flatMapAsync} for async operations\n * @see {@link map} for simple transformations\n * @see {@link gen} for imperative-style chaining\n */\n flatMap<U>(fn: (val: T) => ExperimentalOption<U>): ExperimentalOption<U> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n return fn(this.#val)\n }\n\n /**\n * Chains async operations that return ExperimentalOptions.\n *\n * @template U - The type of the value in the returned ExperimentalOption\n * @param fn - An async function that returns an ExperimentalOption\n * @returns `Promise<ExperimentalOption<U>>` with the result, or `Promise<None>`\n *\n * @example\n * ```ts\n * // Async database lookup chain\n * const profile = await ExperimentalOption.Some(userId)\n * .flatMapAsync(async id => await findUser(id))\n * .flatMapAsync(async user => await getProfile(user.id))\n * .flatMapAsync(async p => await getAvatar(p.avatarId));\n * // Promise<ExperimentalOption<Avatar>>\n *\n * // Practical: multi-step async pipeline\n * const result = await ExperimentalOption.Some(email)\n * .flatMapAsync(validateEmail)\n * .flatMapAsync(e => fetchUserByEmail(e))\n * .flatMapAsync(u => getUserPermissions(u.id));\n * ```\n *\n * @see {@link flatMap} for synchronous operations\n * @see {@link asyncGen} for imperative-style async chaining\n */\n async flatMapAsync<U>(\n fn: (val: T) => Promise<ExperimentalOption<U>>,\n ): Promise<ExperimentalOption<U>> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n return fn(this.#val)\n }\n\n /**\n * Converts `Some` to `None` if the predicate returns `false`.\n *\n * If `Some`, tests the predicate and returns `Some` if true, `None` if false.\n * If `None`, returns `None` without calling the predicate.\n *\n * @param pred - A predicate function to test the contained value\n * @returns `Some<T>` if predicate passes, else `None`\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(5).filter(x => x > 3); // Some(5)\n * ExperimentalOption.Some(5).filter(x => x > 10); // None\n * ExperimentalOption.None.filter(x => x > 3); // None\n *\n * // Age validation\n * const adult = ExperimentalOption.Some(age)\n * .filter(a => a >= 18);\n *\n * // Multiple filters\n * const valid = ExperimentalOption.Some(password)\n * .filter(pw => pw.length >= 8)\n * .filter(pw => /[A-Z]/.test(pw))\n * .filter(pw => /[0-9]/.test(pw));\n * ```\n *\n * @see {@link filterAsync} for async predicates\n * @see {@link fromPredicate} for creating ExperimentalOptions from predicates\n */\n filter(pred: (val: T) => boolean): ExperimentalOption<T> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n return pred(this.#val) ? this : ExperimentalOption.None\n }\n\n /**\n * Converts `Some` to `None` if the async predicate returns `false`.\n *\n * @param pred - An async predicate function to test the contained value\n * @returns `Promise<Some<T>>` if predicate passes, else `Promise<None>`\n *\n * @example\n * ```ts\n * // Async validation\n * const valid = await ExperimentalOption.Some(email)\n * .filterAsync(async e => await checkEmailDomain(e));\n *\n * // Practical: database validation\n * const unique = await ExperimentalOption.Some(username)\n * .filterAsync(async u => await isUsernameAvailable(u));\n * ```\n *\n * @see {@link filter} for synchronous predicates\n */\n async filterAsync(\n pred: (val: T) => Promise<boolean>,\n ): Promise<ExperimentalOption<T>> {\n if (this.isNone()) {\n return Promise.resolve(ExperimentalOption.None)\n }\n\n return pred(this.#val).then((passed) =>\n passed ? this : ExperimentalOption.None,\n )\n }\n\n /**\n * Pairs the original value with a derived value.\n *\n * Creates a tuple `[original, derived]` where the second value is computed\n * from the first using the provided function.\n *\n * This method rejects async mappers at compile time - use {@link zipAsync} for those.\n *\n * @template U - The type of the derived value\n * @param fn - A function that derives a value from the contained value\n * @returns `Some<[T, U]>` with the tuple, or `None`\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(5).zip(x => x * 2); // Some([5, 10])\n * ExperimentalOption.None.zip(x => x * 2); // None\n *\n * // Keep original while computing derived value\n * ExperimentalOption.Some(user).zip(u => u.permissions.length);\n * // Some([user, 5])\n *\n * // Practical: price with discount\n * const priceWithDiscount = ExperimentalOption.Some(100)\n * .zip(price => price * 0.9);\n * // Some([100, 90])\n *\n * // Derive metadata while keeping original\n * ExperimentalOption.Some(request).zip(req => ({\n * size: JSON.stringify(req).length,\n * timestamp: Date.now()\n * }));\n * // Some([request, { size, timestamp }])\n * ```\n *\n * @see {@link zipAsync} for async derivation\n * @see {@link flatZip} for combining with another ExperimentalOption\n */\n zip<U>(fn: (val: T) => Promise<U>): never\n zip<U>(fn: (val: T) => U): ExperimentalOption<[prev: T, curr: U]>\n zip<U>(fn: (val: T) => U): ExperimentalOption<[T, U]> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n return ExperimentalOption.Some([this.#val, fn(this.#val)])\n }\n\n /**\n * Pairs the original value with an async derived value.\n *\n * @template U - The type of the derived value\n * @param fn - An async function that derives a value from the contained value\n * @returns `Promise<Some<[T, U]>>` with the tuple, or `Promise<None>`\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.Some(user)\n * .zipAsync(async u => await fetchCount(u));\n * // Some([user, number])\n *\n * // Practical: user with additional data\n * const enriched = await ExperimentalOption.Some(userId)\n * .zipAsync(async id => await fetchUser(id))\n * .then(o => o.zipAsync(async ([id, user]) => await getStats(user.id)));\n * // Promise<ExperimentalOption<[userId, User, Stats]>>\n * ```\n *\n * @see {@link zip} for synchronous derivation\n */\n async zipAsync<U>(\n fn: (val: T) => Promise<U>,\n ): Promise<ExperimentalOption<[T, U]>> {\n if (this.isNone()) {\n return Promise.resolve(ExperimentalOption.None)\n }\n\n return fn(this.#val).then((u) => ExperimentalOption.Some([this.#val, u]))\n }\n\n /**\n * Pairs the original value with a value from another ExperimentalOption.\n *\n * Combines two independent ExperimentalOptions into a tuple. Both must be `Some` to succeed.\n *\n * @template U - The type of the value in the other ExperimentalOption\n * @param fn - A function that returns an ExperimentalOption to combine with\n * @returns `Some<[T, U]>` with both values, or `None`\n *\n * @example\n * ```ts\n * // Basic usage\n * ExperimentalOption.Some(5).flatZip(x => ExperimentalOption.Some(10)); // Some([5, 10])\n * ExperimentalOption.Some(5).flatZip(x => ExperimentalOption.None); // None\n * ExperimentalOption.None.flatZip(x => ExperimentalOption.Some(10)); // None\n *\n * // Practical: combine independent lookups\n * const productData = ExperimentalOption.Some(productId)\n * .flatZip(id => fetchProductPrice(id));\n * // ExperimentalOption<[productId, price]>\n *\n * // Multiple dependencies\n * const complete = ExperimentalOption.Some(userId)\n * .flatZip(id => fetchUser(id))\n * .flatMap(([id, user]) => ExperimentalOption.Some([id, user.profileId]))\n * .flatZip(([id, profileId]) => fetchProfile(profileId));\n * // ExperimentalOption<[userId, profileId, profile]>\n * ```\n *\n * @see {@link flatZipAsync} for async ExperimentalOptions\n * @see {@link zip} for derived values\n * @see {@link all} for combining multiple ExperimentalOptions at once\n */\n flatZip<U>(\n fn: (val: T) => ExperimentalOption<U>,\n ): ExperimentalOption<[T, U]> {\n if (this.isNone()) {\n return ExperimentalOption.None\n }\n\n const other = fn(this.#val)\n if (other.isNone()) {\n return ExperimentalOption.None\n }\n\n return ExperimentalOption.Some([this.#val, other.unwrap()])\n }\n\n /**\n * Pairs the original value with a value from an async ExperimentalOption.\n *\n * @template U - The type of the value in the other ExperimentalOption\n * @param fn - An async function that returns an ExperimentalOption\n * @returns `Promise<Some<[T, U]>>` with both values, or `Promise<None>`\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.Some(userId)\n * .flatZipAsync(async id => await fetchUser(id));\n * // ExperimentalOption<[userId, User]>\n *\n * // Practical: async pipeline\n * const enriched = await ExperimentalOption.Some(userId)\n * .flatZipAsync(async id => await fetchUser(id))\n * .then(o => o.flatMapAsync(async ([id, user]) =>\n * ExperimentalOption.Some([id, user, await fetchProfile(user.profileId)])\n * ));\n * ```\n *\n * @see {@link flatZip} for synchronous ExperimentalOptions\n */\n async flatZipAsync<U>(\n fn: (val: T) => Promise<ExperimentalOption<U>>,\n ): Promise<ExperimentalOption<[T, U]>> {\n if (this.isNone()) {\n return Promise.resolve(ExperimentalOption.None)\n }\n\n return fn(this.#val).then((other) => {\n if (other.isNone()) {\n return ExperimentalOption.None\n }\n return ExperimentalOption.Some([this.#val, other.unwrap()])\n })\n }\n\n /**\n * Executes a side effect function if `Some`, returning `this` unchanged.\n *\n * Useful for logging, debugging, or executing effects without breaking the chain.\n *\n * @param fn - A side effect function to execute with the contained value\n * @returns `this` (unchanged, for chaining)\n *\n * @example\n * ```ts\n * // Logging without breaking chain\n * ExperimentalOption.Some(user)\n * .tap(u => console.log(`Processing ${u.name}`))\n * .map(u => u.email);\n *\n * // Debugging\n * ExperimentalOption.Some(input)\n * .tap(val => console.log(\"Before:\", val))\n * .map(transform)\n * .tap(val => console.log(\"After:\", val));\n *\n * // Practical: audit trail\n * const result = ExperimentalOption.Some(transaction)\n * .tap((t) => auditLog(\"start\", t.id))\n * .flatMap((t) => process(t))\n * .tap((r) => auditLog(\"success\", r.id));\n * ```\n *\n * @see {@link tapAsync} for async side effects\n */\n tap<F extends (val: T) => unknown>(\n fn: ReturnType<F> extends PromiseLike<unknown> ? never : F,\n ): ExperimentalOption<T> {\n if (this.isSome()) {\n fn(this.#val)\n }\n return this\n }\n\n /**\n * Executes an async side effect function if `Some`, returning `this` unchanged.\n *\n * @param fn - An async side effect function to execute\n * @returns `Promise<ExperimentalOption<T>>` that resolves to `this`\n *\n * @example\n * ```ts\n * // Async logging\n * await ExperimentalOption.Some(user)\n * .tapAsync(async u => await logAnalytics(u.id))\n * .map(u => u.email);\n *\n * // Practical: metrics collection\n * const result = await ExperimentalOption.Some(request)\n * .tapAsync(async req => await trackMetric(\"request_start\", req.id))\n * .flatMapAsync(async req => await processRequest(req))\n * .tapAsync(async res => await trackMetric(\"request_success\", res.id));\n * ```\n *\n * @see {@link tap} for synchronous side effects\n */\n async tapAsync(\n fn: (val: T) => Promise<void>,\n ): Promise<ExperimentalOption<T>> {\n if (this.isSome()) {\n return fn(this.#val).then(() => this)\n }\n return Promise.resolve(this)\n }\n\n /**\n * Converts this ExperimentalOption to a Result.\n *\n * `Some` becomes `Ok`, `None` becomes `Err` with the provided error.\n *\n * @template E - The type of the error for the `Err` variant\n * @param error - The error value to use if this is `None`\n * @returns `Result<T, E>` with the value or error\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(42).toResult(\"was none\"); // Ok(42)\n * ExperimentalOption.None.toResult(\"was none\"); // Err(\"was none\")\n *\n * // Practical: convert to Result for error handling\n * const user = ExperimentalOption.fromNullable(getUser())\n * .toResult(new Error(\"User not found\"));\n *\n * // With custom error types\n * const config = ExperimentalOption.fromNullable(loadConfig())\n * .toResult({ code: \"CONFIG_MISSING\", message: \"Config file not found\" });\n * ```\n *\n * @see {@link ExperimentalResult} for the Result type\n */\n toResult<E>(error: E): ExperimentalResult<T, E> {\n if (this.isNone()) {\n return ExperimentalResult.Err(error)\n }\n return ExperimentalResult.Ok(this.#val)\n }\n\n /**\n * Maps over array elements inside an `ExperimentalOption<Array<T>>`.\n *\n * Only callable when `T` is an array type. Applies the mapper to each\n * element if `Some`, or returns `None`.\n *\n * @template Inner - The element type of the array\n * @template Out - The output element type\n * @param mapper - A function to transform each array element\n * @returns `Some<Out[]>` with mapped array, or `None`\n * @throws {TypeError} if called on a non-array ExperimentalOption\n *\n * @example\n * ```ts\n * ExperimentalOption.Some([1, 2, 3]).innerMap(n => n * 2);\n * // Some([2, 4, 6])\n *\n * ExperimentalOption.None.innerMap(n => n * 2);\n * // None\n *\n * // Practical: transform list results\n * const users = await fetchUsers() // ExperimentalOption<User[]>\n * .innerMap(u => u.name)\n * .innerMap(names => names.sort());\n * // Some<string[]>\n *\n * // Error case\n * ExperimentalOption.Some(42).innerMap(x => x * 2);\n * // throws TypeError: innerMap can only be called on ExperimentalOption<Array<T>>\n * ```\n *\n * @see {@link map} for transforming the contained value directly\n */\n innerMap<Inner, Out>(\n this: ExperimentalOption<Array<Inner>>,\n mapper: (val: Inner) => Out,\n ): ExperimentalOption<Out[]> {\n if (this.isNone()) return ExperimentalOption.None\n\n if (!Array.isArray(this.#val)) {\n throw new TypeError(\n \"innerMap can only be called on ExperimentalOption<Array<T>>\",\n )\n }\n\n return ExperimentalOption.Some((this.#val as Inner[]).map(mapper))\n }\n\n /**\n * Returns a string representation of the ExperimentalOption.\n *\n * @returns A string describing the ExperimentalOption state and value\n *\n * @example\n * ```ts\n * ExperimentalOption.Some(42).toString(); // \"ExperimentalOption::Some(42)\"\n * ExperimentalOption.None.toString(); // \"ExperimentalOption::None\"\n * ExperimentalOption.Some(\"hello\").toString(); // \"ExperimentalOption::Some(hello)\"\n * ```\n */\n toString(): string {\n if (this.isNone()) return \"ExperimentalOption::None\"\n return `ExperimentalOption::Some(${String(this.#val)})`\n }\n\n /**\n * Makes ExperimentalOption iterable for use with generator-based syntax.\n *\n * Yields self and returns the unwrapped value when resumed.\n * Used internally by {@link ExperimentalOption.gen} for `yield*` syntax.\n *\n * @example\n * ```ts\n * const result = ExperimentalOption.gen(function* () {\n * const value = yield* ExperimentalOption.Some(42);\n * return value * 2;\n * });\n * // Some(84)\n * ```\n *\n * @internal\n */\n *[Symbol.iterator](): Generator<ExperimentalOption<T>, T, unknown> {\n const trace = new Error().stack\n return (yield new CapturedTrace(\n this,\n trace,\n ) as unknown as ExperimentalOption<T>) as T\n }\n\n /**\n * Makes ExperimentalOption iterable for use with async generator-based syntax.\n *\n * Yields self and returns the unwrapped value when resumed.\n * Used internally by {@link ExperimentalOption.asyncGen} for `yield*` syntax.\n *\n * @example\n * ```ts\n * const result = await ExperimentalOption.asyncGen(async function* () {\n * const value = yield* await Promise.resolve(ExperimentalOption.Some(42));\n * return value * 2;\n * });\n * // Some(84)\n * ```\n *\n * @internal\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<\n ExperimentalOption<T>,\n Awaited<T>,\n unknown\n > {\n const trace = new Error().stack\n return (yield new CapturedTrace(\n this,\n trace,\n ) as unknown as ExperimentalOption<T>) as Awaited<T>\n }\n\n /**\n * Generator-based syntax for chaining ExperimentalOption operations (simplified, no adapter).\n *\n * Provides imperative-style code while maintaining functional ExperimentalOption handling.\n * Use `yield*` to unwrap ExperimentalOptions or short-circuit on `None`.\n *\n * Short-circuits on first `None`, returning singleton `None`. Uses iteration\n * instead of recursion to avoid stack overflow on deep chains.\n *\n * @template T - The return type of the generator\n * @param genFn - A generator function that yields ExperimentalOptions\n * @returns `Some<T>` with the generator's return value, or `None`\n *\n * @example\n * ```ts\n * // Simple sync chain\n * const result = ExperimentalOption.gen(function* () {\n * const a = yield* ExperimentalOption.Some(1);\n * const b = yield* ExperimentalOption.Some(2);\n * return a + b;\n * });\n * // Some(3)\n *\n * // None short-circuit\n * const shortCircuit = ExperimentalOption.gen(function* () {\n * const a = yield* ExperimentalOption.Some(1);\n * const b = yield* ExperimentalOption.None; // Short-circuits here\n * const c = yield* ExperimentalOption.Some(3); // Never executes\n * return a + b + c;\n * });\n * // None\n *\n * // Chaining optional operations\n * const email = ExperimentalOption.gen(function* () {\n * const user = yield* findUser(userId);\n * const profile = yield* ExperimentalOption.fromNullable(user.profile);\n * const settings = yield* ExperimentalOption.fromNullable(profile.settings);\n * return settings.email;\n * });\n *\n * // Nested optional access\n * const city = ExperimentalOption.gen(function* () {\n * const user = yield* ExperimentalOption.fromNullable(getUser());\n * const address = yield* ExperimentalOption.fromNullable(user?.address);\n * const city = yield* ExperimentalOption.fromNullable(address?.city);\n * return city;\n * });\n * ```\n *\n * @see {@link genAdapter} for better type inference in complex chains\n * @see {@link asyncGen} for async operations\n */\n static gen<T>(\n this: void,\n genFn: () => Generator<ExperimentalOption<unknown>, T, unknown>,\n ): ExperimentalOption<T> {\n const iterator = genFn()\n\n // Use iteration instead of recursion to avoid stack overflow\n let nextArg: unknown\n let currentResult: ExperimentalOption<T>\n\n let naturalCompleted = false\n try {\n while (true) {\n const next = iterator.next(nextArg)\n\n if (next.done) {\n naturalCompleted = true\n // Generator completed successfully - wrap return value in Some\n currentResult = ExperimentalOption.Some(next.value)\n break\n }\n\n // next.value is the ExperimentalOption that was yielded\n let yielded = next.value as ExperimentalOption<unknown>\n\n if (isCapturedTrace(yielded)) {\n yielded = yielded.value as ExperimentalOption<unknown>\n }\n\n if (yielded.isNone()) {\n // Early termination on None - return singleton None\n currentResult = ExperimentalOption.None\n break\n }\n\n // Unwrap the Some value and pass it back to the generator\n nextArg = yielded.unwrap()\n }\n } finally {\n if (!naturalCompleted) {\n closeGenerator(iterator, (yielded) => {\n let effect = yielded\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n const option = effect as ExperimentalOption<unknown>\n return option.isNone() ? undefined : option.unwrap()\n })\n }\n }\n\n return currentResult\n }\n\n /**\n * Generator-based syntax for chaining ExperimentalOption operations with an adapter function.\n *\n * Provides better type inference and IDE support compared to {@link gen}.\n * The `$` adapter wraps ExperimentalOptions and enables clearer type tracking.\n *\n * Short-circuits on first `None`, returning singleton `None`. Uses iteration\n * instead of recursion to avoid stack overflow on deep chains.\n *\n * @template Eff - The effect type (inferred from usage)\n * @template T - The return type of the generator\n * @param genFn - A generator function receiving an adapter `$`\n * @returns `Some<T>` with the generator's return value, or `None`\n *\n * @example\n * ```ts\n * // Better type inference\n * const result = ExperimentalOption.genAdapter(function* ($) {\n * const a = yield* $(ExperimentalOption.Some(1));\n * const b = yield* $(ExperimentalOption.Some(2));\n * return a + b;\n * });\n * // Some(3)\n *\n * // Deep nested access with better type safety\n * const email = ExperimentalOption.genAdapter(function* ($) {\n * const user = yield* $(ExperimentalOption.fromNullable(apiResponse?.user));\n * const profile = yield* $(ExperimentalOption.fromNullable(user?.profile));\n * const contact = yield* $(ExperimentalOption.fromNullable(profile?.contact));\n * return contact?.email;\n * });\n *\n * // Complex validation chain\n * const validConfig = ExperimentalOption.genAdapter(function* ($) {\n * const raw = yield* $(loadConfig());\n * const parsed = yield* $(parseConfig(raw));\n * const validated = yield* $(validateConfig(parsed));\n * return validated;\n * });\n * ```\n *\n * @see {@link gen} for simpler chains without adapter\n * @see {@link asyncGenAdapter} for async operations\n */\n // biome-ignore lint/suspicious/noExplicitAny: inference\n static genAdapter<Eff extends OptionYieldWrap<any>, T>(\n this: void,\n genFn: (\n adapter: <A>(option: ExperimentalOption<A>) => OptionYieldWrap<A>,\n // biome-ignore lint/suspicious/noExplicitAny: inference\n ) => Generator<Eff, T, any>,\n ): ExperimentalOption<T> {\n const adapter = <A>(option: ExperimentalOption<A>): OptionYieldWrap<A> =>\n new OptionYieldWrap(option)\n\n const iterator = genFn(adapter)\n\n // Use iteration instead of recursion to avoid stack overflow\n let nextArg: unknown\n let currentResult: ExperimentalOption<T>\n\n let naturalCompleted = false\n try {\n while (true) {\n const next = iterator.next(nextArg)\n\n if (next.done) {\n naturalCompleted = true\n // Generator completed successfully - wrap return value in Some\n currentResult = ExperimentalOption.Some(next.value)\n break\n }\n\n // next.value is the OptionYieldWrap that was yielded\n const wrapped = next.value as OptionYieldWrap<unknown>\n let option = wrapped.option\n\n if (isCapturedTrace(option)) {\n option = (option as CapturedTrace<ExperimentalOption<unknown>>)\n .value as ExperimentalOption<unknown>\n }\n\n if (option.isNone()) {\n // Early termination on None - return singleton None\n currentResult = ExperimentalOption.None\n break\n }\n\n // Unwrap the Some value and pass it back to the generator\n nextArg = option.unwrap()\n }\n } finally {\n if (!naturalCompleted) {\n closeGenerator(iterator, (yielded) => {\n let effect = yielded\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n effect = (effect as OptionYieldWrap<unknown>).option\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n const option = effect as ExperimentalOption<unknown>\n return option.isNone() ? undefined : option.unwrap()\n })\n }\n }\n\n return currentResult\n }\n\n /**\n * Async generator-based syntax for chaining ExperimentalOption operations (simplified, no adapter).\n *\n * Use `yield*` with `ExperimentalOption<T>` values directly. For `Promise<ExperimentalOption<T>>`,\n * await first then `yield*`.\n *\n * Short-circuits on first `None`, returning singleton `None`. Uses async iteration\n * instead of recursion to avoid stack overflow on deep chains.\n *\n * @template T - The return type of the generator\n * @param genFn - An async generator function that yields ExperimentalOptions\n * @returns `Promise<Some<T>>` with the generator's return value, or `Promise<None>`\n *\n * @example\n * ```ts\n * // Simple async chain\n * const result = await ExperimentalOption.asyncGen(async function* () {\n * const a = yield* ExperimentalOption.Some(1);\n * const b = yield* await asyncOperation(a); // await Promise<ExperimentalOption> first\n * const c = yield* ExperimentalOption.Some(3);\n * return a + b + c;\n * });\n * // Some(result)\n *\n * // None short-circuit in async\n * const shortCircuit = await ExperimentalOption.asyncGen(async function* () {\n * const data = yield* await fetchOptionalData();\n * const parsed = yield* parse(data); // Short-circuits on None\n * const validated = yield* validate(parsed); // Never executes\n * return validated;\n * });\n * // None\n *\n * // Mixed sync/async workflow\n * const result = await ExperimentalOption.asyncGen(async function* () {\n * const id = yield* ExperimentalOption.Some(parseInt(input)); // sync\n * const user = yield* await fetchUser(id); // async\n * const profile = yield* ExperimentalOption.fromNullable(user?.profile); // sync\n * const enriched = yield* await enrichProfile(profile); // async\n * return enriched;\n * });\n *\n * // Complex pipeline with multiple optional steps\n * async function processLead(email: string): Promise<ExperimentalOption<Lead>> {\n * return await ExperimentalOption.asyncGen(async function* () {\n * const normalized = yield* ExperimentalOption.Some(normalizeEmail(email));\n * const existing = yield* await findExistingLead(normalized);\n * const enriched = yield* await enrichLeadData(existing);\n * const validated = yield* validateLead(enriched);\n * return validated;\n * });\n * }\n * ```\n *\n * @see {@link asyncGenAdapter} for better type inference and cleaner syntax\n * @see {@link gen} for synchronous operations\n */\n static async asyncGen<T>(\n this: void,\n genFn: () => AsyncGenerator<ExperimentalOption<unknown>, T, unknown>,\n ): Promise<ExperimentalOption<T>> {\n const iterator = genFn()\n\n // Use iteration instead of recursion to avoid stack overflow\n let nextArg: unknown\n let currentResult: ExperimentalOption<T>\n\n let naturalCompleted = false\n try {\n while (true) {\n const next = await iterator.next(nextArg)\n\n if (next.done) {\n naturalCompleted = true\n // Generator completed successfully - wrap return value in Some\n currentResult = ExperimentalOption.Some(next.value)\n break\n }\n\n // next.value is an ExperimentalOption (user awaits promises before yielding)\n let option = next.value as ExperimentalOption<unknown>\n\n if (isCapturedTrace(option)) {\n option = option.value as ExperimentalOption<unknown>\n }\n\n if (option.isNone()) {\n // Early termination on None - return singleton None\n currentResult = ExperimentalOption.None\n break\n }\n\n // Unwrap the Some value\n nextArg = await option.unwrap()\n }\n } finally {\n if (!naturalCompleted) {\n await closeAsyncGenerator(iterator, async (yielded) => {\n let effect = await yielded\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n const option = effect as ExperimentalOption<unknown>\n return option.isNone() ? undefined : option.unwrap()\n })\n }\n }\n\n return currentResult\n }\n\n /**\n * Async generator-based syntax for chaining ExperimentalOption operations with an adapter function.\n *\n * The `$` adapter handles both sync `ExperimentalOption<T>` and async `Promise<ExperimentalOption<T>>`,\n * automatically awaiting promises. This provides cleaner syntax for mixed sync/async workflows.\n *\n * Short-circuits on first `None`, returning singleton `None`. Uses async iteration\n * instead of recursion to avoid stack overflow on deep chains.\n *\n * @template Eff - The effect type (inferred from usage)\n * @template T - The return type of the generator\n * @param genFn - An async generator function receiving an adapter `$`\n * @returns `Promise<Some<T>>` with the generator's return value, or `Promise<None>`\n *\n * @example\n * ```ts\n * // No need to manually await - adapter handles it\n * const result = await ExperimentalOption.asyncGenAdapter(async function* ($) {\n * const a = yield* $(ExperimentalOption.Some(1)); // sync ExperimentalOption\n * const b = yield* $(asyncOperation(a)); // Promise<ExperimentalOption> - auto-awaited\n * const c = yield* $(ExperimentalOption.Some(3));\n * return a + b + c;\n * });\n *\n * // Complex workflow with database and API calls\n * const userData = await ExperimentalOption.asyncGenAdapter(async function* ($) {\n * const session = yield* $(getSession()); // Promise<ExperimentalOption<Session>>\n * const userId = yield* $(ExperimentalOption.fromNullable(session?.userId));\n * const profile = yield* $(await fetchProfile(userId)); // Promise<ExperimentalOption<Profile>>\n * const preferences = yield* $(ExperimentalOption.fromNullable(profile?.preferences));\n * const enriched = yield* $(await enrichPreferences(preferences));\n * return enriched;\n * });\n *\n * // Real-world: Optional data enrichment\n * async function getProductDetails(productId: string): Promise<ExperimentalOption<ProductDetails>> {\n * return await ExperimentalOption.asyncGenAdapter(async function* ($) {\n * const product = yield* $(await fetchProduct(productId));\n * const pricing = yield* $(await fetchPricing(product.sku));\n * const inventory = yield* $(await checkInventory(product.id));\n * const reviews = yield* $(await fetchReviews(product.id));\n * const related = yield* $(await fetchRelatedProducts(product.category));\n *\n * return { product, pricing, inventory, reviews, related };\n * });\n * }\n * ```\n *\n * @see {@link asyncGen} when you want explicit `await` for async operations\n * @see {@link genAdapter} for synchronous operations\n */\n // biome-ignore lint/suspicious/noExplicitAny: inference\n static async asyncGenAdapter<Eff extends AsyncOptionYieldWrap<any>, T>(\n this: void,\n genFn: (\n adapter: <A>(\n option: ExperimentalOption<A> | Promise<ExperimentalOption<A>>,\n ) => AsyncOptionYieldWrap<A>,\n // biome-ignore lint/suspicious/noExplicitAny: inference\n ) => AsyncGenerator<Eff, T, any>,\n ): Promise<ExperimentalOption<T>> {\n const adapter = <A>(\n option: ExperimentalOption<A> | Promise<ExperimentalOption<A>>,\n ): AsyncOptionYieldWrap<A> => new AsyncOptionYieldWrap(option)\n\n const iterator = genFn(adapter)\n\n // Use iteration instead of recursion to avoid stack overflow\n let nextArg: unknown\n let currentResult: ExperimentalOption<T>\n\n let naturalCompleted = false\n try {\n while (true) {\n const next = await iterator.next(nextArg)\n\n if (next.done) {\n naturalCompleted = true\n // Generator completed successfully - wrap return value in Some\n currentResult = ExperimentalOption.Some(next.value)\n break\n }\n\n // next.value is the AsyncOptionYieldWrap that was yielded\n const wrapped = next.value as AsyncOptionYieldWrap<unknown>\n let option = await wrapped.option\n\n if (isCapturedTrace(option)) {\n option = (option as CapturedTrace<ExperimentalOption<unknown>>)\n .value as ExperimentalOption<unknown>\n }\n\n if (option.isNone()) {\n // Early termination on None - return singleton None\n currentResult = ExperimentalOption.None\n break\n }\n\n // Unwrap the Some value\n nextArg = await option.unwrap()\n }\n } finally {\n if (!naturalCompleted) {\n await closeAsyncGenerator(iterator, async (yielded) => {\n let effect = await yielded\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n effect = await (effect as AsyncOptionYieldWrap<unknown>).option\n if (isCapturedTrace(effect)) {\n effect = effect.value\n }\n const option = effect as ExperimentalOption<unknown>\n return option.isNone() ? undefined : option.unwrap()\n })\n }\n }\n\n return currentResult\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,gBAAb,cAAmC,MAAM;CAC9B,OAAO;CAEhB,cAAc;EACZ,MAAM,8CAA8C;CACtD;AACF;AAEA,MAAM,qBAAqB,IAAI,cAAc;AAE7C,MAAM,WAAW,OAAO,0BAA0B;;;;;;AAqBlD,IAAM,kBAAN,MAAyB;CACF;CAArB,YAAqB,QAA+B;EAA/B;CAAgC;CAErD,EAAE,OAAO,YAAuD;EAC9D,OAAQ,MAAM;CAChB;AACF;;;;;;AAOA,IAAM,uBAAN,MAA8B;CACnB;CAET,YAAY,QAAgE;EAC1E,KAAK,SACHA,4BAAc,MAAM,IAAI,SAAS,QAAQ,QAAQ,MAAM;CAE3D;CAEA,QAAQ,OAAO,iBAIb;EACA,OAAQ,MAAM;CAChB;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,IAAa,qBAAb,MAAa,mBAAsB;;CAExB;CAEA;CAED,YAAY,KAAQ,KAAsB;EAChD,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;;;;;;;;;;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