pf-pipe
v1.0.2
Published
Point Free Pipe function
Readme
import { pipe } from 'fn-pipe';
const numbers = [1, 2, 3, 4, 5]; const newNumbers = pipe( num => num.map(n => n + 1), num => num.reduce((acc, n) => [...acc, n * 2], []), num => num.map(n => n + 1) )(numbers) // return [5, 7, 9, 11, 13]
import { pipe } from 'fn-pipe';
const userPipe = pipe( getUserById, getUserHistory, transformHistory, convertToJson )(userId)
import { pipe } from 'fn-pipe';
const myPromise = (num) => new Promise((resolve, reject) => { if(true){ setTimeout(() => { resolve(num) }, 3000) } else { reject({ error: "Promise reject" }) } })
const myOwnFn = (num) => { return num.filter(num => num != 5) }
const numbers = [1, 2, 3, 4, 5]; const promise = pipe( myPromise, myOwnFn )(numbers) promise .then(res => console.log(res)) // [1, 2, 3, 4] .catch(err => console.log(err))
