Pipey
Utility functions to convert instance methods's to context-free functions ready for use with esnext pipeline operator and point-free functional programming.
Read the documentation for more information
Install
To add the project to your project
yarn add pipey
Usage
Import it to your file
;// Note: compose is a regular lodash-like compose function
fromClassPrototype
const map filter = ; const doubleNumbers = ;const doubleOddNumbers = ; ; // Returns [ 6, 10 ]
createPipe
const forEach = ; 1 2 3 4 ; // Logs 1 2 3 4
createPipes
const map filter split = ;const head = first;const compact = ; const getFirstNames = names |> compact |> |> ; ; // Returns ['Akshay', 'John', 'Bruce']
Example use cases
- Using with the amazing pipe operator
const map filter reduce = ; const fromPairs = ; const getInputData = ...document |> |> |> fromPairs; ; // Returns something like { email: 'han.solo@gmail.com', name: 'Han Solo' }
- Working with collection methods
// Two ways to extract methods out (createPipes & fromClassPrototype)const map filter = ;const split = ;const head = first; const getFirstNames = ; ; // Returns ['Akshay', 'John', 'Bruce']
- Working with dom methods
const forEach join = ;const setAttribute = ;const inputs = '.js-input-name' '.js-input-email'; inputs |> |> document |> ;