1 # onetime [![Build Status](https://travis-ci.org/sindresorhus/onetime.svg?branch=master)](https://travis-ci.org/sindresorhus/onetime)
3 > Only call a function once
5 When called multiple times it will return the return value from the first call.
7 *Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.*
13 $ npm install --save onetime
22 const foo = onetime(() => i++);
32 ### onetime(function, [shouldThrow])
38 Function that should only be called once.
45 ![](screenshot-shouldthrow.png)
47 Set to `true` if you want it to fail with a nice and descriptive error when called more than once.
52 MIT © [Sindre Sorhus](http://sindresorhus.com)