Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
gordonbrander/pipeUtils for piping and composing functions.
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers




JSR Score
76%
Published
10 months ago (0.1.0)
Pipe
Utils for piping and composing functions.
import { flow, pipe } from "@gordonb/pipe"; const double = (n: number) => n * 2; const addOne = (n: number) => n + 1; const toString = (n: number) => n.toString(); const result = pipe(5, double, addOne, toString); // "11" const combined = flow(double, addOne, toString); combined(5); // "11"
This module offers four functions:
pipe(value, ...fns)pipe value through one-argument functions, returning result.pipeAsync(value, ...fns)pipe value through async functions, returning promise for result. The return value of each step is awaited. The next function in the chain will receive the awaited value. pipeAsync allows using sync or async functions in the pipeline.flow(...fns)composes many one-argument functions into a single one-argument function that will apply them left-to-right. This is the opposite direction of traditional function composition, but it reads more nicely with the way JavaScript is typically read/written.flowAsync(...fns)composes many one-argument async functions into a single one-argument async function that will apply them left-to-right. flowAsync supports using both async and ordinary one-argument functions.
All functions support typesafe overloads for up to 20 functions.
Built and signed on
GitHub Actions
Add Package
deno add jsr:@gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";
Import directly with a jsr specifier
import * as pipe from "jsr:@gordonb/pipe";
Add Package
pnpm i jsr:@gordonb/pipe
pnpm dlx jsr add @gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";
Add Package
yarn add jsr:@gordonb/pipe
yarn dlx jsr add @gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";
Add Package
vlt install jsr:@gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";
Add Package
npx jsr add @gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";
Add Package
bunx jsr add @gordonb/pipe
Import symbol
import * as pipe from "@gordonb/pipe";