dream-jobs
TypeScript icon, indicating that this package has built-in type declarations

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);
    });

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.13
    1
    • latest

Version History

Package Sidebar

Install

npm i dream-jobs

Weekly Downloads

1

Version

0.0.13

License

none

Unpacked Size

7.56 kB

Total Files

5

Last publish

Collaborators

  • mariandev