npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

workworkjs

v1.3.0

Published

A library that speeds up computation-heavy tasks in JavaScript with multi-threading and Web Workers.

Downloads

15

Readme

WorkWorkJS

A library that speeds up computation-heavy tasks in JavaScript with multi-threading and Web Workers.

Demo

https://workworkjs.github.io/workworkjs

Using it

Example

var arr = [64, 70, 80];

WorkWork.map(arr, function (elem) {
    return fibonacci(elem);
})
.then(function (resultArr) {
    console.log(resultArr);
})

// logs the 64th, the 70th, and the 80th fibonacci numbers

Installing it

You can get the raw js file here: https://raw.githubusercontent.com/workworkjs/workworkjs/master/workwork.js

OR run

npm install workworkjs --save 

and configure your static routing to correctly look into the node_modules folder.

Just put it into your script tag like so:

<script src="workwork.js"></script> 
<!-- or -->
<script src="node_modules/workworkjs/workwork.js"></script>

When should I use this?

WorkWork is best suited for situations where heavy blocking computation would otherwise be necessary. It is not intended to replace the original Array.prototype map and filter but rather to supplement them when heavy computation should be performed on a separate thread.

Example

var arr = [1, 2, 3];

WorkWork.map(arr, function (elem) {
    return elem + 1;
})
.then(function (resultArr) {
    console.log(resultArr);
})

This is slower than if you just used

Array.prototype.map 

Methods

WorkWork.map(arr, fn)

Takes in an array as the first argument, and a function as the second that returns a modified elem. Works just like the native Array.prototype.map except WorkWork.map returns a promise that must be resolved.

Example

var arr = [50000, 56456, 125694];

WorkWork.map(arr, nthPrime)
.then(function (resultArr) {
    console.log(resultArr);
});

// logs a new array with the 50,000th, the 56456th, and the 125694th prime numbers

WorkWork.filter(arr, fn)

Takes in an array as the first argument, and a function as the second that returns a true or false. Works just like the native Array.prototype.filter except WorkWork.filter returns a promise that must be resolved.

Example

var arr = [50000, 56456, 125694];

WorkWork.map(arr, nthPrime)
.then(function (resultArr) {
    return WorkWork.filter(resultArr, function (elem) {
        return (elem % 2 === 0);
    });
})
.then(function (resultFilter) {
    console.log(resultFilter);
})

// logs a new array with only the even prime numbers from before

Can also be used in isolation

Example

var arr = [50000, 56456, 125694];

WorkWork.filter(arr, isPrime)
.then(function (resultArr) {
    console.log(resultArr);
})

// logs an empty array since none of the elements are prime

Notes

Our name: https://www.youtube.com/watch?v=2ccZBlLJQ24


More about Web Workers: http://ejohn.org/blog/web-workers/

More about Blobs and inline Workers: http://www.html5rocks.com/en/tutorials/workers/basics/#toc-inlineworkers

Intel's Efforts in River Trail: https://software.intel.com/en-us/articles/river-trail-bringing-parallel-javascript-to-the-web

Parallel.js https://adambom.github.io/parallel.js/