Skip to content

Small method that behaves like the pipe operator of functional languages.

License

Notifications You must be signed in to change notification settings

0xc14m1z/popipe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

popipe

Build Status Coverage Status Maintainability

Small method that behaves like the pipe operator of functional languages.

how to install

$ npm install --save popipe

how to use it

The pipe method takes a variable number of arguments and apply them as transformations to the first argument in a clean way, instead of method calls fall.

import pipe from "popipe"
// or var pipe = require("pipe")

// transformation methods
const doubler = x => x * 2
const incrementer = x => x + 1

const answerOfLife = pipe(5, doubler, doubler, incrementer, doubler)
// 42

If you want to apply additional arguments to transformation methods, use the currying technique having a function that accepts a single parameter as your final result.

const multiplier = y => x => x * y

const answerOfLife = pipe(5, doubler, multiplier(2), incrementer, doubler)
// 42

About

Small method that behaves like the pipe operator of functional languages.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published