Extra methods for promises for arrays
npm install then-array
ArrayPromise
inherits the entire API of promise but all methods return instances of ArrayPromise
where they would've returned instances of Promise
. Those methods are:
ArrayPromise.from(value)
ArrayPromise.all(array) / Promise.all(a, b, c, ...)
ArrayPromise.denodeify(fn)
ArrayPromise.nodeify(fn)
ArrayPromise#then(onFulfilled, onRejected)
ArrayPromise#done(onFulfilled, onRejected)
ArrayPromise#nodeify(callback)
In addition, the following methods are provided with APIs that correspond to the Array equivallents but which support promises everywhere:
-
ArrayPromise#reverse()
returns a promise for a new array with the elements reversed -
ArrayPromise#concat(args...)
if args are arrays or promises for arrays it will return a promise for all the arrays concatenated together. -
ArrayPromise#slice(begin[, end])
return a promise for that portion of the array -
ArrayPromise#map(fn)
parallel, promised map -
ArrayPromise#filter(fn)
parallel, promised filter -
ArrayPromise#reduce(fn[, initial])
promised reduce -
ArrayPromise#reduceRight(fn[, initial])
promised reduceRight
MIT