Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

map

import { map } from "https://github.gh-proxy.cn/raw.githubusercontent.com/baetheus/fun/main/promise.ts";

Create a new Promise by mapping over the result of an existing Promise. This is effectively Promise.then, but narrowed to non-promise returning functions. If the mapping function returns a Promise then the type for this function will be incorrect, as there is no way to create a Promise<Promise>.

@example
import { wrap, map } from "./promise.ts";
import { pipe } from "./fn.ts";

const result = await pipe(
  wrap(1),
  map(n => n + 1),
); // 2
function map<A, I>(fai: (a: A) => I): (ua: Promise<A>) => Promise<I>;
§
map<A, I>(fai: (a: A) => I): (ua: Promise<A>) => Promise<I>
[src]

§Type Parameters

§Parameters

§
fai: (a: A) => I
[src]

§Return Type

§
(ua: Promise<A>) => Promise<I>
[src]