happy-rusty 1.3.0 → 1.3.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/dist/main.cjs +1 -1
- package/dist/main.cjs.map +1 -1
- package/dist/main.mjs +1 -1
- package/dist/main.mjs.map +1 -1
- package/docs/functions/Err.md +1 -1
- package/docs/functions/Ok.md +1 -1
- package/docs/functions/Some.md +1 -1
- package/docs/functions/isOption.md +1 -1
- package/docs/functions/isResult.md +1 -1
- package/docs/functions/promiseToAsyncResult.md +1 -1
- package/docs/interfaces/None.md +28 -28
- package/docs/interfaces/Option.md +27 -27
- package/docs/interfaces/Result.md +29 -29
- package/docs/type-aliases/AsyncIOResult.md +1 -1
- package/docs/type-aliases/AsyncOption.md +1 -1
- package/docs/type-aliases/AsyncResult.md +1 -1
- package/docs/type-aliases/IOResult.md +1 -1
- package/docs/variables/None.md +1 -1
- package/docs/variables/RESULT_FALSE.md +1 -1
- package/docs/variables/RESULT_TRUE.md +1 -1
- package/docs/variables/RESULT_ZERO.md +1 -1
- package/package.json +2 -2
- package/src/enum/prelude.ts +1 -1
package/dist/main.cjs
CHANGED
package/dist/main.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.cjs","sources":["../src/enum/symbols.ts","../src/enum/helpers.ts","../src/enum/prelude.ts","../src/enum/constants.ts","../src/enum/extensions.ts"],"sourcesContent":["/**\n * Symbol for Option kind: `Some` or `None`.\n */\nexport const OptionKindSymbol = Symbol('Option kind');\n\n/**\n * Symbol for Result kind: `Ok` or `Err`.\n */\nexport const ResultKindSymbol = Symbol('Result kind');","import type { Option, Result } from './core.ts';\nimport { OptionKindSymbol, ResultKindSymbol } 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 */\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/**\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 */\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}","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { Option, Result } from './core.ts';\nimport { isOption, isResult } from './helpers.ts';\nimport { OptionKindSymbol, ResultKindSymbol } from './symbols.ts';\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 unwrapOr<T>(defaultValue: T): T;\n unwrapOrElse<T>(fn: () => T): T;\n\n transpose(): Result<None, never>;\n\n filter(predicate: (value: never) => boolean): None;\n flatten(): None;\n map<U>(fn: (value: never) => U): None;\n\n zip<U>(other: Option<U>): None;\n zipWith<U, R>(other: Option<U>, fn: (value: never, otherValue: U) => R): None;\n unzip(): [None, None];\n\n and<U>(other: Option<U>): None;\n andThen<U>(fn: (value: never) => Option<U>): None;\n or<T>(other: Option<T>): Option<T>;\n orElse<T>(fn: () => Option<T>): Option<T>;\n xor<T>(other: Option<T>): Option<T>;\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 *\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> = {\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'Some',\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\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\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<T, E>(): Result<Option<T>, E> {\n const r = value as unknown as Result<T, E>;\n assertResult(r);\n return r.isOk() ? Ok(Some(r.unwrap())) : Err(r.unwrapErr());\n },\n\n filter(predicate: (value: T) => boolean): Option<T> {\n return predicate(value) ? some : None;\n },\n flatten<T>(): Option<T> {\n const o = value as unknown as Option<T>;\n assertOption(o);\n return o;\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(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(other);\n return other.isSome() ? Some(fn(value, other.unwrap())) : None;\n },\n unzip<T, U>(): [Option<T>, Option<U>] {\n const tuple = value as unknown as [T, U];\n\n if (!Array.isArray(tuple) || tuple.length !== 2) {\n throw new TypeError('Unzip format is incorrect.');\n }\n\n const [a, b] = tuple;\n return [Some(a), Some(b)];\n },\n\n and<U>(other: Option<U>): Option<U> {\n assertOption(other);\n return other;\n },\n andThen<U>(fn: (value: T) => Option<U>): Option<U> {\n return 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 xor(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other.isSome() && other.unwrap() === value;\n },\n\n toString(): string {\n return `Some(${ 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 */\nexport const None = Object.freeze<None>({\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'None',\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\n expect(msg: string): never {\n throw new TypeError(msg);\n },\n unwrap(): never {\n throw new TypeError('Called `Option::unwrap()` 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\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\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 or<T>(other: Option<T>): Option<T> {\n assertOption(other);\n return other;\n },\n orElse<T>(fn: () => Option<T>): Option<T> {\n return fn();\n },\n xor<T>(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other === None;\n },\n\n toString(): string {\n return 'None';\n },\n}) as 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 *\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>(value: T): Result<T, E> {\n const ok: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Ok',\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);\n },\n isErrAnd(_predicate: (error: E) => boolean): false {\n return false;\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: (error: E) => T): T {\n return value;\n },\n\n expectErr(msg: string): E {\n throw new TypeError(`${ msg }: ${ value }`);\n },\n unwrapErr(): E {\n throw new TypeError('Called `Result::unwrapErr()` on an `Ok` value');\n },\n\n ok(): Option<T> {\n return Some(value);\n },\n err(): None {\n return None;\n },\n transpose<T>(): Option<Result<T, E>> {\n const o = value as Option<T>;\n assertOption(o);\n return o.isSome() ? Some(Ok(o.unwrap())) : None;\n },\n\n map<U>(fn: (value: T) => U): Result<U, E> {\n return Ok(fn(value));\n },\n mapErr<F>(_fn: (error: E) => F): Result<T, F> {\n return Ok(value);\n },\n mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n return fn(value);\n },\n mapOrElse<U>(_defaultFn: (error: E) => U, fn: (value: T) => U): U {\n return fn(value);\n },\n flatten<T>(): Result<T, E> {\n const r = value as Result<T, E>;\n assertResult(r);\n return r;\n },\n\n and<U>(other: Result<U, E>): Result<U, E> {\n assertResult(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);\n },\n orElse<F>(_fn: (error: E) => Result<T, F>): Result<T, F> {\n return ok as unknown as Result<T, F>;\n },\n\n inspect(fn: (value: T) => void): Result<T, E> {\n fn(value);\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(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('Called `Result::asErr()` on an `Ok` value');\n },\n\n toString(): string {\n return `Ok(${ value })`;\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 *\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, E>(error: E): Result<T, E> {\n const err: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Err',\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 isErrAnd(predicate: (error: E) => boolean): boolean {\n return predicate(error);\n },\n\n expect(msg: string): T {\n throw new TypeError(`${ msg }: ${ error }`);\n },\n unwrap(): T {\n throw new TypeError('Called `Result::unwrap()` 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\n expectErr(_msg: string): E {\n return error;\n },\n unwrapErr(): E {\n return error;\n },\n\n ok(): None {\n return None;\n },\n err(): Option<E> {\n return Some(error);\n },\n transpose<T>(): Option<Result<T, E>> {\n return Some(err as unknown as Result<T, 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<T>(): Result<T, E> {\n return err as unknown as Result<T, 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(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 orElse<F>(fn: (error: E) => Result<T, F>): Result<T, F> {\n return 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(other);\n return other.isErr() && other.unwrapErr() === error;\n },\n\n asOk(): never {\n throw new TypeError('Called `Result::asOk()` on an `Err` value');\n },\n asErr<U>(): Result<U, E> {\n return err as unknown as Result<U, E>;\n },\n\n toString(): string {\n return `Err(${ error })`;\n },\n } as const;\n\n return err;\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 */\nfunction assertOption<T>(o: Option<T>): void {\n if (!isOption(o)) {\n throw new TypeError(`This(${ o }) is not an Option`);\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 */\nfunction assertResult<T, E>(r: Result<T, E>): void {\n if (!isResult(r)) {\n throw new TypeError(`This(${ r }) is not a Result`);\n }\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Result } from './core.ts';\nimport { Ok } from './prelude.ts';\n\n/**\n * Exports some Result constants.\n */\n\n/**\n * Result constant for `true`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_TRUE: Result<boolean, any> = Ok(true);\n\n/**\n * Result constant for `false`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_FALSE: Result<boolean, any> = Ok(false);\n\n/**\n * Result constant for `0`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_ZERO: Result<number, any> = Ok(0);","import type { Result } from './core.ts';\nimport { Err, Ok } from './prelude.ts';\n\n/**\n * Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.\n * This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @typeParam E - The type of the error that the promise may reject with, defaults to `Error`.\n * @param p - The promise to convert into a `Result` type.\n * @returns A promise that resolves to a `Result<T, E>`. If the input promise `p` resolves, the resulting promise will resolve with `Ok<T>`. If the input promise `p` rejects, the resulting promise will resolve with `Err<E>`.\n *\n * @example\n * ```ts\n * async function example() {\n * const result = await promiseToAsyncResult(fetchData());\n * if (result.isOk()) {\n * console.log('Data:', result.unwrap());\n * } else {\n * console.error('Error:', result.unwrapErr());\n * }\n * }\n * ```\n */\nexport function promiseToAsyncResult<T, E = Error>(p: Promise<T>): Promise<Result<T, E>> {\n return p.then((x): Result<T, E> => {\n return Ok(x);\n }).catch((err: E): Result<T, E> => {\n return Err(err);\n });\n}"],"names":[],"mappings":";;AAGa,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA,CAAA;AAKvC,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA;;ACE7C,SAAS,SAAY,CAA4B,EAAA;AAEpD,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE,CAAA;AAUO,SAAS,SAAe,CAA+B,EAAA;AAE1D,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE;;AC4BO,SAAS,KAAQ,KAAqB,EAAA;AACzC,EAAA,MAAM,IAAkB,GAAA;AAAA,IACpB,CAAC,MAAO,CAAA,WAAW,GAAG,QAAA;AAAA,IACtB,CAAC,gBAAgB,GAAG,MAAA;AAAA,IAEpB,MAAe,GAAA;AACX,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAAA,IACA,MAAgB,GAAA;AACZ,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,UAAU,SAA2C,EAAA;AACjD,MAAA,OAAO,UAAU,KAAK,CAAA,CAAA;AAAA,KAC1B;AAAA,IAEA,OAAO,IAAiB,EAAA;AACpB,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,MAAY,GAAA;AACR,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,SAAS,aAAqB,EAAA;AAC1B,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,aAAa,GAAiB,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A;AAM3C,MAAA,YAAA,GAAqC,GAAG,KAAK,EAAA;AAM7C,MAAA,WAAA,GAAmC,GAAG,CAAC;;ACA7C,SAAS,qBAAmC,CAAsC,EAAA;AACrF,EAAO,OAAA,CAAA,CAAE,IAAK,CAAA,CAAC,CAAoB,KAAA;AAC/B,IAAA,OAAO,GAAG,CAAC,CAAA,CAAA;AAAA,GACd,CAAA,CAAE,KAAM,CAAA,CAAC,GAAyB,KAAA;AAC/B,IAAA,OAAO,IAAI,GAAG,CAAA,CAAA;AAAA,GACjB,CAAA,CAAA;AACL;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"main.cjs","sources":["../src/enum/symbols.ts","../src/enum/helpers.ts","../src/enum/prelude.ts","../src/enum/constants.ts","../src/enum/extensions.ts"],"sourcesContent":["/**\n * Symbol for Option kind: `Some` or `None`.\n */\nexport const OptionKindSymbol = Symbol('Option kind');\n\n/**\n * Symbol for Result kind: `Ok` or `Err`.\n */\nexport const ResultKindSymbol = Symbol('Result kind');","import type { Option, Result } from './core.ts';\nimport { OptionKindSymbol, ResultKindSymbol } 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 */\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/**\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 */\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}","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { Option, Result } from './core.ts';\nimport { isOption, isResult } from './helpers.ts';\nimport { OptionKindSymbol, ResultKindSymbol } from './symbols.ts';\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 unwrapOr<T>(defaultValue: T): T;\n unwrapOrElse<T>(fn: () => T): T;\n\n transpose(): Result<None, never>;\n\n filter(predicate: (value: never) => boolean): None;\n flatten(): None;\n map<U>(fn: (value: never) => U): None;\n\n zip<U>(other: Option<U>): None;\n zipWith<U, R>(other: Option<U>, fn: (value: never, otherValue: U) => R): None;\n unzip(): [None, None];\n\n and<U>(other: Option<U>): None;\n andThen<U>(fn: (value: never) => Option<U>): None;\n or<T>(other: Option<T>): Option<T>;\n orElse<T>(fn: () => Option<T>): Option<T>;\n xor<T>(other: Option<T>): Option<T>;\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 *\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> = {\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'Some',\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\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\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<T, E>(): Result<Option<T>, E> {\n const r = value as unknown as Result<T, E>;\n assertResult(r);\n return r.isOk() ? Ok(Some(r.unwrap())) : Err(r.unwrapErr());\n },\n\n filter(predicate: (value: T) => boolean): Option<T> {\n return predicate(value) ? some : None;\n },\n flatten<T>(): Option<T> {\n const o = value as unknown as Option<T>;\n assertOption(o);\n return o;\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(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(other);\n return other.isSome() ? Some(fn(value, other.unwrap())) : None;\n },\n unzip<T, U>(): [Option<T>, Option<U>] {\n const tuple = value as unknown as [T, U];\n\n if (!Array.isArray(tuple) || tuple.length !== 2) {\n throw new TypeError('Unzip format is incorrect.');\n }\n\n const [a, b] = tuple;\n return [Some(a), Some(b)];\n },\n\n and<U>(other: Option<U>): Option<U> {\n assertOption(other);\n return other;\n },\n andThen<U>(fn: (value: T) => Option<U>): Option<U> {\n return 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 xor(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other.isSome() && other.unwrap() === value;\n },\n\n toString(): string {\n return `Some(${ 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 */\nexport const None = Object.freeze<None>({\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'None',\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\n expect(msg: string): never {\n throw new TypeError(msg);\n },\n unwrap(): never {\n throw new TypeError('Called `Option::unwrap()` 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\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\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 or<T>(other: Option<T>): Option<T> {\n assertOption(other);\n return other;\n },\n orElse<T>(fn: () => Option<T>): Option<T> {\n return fn();\n },\n xor<T>(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other === None;\n },\n\n toString(): string {\n return 'None';\n },\n}) as 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 *\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>(value: T): Result<T, E> {\n const ok: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Ok',\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);\n },\n isErrAnd(_predicate: (error: E) => boolean): false {\n return false;\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: (error: E) => T): T {\n return value;\n },\n\n expectErr(msg: string): E {\n throw new TypeError(`${ msg }: ${ value }`);\n },\n unwrapErr(): E {\n throw new TypeError('Called `Result::unwrapErr()` on an `Ok` value');\n },\n\n ok(): Option<T> {\n return Some(value);\n },\n err(): None {\n return None;\n },\n transpose<T>(): Option<Result<T, E>> {\n const o = value as Option<T>;\n assertOption(o);\n return o.isSome() ? Some(Ok(o.unwrap())) : None;\n },\n\n map<U>(fn: (value: T) => U): Result<U, E> {\n return Ok(fn(value));\n },\n mapErr<F>(_fn: (error: E) => F): Result<T, F> {\n return Ok(value);\n },\n mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n return fn(value);\n },\n mapOrElse<U>(_defaultFn: (error: E) => U, fn: (value: T) => U): U {\n return fn(value);\n },\n flatten<T>(): Result<T, E> {\n const r = value as Result<T, E>;\n assertResult(r);\n return r;\n },\n\n and<U>(other: Result<U, E>): Result<U, E> {\n assertResult(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);\n },\n orElse<F>(_fn: (error: E) => Result<T, F>): Result<T, F> {\n return ok as unknown as Result<T, F>;\n },\n\n inspect(fn: (value: T) => void): Result<T, E> {\n fn(value);\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(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('Called `Result::asErr()` on an `Ok` value');\n },\n\n toString(): string {\n return `Ok(${ value })`;\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 *\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, E>(error: E): Result<T, E> {\n const err: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Err',\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 isErrAnd(predicate: (error: E) => boolean): boolean {\n return predicate(error);\n },\n\n expect(msg: string): T {\n throw new TypeError(`${ msg }: ${ error }`);\n },\n unwrap(): T {\n throw new TypeError('Called `Result::unwrap()` 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\n expectErr(_msg: string): E {\n return error;\n },\n unwrapErr(): E {\n return error;\n },\n\n ok(): None {\n return None;\n },\n err(): Option<E> {\n return Some(error);\n },\n transpose<T>(): Option<Result<T, E>> {\n return Some(err as unknown as Result<T, E>);\n },\n\n map<U>(_fn: (value: T) => U): Result<U, E> {\n return Err(error);\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<T>(): Result<T, E> {\n return err as unknown as Result<T, 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(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 orElse<F>(fn: (error: E) => Result<T, F>): Result<T, F> {\n return 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(other);\n return other.isErr() && other.unwrapErr() === error;\n },\n\n asOk(): never {\n throw new TypeError('Called `Result::asOk()` on an `Err` value');\n },\n asErr<U>(): Result<U, E> {\n return err as unknown as Result<U, E>;\n },\n\n toString(): string {\n return `Err(${ error })`;\n },\n } as const;\n\n return err;\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 */\nfunction assertOption<T>(o: Option<T>): void {\n if (!isOption(o)) {\n throw new TypeError(`This(${ o }) is not an Option`);\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 */\nfunction assertResult<T, E>(r: Result<T, E>): void {\n if (!isResult(r)) {\n throw new TypeError(`This(${ r }) is not a Result`);\n }\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Result } from './core.ts';\nimport { Ok } from './prelude.ts';\n\n/**\n * Exports some Result constants.\n */\n\n/**\n * Result constant for `true`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_TRUE: Result<boolean, any> = Ok(true);\n\n/**\n * Result constant for `false`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_FALSE: Result<boolean, any> = Ok(false);\n\n/**\n * Result constant for `0`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_ZERO: Result<number, any> = Ok(0);","import type { Result } from './core.ts';\nimport { Err, Ok } from './prelude.ts';\n\n/**\n * Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.\n * This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @typeParam E - The type of the error that the promise may reject with, defaults to `Error`.\n * @param p - The promise to convert into a `Result` type.\n * @returns A promise that resolves to a `Result<T, E>`. If the input promise `p` resolves, the resulting promise will resolve with `Ok<T>`. If the input promise `p` rejects, the resulting promise will resolve with `Err<E>`.\n *\n * @example\n * ```ts\n * async function example() {\n * const result = await promiseToAsyncResult(fetchData());\n * if (result.isOk()) {\n * console.log('Data:', result.unwrap());\n * } else {\n * console.error('Error:', result.unwrapErr());\n * }\n * }\n * ```\n */\nexport function promiseToAsyncResult<T, E = Error>(p: Promise<T>): Promise<Result<T, E>> {\n return p.then((x): Result<T, E> => {\n return Ok(x);\n }).catch((err: E): Result<T, E> => {\n return Err(err);\n });\n}"],"names":[],"mappings":";;AAGa,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA,CAAA;AAKvC,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA;;ACE7C,SAAS,SAAY,CAA4B,EAAA;AAEpD,E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ANGED
package/dist/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","sources":["../src/enum/symbols.ts","../src/enum/helpers.ts","../src/enum/prelude.ts","../src/enum/constants.ts","../src/enum/extensions.ts"],"sourcesContent":["/**\n * Symbol for Option kind: `Some` or `None`.\n */\nexport const OptionKindSymbol = Symbol('Option kind');\n\n/**\n * Symbol for Result kind: `Ok` or `Err`.\n */\nexport const ResultKindSymbol = Symbol('Result kind');","import type { Option, Result } from './core.ts';\nimport { OptionKindSymbol, ResultKindSymbol } 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 */\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/**\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 */\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}","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { Option, Result } from './core.ts';\nimport { isOption, isResult } from './helpers.ts';\nimport { OptionKindSymbol, ResultKindSymbol } from './symbols.ts';\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 unwrapOr<T>(defaultValue: T): T;\n unwrapOrElse<T>(fn: () => T): T;\n\n transpose(): Result<None, never>;\n\n filter(predicate: (value: never) => boolean): None;\n flatten(): None;\n map<U>(fn: (value: never) => U): None;\n\n zip<U>(other: Option<U>): None;\n zipWith<U, R>(other: Option<U>, fn: (value: never, otherValue: U) => R): None;\n unzip(): [None, None];\n\n and<U>(other: Option<U>): None;\n andThen<U>(fn: (value: never) => Option<U>): None;\n or<T>(other: Option<T>): Option<T>;\n orElse<T>(fn: () => Option<T>): Option<T>;\n xor<T>(other: Option<T>): Option<T>;\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 *\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> = {\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'Some',\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\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\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<T, E>(): Result<Option<T>, E> {\n const r = value as unknown as Result<T, E>;\n assertResult(r);\n return r.isOk() ? Ok(Some(r.unwrap())) : Err(r.unwrapErr());\n },\n\n filter(predicate: (value: T) => boolean): Option<T> {\n return predicate(value) ? some : None;\n },\n flatten<T>(): Option<T> {\n const o = value as unknown as Option<T>;\n assertOption(o);\n return o;\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(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(other);\n return other.isSome() ? Some(fn(value, other.unwrap())) : None;\n },\n unzip<T, U>(): [Option<T>, Option<U>] {\n const tuple = value as unknown as [T, U];\n\n if (!Array.isArray(tuple) || tuple.length !== 2) {\n throw new TypeError('Unzip format is incorrect.');\n }\n\n const [a, b] = tuple;\n return [Some(a), Some(b)];\n },\n\n and<U>(other: Option<U>): Option<U> {\n assertOption(other);\n return other;\n },\n andThen<U>(fn: (value: T) => Option<U>): Option<U> {\n return 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 xor(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other.isSome() && other.unwrap() === value;\n },\n\n toString(): string {\n return `Some(${ 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 */\nexport const None = Object.freeze<None>({\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'None',\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\n expect(msg: string): never {\n throw new TypeError(msg);\n },\n unwrap(): never {\n throw new TypeError('Called `Option::unwrap()` 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\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\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 or<T>(other: Option<T>): Option<T> {\n assertOption(other);\n return other;\n },\n orElse<T>(fn: () => Option<T>): Option<T> {\n return fn();\n },\n xor<T>(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other === None;\n },\n\n toString(): string {\n return 'None';\n },\n}) as 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 *\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>(value: T): Result<T, E> {\n const ok: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Ok',\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);\n },\n isErrAnd(_predicate: (error: E) => boolean): false {\n return false;\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: (error: E) => T): T {\n return value;\n },\n\n expectErr(msg: string): E {\n throw new TypeError(`${ msg }: ${ value }`);\n },\n unwrapErr(): E {\n throw new TypeError('Called `Result::unwrapErr()` on an `Ok` value');\n },\n\n ok(): Option<T> {\n return Some(value);\n },\n err(): None {\n return None;\n },\n transpose<T>(): Option<Result<T, E>> {\n const o = value as Option<T>;\n assertOption(o);\n return o.isSome() ? Some(Ok(o.unwrap())) : None;\n },\n\n map<U>(fn: (value: T) => U): Result<U, E> {\n return Ok(fn(value));\n },\n mapErr<F>(_fn: (error: E) => F): Result<T, F> {\n return Ok(value);\n },\n mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n return fn(value);\n },\n mapOrElse<U>(_defaultFn: (error: E) => U, fn: (value: T) => U): U {\n return fn(value);\n },\n flatten<T>(): Result<T, E> {\n const r = value as Result<T, E>;\n assertResult(r);\n return r;\n },\n\n and<U>(other: Result<U, E>): Result<U, E> {\n assertResult(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);\n },\n orElse<F>(_fn: (error: E) => Result<T, F>): Result<T, F> {\n return ok as unknown as Result<T, F>;\n },\n\n inspect(fn: (value: T) => void): Result<T, E> {\n fn(value);\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(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('Called `Result::asErr()` on an `Ok` value');\n },\n\n toString(): string {\n return `Ok(${ value })`;\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 *\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, E>(error: E): Result<T, E> {\n const err: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Err',\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 isErrAnd(predicate: (error: E) => boolean): boolean {\n return predicate(error);\n },\n\n expect(msg: string): T {\n throw new TypeError(`${ msg }: ${ error }`);\n },\n unwrap(): T {\n throw new TypeError('Called `Result::unwrap()` 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\n expectErr(_msg: string): E {\n return error;\n },\n unwrapErr(): E {\n return error;\n },\n\n ok(): None {\n return None;\n },\n err(): Option<E> {\n return Some(error);\n },\n transpose<T>(): Option<Result<T, E>> {\n return Some(err as unknown as Result<T, 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<T>(): Result<T, E> {\n return err as unknown as Result<T, 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(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 orElse<F>(fn: (error: E) => Result<T, F>): Result<T, F> {\n return 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(other);\n return other.isErr() && other.unwrapErr() === error;\n },\n\n asOk(): never {\n throw new TypeError('Called `Result::asOk()` on an `Err` value');\n },\n asErr<U>(): Result<U, E> {\n return err as unknown as Result<U, E>;\n },\n\n toString(): string {\n return `Err(${ error })`;\n },\n } as const;\n\n return err;\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 */\nfunction assertOption<T>(o: Option<T>): void {\n if (!isOption(o)) {\n throw new TypeError(`This(${ o }) is not an Option`);\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 */\nfunction assertResult<T, E>(r: Result<T, E>): void {\n if (!isResult(r)) {\n throw new TypeError(`This(${ r }) is not a Result`);\n }\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Result } from './core.ts';\nimport { Ok } from './prelude.ts';\n\n/**\n * Exports some Result constants.\n */\n\n/**\n * Result constant for `true`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_TRUE: Result<boolean, any> = Ok(true);\n\n/**\n * Result constant for `false`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_FALSE: Result<boolean, any> = Ok(false);\n\n/**\n * Result constant for `0`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_ZERO: Result<number, any> = Ok(0);","import type { Result } from './core.ts';\nimport { Err, Ok } from './prelude.ts';\n\n/**\n * Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.\n * This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @typeParam E - The type of the error that the promise may reject with, defaults to `Error`.\n * @param p - The promise to convert into a `Result` type.\n * @returns A promise that resolves to a `Result<T, E>`. If the input promise `p` resolves, the resulting promise will resolve with `Ok<T>`. If the input promise `p` rejects, the resulting promise will resolve with `Err<E>`.\n *\n * @example\n * ```ts\n * async function example() {\n * const result = await promiseToAsyncResult(fetchData());\n * if (result.isOk()) {\n * console.log('Data:', result.unwrap());\n * } else {\n * console.error('Error:', result.unwrapErr());\n * }\n * }\n * ```\n */\nexport function promiseToAsyncResult<T, E = Error>(p: Promise<T>): Promise<Result<T, E>> {\n return p.then((x): Result<T, E> => {\n return Ok(x);\n }).catch((err: E): Result<T, E> => {\n return Err(err);\n });\n}"],"names":[],"mappings":"AAGa,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA,CAAA;AAKvC,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA;;ACE7C,SAAS,SAAY,CAA4B,EAAA;AAEpD,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE,CAAA;AAUO,SAAS,SAAe,CAA+B,EAAA;AAE1D,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE;;AC4BO,SAAS,KAAQ,KAAqB,EAAA;AACzC,EAAA,MAAM,IAAkB,GAAA;AAAA,IACpB,CAAC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A;AAAA,KACzB;AAAA,GACJ,CAAA;AAEA,EAAO,OAAA,GAAA,CAAA;AACX,CAAA;AASA,SAAS,aAAgB,CAAoB,EAAA;AACzC,EAAI,IAAA,CAAC,QAAS,CAAA,CAAC,CAAG,EAAA;AACd,IAAA,MAAM,IAAI,SAAA,CAAU,CAAS,KAAA,EAAA,CAAE,CAAoB,kBAAA,CAAA,CAAA,CAAA;AAAA,GACvD;AACJ,CAAA;AAUA,SAAS,aAAmB,CAAuB,EAAA;AAC/C,EAAI,IAAA,CAAC,QAAS,CAAA,CAAC,CAAG,EAAA;AACd,IAAA,MAAM,IAAI,SAAA,CAAU,CAAS,KAAA,EAAA,CAAE,CAAmB,iBAAA,CAAA,CAAA,CAAA;AAAA,GACtD;AACJ;;ACnhBa,MAAA,WAAA,GAAoC,GAAG,IAAI,EAAA;AAM3C,MAAA,YAAA,GAAqC,GAAG,KAAK,EAAA;AAM7C,MAAA,WAAA,GAAmC,GAAG,CAAC;;ACA7C,SAAS,qBAAmC,CAAsC,EAAA;AACrF,EAAO,OAAA,CAAA,CAAE,IAAK,CAAA,CAAC,CAAoB,KAAA;AAC/B,IAAA,OAAO,GAAG,CAAC,CAAA,CAAA;AAAA,GACd,CAAA,CAAE,KAAM,CAAA,CAAC,GAAyB,KAAA;AAC/B,IAAA,OAAO,IAAI,GAAG,CAAA,CAAA;AAAA,GACjB,CAAA,CAAA;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"main.mjs","sources":["../src/enum/symbols.ts","../src/enum/helpers.ts","../src/enum/prelude.ts","../src/enum/constants.ts","../src/enum/extensions.ts"],"sourcesContent":["/**\n * Symbol for Option kind: `Some` or `None`.\n */\nexport const OptionKindSymbol = Symbol('Option kind');\n\n/**\n * Symbol for Result kind: `Ok` or `Err`.\n */\nexport const ResultKindSymbol = Symbol('Result kind');","import type { Option, Result } from './core.ts';\nimport { OptionKindSymbol, ResultKindSymbol } 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 */\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/**\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 */\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}","/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { Option, Result } from './core.ts';\nimport { isOption, isResult } from './helpers.ts';\nimport { OptionKindSymbol, ResultKindSymbol } from './symbols.ts';\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 unwrapOr<T>(defaultValue: T): T;\n unwrapOrElse<T>(fn: () => T): T;\n\n transpose(): Result<None, never>;\n\n filter(predicate: (value: never) => boolean): None;\n flatten(): None;\n map<U>(fn: (value: never) => U): None;\n\n zip<U>(other: Option<U>): None;\n zipWith<U, R>(other: Option<U>, fn: (value: never, otherValue: U) => R): None;\n unzip(): [None, None];\n\n and<U>(other: Option<U>): None;\n andThen<U>(fn: (value: never) => Option<U>): None;\n or<T>(other: Option<T>): Option<T>;\n orElse<T>(fn: () => Option<T>): Option<T>;\n xor<T>(other: Option<T>): Option<T>;\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 *\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> = {\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'Some',\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\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\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<T, E>(): Result<Option<T>, E> {\n const r = value as unknown as Result<T, E>;\n assertResult(r);\n return r.isOk() ? Ok(Some(r.unwrap())) : Err(r.unwrapErr());\n },\n\n filter(predicate: (value: T) => boolean): Option<T> {\n return predicate(value) ? some : None;\n },\n flatten<T>(): Option<T> {\n const o = value as unknown as Option<T>;\n assertOption(o);\n return o;\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(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(other);\n return other.isSome() ? Some(fn(value, other.unwrap())) : None;\n },\n unzip<T, U>(): [Option<T>, Option<U>] {\n const tuple = value as unknown as [T, U];\n\n if (!Array.isArray(tuple) || tuple.length !== 2) {\n throw new TypeError('Unzip format is incorrect.');\n }\n\n const [a, b] = tuple;\n return [Some(a), Some(b)];\n },\n\n and<U>(other: Option<U>): Option<U> {\n assertOption(other);\n return other;\n },\n andThen<U>(fn: (value: T) => Option<U>): Option<U> {\n return 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 xor(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other.isSome() && other.unwrap() === value;\n },\n\n toString(): string {\n return `Some(${ 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 */\nexport const None = Object.freeze<None>({\n [Symbol.toStringTag]: 'Option',\n [OptionKindSymbol]: 'None',\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\n expect(msg: string): never {\n throw new TypeError(msg);\n },\n unwrap(): never {\n throw new TypeError('Called `Option::unwrap()` 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\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\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 or<T>(other: Option<T>): Option<T> {\n assertOption(other);\n return other;\n },\n orElse<T>(fn: () => Option<T>): Option<T> {\n return fn();\n },\n xor<T>(other: Option<T>): Option<T> {\n assertOption(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(other);\n return other === None;\n },\n\n toString(): string {\n return 'None';\n },\n}) as 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 *\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>(value: T): Result<T, E> {\n const ok: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Ok',\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);\n },\n isErrAnd(_predicate: (error: E) => boolean): false {\n return false;\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: (error: E) => T): T {\n return value;\n },\n\n expectErr(msg: string): E {\n throw new TypeError(`${ msg }: ${ value }`);\n },\n unwrapErr(): E {\n throw new TypeError('Called `Result::unwrapErr()` on an `Ok` value');\n },\n\n ok(): Option<T> {\n return Some(value);\n },\n err(): None {\n return None;\n },\n transpose<T>(): Option<Result<T, E>> {\n const o = value as Option<T>;\n assertOption(o);\n return o.isSome() ? Some(Ok(o.unwrap())) : None;\n },\n\n map<U>(fn: (value: T) => U): Result<U, E> {\n return Ok(fn(value));\n },\n mapErr<F>(_fn: (error: E) => F): Result<T, F> {\n return Ok(value);\n },\n mapOr<U>(_defaultValue: U, fn: (value: T) => U): U {\n return fn(value);\n },\n mapOrElse<U>(_defaultFn: (error: E) => U, fn: (value: T) => U): U {\n return fn(value);\n },\n flatten<T>(): Result<T, E> {\n const r = value as Result<T, E>;\n assertResult(r);\n return r;\n },\n\n and<U>(other: Result<U, E>): Result<U, E> {\n assertResult(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);\n },\n orElse<F>(_fn: (error: E) => Result<T, F>): Result<T, F> {\n return ok as unknown as Result<T, F>;\n },\n\n inspect(fn: (value: T) => void): Result<T, E> {\n fn(value);\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(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('Called `Result::asErr()` on an `Ok` value');\n },\n\n toString(): string {\n return `Ok(${ value })`;\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 *\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, E>(error: E): Result<T, E> {\n const err: Result<T, E> = {\n [Symbol.toStringTag]: 'Result',\n [ResultKindSymbol]: 'Err',\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 isErrAnd(predicate: (error: E) => boolean): boolean {\n return predicate(error);\n },\n\n expect(msg: string): T {\n throw new TypeError(`${ msg }: ${ error }`);\n },\n unwrap(): T {\n throw new TypeError('Called `Result::unwrap()` 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\n expectErr(_msg: string): E {\n return error;\n },\n unwrapErr(): E {\n return error;\n },\n\n ok(): None {\n return None;\n },\n err(): Option<E> {\n return Some(error);\n },\n transpose<T>(): Option<Result<T, E>> {\n return Some(err as unknown as Result<T, E>);\n },\n\n map<U>(_fn: (value: T) => U): Result<U, E> {\n return Err(error);\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<T>(): Result<T, E> {\n return err as unknown as Result<T, 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(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 orElse<F>(fn: (error: E) => Result<T, F>): Result<T, F> {\n return 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(other);\n return other.isErr() && other.unwrapErr() === error;\n },\n\n asOk(): never {\n throw new TypeError('Called `Result::asOk()` on an `Err` value');\n },\n asErr<U>(): Result<U, E> {\n return err as unknown as Result<U, E>;\n },\n\n toString(): string {\n return `Err(${ error })`;\n },\n } as const;\n\n return err;\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 */\nfunction assertOption<T>(o: Option<T>): void {\n if (!isOption(o)) {\n throw new TypeError(`This(${ o }) is not an Option`);\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 */\nfunction assertResult<T, E>(r: Result<T, E>): void {\n if (!isResult(r)) {\n throw new TypeError(`This(${ r }) is not a Result`);\n }\n}","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { Result } from './core.ts';\nimport { Ok } from './prelude.ts';\n\n/**\n * Exports some Result constants.\n */\n\n/**\n * Result constant for `true`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_TRUE: Result<boolean, any> = Ok(true);\n\n/**\n * Result constant for `false`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_FALSE: Result<boolean, any> = Ok(false);\n\n/**\n * Result constant for `0`.\n * Can be used anywhere due to immutability.\n */\nexport const RESULT_ZERO: Result<number, any> = Ok(0);","import type { Result } from './core.ts';\nimport { Err, Ok } from './prelude.ts';\n\n/**\n * Converts a Promise to a Result type, capturing the resolved value in an `Ok`, or the error in an `Err`.\n * This allows for promise-based asynchronous operations to be handled in a way that is more in line with the Result pattern.\n *\n * @typeParam T - The type of the value that the promise resolves to.\n * @typeParam E - The type of the error that the promise may reject with, defaults to `Error`.\n * @param p - The promise to convert into a `Result` type.\n * @returns A promise that resolves to a `Result<T, E>`. If the input promise `p` resolves, the resulting promise will resolve with `Ok<T>`. If the input promise `p` rejects, the resulting promise will resolve with `Err<E>`.\n *\n * @example\n * ```ts\n * async function example() {\n * const result = await promiseToAsyncResult(fetchData());\n * if (result.isOk()) {\n * console.log('Data:', result.unwrap());\n * } else {\n * console.error('Error:', result.unwrapErr());\n * }\n * }\n * ```\n */\nexport function promiseToAsyncResult<T, E = Error>(p: Promise<T>): Promise<Result<T, E>> {\n return p.then((x): Result<T, E> => {\n return Ok(x);\n }).catch((err: E): Result<T, E> => {\n return Err(err);\n });\n}"],"names":[],"mappings":"AAGa,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA,CAAA;AAKvC,MAAA,gBAAA,GAAmB,OAAO,aAAa,CAAA;;ACE7C,SAAS,SAAY,CAA4B,EAAA;AAEpD,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE,CAAA;AAUO,SAAS,SAAe,CAA+B,EAAA;AAE1D,EAAA,OAAO,CAAK,IAAA,IAAA,IAAQ,OAAO,CAAA,KAAM,YAAY,gBAAoB,IAAA,CAAA,CAAA;AACrE;;AC4BO,SAAS,KAAQ,KAAqB,EAAA;AACzC,EAAA,MAAM,IAAkB,GAAA;AAAA,IACpB,CAAC,MAAO,CAAA,WAAW,GAAG,QAAA;AAAA,IACtB,CAAC,gBAAgB,GAAG,MAAA;AAAA,IAEpB,MAAe,GAAA;AACX,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAAA,IACA,MAAgB,GAAA;AACZ,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,UAAU,SAA2C,EAAA;AACjD,MAAA,OAAO,UAAU,KAAK,CAAA,CAAA;AAAA,KAC1B;AAAA,IAEA,OAAO,IAAiB,EAAA;AACpB,MAAO,OAAA,KAAA,CAAA;AAAA,KACX;AAAA,IACA,MAAY,GAAA;AACR,MAAO,OAAA,KAAA,CAAA;AAAA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S,KAAA,EAAA,CAAE,CAAmB,iBAAA,CAAA,CAAA,CAAA;AAAA,GACtD;AACJ;;ACnhBa,MAAA,WAAA,GAAoC,GAAG,IAAI,EAAA;AAM3C,MAAA,YAAA,GAAqC,GAAG,KAAK,EAAA;AAM7C,MAAA,WAAA,GAAmC,GAAG,CAAC;;ACA7C,SAAS,qBAAmC,CAAsC,EAAA;AACrF,EAAO,OAAA,CAAA,CAAE,IAAK,CAAA,CAAC,CAAoB,KAAA;AAC/B,IAAA,OAAO,GAAG,CAAC,CAAA,CAAA;AAAA,GACd,CAAA,CAAE,KAAM,CAAA,CAAC,GAAyB,KAAA;AAC/B,IAAA,OAAO,IAAI,GAAG,CAAA,CAAA;AAAA,GACjB,CAAA,CAAA;AACL;;;;"}
|
package/docs/functions/Err.md
CHANGED
|
@@ -43,4 +43,4 @@ if (badResult.isErr()) {
|
|
|
43
43
|
|
|
44
44
|
## Defined in
|
|
45
45
|
|
|
46
|
-
[prelude.ts:413](https://github.com/JiangJie/happy-rusty/blob/
|
|
46
|
+
[prelude.ts:413](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L413)
|
package/docs/functions/Ok.md
CHANGED
|
@@ -43,4 +43,4 @@ if (goodResult.isOk()) {
|
|
|
43
43
|
|
|
44
44
|
## Defined in
|
|
45
45
|
|
|
46
|
-
[prelude.ts:286](https://github.com/JiangJie/happy-rusty/blob/
|
|
46
|
+
[prelude.ts:286](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L286)
|
package/docs/functions/Some.md
CHANGED
|
@@ -42,4 +42,4 @@ if (maybeValue.isSome()) {
|
|
|
42
42
|
|
|
43
43
|
## Defined in
|
|
44
44
|
|
|
45
|
-
[prelude.ts:55](https://github.com/JiangJie/happy-rusty/blob/
|
|
45
|
+
[prelude.ts:55](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L55)
|
|
@@ -32,4 +32,4 @@ Checks if a value is an `Option`.
|
|
|
32
32
|
|
|
33
33
|
## Defined in
|
|
34
34
|
|
|
35
|
-
[helpers.ts:11](https://github.com/JiangJie/happy-rusty/blob/
|
|
35
|
+
[helpers.ts:11](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/helpers.ts#L11)
|
|
@@ -33,4 +33,4 @@ Checks if a value is a `Result`.
|
|
|
33
33
|
|
|
34
34
|
## Defined in
|
|
35
35
|
|
|
36
|
-
[helpers.ts:24](https://github.com/JiangJie/happy-rusty/blob/
|
|
36
|
+
[helpers.ts:24](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/helpers.ts#L24)
|
|
@@ -47,4 +47,4 @@ async function example() {
|
|
|
47
47
|
|
|
48
48
|
## Defined in
|
|
49
49
|
|
|
50
|
-
[extensions.ts:25](https://github.com/JiangJie/happy-rusty/blob/
|
|
50
|
+
[extensions.ts:25](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/extensions.ts#L25)
|
package/docs/interfaces/None.md
CHANGED
|
@@ -17,8 +17,8 @@ The type parameter is set to `never` because `None` does not hold a value.
|
|
|
17
17
|
|
|
18
18
|
| Property | Modifier | Type | Description | Overrides | Inherited from | Defined in |
|
|
19
19
|
| ------ | ------ | ------ | ------ | ------ | ------ | ------ |
|
|
20
|
-
| `[OptionKindSymbol]` | `readonly` | `"None"` | When using `None` alone, the following overrides can make type inference more accurate. | `Option.[OptionKindSymbol]` | - | [prelude.ts:15](https://github.com/JiangJie/happy-rusty/blob/
|
|
21
|
-
| `[toStringTag]` | `public` | `"Option"` | [object Option]. | - | [`Option`](Option.md).`[toStringTag]` | [core.ts:30](https://github.com/JiangJie/happy-rusty/blob/
|
|
20
|
+
| `[OptionKindSymbol]` | `readonly` | `"None"` | When using `None` alone, the following overrides can make type inference more accurate. | `Option.[OptionKindSymbol]` | - | [prelude.ts:15](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L15) |
|
|
21
|
+
| `[toStringTag]` | `public` | `"Option"` | [object Option]. | - | [`Option`](Option.md).`[toStringTag]` | [core.ts:30](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L30) |
|
|
22
22
|
|
|
23
23
|
## Methods
|
|
24
24
|
|
|
@@ -55,7 +55,7 @@ This is sometimes called "and then" because it is similar to a logical AND opera
|
|
|
55
55
|
|
|
56
56
|
#### Defined in
|
|
57
57
|
|
|
58
|
-
[prelude.ts:30](https://github.com/JiangJie/happy-rusty/blob/
|
|
58
|
+
[prelude.ts:30](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L30)
|
|
59
59
|
|
|
60
60
|
***
|
|
61
61
|
|
|
@@ -92,7 +92,7 @@ The result of `fn` if `this` is `Some`, otherwise `None`.
|
|
|
92
92
|
|
|
93
93
|
#### Defined in
|
|
94
94
|
|
|
95
|
-
[prelude.ts:31](https://github.com/JiangJie/happy-rusty/blob/
|
|
95
|
+
[prelude.ts:31](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L31)
|
|
96
96
|
|
|
97
97
|
***
|
|
98
98
|
|
|
@@ -129,7 +129,7 @@ This method can be used for comparing `Option` instances in a value-sensitive ma
|
|
|
129
129
|
|
|
130
130
|
#### Defined in
|
|
131
131
|
|
|
132
|
-
[prelude.ts:36](https://github.com/JiangJie/happy-rusty/blob/
|
|
132
|
+
[prelude.ts:36](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L36)
|
|
133
133
|
|
|
134
134
|
***
|
|
135
135
|
|
|
@@ -161,7 +161,7 @@ Throws an error with the provided message if the Option is a `None`.
|
|
|
161
161
|
|
|
162
162
|
#### Defined in
|
|
163
163
|
|
|
164
|
-
[core.ts:76](https://github.com/JiangJie/happy-rusty/blob/
|
|
164
|
+
[core.ts:76](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L76)
|
|
165
165
|
|
|
166
166
|
***
|
|
167
167
|
|
|
@@ -191,7 +191,7 @@ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapp
|
|
|
191
191
|
|
|
192
192
|
#### Defined in
|
|
193
193
|
|
|
194
|
-
[prelude.ts:22](https://github.com/JiangJie/happy-rusty/blob/
|
|
194
|
+
[prelude.ts:22](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L22)
|
|
195
195
|
|
|
196
196
|
***
|
|
197
197
|
|
|
@@ -215,7 +215,7 @@ Converts from `Option<Option<T>>` to `Option<T>`.
|
|
|
215
215
|
|
|
216
216
|
#### Defined in
|
|
217
217
|
|
|
218
|
-
[prelude.ts:23](https://github.com/JiangJie/happy-rusty/blob/
|
|
218
|
+
[prelude.ts:23](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L23)
|
|
219
219
|
|
|
220
220
|
***
|
|
221
221
|
|
|
@@ -246,7 +246,7 @@ This is primarily for side effects and does not transform the `Option`.
|
|
|
246
246
|
|
|
247
247
|
#### Defined in
|
|
248
248
|
|
|
249
|
-
[core.ts:263](https://github.com/JiangJie/happy-rusty/blob/
|
|
249
|
+
[core.ts:263](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L263)
|
|
250
250
|
|
|
251
251
|
***
|
|
252
252
|
|
|
@@ -268,7 +268,7 @@ Returns `true` if the Option is a `None` value.
|
|
|
268
268
|
|
|
269
269
|
#### Defined in
|
|
270
270
|
|
|
271
|
-
[core.ts:55](https://github.com/JiangJie/happy-rusty/blob/
|
|
271
|
+
[core.ts:55](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L55)
|
|
272
272
|
|
|
273
273
|
***
|
|
274
274
|
|
|
@@ -290,7 +290,7 @@ Returns `true` if the Option is a `Some` value.
|
|
|
290
290
|
|
|
291
291
|
#### Defined in
|
|
292
292
|
|
|
293
|
-
[core.ts:50](https://github.com/JiangJie/happy-rusty/blob/
|
|
293
|
+
[core.ts:50](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L50)
|
|
294
294
|
|
|
295
295
|
***
|
|
296
296
|
|
|
@@ -318,7 +318,7 @@ Returns `true` if the Option is a `Some` value and the predicate returns `true`
|
|
|
318
318
|
|
|
319
319
|
#### Defined in
|
|
320
320
|
|
|
321
|
-
[core.ts:61](https://github.com/JiangJie/happy-rusty/blob/
|
|
321
|
+
[core.ts:61](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L61)
|
|
322
322
|
|
|
323
323
|
***
|
|
324
324
|
|
|
@@ -352,7 +352,7 @@ Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
|
|
|
352
352
|
|
|
353
353
|
#### Defined in
|
|
354
354
|
|
|
355
|
-
[prelude.ts:24](https://github.com/JiangJie/happy-rusty/blob/
|
|
355
|
+
[prelude.ts:24](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L24)
|
|
356
356
|
|
|
357
357
|
***
|
|
358
358
|
|
|
@@ -387,7 +387,7 @@ Maps an `Option<T>` to `U` by applying a function to the contained value (if any
|
|
|
387
387
|
|
|
388
388
|
#### Defined in
|
|
389
389
|
|
|
390
|
-
[core.ts:159](https://github.com/JiangJie/happy-rusty/blob/
|
|
390
|
+
[core.ts:159](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L159)
|
|
391
391
|
|
|
392
392
|
***
|
|
393
393
|
|
|
@@ -422,7 +422,7 @@ Maps an `Option<T>` to `U` by applying a function to a contained value (if any),
|
|
|
422
422
|
|
|
423
423
|
#### Defined in
|
|
424
424
|
|
|
425
|
-
[core.ts:167](https://github.com/JiangJie/happy-rusty/blob/
|
|
425
|
+
[core.ts:167](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L167)
|
|
426
426
|
|
|
427
427
|
***
|
|
428
428
|
|
|
@@ -456,7 +456,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
456
456
|
|
|
457
457
|
#### Defined in
|
|
458
458
|
|
|
459
|
-
[core.ts:109](https://github.com/JiangJie/happy-rusty/blob/
|
|
459
|
+
[core.ts:109](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L109)
|
|
460
460
|
|
|
461
461
|
***
|
|
462
462
|
|
|
@@ -490,7 +490,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
490
490
|
|
|
491
491
|
#### Defined in
|
|
492
492
|
|
|
493
|
-
[core.ts:116](https://github.com/JiangJie/happy-rusty/blob/
|
|
493
|
+
[core.ts:116](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L116)
|
|
494
494
|
|
|
495
495
|
***
|
|
496
496
|
|
|
@@ -527,7 +527,7 @@ This can be used for providing a fallback `Option`.
|
|
|
527
527
|
|
|
528
528
|
#### Defined in
|
|
529
529
|
|
|
530
|
-
[prelude.ts:32](https://github.com/JiangJie/happy-rusty/blob/
|
|
530
|
+
[prelude.ts:32](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L32)
|
|
531
531
|
|
|
532
532
|
***
|
|
533
533
|
|
|
@@ -564,7 +564,7 @@ This method can be used for lazy fallbacks, as `fn` is only evaluated if `this`
|
|
|
564
564
|
|
|
565
565
|
#### Defined in
|
|
566
566
|
|
|
567
|
-
[prelude.ts:33](https://github.com/JiangJie/happy-rusty/blob/
|
|
567
|
+
[prelude.ts:33](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L33)
|
|
568
568
|
|
|
569
569
|
***
|
|
570
570
|
|
|
@@ -586,7 +586,7 @@ Custom `toString` implementation that uses the `Option`'s contained value.
|
|
|
586
586
|
|
|
587
587
|
#### Defined in
|
|
588
588
|
|
|
589
|
-
[core.ts:280](https://github.com/JiangJie/happy-rusty/blob/
|
|
589
|
+
[core.ts:280](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L280)
|
|
590
590
|
|
|
591
591
|
***
|
|
592
592
|
|
|
@@ -612,7 +612,7 @@ Transposes an `Option` of a `Result` into a `Result` of an `Option`.
|
|
|
612
612
|
|
|
613
613
|
#### Defined in
|
|
614
614
|
|
|
615
|
-
[prelude.ts:20](https://github.com/JiangJie/happy-rusty/blob/
|
|
615
|
+
[prelude.ts:20](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L20)
|
|
616
616
|
|
|
617
617
|
***
|
|
618
618
|
|
|
@@ -638,7 +638,7 @@ Throws an error if the value is a `None`.
|
|
|
638
638
|
|
|
639
639
|
#### Defined in
|
|
640
640
|
|
|
641
|
-
[core.ts:82](https://github.com/JiangJie/happy-rusty/blob/
|
|
641
|
+
[core.ts:82](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L82)
|
|
642
642
|
|
|
643
643
|
***
|
|
644
644
|
|
|
@@ -672,7 +672,7 @@ Returns the contained `Some` value or a provided default.
|
|
|
672
672
|
|
|
673
673
|
#### Defined in
|
|
674
674
|
|
|
675
|
-
[prelude.ts:17](https://github.com/JiangJie/happy-rusty/blob/
|
|
675
|
+
[prelude.ts:17](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L17)
|
|
676
676
|
|
|
677
677
|
***
|
|
678
678
|
|
|
@@ -706,7 +706,7 @@ Returns the contained `Some` value or computes it from a closure.
|
|
|
706
706
|
|
|
707
707
|
#### Defined in
|
|
708
708
|
|
|
709
|
-
[prelude.ts:18](https://github.com/JiangJie/happy-rusty/blob/
|
|
709
|
+
[prelude.ts:18](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L18)
|
|
710
710
|
|
|
711
711
|
***
|
|
712
712
|
|
|
@@ -732,7 +732,7 @@ A tuple of `Options`, one for each element in the original `Option` of a tuple.
|
|
|
732
732
|
|
|
733
733
|
#### Defined in
|
|
734
734
|
|
|
735
|
-
[prelude.ts:28](https://github.com/JiangJie/happy-rusty/blob/
|
|
735
|
+
[prelude.ts:28](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L28)
|
|
736
736
|
|
|
737
737
|
***
|
|
738
738
|
|
|
@@ -769,7 +769,7 @@ This can be thought of as an exclusive or operation on `Option` values.
|
|
|
769
769
|
|
|
770
770
|
#### Defined in
|
|
771
771
|
|
|
772
|
-
[prelude.ts:34](https://github.com/JiangJie/happy-rusty/blob/
|
|
772
|
+
[prelude.ts:34](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L34)
|
|
773
773
|
|
|
774
774
|
***
|
|
775
775
|
|
|
@@ -807,7 +807,7 @@ An `Option` containing a tuple of the values if both are `Some`, otherwise `None
|
|
|
807
807
|
|
|
808
808
|
#### Defined in
|
|
809
809
|
|
|
810
|
-
[prelude.ts:26](https://github.com/JiangJie/happy-rusty/blob/
|
|
810
|
+
[prelude.ts:26](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L26)
|
|
811
811
|
|
|
812
812
|
***
|
|
813
813
|
|
|
@@ -847,4 +847,4 @@ An `Option` containing the result of `fn` if both `Options` are `Some`, otherwis
|
|
|
847
847
|
|
|
848
848
|
#### Defined in
|
|
849
849
|
|
|
850
|
-
[prelude.ts:27](https://github.com/JiangJie/happy-rusty/blob/
|
|
850
|
+
[prelude.ts:27](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L27)
|
|
@@ -31,7 +31,7 @@ pub enum Option<T> {
|
|
|
31
31
|
|
|
32
32
|
| Property | Type | Description | Defined in |
|
|
33
33
|
| ------ | ------ | ------ | ------ |
|
|
34
|
-
| `[toStringTag]` | `"Option"` | [object Option]. | [core.ts:30](https://github.com/JiangJie/happy-rusty/blob/
|
|
34
|
+
| `[toStringTag]` | `"Option"` | [object Option]. | [core.ts:30](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L30) |
|
|
35
35
|
|
|
36
36
|
## Methods
|
|
37
37
|
|
|
@@ -64,7 +64,7 @@ This is sometimes called "and then" because it is similar to a logical AND opera
|
|
|
64
64
|
|
|
65
65
|
#### Defined in
|
|
66
66
|
|
|
67
|
-
[core.ts:220](https://github.com/JiangJie/happy-rusty/blob/
|
|
67
|
+
[core.ts:220](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L220)
|
|
68
68
|
|
|
69
69
|
***
|
|
70
70
|
|
|
@@ -97,7 +97,7 @@ The result of `fn` if `this` is `Some`, otherwise `None`.
|
|
|
97
97
|
|
|
98
98
|
#### Defined in
|
|
99
99
|
|
|
100
|
-
[core.ts:229](https://github.com/JiangJie/happy-rusty/blob/
|
|
100
|
+
[core.ts:229](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L229)
|
|
101
101
|
|
|
102
102
|
***
|
|
103
103
|
|
|
@@ -124,7 +124,7 @@ This method can be used for comparing `Option` instances in a value-sensitive ma
|
|
|
124
124
|
|
|
125
125
|
#### Defined in
|
|
126
126
|
|
|
127
|
-
[core.ts:273](https://github.com/JiangJie/happy-rusty/blob/
|
|
127
|
+
[core.ts:273](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L273)
|
|
128
128
|
|
|
129
129
|
***
|
|
130
130
|
|
|
@@ -152,7 +152,7 @@ Throws an error with the provided message if the Option is a `None`.
|
|
|
152
152
|
|
|
153
153
|
#### Defined in
|
|
154
154
|
|
|
155
|
-
[core.ts:76](https://github.com/JiangJie/happy-rusty/blob/
|
|
155
|
+
[core.ts:76](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L76)
|
|
156
156
|
|
|
157
157
|
***
|
|
158
158
|
|
|
@@ -178,7 +178,7 @@ Returns `None` if the Option is `None`, otherwise calls predicate with the wrapp
|
|
|
178
178
|
|
|
179
179
|
#### Defined in
|
|
180
180
|
|
|
181
|
-
[core.ts:138](https://github.com/JiangJie/happy-rusty/blob/
|
|
181
|
+
[core.ts:138](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L138)
|
|
182
182
|
|
|
183
183
|
***
|
|
184
184
|
|
|
@@ -210,7 +210,7 @@ Converts from `Option<Option<T>>` to `Option<T>`.
|
|
|
210
210
|
|
|
211
211
|
#### Defined in
|
|
212
212
|
|
|
213
|
-
[core.ts:144](https://github.com/JiangJie/happy-rusty/blob/
|
|
213
|
+
[core.ts:144](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L144)
|
|
214
214
|
|
|
215
215
|
***
|
|
216
216
|
|
|
@@ -237,7 +237,7 @@ This is primarily for side effects and does not transform the `Option`.
|
|
|
237
237
|
|
|
238
238
|
#### Defined in
|
|
239
239
|
|
|
240
|
-
[core.ts:263](https://github.com/JiangJie/happy-rusty/blob/
|
|
240
|
+
[core.ts:263](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L263)
|
|
241
241
|
|
|
242
242
|
***
|
|
243
243
|
|
|
@@ -255,7 +255,7 @@ Returns `true` if the Option is a `None` value.
|
|
|
255
255
|
|
|
256
256
|
#### Defined in
|
|
257
257
|
|
|
258
|
-
[core.ts:55](https://github.com/JiangJie/happy-rusty/blob/
|
|
258
|
+
[core.ts:55](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L55)
|
|
259
259
|
|
|
260
260
|
***
|
|
261
261
|
|
|
@@ -273,7 +273,7 @@ Returns `true` if the Option is a `Some` value.
|
|
|
273
273
|
|
|
274
274
|
#### Defined in
|
|
275
275
|
|
|
276
|
-
[core.ts:50](https://github.com/JiangJie/happy-rusty/blob/
|
|
276
|
+
[core.ts:50](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L50)
|
|
277
277
|
|
|
278
278
|
***
|
|
279
279
|
|
|
@@ -297,7 +297,7 @@ Returns `true` if the Option is a `Some` value and the predicate returns `true`
|
|
|
297
297
|
|
|
298
298
|
#### Defined in
|
|
299
299
|
|
|
300
|
-
[core.ts:61](https://github.com/JiangJie/happy-rusty/blob/
|
|
300
|
+
[core.ts:61](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L61)
|
|
301
301
|
|
|
302
302
|
***
|
|
303
303
|
|
|
@@ -327,7 +327,7 @@ Maps an `Option<T>` to `Option<U>` by applying a function to a contained value.
|
|
|
327
327
|
|
|
328
328
|
#### Defined in
|
|
329
329
|
|
|
330
|
-
[core.ts:151](https://github.com/JiangJie/happy-rusty/blob/
|
|
330
|
+
[core.ts:151](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L151)
|
|
331
331
|
|
|
332
332
|
***
|
|
333
333
|
|
|
@@ -358,7 +358,7 @@ Maps an `Option<T>` to `U` by applying a function to the contained value (if any
|
|
|
358
358
|
|
|
359
359
|
#### Defined in
|
|
360
360
|
|
|
361
|
-
[core.ts:159](https://github.com/JiangJie/happy-rusty/blob/
|
|
361
|
+
[core.ts:159](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L159)
|
|
362
362
|
|
|
363
363
|
***
|
|
364
364
|
|
|
@@ -389,7 +389,7 @@ Maps an `Option<T>` to `U` by applying a function to a contained value (if any),
|
|
|
389
389
|
|
|
390
390
|
#### Defined in
|
|
391
391
|
|
|
392
|
-
[core.ts:167](https://github.com/JiangJie/happy-rusty/blob/
|
|
392
|
+
[core.ts:167](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L167)
|
|
393
393
|
|
|
394
394
|
***
|
|
395
395
|
|
|
@@ -419,7 +419,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
419
419
|
|
|
420
420
|
#### Defined in
|
|
421
421
|
|
|
422
|
-
[core.ts:109](https://github.com/JiangJie/happy-rusty/blob/
|
|
422
|
+
[core.ts:109](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L109)
|
|
423
423
|
|
|
424
424
|
***
|
|
425
425
|
|
|
@@ -449,7 +449,7 @@ Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to `Ok(v)` a
|
|
|
449
449
|
|
|
450
450
|
#### Defined in
|
|
451
451
|
|
|
452
|
-
[core.ts:116](https://github.com/JiangJie/happy-rusty/blob/
|
|
452
|
+
[core.ts:116](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L116)
|
|
453
453
|
|
|
454
454
|
***
|
|
455
455
|
|
|
@@ -476,7 +476,7 @@ This can be used for providing a fallback `Option`.
|
|
|
476
476
|
|
|
477
477
|
#### Defined in
|
|
478
478
|
|
|
479
|
-
[core.ts:237](https://github.com/JiangJie/happy-rusty/blob/
|
|
479
|
+
[core.ts:237](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L237)
|
|
480
480
|
|
|
481
481
|
***
|
|
482
482
|
|
|
@@ -503,7 +503,7 @@ This method can be used for lazy fallbacks, as `fn` is only evaluated if `this`
|
|
|
503
503
|
|
|
504
504
|
#### Defined in
|
|
505
505
|
|
|
506
|
-
[core.ts:245](https://github.com/JiangJie/happy-rusty/blob/
|
|
506
|
+
[core.ts:245](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L245)
|
|
507
507
|
|
|
508
508
|
***
|
|
509
509
|
|
|
@@ -521,7 +521,7 @@ Custom `toString` implementation that uses the `Option`'s contained value.
|
|
|
521
521
|
|
|
522
522
|
#### Defined in
|
|
523
523
|
|
|
524
|
-
[core.ts:280](https://github.com/JiangJie/happy-rusty/blob/
|
|
524
|
+
[core.ts:280](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L280)
|
|
525
525
|
|
|
526
526
|
***
|
|
527
527
|
|
|
@@ -556,7 +556,7 @@ Transposes an `Option` of a `Result` into a `Result` of an `Option`.
|
|
|
556
556
|
|
|
557
557
|
#### Defined in
|
|
558
558
|
|
|
559
|
-
[core.ts:126](https://github.com/JiangJie/happy-rusty/blob/
|
|
559
|
+
[core.ts:126](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L126)
|
|
560
560
|
|
|
561
561
|
***
|
|
562
562
|
|
|
@@ -578,7 +578,7 @@ Throws an error if the value is a `None`.
|
|
|
578
578
|
|
|
579
579
|
#### Defined in
|
|
580
580
|
|
|
581
|
-
[core.ts:82](https://github.com/JiangJie/happy-rusty/blob/
|
|
581
|
+
[core.ts:82](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L82)
|
|
582
582
|
|
|
583
583
|
***
|
|
584
584
|
|
|
@@ -602,7 +602,7 @@ Returns the contained `Some` value or a provided default.
|
|
|
602
602
|
|
|
603
603
|
#### Defined in
|
|
604
604
|
|
|
605
|
-
[core.ts:88](https://github.com/JiangJie/happy-rusty/blob/
|
|
605
|
+
[core.ts:88](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L88)
|
|
606
606
|
|
|
607
607
|
***
|
|
608
608
|
|
|
@@ -626,7 +626,7 @@ Returns the contained `Some` value or computes it from a closure.
|
|
|
626
626
|
|
|
627
627
|
#### Defined in
|
|
628
628
|
|
|
629
|
-
[core.ts:94](https://github.com/JiangJie/happy-rusty/blob/
|
|
629
|
+
[core.ts:94](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L94)
|
|
630
630
|
|
|
631
631
|
***
|
|
632
632
|
|
|
@@ -661,7 +661,7 @@ A tuple of `Options`, one for each element in the original `Option` of a tuple.
|
|
|
661
661
|
|
|
662
662
|
#### Defined in
|
|
663
663
|
|
|
664
|
-
[core.ts:203](https://github.com/JiangJie/happy-rusty/blob/
|
|
664
|
+
[core.ts:203](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L203)
|
|
665
665
|
|
|
666
666
|
***
|
|
667
667
|
|
|
@@ -688,7 +688,7 @@ This can be thought of as an exclusive or operation on `Option` values.
|
|
|
688
688
|
|
|
689
689
|
#### Defined in
|
|
690
690
|
|
|
691
|
-
[core.ts:253](https://github.com/JiangJie/happy-rusty/blob/
|
|
691
|
+
[core.ts:253](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L253)
|
|
692
692
|
|
|
693
693
|
***
|
|
694
694
|
|
|
@@ -722,7 +722,7 @@ An `Option` containing a tuple of the values if both are `Some`, otherwise `None
|
|
|
722
722
|
|
|
723
723
|
#### Defined in
|
|
724
724
|
|
|
725
|
-
[core.ts:181](https://github.com/JiangJie/happy-rusty/blob/
|
|
725
|
+
[core.ts:181](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L181)
|
|
726
726
|
|
|
727
727
|
***
|
|
728
728
|
|
|
@@ -758,4 +758,4 @@ An `Option` containing the result of `fn` if both `Options` are `Some`, otherwis
|
|
|
758
758
|
|
|
759
759
|
#### Defined in
|
|
760
760
|
|
|
761
|
-
[core.ts:193](https://github.com/JiangJie/happy-rusty/blob/
|
|
761
|
+
[core.ts:193](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L193)
|
|
@@ -29,7 +29,7 @@ pub enum Result<T, E> {
|
|
|
29
29
|
|
|
30
30
|
| Property | Type | Description | Defined in |
|
|
31
31
|
| ------ | ------ | ------ | ------ |
|
|
32
|
-
| `[toStringTag]` | `"Result"` | [object Result]. | [core.ts:304](https://github.com/JiangJie/happy-rusty/blob/
|
|
32
|
+
| `[toStringTag]` | `"Result"` | [object Result]. | [core.ts:304](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L304) |
|
|
33
33
|
|
|
34
34
|
## Methods
|
|
35
35
|
|
|
@@ -61,7 +61,7 @@ The passed `Result` if `this` is `Ok`, otherwise returns `this` (which is `Err`)
|
|
|
61
61
|
|
|
62
62
|
#### Defined in
|
|
63
63
|
|
|
64
|
-
[core.ts:489](https://github.com/JiangJie/happy-rusty/blob/
|
|
64
|
+
[core.ts:489](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L489)
|
|
65
65
|
|
|
66
66
|
***
|
|
67
67
|
|
|
@@ -93,7 +93,7 @@ The result of `fn` if `this` is `Ok`, otherwise `this` as `Err`.
|
|
|
93
93
|
|
|
94
94
|
#### Defined in
|
|
95
95
|
|
|
96
|
-
[core.ts:505](https://github.com/JiangJie/happy-rusty/blob/
|
|
96
|
+
[core.ts:505](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L505)
|
|
97
97
|
|
|
98
98
|
***
|
|
99
99
|
|
|
@@ -122,7 +122,7 @@ Just same as `result as unknown as Result<U, E>`.
|
|
|
122
122
|
|
|
123
123
|
#### Defined in
|
|
124
124
|
|
|
125
|
-
[core.ts:563](https://github.com/JiangJie/happy-rusty/blob/
|
|
125
|
+
[core.ts:563](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L563)
|
|
126
126
|
|
|
127
127
|
***
|
|
128
128
|
|
|
@@ -150,7 +150,7 @@ Just same as `result as unknown as Result<T, F>`.
|
|
|
150
150
|
|
|
151
151
|
#### Defined in
|
|
152
152
|
|
|
153
|
-
[core.ts:552](https://github.com/JiangJie/happy-rusty/blob/
|
|
153
|
+
[core.ts:552](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L552)
|
|
154
154
|
|
|
155
155
|
***
|
|
156
156
|
|
|
@@ -176,7 +176,7 @@ Tests whether `this` and `other` are both `Ok` containing equal values, or both
|
|
|
176
176
|
|
|
177
177
|
#### Defined in
|
|
178
178
|
|
|
179
|
-
[core.ts:540](https://github.com/JiangJie/happy-rusty/blob/
|
|
179
|
+
[core.ts:540](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L540)
|
|
180
180
|
|
|
181
181
|
***
|
|
182
182
|
|
|
@@ -196,7 +196,7 @@ If the result is `Ok`, returns `None`.
|
|
|
196
196
|
|
|
197
197
|
#### Defined in
|
|
198
198
|
|
|
199
|
-
[core.ts:413](https://github.com/JiangJie/happy-rusty/blob/
|
|
199
|
+
[core.ts:413](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L413)
|
|
200
200
|
|
|
201
201
|
***
|
|
202
202
|
|
|
@@ -224,7 +224,7 @@ Throws an error with the provided message if the result is an `Err`.
|
|
|
224
224
|
|
|
225
225
|
#### Defined in
|
|
226
226
|
|
|
227
|
-
[core.ts:356](https://github.com/JiangJie/happy-rusty/blob/
|
|
227
|
+
[core.ts:356](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L356)
|
|
228
228
|
|
|
229
229
|
***
|
|
230
230
|
|
|
@@ -252,7 +252,7 @@ Throws an error with the provided message if the result is an `Ok`.
|
|
|
252
252
|
|
|
253
253
|
#### Defined in
|
|
254
254
|
|
|
255
|
-
[core.ts:385](https://github.com/JiangJie/happy-rusty/blob/
|
|
255
|
+
[core.ts:385](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L385)
|
|
256
256
|
|
|
257
257
|
***
|
|
258
258
|
|
|
@@ -284,7 +284,7 @@ If the result is `Ok(Err(E))` or `Err(E)`, returns `Err(E)`.
|
|
|
284
284
|
|
|
285
285
|
#### Defined in
|
|
286
286
|
|
|
287
|
-
[core.ts:473](https://github.com/JiangJie/happy-rusty/blob/
|
|
287
|
+
[core.ts:473](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L473)
|
|
288
288
|
|
|
289
289
|
***
|
|
290
290
|
|
|
@@ -311,7 +311,7 @@ Does not modify the `Result`.
|
|
|
311
311
|
|
|
312
312
|
#### Defined in
|
|
313
313
|
|
|
314
|
-
[core.ts:523](https://github.com/JiangJie/happy-rusty/blob/
|
|
314
|
+
[core.ts:523](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L523)
|
|
315
315
|
|
|
316
316
|
***
|
|
317
317
|
|
|
@@ -338,7 +338,7 @@ Does not modify the `Result`.
|
|
|
338
338
|
|
|
339
339
|
#### Defined in
|
|
340
340
|
|
|
341
|
-
[core.ts:531](https://github.com/JiangJie/happy-rusty/blob/
|
|
341
|
+
[core.ts:531](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L531)
|
|
342
342
|
|
|
343
343
|
***
|
|
344
344
|
|
|
@@ -356,7 +356,7 @@ Returns `true` if the result is `Err`.
|
|
|
356
356
|
|
|
357
357
|
#### Defined in
|
|
358
358
|
|
|
359
|
-
[core.ts:329](https://github.com/JiangJie/happy-rusty/blob/
|
|
359
|
+
[core.ts:329](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L329)
|
|
360
360
|
|
|
361
361
|
***
|
|
362
362
|
|
|
@@ -380,7 +380,7 @@ Returns `true` if the result is `Err` and the provided predicate returns `true`
|
|
|
380
380
|
|
|
381
381
|
#### Defined in
|
|
382
382
|
|
|
383
|
-
[core.ts:341](https://github.com/JiangJie/happy-rusty/blob/
|
|
383
|
+
[core.ts:341](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L341)
|
|
384
384
|
|
|
385
385
|
***
|
|
386
386
|
|
|
@@ -398,7 +398,7 @@ Returns `true` if the result is `Ok`.
|
|
|
398
398
|
|
|
399
399
|
#### Defined in
|
|
400
400
|
|
|
401
|
-
[core.ts:324](https://github.com/JiangJie/happy-rusty/blob/
|
|
401
|
+
[core.ts:324](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L324)
|
|
402
402
|
|
|
403
403
|
***
|
|
404
404
|
|
|
@@ -422,7 +422,7 @@ Returns `true` if the result is `Ok` and the provided predicate returns `true` f
|
|
|
422
422
|
|
|
423
423
|
#### Defined in
|
|
424
424
|
|
|
425
|
-
[core.ts:335](https://github.com/JiangJie/happy-rusty/blob/
|
|
425
|
+
[core.ts:335](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L335)
|
|
426
426
|
|
|
427
427
|
***
|
|
428
428
|
|
|
@@ -453,7 +453,7 @@ leaving an `Err` value untouched.
|
|
|
453
453
|
|
|
454
454
|
#### Defined in
|
|
455
455
|
|
|
456
|
-
[core.ts:434](https://github.com/JiangJie/happy-rusty/blob/
|
|
456
|
+
[core.ts:434](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L434)
|
|
457
457
|
|
|
458
458
|
***
|
|
459
459
|
|
|
@@ -484,7 +484,7 @@ leaving an `Ok` value untouched.
|
|
|
484
484
|
|
|
485
485
|
#### Defined in
|
|
486
486
|
|
|
487
|
-
[core.ts:446](https://github.com/JiangJie/happy-rusty/blob/
|
|
487
|
+
[core.ts:446](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L446)
|
|
488
488
|
|
|
489
489
|
***
|
|
490
490
|
|
|
@@ -515,7 +515,7 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
515
515
|
|
|
516
516
|
#### Defined in
|
|
517
517
|
|
|
518
|
-
[core.ts:458](https://github.com/JiangJie/happy-rusty/blob/
|
|
518
|
+
[core.ts:458](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L458)
|
|
519
519
|
|
|
520
520
|
***
|
|
521
521
|
|
|
@@ -546,7 +546,7 @@ Maps a `Result<T, E>` to `U` by applying a function to the contained `Ok` value
|
|
|
546
546
|
|
|
547
547
|
#### Defined in
|
|
548
548
|
|
|
549
|
-
[core.ts:466](https://github.com/JiangJie/happy-rusty/blob/
|
|
549
|
+
[core.ts:466](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L466)
|
|
550
550
|
|
|
551
551
|
***
|
|
552
552
|
|
|
@@ -566,7 +566,7 @@ If the result is `Err`, returns `None`.
|
|
|
566
566
|
|
|
567
567
|
#### Defined in
|
|
568
568
|
|
|
569
|
-
[core.ts:406](https://github.com/JiangJie/happy-rusty/blob/
|
|
569
|
+
[core.ts:406](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L406)
|
|
570
570
|
|
|
571
571
|
***
|
|
572
572
|
|
|
@@ -598,7 +598,7 @@ Returns `this` if it is `Ok`, otherwise returns the passed `Result`.
|
|
|
598
598
|
|
|
599
599
|
#### Defined in
|
|
600
600
|
|
|
601
|
-
[core.ts:497](https://github.com/JiangJie/happy-rusty/blob/
|
|
601
|
+
[core.ts:497](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L497)
|
|
602
602
|
|
|
603
603
|
***
|
|
604
604
|
|
|
@@ -630,7 +630,7 @@ The result of `fn` if `this` is `Err`, otherwise `this` as `Ok`.
|
|
|
630
630
|
|
|
631
631
|
#### Defined in
|
|
632
632
|
|
|
633
|
-
[core.ts:513](https://github.com/JiangJie/happy-rusty/blob/
|
|
633
|
+
[core.ts:513](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L513)
|
|
634
634
|
|
|
635
635
|
***
|
|
636
636
|
|
|
@@ -648,7 +648,7 @@ Custom `toString` implementation that uses the `Result`'s contained value.
|
|
|
648
648
|
|
|
649
649
|
#### Defined in
|
|
650
650
|
|
|
651
|
-
[core.ts:568](https://github.com/JiangJie/happy-rusty/blob/
|
|
651
|
+
[core.ts:568](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L568)
|
|
652
652
|
|
|
653
653
|
***
|
|
654
654
|
|
|
@@ -682,7 +682,7 @@ Transposes a `Result` of an `Option` into an `Option` of a `Result`.
|
|
|
682
682
|
|
|
683
683
|
#### Defined in
|
|
684
684
|
|
|
685
|
-
[core.ts:422](https://github.com/JiangJie/happy-rusty/blob/
|
|
685
|
+
[core.ts:422](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L422)
|
|
686
686
|
|
|
687
687
|
***
|
|
688
688
|
|
|
@@ -704,7 +704,7 @@ Throws an error if the result is an `Err`.
|
|
|
704
704
|
|
|
705
705
|
#### Defined in
|
|
706
706
|
|
|
707
|
-
[core.ts:362](https://github.com/JiangJie/happy-rusty/blob/
|
|
707
|
+
[core.ts:362](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L362)
|
|
708
708
|
|
|
709
709
|
***
|
|
710
710
|
|
|
@@ -726,7 +726,7 @@ Throws an error if the result is an `Ok`.
|
|
|
726
726
|
|
|
727
727
|
#### Defined in
|
|
728
728
|
|
|
729
|
-
[core.ts:391](https://github.com/JiangJie/happy-rusty/blob/
|
|
729
|
+
[core.ts:391](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L391)
|
|
730
730
|
|
|
731
731
|
***
|
|
732
732
|
|
|
@@ -750,7 +750,7 @@ Returns the contained `Ok` value or a provided default.
|
|
|
750
750
|
|
|
751
751
|
#### Defined in
|
|
752
752
|
|
|
753
|
-
[core.ts:368](https://github.com/JiangJie/happy-rusty/blob/
|
|
753
|
+
[core.ts:368](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L368)
|
|
754
754
|
|
|
755
755
|
***
|
|
756
756
|
|
|
@@ -774,4 +774,4 @@ Returns the contained `Ok` value or computes it from a closure if the result is
|
|
|
774
774
|
|
|
775
775
|
#### Defined in
|
|
776
776
|
|
|
777
|
-
[core.ts:374](https://github.com/JiangJie/happy-rusty/blob/
|
|
777
|
+
[core.ts:374](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/core.ts#L374)
|
|
@@ -21,4 +21,4 @@ This is a promise that resolves to `Ok(T)` if the I/O operation was successful,
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[defines.ts:38](https://github.com/JiangJie/happy-rusty/blob/
|
|
24
|
+
[defines.ts:38](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/defines.ts#L38)
|
|
@@ -21,4 +21,4 @@ This is a promise that resolves to either `Some(T)` if the value is present, or
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[defines.ts:13](https://github.com/JiangJie/happy-rusty/blob/
|
|
24
|
+
[defines.ts:13](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/defines.ts#L13)
|
|
@@ -22,4 +22,4 @@ This is a promise that resolves to `Ok(T)` if the operation was successful, or `
|
|
|
22
22
|
|
|
23
23
|
## Defined in
|
|
24
24
|
|
|
25
|
-
[defines.ts:22](https://github.com/JiangJie/happy-rusty/blob/
|
|
25
|
+
[defines.ts:22](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/defines.ts#L22)
|
|
@@ -21,4 +21,4 @@ This is a result that is either `Ok(T)` if the operation was successful, or `Err
|
|
|
21
21
|
|
|
22
22
|
## Defined in
|
|
23
23
|
|
|
24
|
-
[defines.ts:30](https://github.com/JiangJie/happy-rusty/blob/
|
|
24
|
+
[defines.ts:30](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/defines.ts#L30)
|
package/docs/variables/None.md
CHANGED
|
@@ -15,4 +15,4 @@ This constant is frozen to ensure it is immutable and cannot be altered, preserv
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[prelude.ts:10](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[prelude.ts:10](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/prelude.ts#L10)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:19](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:19](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/constants.ts#L19)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:13](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:13](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/constants.ts#L13)
|
|
@@ -15,4 +15,4 @@ Can be used anywhere due to immutability.
|
|
|
15
15
|
|
|
16
16
|
## Defined in
|
|
17
17
|
|
|
18
|
-
[constants.ts:25](https://github.com/JiangJie/happy-rusty/blob/
|
|
18
|
+
[constants.ts:25](https://github.com/JiangJie/happy-rusty/blob/568a73f526d9ce3608e5c5e0ed80e93107bc6adb/src/enum/constants.ts#L25)
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Porting some excellent design implementations from Rust to JavaScript.",
|
|
4
4
|
"author": "jiang115jie@gmail.com",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
|
-
"version": "1.3.
|
|
6
|
+
"version": "1.3.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"source": "src/mod.ts",
|
|
9
9
|
"main": "dist/main.cjs",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@eslint/js": "^9.8.0",
|
|
51
51
|
"@types/eslint__js": "^8.42.3",
|
|
52
52
|
"eslint": "^9.8.0",
|
|
53
|
-
"rollup": "^4.
|
|
53
|
+
"rollup": "^4.20.0",
|
|
54
54
|
"rollup-plugin-dts": "^6.1.1",
|
|
55
55
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
56
56
|
"typedoc": "^0.26.5",
|
package/src/enum/prelude.ts
CHANGED
|
@@ -459,7 +459,7 @@ export function Err<T, E>(error: E): Result<T, E> {
|
|
|
459
459
|
},
|
|
460
460
|
|
|
461
461
|
map<U>(_fn: (value: T) => U): Result<U, E> {
|
|
462
|
-
return
|
|
462
|
+
return Err(error);
|
|
463
463
|
},
|
|
464
464
|
mapErr<F>(fn: (error: E) => F): Result<T, F> {
|
|
465
465
|
return Err(fn(error));
|