Skip to main content
Home

@ton1c/fp@0.1.3

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
11%
Published
5 months ago (0.1.3)
class ResultAsync
implements PromiseLike<Result<T, E>>

Constructors

new
ResultAsync(promise: Promise<Result<T, E>>)

Type Parameters

Methods

private
_transform<
U,
F = E,
>
(fn: (res: Result<T, E>) => Result<U, F>): ResultAsync<U, F>
private
_transformAsync<
U,
F = E,
>
(fn: (res: Result<T, E>) => Promise<Result<U, F>>): ResultAsync<U, F>
andThen<
U,
F,
>
(fn: (value: T) => Result<U, F>): ResultAsync<U, E | F>
andThenAsync<
U,
F,
>
(fn: (value: T) => ResultAsync<U, E | F> | Promise<Result<U, E | F>>): ResultAsync<U, E | F>
flatten(): FlattenResultAsync<ResultAsync<T, E>>
ifErr(fn: (err: E) => unknown): Promise<Result<T, E>>
ifOk(fn: (val: T) => unknown): Promise<Result<T, E>>
map<U>(fn: (value: T) => U): ResultAsync<U, E>
mapAsync<U>(fn: (value: T) => Promise<U>): ResultAsync<U, E>
mapErr<U>(fn: (err: E) => U): ResultAsync<T, U>
mapErrAsync<U>(fn: (value: E) => Promise<U>): ResultAsync<T, U>
match<
A,
B = A,
>
(
ok: (value: T) => A,
err: (err: E) => B,
): Promise<A | B>
then<
A,
B,
>
(
onFulfilled?: (res: Result<T, E>) => A | PromiseLike<A>,
onRejected?: (reason: unknown) => B | PromiseLike<B>,
): PromiseLike<A | B>
toJSON(): Promise<ResultJSON<T, E>>
unwrapOr<U>(defaultValue: U): Promise<T | U>
unwrapOrElse<U>(fn: () => U): Promise<T | U>
void(): ResultAsync<void, E>

Static Methods

fromPromise<
T,
E,
>
(
promise: Promise<T>,
errorMapper: (error: unknown) => E,
): ResultAsync<T, E>
fromPromiseExecutor<
T = void,
E = void,
>
(executor: (
resolve: (value: T | PromiseLike<T>) => void,
reject: (reason?: E) => void,
) => void
): ResultAsync<T, E>
fromSafePromise<T>(promise: Promise<T>): ResultAsync<T, never>
fromThrowable<
Fn extends (...args: any[]) => Promise<any>,
E,
>
(
fn: Fn,
errorMapper: (e: unknown) => E,
): (...args: Parameters<Fn>) => ResultAsync<Awaited<ReturnType<Fn>>, E>
isInstance(obj: unknown): boolean

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";
or

Import directly with a jsr specifier

import { ResultAsync } from "jsr:@ton1c/fp";

Add Package

pnpm i jsr:@ton1c/fp
or (using pnpm 10.8 or older)
pnpm dlx jsr add @ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";

Add Package

yarn add jsr:@ton1c/fp
or (using Yarn 4.8 or older)
yarn dlx jsr add @ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";

Add Package

vlt install jsr:@ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";

Add Package

npx jsr add @ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";

Add Package

bunx jsr add @ton1c/fp

Import symbol

import { ResultAsync } from "@ton1c/fp";