function-pipe
Motivation
Javascript is a very powerful language. Why not make it even more powerful with a simple functional composition tool? Function pipe allows you to create functions by combining other functions, just like lego blocks.
Features
- Supports Promises or any mixture of sync and async functions
- First function in the pipe can accept multiple arguments
- Peturns a promise when there is a promise in the pipe
- Works synchronously when all the parts of the pipe are synchronous
- Flattens nested arrays of functions
Installation
npm install function-pipe
Usage
const toUppercase = stringconst reverse = stringconst splitInWords = string // Simple useconst pipe1 = console// -> [ '!EGOD', 'HCUM', 'YREV', 'HCUS', 'WOW' ] // -> [ '!EGOD', 'HCUM', 'YREV', 'HCUS', 'WOW' ] // Multiple argumentsconst join = array const pipe2 = console// -> 'DOGE-WOW' // Async functions in the pipeconst asyncPipe = console;
Testing
npm test