popipe

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

Usage no npm install needed!

<script type="module">
  import popipe from 'https://cdn.skypack.dev/popipe';
</script>

README

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