once-later

1.0.1 • Public • Published

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.

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i once-later

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • schoonology