map/filter/reduce code that runs much faster than the equivalent native
Instead of passing function arguments to the native array methods
map/filter/reduce to produce a result value in 1 step:
var result = arr.map((x) => x.p).filter((x) => x != null).reduce((a,b) => a + b);
transfun.js uses a 2-step approach: first generate very fast code, then call it:
var appfun = map( '.p' ).filter( '!=null' ).reduce( '+' ); var result = appfun( arr ); // very fast!
Usage with functions
transfun.js also supports normal function arguments:
var appfun = map((x) => x.p ).filter((x) => x!=null ).reduce((out,v) => out+v ); var result = appfun( arr ); // fast!
Merging loops for speed
transfun.js automatically merges consecutive loops into one loop, then generates fast code for that loop (similar to stream fusion in Haskell).
A domain-specific language is used to define
map/filter/reduce. With this language, library users can define other transformations:
sum, and, or...
For the hurried ones
...you can jump directly to the speed results
More about this
The Boost License apply, as described in the file LICENSE.