Skip to content
Make a method callable only once
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
History.md
Makefile
Readme.md
component.json
index.js
package.json

Readme.md

once

Make a function or method callable only once. Useful for initialization methods that may be lazily invoked from several locations, but must only be called once, otherwise the method is a noop.

Installation

$ component install component/once

API

var once = require('once');

Foo.prototype.setup = once(function(){
  // expensive stuff here
});

License

MIT

Something went wrong with that request. Please try again.