ensue
Ensue performs left-to-right function composition and works like the pipe operator, more common in functional programming languages.
Ensue turns
const seo = data => c(b(a(data)))
into linear form
seq=P( a, b, c )
seq( data )
or even array for steps
seq=[ a, b, c ]
ensue( seq )( data )
Also lib supports nested array of pipes, so you can describe your sequences as simple function lists
Install
npm install --save ensue
Usage
Let's write some short sequences
//Simple validationconst hasStringId = R R//Another sequence: selectorconst getUsers = R Rvalues R
Now we can use composition to get new sequences
const checkLastId = getUsers Rlast hasStringId //Make native function with ensueconst validator = { return flag: }
License
MIT © Zero Bias