orbitdb/test/promise-map-series.js
haad 8f990e0ccc Immutable ipfs-log
Use immutable ipfs-log.
Simplify internals.
Remove obsolete dependencies.
Update dependencies.
Use @dignifiedquire's mapSeries for Promises.
Split tests to individual stores.
Improve tests.
Fix build process.
Build size down to 121kb.
Fix benchmarks and examples.
Move Cache to Stores (and to its own module).
2017-03-21 18:13:58 +01:00

17 lines
371 B
JavaScript

'use strict'
// https://gist.github.com/dignifiedquire/dd08d2f3806a7b87f45b00c41fe109b7
module.exports = function mapSeries (list, func) {
const res = []
return list.reduce((acc, next) => {
return acc.then((val) => {
res.push(val)
return func(next)
})
}, Promise.resolve(null)).then((val) => {
res.push(val)
return res.slice(1)
})
}