fnal-pipe
Part of a series of f
unctional
helpers:
Installation
yarn add fnal-pipe
or
npm install fnal-pipe
Use
import / require
// With >= ES6
// With <= ES5var fnalPipe = default
Syntax
IMPORTANT! All methods can be sync or async, will works \o/
If at least one method is async, the result will be a Promise
Default use
const result =
Using Curring
const result = initialValue
Will implements:
const result =
or (more readble)
const temp1 = const temp2 = const result =
Samples
let resultconst sum2 = value + 2const double = value * 2 // (3 * 2) + 2 = 8result = // result = 8 // (3 + 2) * 2 = 10result = // result = 10 // (((3 + 2) + 2) + 2) = 9result = // result = 9
With async methods
const sum2 = value + 2const square = Promise// (3 + 2) ^ 2 = 25const result = await // result = 25 after all promises be resolved
With async methods inline (Promise syntax)
// (2 + 1) ^ 3 = 27 // result = 27 after all promises be resolved
With inline functions
const initialValue = 5const result = // result = 3600
With async methods inline
const initialValue = 5const result = await //result = 3600 after all promises be resolved
With ES5
const initialValue = 5 //result = 3600 after all promises be resolved