Skip to main content
Module

x/fun/promise.ts>chain

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function chain
import { chain } from "https://deno.land/x/fun@v.2.0.0-alpha.11/promise.ts";

Create a new Promise by chaining over the result of an existing Promise. This is effectively Promise.then.

Examples

Example 1

import { of, chain } from "./promise.ts";
import { pipe } from "./fn.ts";

const result = await pipe(
  of(1),
  chain(n => of(n + 1)),
); // 2

Parameters

faui: (a: A) => Promise<I>

Returns

(ua: Promise<A>) => Promise<I>