node/deps/npm/node_modules/once
isaacs 3ccee08759 npm: Upgrade to 1.1.49
- node-gyp@0.6.5
- abstracted-out configs
- publishing over proxies
- bugfixes to all the deps
2012-08-14 20:27:28 -07:00
..
test npm: Upgrade to 1.1.49 2012-08-14 20:27:28 -07:00
LICENSE npm: Upgrade to 1.1.49 2012-08-14 20:27:28 -07:00
README.md npm: Upgrade to 1.1.49 2012-08-14 20:27:28 -07:00
once.js npm: Upgrade to 1.1.49 2012-08-14 20:27:28 -07:00
package.json npm: Upgrade to 1.1.49 2012-08-14 20:27:28 -07:00

README.md

once

Only call a function once.

usage

var once = require('once')

function load (file, cb) {
  cb = once(cb)
  loader.load('file')
  loader.once('load', cb)
  loader.once('error', cb)
}

Or add to the Function.prototype in a responsible way:

// only has to be done once
require('once').proto()

function load (file, cb) {
  cb = cb.once()
  loader.load('file')
  loader.once('load', cb)
  loader.once('error', cb)
}

Ironically, the prototype feature makes this module twice as complicated as necessary.