Skip to main content
Module

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

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

Examples

Example 1

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

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

Parameters

ms: number

Returns

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