New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parallel-es

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parallel-es

Simple parallelization for EcmaScript

  • 0.1.18
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

parallel.es

Build Status Coverage Status npm version

A JavaScript library to perform parallel JavaScript computations with ease (and other environments soon).

Getting Started

Install Parallel.es using npm:

npm install --save parallel-es

or yarn:

yarn add parallel-es

Performing a single computation in a background thread is as simple as calling a normal method:

import parallel from "parallel-es";

parallel.run(function () {
	//… compute
	return [1, 2, 3];
}).then(result => console.log(result));

Or use the reactive API to parallelize data stream based operations. The reactive API automatically splits the input array into sub-arrays, computes the sub-results in a web worker, and joins the resulting arrays:

parallel.range(0, 100000)
	.map(value => value * value)
	.then(result => console.log(result));

To show a progress update, use the subscribe method to register a callback that is invoked whenever a sub-result has been computed:

parallel.range(0, 100000)
	.map(value => value * value)
	.subscribe((subresult, taskIndex) => console.log(`The result of the task ${taskIndex} is`, subresult);)
	.then(result => console.log(result));

For more detail, take a look at the API Documentation.

Debugging Support

Parallel.es uses function serialization and, therefore, debugging is not supported out of the box (except if the debugger statement is used. However, there is a webpack plugin that transpiles the program code and generates the needed source maps to enable debugging (at least in Chrome and Firefox Nightly).

Referenced Functions, Variables, and Imports

Parallel.es uses function serialization and, therefore, the variables from the closure (outer scope) are no longer available when the function is invoked in the background thread. However, there is a webpack plugin that rewrites your code and allows you to use constant variables, and as well, functions defined in the outer scope of the task function. The plugin also exposes any used imports in the background thread.

Documentation

The API Documentation is available online. The wiki describes the architecture in more detail. An academical description of the work is available here.

Examples

An example project using parallel-es and comparing its performance to related projects is parallel-es-example. The examples are hosted here.

Browsers support made by @godban

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
iOS Safari
iOS Safari
Chrome for Android
Android
IE10, IE11, Edgelast 2 versionslast 2 versionslast 2 versionslast 2 versionsiOS 5.1, iOS 6, iOS 7, iOS 8, iOS 9Chrome, Android 4.4

Automated browser testing is performed using BrowserStack's open source offer.

BrowserStack

There exist other runtime systems with identical or similar goals. The report of the project thesis compares these runtime systems concerning applicability and runtime performance.

Keywords

FAQs

Package last updated on 16 May 2017

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