Skip to main content
Module

x/xnd/pipe.ts>default

JavaScript augmentations and supplements
Latest
variable default
import { default } from "https://deno.land/x/xnd@v3.0.2/pipe.ts";

Call some function on a value as its argument and then continue with the return value.

Useful for transforming some value—especially in conjunction with optional chaining (?.).

import pipe from "../pipe.ts";

function getSpecialRandomNumber() {
  return Math.random()[pipe]((n) => n < 0.5 ? n : n * 10);
}

instead of

function getSpecialRandomNumber() {
  const n = Math.random();
  return n < 0.5 ? n : n * 10;
}

type

symbol