Skip to content

djelic/perioda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perioda

Periodical task runner for Node.js with support for callbacks and promises.

Install

npm install perioda --save

Usage

const perioda = require('perioda')

const fn = function (cb) {
  console.log('running task')
  process.nextTick(cb)
}

// or return Promise

const fn = function () {
  return new Promise((resolve, reject) => {
    // do something
    resolve()
  })
}

const task = perioda(fn, 1000).start()

task.on('error', (err) => {
  console.log('processing error: %s', err.message)
  task.stop()
})

task.on('result', (resutl) => {
  console.log('task result: %j', result)
})

Test

npm test

Licence

MIT

About

Periodical task runner for Node.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published