1.0.0 • Published 4 years ago

@redningsselskapet/data-worker v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

data-worker

Runs a worker function on interval. Every worker instance can be started, stopped, get running status. Optionally name your worker and the worker will be named to what ever you name it + an unique id.

Example code:

// import library
const createWorker = require('data-worker')

// create a worker that runs a worker function every 30 seconds
const myWorker = createWorker({worker: () => console.log('Doing som work...'), interval: 30000, name: 'my-worker'})

// start worker
myWorker.start()

// get worker status
console.log(myWorker.isRunning()) // true

// get worker name
console.log(myWorker.name()) // my-worker-c234df

// stop worker
myWorker.stop()

// get worker status
console.log(myWorker.isRunning()) // false

Run test:

npm test

Configured for use with wallaby testing tool.

1.0.0

4 years ago