Skip to content

ivan7237d/pipe-function

Repository files navigation

pipe function

A function to pipe a value through a number of transforms.

Installation

npm install pipe-function

or

yarn add pipe-function

or

pnpm add pipe-function

Usage

import { pipe } from "pipe-function";

Takes between 2 and 20 arguments. pipe(x, a, b) is equivalent to b(a(x)), in other words, this function pipes a value through a number of functions in the order that they appear. This article talks about why this function is useful.

When you have a single argument, like const y = pipe(x), pipe is redundant, so you will get a type error, but the code will run and return x. Despite the type error, the type of y will be inferred correctly as type of x.


Contributing guidelines

About

A function to pipe a value through a number of transforms

Topics

Resources

License

Stars

Watchers

Forks