Function: unwrapOrNull()
Call Signature
unwrapOrNull<
R>(result):null|UnwrapOk<R>
Defined in: index.ts:433
Unwraps a Result, returning the data for Ok results and null for Err results. This is a convenience function that's equivalent to calling unwrapOr(result, null).
Type Parameters
R
R extends Result<any, any>
Type of the Result to unwrap
Parameters
result
NonPromise<R>
The Result to unwrap
Returns
null | UnwrapOk<R>
Data from the Ok result or null for Err results
Example
unwrapOrNull(ok("hello")); // "hello"
unwrapOrNull(err("error")); // nullCall Signature
unwrapOrNull<
R>(result):Promise<null|UnwrapOk<R>>
Defined in: index.ts:434
Unwraps a Result, returning the data for Ok results and null for Err results. This is a convenience function that's equivalent to calling unwrapOr(result, null).
Type Parameters
R
R extends OrPromise<Result<any, any>>
Type of the Result to unwrap
Parameters
result
R
The Result to unwrap
Returns
Promise<null | UnwrapOk<R>>
Data from the Ok result or null for Err results
Example
unwrapOrNull(ok("hello")); // "hello"
unwrapOrNull(err("error")); // null