1.0.0-beta • Published 9 years ago

p-j-s v1.0.0-beta

Weekly downloads
109
License
-
Repository
github
Last release
9 years ago

p-j-s build status

A library to parallelize map, filter and reduce operations on typed arrays through the use of Web Workers.

Installing

npm i p-j-s

Usage

It's as simple as:

var pjs = require('p-j-s');

pjs.init(); // initialize the library

pjs(new Uint32Array([1,2,3,4]))
.filter(function(e){
  return e % 2 === 0;
}).map(function(e){
  return e * 2;
}).seq(function(err, result){
    // result is [4,8] a new Uint32Array

    // if we are not using the library any more cleanup once we are done
    pjs.terminate();
});

Operations

map

The map operation invokes the mapper function on each element of the wrapped TypedArray. It produces a new array of the same type where each element is the result of the mapper function.

filter

The filter operation invokes the predicate function on each element of the wrapped TypedArray. It produces a new array of the same type which only includes the original elements for which the predicate function returns true (or a truthy value).

reduce

The reduce operation invokes the reducer function on each element of the wrapped TypedArray passing the value of the previous invocation as current.

The reduction is first performed in the Web Workers using identity as the intial value for current. The results from the Web Workers are collected and a new reduction is performed on them using seed and identityReducer function.

Documentation

You can find out more by checking out the complete API and the How Tos in our wiki.

Acknowledgements

1.0.0-beta

9 years ago

0.5.1

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.0

9 years ago

0.1.0

9 years ago

0.0.1

9 years ago