1.0.0 • Published 7 years ago
then-fold v1.0.0
- then-fold
Really simple utility function for reducing a Promise returning function with an array of other functions.
#+BEGIN_SRC javascript npm install then-fold #+END_SRC
#+BEGIN_SRC javascript const thenFold = require('then-fold')
// function that returns a Promise function example (x) { return new Promise((resolve, reject) => { resolve(x) }) }
// transformation function function t1 (x) { return x + 1 }
// transformation function that returns a Promise function t2 (x) { return new Promise((resolve, reject) => { setTimeout(() => { resolve(x + 1) }, 200) })
thenFold(example(5), t1, t2 ) // => 7 #+END_SRC
1.0.0
7 years ago