Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/fun/promise.ts>flatmap

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Latest
function flatmap
import { flatmap } from "https://deno.land/x/fun@v2.0.0/promise.ts";

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

Examples

Example 1

import { wrap, flatmap } from "./promise.ts";
import { pipe } from "./fn.ts";

const result = await pipe(
  wrap(1),
  flatmap(n => wrap(n + 1)),
); // 2

Parameters

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

Returns

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