Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

dream-jobs

0.0.13 • Public • Published

Build Status

Offload computationally heavy tasks to Web Workers in supported browsers

Unsupported browsers will run the jobs on the main thread automatically

Examples

const AddNumbers = new Job(function(args) {
    let sum = 0;
    for(const arg of args) {
        sum += arg;
    }
    return sum;
});
 
AddNumbers
    .RunWith([1, 2, 3, 4, 5])
    .then(function(sum) {
        console.log(sum);
    });
const NthFibonacci = new Job(function(n) {
    const one = BigInt(1);
    if(<= 2) return one;
    let a = one, b = one;
 
    for(let i = 2;< n; i++) b = a + (= b);
 
    return b;
});
 
NthFibonacci
    .RunWith(10)
    .then(function(nthFibonacci) {
        console.log(nthFibonacci);
    });
 
NthFibonacci
    .RunWith(10000)
    .then(function(nthFibonacci) {
        console.log(nthFibonacci);
    });

Keywords

none

Install

npm i dream-jobs

DownloadsWeekly Downloads

13

Version

0.0.13

License

none

Unpacked Size

7.56 kB

Total Files

5

Last publish

Collaborators

  • avatar