The instance methods listed below all return promises. Unless noted otherwise
they'll return a new Series
promise. If the original promise is fulfilled
with a value other than an array, the returned promise will (unless noted
otherwise), be fulfilled with a new, empty array. If the original promise
is rejected, the returned promise will be rejected with the same reason.
Iterator callbacks are called with items from the array. No other arguments
are passed. The callbacks may return a value or a Promise
instance.
thenables
are not assimilated.
Parallelization controls the number of pending promises (as returned by an iterator callback) an operation is waiting on. Per operation no new callbacks are invoked when this number reaches the maximum concurrency.
Besides instance methods, the following class methods are inherited from
Promise
:
Series.isInstance()
Series.from()
Series.rejected()
Series.all()
Series.any()
Series.some()
Series.join()
Series.denodeify()
(You may notice all other operations build on top of this method.)
Unlike Array#reduce()
the initial value must be passed as the first
argument. initialValue
may be a promise, iterator
won't be called until
initialValue
has fulfilled. If it rejects, the returned promise is rejected
with the same reason.
This method has no parallel equivalent. Use Series#mapParallel()
to collect
values concurrently, and then use this method with a synchronous iterator.
Iteration is stopped when the promise is fulfilled.
Iteration is stopped when the promise is fulfilled.
Iteration is stopped when the promise is fulfilled.
function compareFunction(a, b) {
return a < b ? -1 : 1;
}
Eventually modifies and returns the original array.
Series
A subclass of
Promise
that makes it easier to interact with promises-for-arrays. Thus, aSeries
promise is expected to be fulfilled with an array.