Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/19h/rsult
/ functions
Functions
264 in github.com/19h/rsult
⨍
Functions
264
◇
Types & classes
38
↓ 130 callers
Method
unwrap
* Returns the contained `Ok` value, or throws. * * @throws Error if this is `Err`
src/result.ts:82
↓ 91 callers
Function
Some
(val: T)
src/option.ts:646
↓ 86 callers
Function
Ok
(val: T)
src/result.ts:622
↓ 60 callers
Function
None
()
src/option.ts:657
↓ 59 callers
Function
Err
(val: E)
src/result.ts:636
↓ 46 callers
Method
ok
* Converts from `Result<T, E>` to `Option<T>`. * * Returns `Some(value)` if `Ok`, otherwise `None`.
src/result.ts:61
↓ 43 callers
Method
is_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 callers
Method
some
* Creates an OptionAsync containing the value.
src/option-async.ts:51
↓ 39 callers
Method
is_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 callers
Method
is_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 callers
Method
is_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 callers
Method
unwrap_err
* Returns the contained `Err` value, or throws. * * @throws Error if this is `Ok`
src/result.ts:96
↓ 22 callers
Method
err
* Converts from `Result<T, E>` to `Option<E>`. * * Returns `Some(error)` if `Err`, otherwise `None`.
src/result.ts:68
↓ 18 callers
Method
map
* Maps a `Result<T, E>` to `Result<U, E>` by applying `fn` to the `Ok` value.
src/result.ts:127
↓ 16 callers
Method
flatten
* Flattens an `Option<Option<U>>` to `Option<U>`. * * If `T` is not an `Option`, this returns the option unchanged.
src/option.ts:207
↓ 13 callers
Method
andThen
* 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 callers
Method
none
* Creates an empty OptionAsync.
src/option-async.ts:58
↓ 12 callers
Method
or
* Returns `res` if `Err`, otherwise returns the `Ok` value of `self`.
src/result.ts:168
↓ 11 callers
Method
then
* Implements PromiseLike so ResultAsync can be awaited directly.
src/result-async.ts:213
↓ 11 callers
Method
then
* Implements PromiseLike so OptionAsync can be awaited directly.
src/option-async.ts:142
↓ 10 callers
Method
and
* Returns `res` if `Ok`, otherwise returns the `Err` value of `self`.
src/result.ts:157
↓ 10 callers
Method
expect
* Returns the contained `Ok` value, or throws with the provided message. * * @throws Error with `msg` if this is `Err`
src/result.ts:75
↓ 10 callers
Method
try
* 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 callers
Method
inspect
* Calls `fn` with the `Ok` value if present, then returns the original result.
src/result.ts:147
↓ 7 callers
Method
filter
* 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 callers
Function
option_from_nullable
(val: T | null | undefined)
src/option.ts:675
↓ 7 callers
Method
orElse
* Chains a function that returns a Result or ResultAsync on error. * * Used for error recovery. * * @example * ```typescript
src/result-async.ts:364
↓ 7 callers
Method
transpose
* 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 callers
Method
zip
* Zips `self` with another `Option`. * * Returns `Some([T, U])` if both are `Some`, otherwise `None`.
src/option.ts:182
↓ 6 callers
Method
match
* Pattern matches on the result, calling the appropriate handler. * * @example * ```typescript * const message = await result.matc
src/result-async.ts:545
↓ 6 callers
Method
unwrap_or
* Returns the contained `Ok` value or the provided default.
src/result.ts:178
↓ 5 callers
Method
fromPromise
* 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 callers
Method
fromResult
* Creates a ResultAsync from an existing Promise<Result<T, E>>.
src/result-async.ts:51
↓ 5 callers
Function
isResultErr
(val: Result<T, E>)
src/result.ts:272
↓ 5 callers
Function
isResultOk
(val: Result<T, E>)
src/result.ts:265
↓ 5 callers
Function
option_from_promise
(promise: Promise<T>)
src/option.ts:692
↓ 4 callers
Method
all
* Combines multiple ResultAsync values into a single ResultAsync containing an array. * * Short-circuits on the first error encountered.
src/result-async.ts:143
↓ 4 callers
Method
and_then
* Calls `fn` if `Ok`, otherwise returns the `Err` value of `self`. * This is the monadic bind operation (flatMap).
src/result.ts:163
↓ 4 callers
Method
fromOption
* Creates an OptionAsync from an existing Promise<Option<T>>.
src/option-async.ts:44
↓ 4 callers
Method
mapOr
* Maps the Ok value, returning a default if Err.
src/result-async.ts:297
↓ 4 callers
Method
map_err
* Maps a `Result<T, E>` to `Result<T, U>` by applying `fn` to the `Err` value.
src/result.ts:142
↓ 4 callers
Method
map_or
* Returns the provided default (if `Err`), or applies `fn` to the `Ok` value.
src/result.ts:132
↓ 4 callers
Method
or_else
* Calls `fn` if `Err`, otherwise returns the `Ok` value of `self`.
src/result.ts:173
↓ 4 callers
Method
toAsync
* Lifts this Result into a ResultAsync.
src/result-async.ts:617
↓ 4 callers
Method
transmute
* 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 callers
Method
unwrapOr
* Unwraps the Ok value, or returns the provided default.
src/result-async.ts:448
↓ 4 callers
Method
unwrap_or_else
* Returns the contained `Ok` value or computes it from `fn`.
src/result.ts:183
↓ 4 callers
Method
xor
* Returns `Some` if exactly one of `self` and `optb` is `Some`, otherwise `None`.
src/option.ts:128
↓ 3 callers
Function
collect
( results: T )
src/result.ts:702
↓ 3 callers
Method
expect_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 callers
Method
fromNullable
* Creates an OptionAsync from a nullable value.
src/option-async.ts:81
↓ 3 callers
Method
is_err_and
* Returns `true` if `Err` and the error satisfies the predicate.
src/result.ts:122
↓ 3 callers
Method
is_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 callers
Method
is_ok_and
* Returns `true` if `Ok` and the value satisfies the predicate.
src/result.ts:117
↓ 3 callers
Method
is_some_and
* Returns `true` if `Some` and the value satisfies the predicate.
src/option.ts:46
↓ 3 callers
Function
matchOption
( option: Option<T>, handlers: { Some: (value: T) => R; None: () => R; } )
src/option.ts:708
↓ 3 callers
Function
matchResult
( result: Result<T, E>, handlers: { Ok: (value: T) => R; Err: (error: E) => R; } )
src/result.ts:727
↓ 3 callers
Method
take_if
* Takes the value out if it satisfies the predicate, leaving `None` in its place.
src/option.ts:166
↓ 3 callers
Method
zip_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 callers
Method
allSettled
* 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 callers
Method
inspectErr
* Calls the function with the Err value for side effects.
src/result-async.ts:485
↓ 2 callers
Method
inspect_err
* Calls `fn` with the `Err` value if present, then returns the original result.
src/result.ts:152
↓ 2 callers
Method
into_err
* Returns the contained `Err` value. Identical to `unwrap_err()`. * * @throws Error if this is `Ok`
src/result.ts:110
↓ 2 callers
Method
into_ok
* Returns the contained `Ok` value. Identical to `unwrap()`. * * @throws Error if this is `Err`
src/result.ts:103
↓ 2 callers
Method
isErr
* Async version of is_err(). Resolves to true if the result is Err.
src/result-async.ts:242
↓ 2 callers
Method
isNone
* Async version of is_none(). Resolves to true if the option is None.
src/option-async.ts:171
↓ 2 callers
Method
isOk
* Async version of is_ok(). Resolves to true if the result is Ok.
src/result-async.ts:234
↓ 2 callers
Method
isSome
* Async version of is_some(). Resolves to true if the option is Some.
src/option-async.ts:163
↓ 2 callers
Method
iter
* Returns an iterator over the possibly contained `Ok` value. * Yields one element if `Ok`, zero if `Err`.
src/result.ts:191
↓ 2 callers
Method
mapErr
* 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 callers
Method
mapOrElse
* Maps the Ok value, computing a default from the error if Err.
src/result-async.ts:308
↓ 2 callers
Method
map_or_else
* Computes a default (if `Err`), or applies `fn` to the `Ok` value.
src/result.ts:137
↓ 2 callers
Method
ok_or
* Transforms `Option<T>` into `Result<T, E>`. * * Returns `Ok(v)` if `Some(v)`, otherwise `Err(err)`. * * @example * ```types
src/option.ts:225
↓ 2 callers
Method
ok_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 callers
Method
replace
* Replaces the actual value with the provided one, returning the old value. * * @returns An `Option` containing the old value
src/option.ts:173
↓ 2 callers
Function
result_from_promise
( val: Promise<T>, )
src/result.ts:678
↓ 2 callers
Method
take
* 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 callers
Function
try_catch
(fn: () => T)
src/result.ts:657
↓ 2 callers
Method
unwrapOrElse
* Unwraps the Ok value, or computes a default from the error.
src/result-async.ts:456
↓ 2 callers
Method
unwrap_or_default
* Returns the contained `Some` value, or `null` if `None`.
src/option.ts:152
↓ 2 callers
Method
unzip
* Unzips an option containing a tuple into a tuple of options. * * @example * ```typescript * Some([1, "hi"]).unzip() // [Some(1)
src/option.ts:251
↓ 1 callers
Function
fallback
()
src/option-async.test.ts:402
↓ 1 callers
Function
fallback
()
src/result-async.test.ts:478
↓ 1 callers
Function
fetchPosts
(userId: number)
src/result-async.test.ts:447
↓ 1 callers
Function
fetchUser
(id: number)
src/result-async.test.ts:442
↓ 1 callers
Function
findProfile
(profileId: number)
src/option-async.test.ts:373
↓ 1 callers
Function
findUser
(id: number)
src/option-async.test.ts:368
↓ 1 callers
Function
liftAsync
( fn: (...args: Args) => Result<T, E> )
src/result-async.ts:588
↓ 1 callers
Function
primary
()
src/option-async.test.ts:400
↓ 1 callers
Function
primary
()
src/result-async.test.ts:477
↓ 1 callers
Function
secondary
()
src/option-async.test.ts:401
↓ 1 callers
Function
step1
()
src/result-async.test.ts:464
↓ 1 callers
Function
step2
()
src/result-async.test.ts:465
↓ 1 callers
Function
step3
()
src/result-async.test.ts:466
↓ 1 callers
Method
take
()
src/option.ts:402
↓ 1 callers
Function
tryAsync
( fn: (...args: Args) => Promise<T>, errorFn?: (error: unknown) => E )
src/result-async.ts:571
↓ 1 callers
Method
zipWith
* Zips with a function.
src/option-async.ts:406
Method
all
* Combines multiple OptionAsync values into a single OptionAsync containing an array. * * Returns None if any option is None.
src/option-async.ts:117
Method
and
* Returns `None` if `self` is `None`, otherwise returns `opt`.
src/option.ts:107
Method
and
(opt: Option<U>)
src/option.ts:363
next →
1–100 of 264, ranked by callers