khrome / maplex

Nonblocking parallel mapper for array-like objects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maplex

A multiplexed mapper

I do a huge amount of work just via map/filter/reduce in js, but the one pattern that has never fit cleanly into this pattern is wanting to produce a single map output from many different parallel arrays, asynchronously (and thus, innately yeilding). This does that.

Usage

    import { Maplex } from 'maplex';
    // or
    const { Maplex } = require('maplex');
    Maplex.map(arrayA, ... arrayN, function(itemA, ... itemN){
        //do your work here and store it in finalItem
        return finalItem;
    }, function(result){
        //do something with your mapped value
    });

If you omit the completion function the results are not gathered, which is useful in streaming cases.

Testing

Just run mocha

Enjoy,

-Abbey Hawk Sparrow

About

Nonblocking parallel mapper for array-like objects.


Languages

Language:JavaScript 100.0%