Skip to content

Making functions self destructing in a few seconds if not executed.

License

Notifications You must be signed in to change notification settings

zkochan/kamikaze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kamikaze

A callback wrapper that executes it with a timeout error if not called in time.

Dependency Status Build Status npm version Coverage Status

Installation

npm install --save kamikaze

Usage

var kamikaze = require('kamikaze')

var cb = kamikaze(5000, function(err, msg) {
  if (err) {
    // if no message was passed for 5 seconds, just output 'Hello world!'
    console.log('Hello world!')
    return
  }

  console.log(msg)
})

// ...if called in less than 5 seconds, this will output 'Just in time!'
cb(null, 'Just in time!')

// to cancel the callback timer just clear it
clearTimeout(cb.timeoutId)

License

MIT © Zoltan Kochan

About

Making functions self destructing in a few seconds if not executed.

Resources

License

Stars

Watchers

Forks

Packages

No packages published