Skip to content

A simple wrapper around callbacks to make them fire both once and later.

License

Notifications You must be signed in to change notification settings

Schoonology/once-later

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Once-Later

A simple wrapper around callbacks to make them fire both once and later.

Installation

npm install once-later --save

Usage

var later = require('once-later')

function doSomethingAsync(callback) {
  callback = later(callback)
  
  ... later ...
  
  if (err) {
    return callback(err) // Once-Later guarantees no funky return value.
  }
  
  callback(null, ...)
}

Doesn't this already exist?

There's a far more popular version, once, that only guarantees that the function will be called once. This combines that with the recommended practice for callback functions that all callbacks are fired later.

About

A simple wrapper around callbacks to make them fire both once and later.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published