Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pipe-ts

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pipe-ts

[What is `pipe`?](https://dev.to/benlesh/a-simple-explanation-of-functional-pipe-in-javascript-2hbj)

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
increased by10.21%
Maintainers
1
Weekly downloads
 
Created
Source

pipe-ts

What is pipe?

Installation

yarn add pipe-ts

npm install pipe-ts

pipe

Create a new function which pipes its value through the list functions.

const add1 = (n: number) => n + 1;
const times2 = (n: number) => n * 2;

const add1ThenTimes2 = pipe(
    add1,
    times2,
);
const result: number = add1ThenTimes2(1);

assert.strictEqual(result, 4);

Allows first function to have multiple parameters, using generic rest parameters

const difference = (a: number, b: number) => a - b;
const add1 = (n: number) => n + 1;

const differenceThenAdd1 = pipe(
    difference,
    add1,
);
const result: number = differenceThenAdd1(5, 4);

assert.strictEqual(result, 2);

pipeWith

Transform a value by piping it through the listed functions. Sugar syntax for pipe(f, g)(value).

const add1 = (n: number) => n + 1;
const times2 = (n: number) => n * 2;

const result: number = pipeWith(1, add1, times2);

assert.strictEqual(result, 4);

Development

yarn
npm run start

Keywords

FAQs

Package last updated on 28 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc