Skip to main content
Module

x/fun/promise.ts>delay

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 delay
import { delay } from "https://deno.land/x/fun@v2.0.0-alpha.12/promise.ts";

Delay the resolution of an existing Promise. This does not affect the original promise directly, it only waits for a ms milliseconds before flatmaping into the original promise.

Examples

Example 1

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

// Waits 250 milliseconds before returning
const result = await pipe(
  wrap(1),
  delay(250),
); // 1

Parameters

ms: number

Returns

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