Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

p-j-s

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-j-s

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

  • 1.0.0-beta
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

FAQs

Package last updated on 23 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc