Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tag: v1.1.50

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
test
LICENSE
README.md
once.js
package.json

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.

Something went wrong with that request. Please try again.