Streamline built-ins
October 17, 2015 ยท View on GitHub
Array functions
These functions are asynchronous variants of the EcmaScript 5 Array functions.
Common Rules:
These variants are postfixed by an underscore.
They take the _ callback as first parameter.
They pass the _ callback as first argument to their fn callback.
Most of them have an optional options second parameter which controls the level of
parallelism. This options parameter may be specified either as { parallel: par }
where par is an integer, or directly as a par integer value.
The par values are interpreted as follows:
- If absent or equal to 1, execution is sequential.
- If > 1, at most
paroperations are parallelized. - if 0, a default number of operations are parallelized.
This default is defined by
flows.funnel.defaultSize(4 by default - seeflowsmodule). - If < 0 or Infinity, operations are fully parallelized (no limit).
Functions:
array.forEach_(_[, options], fn[, thisObj])
fnis called asfn(_, elt, i, array).result = array.map_(_[, options], fn[, thisObj])
fnis called asfn(_, elt, i, array).result = array.filter_(_[, options], fn[, thisObj])
fnis called asfn(_, elt, i, array).bool = array.every_(_[, options], fn[, thisObj])
fnis called asfn(_, elt, i, array).bool = array.some_(_[, options], fn[, thisObj])
fnis called asfn(_, elt, i, array).result = array.reduce_(_, fn, val[, thisObj])
fnis called asval = fn(_, val, elt, i, array).result = array.reduceRight_(_, fn, val[, thisObj])
fnis called asval = fn(_, val, elt, i, array).array = array.sort_(_, compare [, beg [, end]])
compareis called ascmp = compare(_, elt1, elt2).
Note: this function changes the original array (and returns it).
Function functions
result = fn.apply_(_, thisObj, args[, index])
Helper to useFunction.prototype.applyinside streamlined functions.
Equivalent toresult = fn.apply(thisObj, argsWith_)whereargsWith_is a modifiedargsin which the callback has been inserted atindex(at the end of the argument list ifindexis omitted or negative).