var arr = 64 70 80;WorkWork// logs the 64th, the 70th, and the 80th fibonacci numbers
You can get the raw js file here: https://raw.githubusercontent.com/workworkjs/workworkjs/master/workwork.js
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:
<!-- or -->
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
filter but rather to supplement them when heavy computation should be performed on a separate thread.
var arr = 1 2 3;WorkWork
This is slower than if you just used
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.
var arr = 50000 56456 125694;WorkWork;// logs a new array with the 50,000th, the 56456th, and the 125694th prime numbers
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.
var arr = 50000 56456 125694;WorkWork// logs a new array with only the even prime numbers from before
Can also be used in isolation
var arr = 50000 56456 125694;WorkWork// logs an empty array since none of the elements are prime
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