0.0.6 • Published 9 months ago

@fab1o/concurrency v0.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
9 months ago

@fab1o/concurrency

Create simulated jobs for concurrency simulation & testing.

Jobs are all async and each job spend a random amount of time between 0 and 9 seconds to finish.

Examples

Create 100 jobs:

import { createJobs } from '@fab1o/concurrency';

// returns an array of 1000 promises
const jobs = createJobs(100);

Executing jobs

const jobs = createJobs(100);

for (const job of jobs) {
  await job();
}

Erroring out given a frequency rate

If we want every other job to throw an error, we set errorRate option to 0.5 (that is 50%)

const jobs = createJobs(2, { errorRate: 0.5 });

for (const job of jobs) {
  try {
    await job();
    console.log('success');
  } catch {
    console.log('error');
  }
}

// error
// success
0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago