pipe-array
Node.js module for optimizing performance in array chaining transformations, e.g.
array;
Install
npm i --save pipe-array
Run tests
Jest based
npm run test
or
npm run test:watch
Example
; const array = 1 2 4 5 6 7 8; const outcome = ;// [2, 4, 6, 8]// [4, 8, 12, 16]// 40
Recommendations
Use with large array >10e6 as it is still slower than: for-loop
, for-of,
forEach. But it is faster than
Array.prototype.map`.
Specification
pipe
Constructor
Pipe;
returns an object
witch can be chained with map
and filter
in any order many times.
map
any;
Follows the Array.prototype.map
specification.
filter
boolean;
Follows the Array.prototype.filter
specification.
build
any | any;boolean;
If no parameter provided just applies early defined map
s and filter
s.
If provided reduce
function, outcome will be transformed
reduce
Follows the Array.prototype.reduce
specification.