Security update to Drupal 8.4.6
[yaffs-website] / node_modules / onetime / readme.md
1 # onetime [![Build Status](https://travis-ci.org/sindresorhus/onetime.svg?branch=master)](https://travis-ci.org/sindresorhus/onetime)
2
3 > Only call a function once
4
5 When called multiple times it will return the return value from the first call.
6
7 *Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty extending `Function.prototype`.*
8
9
10 ## Install
11
12 ```
13 $ npm install --save onetime
14 ```
15
16
17 ## Usage
18
19 ```js
20 let i = 0;
21
22 const foo = onetime(() => i++);
23
24 foo(); //=> 0
25 foo(); //=> 0
26 foo(); //=> 0
27 ```
28
29
30 ## API
31
32 ### onetime(function, [shouldThrow])
33
34 #### function
35
36 Type: `function`
37
38 Function that should only be called once.
39
40 #### shouldThrow
41
42 Type: `boolean`  
43 Default: `false`
44
45 ![](screenshot-shouldthrow.png)
46
47 Set to `true` if you want it to fail with a nice and descriptive error when called more than once.
48
49
50 ## License
51
52 MIT © [Sindre Sorhus](http://sindresorhus.com)