UNPKG

@dillonkearns/elm-graphql

Version:

<img src="https://cdn.jsdelivr.net/gh/martimatix/logo-graphqelm/logo.svg" alt="dillonearns/elm-graphql logo" width="40%" align="right">

22 lines (17 loc) 474 B
'use strict'; const pReduce = require('p-reduce'); const is = require('@sindresorhus/is'); module.exports = iterable => { const ret = []; for (const task of iterable) { const type = is(task); if (type !== 'Function') { return Promise.reject(new TypeError(`Expected task to be a \`Function\`, received \`${type}\``)); } } return pReduce(iterable, (_, fn) => { return Promise.resolve().then(fn).then(val => { ret.push(val); }); }).then(() => ret); };