Sha256: e113466694272b335372fe1dc26dbafbae3952fb74e2f7a9861b3339a44bf46a
Contents?: true
Size: 911 Bytes
Versions: 62
Compression:
Stored size: 911 Bytes
Contents
# onetime [](https://travis-ci.org/sindresorhus/onetime) > Only call a function once When called multiple times it will return the return value from the first call. *Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.* ## Install ```sh $ npm install --save onetime ``` ## Usage ```js var i = 0; var foo = onetime(function () { return i++; }); foo(); //=> 0 foo(); //=> 0 foo(); //=> 0 ``` ## API ### onetime(function, [shouldThrow]) #### function Type: `function` Function that should only be called once. #### shouldThrow Type: `boolean` Default: `false`  Set to `true` if you want it to fail with a nice and descriptive error when called more than once. ## License MIT © [Sindre Sorhus](http://sindresorhus.com)
Version data entries
62 entries across 62 versions & 1 rubygems