MCPcopy Create free account

hub / github.com/19h/rsult / functions

Functions264 in github.com/19h/rsult

↓ 130 callersMethodunwrap
* Returns the contained `Ok` value, or throws. * * @throws Error if this is `Err`
src/result.ts:82
↓ 91 callersFunctionSome
(val: T)
src/option.ts:646
↓ 86 callersFunctionOk
(val: T)
src/result.ts:622
↓ 60 callersFunctionNone
()
src/option.ts:657
↓ 59 callersFunctionErr
(val: E)
src/result.ts:636
↓ 46 callersMethodok
* Converts from `Result<T, E>` to `Option<T>`. * * Returns `Some(value)` if `Ok`, otherwise `None`.
src/result.ts:61
↓ 43 callersMethodis_some
* Returns `true` if the option is `Some`. * * This is a type guard that narrows the type to `OptionSome<T>`.
src/option.ts:41
↓ 42 callersMethodsome
* Creates an OptionAsync containing the value.
src/option-async.ts:51
↓ 39 callersMethodis_none
* Returns `true` if the option is `None`. * * This is a type guard that narrows the type to `OptionNone<T>`.
src/option.ts:53
↓ 32 callersMethodis_err
* Returns `true` if the result is `Err`. * * This is a type guard that narrows the type to `ResultErr<T, E>`.
src/result.ts:54
↓ 32 callersMethodis_ok
* Returns `true` if the result is `Ok`. * * This is a type guard that narrows the type to `ResultOk<T, E>`.
src/result.ts:47
↓ 23 callersMethodunwrap_err
* Returns the contained `Err` value, or throws. * * @throws Error if this is `Ok`
src/result.ts:96
↓ 22 callersMethoderr
* Converts from `Result<T, E>` to `Option<E>`. * * Returns `Some(error)` if `Err`, otherwise `None`.
src/result.ts:68
↓ 18 callersMethodmap
* Maps a `Result<T, E>` to `Result<U, E>` by applying `fn` to the `Ok` value.
src/result.ts:127
↓ 16 callersMethodflatten
* Flattens an `Option<Option<U>>` to `Option<U>`. * * If `T` is not an `Option`, this returns the option unchanged.
src/option.ts:207
↓ 13 callersMethodandThen
* Chains a function that returns a Result or ResultAsync. * * This is the monadic bind (flatMap) operation for async Results. * *
src/result-async.ts:335
↓ 12 callersMethodnone
* Creates an empty OptionAsync.
src/option-async.ts:58
↓ 12 callersMethodor
* Returns `res` if `Err`, otherwise returns the `Ok` value of `self`.
src/result.ts:168
↓ 11 callersMethodthen
* Implements PromiseLike so ResultAsync can be awaited directly.
src/result-async.ts:213
↓ 11 callersMethodthen
* Implements PromiseLike so OptionAsync can be awaited directly.
src/option-async.ts:142
↓ 10 callersMethodand
* Returns `res` if `Ok`, otherwise returns the `Err` value of `self`.
src/result.ts:157
↓ 10 callersMethodexpect
* Returns the contained `Ok` value, or throws with the provided message. * * @throws Error with `msg` if this is `Err`
src/result.ts:75
↓ 10 callersMethodtry
* Wraps a function that may throw, executing it and capturing the result. * * Supports both sync and async functions. * * @example
src/result-async.ts:111
↓ 9 callersMethodinspect
* Calls `fn` with the `Ok` value if present, then returns the original result.
src/result.ts:147
↓ 7 callersMethodfilter
* Returns `None` if `self` is `None`, otherwise calls `predicate` with the wrapped value. * * Returns `Some(t)` if the predicate returns `tr
src/option.ts:198
↓ 7 callersFunctionoption_from_nullable
(val: T | null | undefined)
src/option.ts:675
↓ 7 callersMethodorElse
* Chains a function that returns a Result or ResultAsync on error. * * Used for error recovery. * * @example * ```typescript
src/result-async.ts:364
↓ 7 callersMethodtranspose
* Transposes an `Option` of a `Result` into a `Result` of an `Option`. * * - `None` → `Ok(None)` * - `Some(Ok(x))` → `Ok(Some(x))`
src/option.ts:267
↓ 7 callersMethodzip
* Zips `self` with another `Option`. * * Returns `Some([T, U])` if both are `Some`, otherwise `None`.
src/option.ts:182
↓ 6 callersMethodmatch
* Pattern matches on the result, calling the appropriate handler. * * @example * ```typescript * const message = await result.matc
src/result-async.ts:545
↓ 6 callersMethodunwrap_or
* Returns the contained `Ok` value or the provided default.
src/result.ts:178
↓ 5 callersMethodfromPromise
* Wraps a Promise, converting resolution to Ok and rejection to Err. * * @param promise - The promise to wrap * @param errorFn - Option
src/result-async.ts:83
↓ 5 callersMethodfromResult
* Creates a ResultAsync from an existing Promise<Result<T, E>>.
src/result-async.ts:51
↓ 5 callersFunctionisResultErr
(val: Result<T, E>)
src/result.ts:272
↓ 5 callersFunctionisResultOk
(val: Result<T, E>)
src/result.ts:265
↓ 5 callersFunctionoption_from_promise
(promise: Promise<T>)
src/option.ts:692
↓ 4 callersMethodall
* Combines multiple ResultAsync values into a single ResultAsync containing an array. * * Short-circuits on the first error encountered.
src/result-async.ts:143
↓ 4 callersMethodand_then
* Calls `fn` if `Ok`, otherwise returns the `Err` value of `self`. * This is the monadic bind operation (flatMap).
src/result.ts:163
↓ 4 callersMethodfromOption
* Creates an OptionAsync from an existing Promise<Option<T>>.
src/option-async.ts:44
↓ 4 callersMethodmapOr
* Maps the Ok value, returning a default if Err.
src/result-async.ts:297
↓ 4 callersMethodmap_err
* Maps a `Result<T, E>` to `Result<T, U>` by applying `fn` to the `Err` value.
src/result.ts:142
↓ 4 callersMethodmap_or
* Returns the provided default (if `Err`), or applies `fn` to the `Ok` value.
src/result.ts:132
↓ 4 callersMethodor_else
* Calls `fn` if `Err`, otherwise returns the `Ok` value of `self`.
src/result.ts:173
↓ 4 callersMethodtoAsync
* Lifts this Result into a ResultAsync.
src/result-async.ts:617
↓ 4 callersMethodtransmute
* Converts between different Result types by narrowing phantom types. * * - On `Ok<T, E>`: returns `Ok<T, never>` (error type becomes `never
src/result.ts:255
↓ 4 callersMethodunwrapOr
* Unwraps the Ok value, or returns the provided default.
src/result-async.ts:448
↓ 4 callersMethodunwrap_or_else
* Returns the contained `Ok` value or computes it from `fn`.
src/result.ts:183
↓ 4 callersMethodxor
* Returns `Some` if exactly one of `self` and `optb` is `Some`, otherwise `None`.
src/option.ts:128
↓ 3 callersFunctioncollect
( results: T )
src/result.ts:702
↓ 3 callersMethodexpect_err
* Returns the contained `Err` value, or throws with the provided message. * * @throws Error with `msg` if this is `Ok`
src/result.ts:89
↓ 3 callersMethodfromNullable
* Creates an OptionAsync from a nullable value.
src/option-async.ts:81
↓ 3 callersMethodis_err_and
* Returns `true` if `Err` and the error satisfies the predicate.
src/result.ts:122
↓ 3 callersMethodis_none_or
* Returns `true` if `None` OR if the value satisfies the predicate. * * This is the logical complement of `is_some_and` with negated predica
src/option.ts:67
↓ 3 callersMethodis_ok_and
* Returns `true` if `Ok` and the value satisfies the predicate.
src/result.ts:117
↓ 3 callersMethodis_some_and
* Returns `true` if `Some` and the value satisfies the predicate.
src/option.ts:46
↓ 3 callersFunctionmatchOption
( option: Option<T>, handlers: { Some: (value: T) => R; None: () => R; } )
src/option.ts:708
↓ 3 callersFunctionmatchResult
( result: Result<T, E>, handlers: { Ok: (value: T) => R; Err: (error: E) => R; } )
src/result.ts:727
↓ 3 callersMethodtake_if
* Takes the value out if it satisfies the predicate, leaving `None` in its place.
src/option.ts:166
↓ 3 callersMethodzip_with
* Zips `self` and another `Option` with a function. * * Returns `Some(f(t, u))` if both are `Some`, otherwise `None`.
src/option.ts:189
↓ 2 callersMethodallSettled
* Combines multiple ResultAsync values, collecting all errors if any fail. * * Unlike `all`, this doesn't short-circuit and will collect all
src/result-async.ts:178
↓ 2 callersMethodinspectErr
* Calls the function with the Err value for side effects.
src/result-async.ts:485
↓ 2 callersMethodinspect_err
* Calls `fn` with the `Err` value if present, then returns the original result.
src/result.ts:152
↓ 2 callersMethodinto_err
* Returns the contained `Err` value. Identical to `unwrap_err()`. * * @throws Error if this is `Ok`
src/result.ts:110
↓ 2 callersMethodinto_ok
* Returns the contained `Ok` value. Identical to `unwrap()`. * * @throws Error if this is `Err`
src/result.ts:103
↓ 2 callersMethodisErr
* Async version of is_err(). Resolves to true if the result is Err.
src/result-async.ts:242
↓ 2 callersMethodisNone
* Async version of is_none(). Resolves to true if the option is None.
src/option-async.ts:171
↓ 2 callersMethodisOk
* Async version of is_ok(). Resolves to true if the result is Ok.
src/result-async.ts:234
↓ 2 callersMethodisSome
* Async version of is_some(). Resolves to true if the option is Some.
src/option-async.ts:163
↓ 2 callersMethoditer
* Returns an iterator over the possibly contained `Ok` value. * Yields one element if `Ok`, zero if `Err`.
src/result.ts:191
↓ 2 callersMethodmapErr
* Maps the Err value using a sync or async function. * * @example * ```typescript * const result = ResultAsync.err(new Error('fail
src/result-async.ts:282
↓ 2 callersMethodmapOrElse
* Maps the Ok value, computing a default from the error if Err.
src/result-async.ts:308
↓ 2 callersMethodmap_or_else
* Computes a default (if `Err`), or applies `fn` to the `Ok` value.
src/result.ts:137
↓ 2 callersMethodok_or
* Transforms `Option<T>` into `Result<T, E>`. * * Returns `Ok(v)` if `Some(v)`, otherwise `Err(err)`. * * @example * ```types
src/option.ts:225
↓ 2 callersMethodok_or_else
* Transforms `Option<T>` into `Result<T, E>` with a lazily computed error. * * Returns `Ok(v)` if `Some(v)`, otherwise `Err(err())`. *
src/option.ts:238
↓ 2 callersMethodreplace
* Replaces the actual value with the provided one, returning the old value. * * @returns An `Option` containing the old value
src/option.ts:173
↓ 2 callersFunctionresult_from_promise
( val: Promise<T>, )
src/result.ts:678
↓ 2 callersMethodtake
* Takes the value out of the option, leaving a `None` in its place. * * @returns An `Option` containing the original value
src/option.ts:161
↓ 2 callersFunctiontry_catch
(fn: () => T)
src/result.ts:657
↓ 2 callersMethodunwrapOrElse
* Unwraps the Ok value, or computes a default from the error.
src/result-async.ts:456
↓ 2 callersMethodunwrap_or_default
* Returns the contained `Some` value, or `null` if `None`.
src/option.ts:152
↓ 2 callersMethodunzip
* Unzips an option containing a tuple into a tuple of options. * * @example * ```typescript * Some([1, "hi"]).unzip() // [Some(1)
src/option.ts:251
↓ 1 callersFunctionfallback
()
src/option-async.test.ts:402
↓ 1 callersFunctionfallback
()
src/result-async.test.ts:478
↓ 1 callersFunctionfetchPosts
(userId: number)
src/result-async.test.ts:447
↓ 1 callersFunctionfetchUser
(id: number)
src/result-async.test.ts:442
↓ 1 callersFunctionfindProfile
(profileId: number)
src/option-async.test.ts:373
↓ 1 callersFunctionfindUser
(id: number)
src/option-async.test.ts:368
↓ 1 callersFunctionliftAsync
( fn: (...args: Args) => Result<T, E> )
src/result-async.ts:588
↓ 1 callersFunctionprimary
()
src/option-async.test.ts:400
↓ 1 callersFunctionprimary
()
src/result-async.test.ts:477
↓ 1 callersFunctionsecondary
()
src/option-async.test.ts:401
↓ 1 callersFunctionstep1
()
src/result-async.test.ts:464
↓ 1 callersFunctionstep2
()
src/result-async.test.ts:465
↓ 1 callersFunctionstep3
()
src/result-async.test.ts:466
↓ 1 callersMethodtake
()
src/option.ts:402
↓ 1 callersFunctiontryAsync
( fn: (...args: Args) => Promise<T>, errorFn?: (error: unknown) => E )
src/result-async.ts:571
↓ 1 callersMethodzipWith
* Zips with a function.
src/option-async.ts:406
Methodall
* Combines multiple OptionAsync values into a single OptionAsync containing an array. * * Returns None if any option is None.
src/option-async.ts:117
Methodand
* Returns `None` if `self` is `None`, otherwise returns `opt`.
src/option.ts:107
Methodand
(opt: Option<U>)
src/option.ts:363
next →1–100 of 264, ranked by callers