{"_id":"onetime","_rev":"175671","name":"onetime","description":"Ensure a function is only called once","dist-tags":{"latest":"6.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2022-10-18T09:10:55.000Z","created":"2013-12-13T21:20:18.951Z","6.0.0":"2021-04-08T13:48:04.866Z","5.1.2":"2020-08-09T20:29:04.963Z","5.1.1":"2020-08-02T10:28:50.856Z","5.1.0":"2019-04-02T02:39:48.168Z","5.0.0":"2019-03-08T05:58:33.472Z","4.0.0":"2019-03-01T09:15:21.375Z","3.0.0":"2019-01-20T15:38:13.275Z","2.0.1":"2017-03-20T03:24:17.619Z","2.0.0":"2016-10-19T18:41:56.004Z","1.1.0":"2015-12-18T00:30:55.390Z","1.0.0":"2014-08-13T17:03:51.426Z","0.1.1":"2014-04-30T22:39:14.004Z","0.1.0":"2013-12-13T21:20:18.951Z"},"users":{},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"versions":{"6.0.0":{"name":"onetime","version":"6.0.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"e5fd86f2303546a2d9cc82f2a72c3ea840f6a2dc","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@6.0.0","_nodeVersion":"12.20.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7c24c18ed1fd2e9bca4bd26806a33613c77d34b4","size":2620,"noattachment":false,"key":"/onetime/-/onetime-6.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-6.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_6.0.0_1617889684671_0.003830851530065793"},"_hasShrinkwrap":false,"publish_time":1617889684866,"_cnpm_publish_time":1617889684866,"_cnpmcore_publish_time":"2021-12-13T12:02:19.424Z"},"5.1.2":{"name":"onetime","version":"5.1.2","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^2.1.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"4fa3c9a40798476514fec36a1720dc85b897cc04","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@5.1.2","_nodeVersion":"14.5.0","_npmVersion":"6.14.7","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"d0e96ebb56b07476df1dd9c4806e5237985ca45e","size":2741,"noattachment":false,"key":"/onetime/-/onetime-5.1.2.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-5.1.2.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_5.1.2_1597004944849_0.8241938525832997"},"_hasShrinkwrap":false,"publish_time":1597004944963,"_cnpm_publish_time":1597004944963},"5.1.1":{"name":"onetime","version":"5.1.1","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^2.1.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"59e0ad2204b5d44b448a71afb13f228d1977f07f","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@5.1.1","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5c8016847b0d67fcedb7eef254751cfcdc7e9418","size":2751,"noattachment":false,"key":"/onetime/-/onetime-5.1.1.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-5.1.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_5.1.1_1596364130751_0.20576953897408923"},"_hasShrinkwrap":false,"publish_time":1596364130856,"_cnpm_publish_time":1596364130856},"5.1.0":{"name":"onetime","version":"5.1.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^2.1.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.1","xo":"^0.24.0"},"gitHead":"8bb24f70649ee69849a0701477ebc7170e7a4f87","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@5.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"fff0f3c91617fe62bb50189636e99ac8a6df7be5","size":2472,"noattachment":false,"key":"/onetime/-/onetime-5.1.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-5.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_5.1.0_1554172787964_0.04244092407114519"},"_hasShrinkwrap":false,"publish_time":1554172788168,"_cnpm_publish_time":1554172788168},"5.0.0":{"name":"onetime","version":"5.0.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^2.0.0"},"devDependencies":{"ava":"^1.3.1","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"4f1b26154e811b5af3958b759b7c29a2c4692ebd","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@5.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"eae9df4c4e114f4fe194167bc14cce2d71939606","size":2425,"noattachment":false,"key":"/onetime/-/onetime-5.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-5.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_5.0.0_1552024713328_0.24572920152994504"},"_hasShrinkwrap":false,"publish_time":1552024713472,"_cnpm_publish_time":1552024713472},"4.0.0":{"name":"onetime","version":"4.0.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^1.0.0"},"devDependencies":{"ava":"^1.1.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"65ad3c02a2ad06d6ec1f49ce80c98f4a5c172bf6","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@4.0.0","_nodeVersion":"10.15.1","_npmVersion":"6.8.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"143112c91abc470e9e70a7b2636ce773c1fdf5b2","size":2386,"noattachment":false,"key":"/onetime/-/onetime-4.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_4.0.0_1551431721222_0.5847573580409424"},"_hasShrinkwrap":false,"publish_time":1551431721375,"_cnpm_publish_time":1551431721375},"3.0.0":{"name":"onetime","version":"3.0.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^1.0.0"},"devDependencies":{"ava":"^1.1.0","xo":"^0.24.0"},"gitHead":"2057a659c432c544e2f14bee3b7e99abc210ba9c","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@3.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"7fc4d348742091d2510328455a556cf137e16d75","size":1987,"noattachment":false,"key":"/onetime/-/onetime-3.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_3.0.0_1547998692929_0.8925190275053334"},"_hasShrinkwrap":false,"publish_time":1547998693275,"_cnpm_publish_time":1547998693275},"2.0.1":{"name":"onetime","version":"2.0.1","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^1.0.0"},"devDependencies":{"ava":"*","xo":"*"},"gitHead":"32bca382f5934c8fe7fd78bcef9ad16b3474948f","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@2.0.1","_shasum":"067428230fd67443b2794b22bba528b6867962d4","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"067428230fd67443b2794b22bba528b6867962d4","size":1943,"noattachment":false,"key":"/onetime/-/onetime-2.0.1.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-2.0.1.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/onetime-2.0.1.tgz_1489980257371_0.244376125279814"},"directories":{},"publish_time":1489980257619,"_cnpm_publish_time":1489980257619,"_hasShrinkwrap":false},"2.0.0":{"name":"onetime","version":"2.0.0","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/onetime.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"mimic-fn":"^1.0.0"},"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"bb498adb2da79e62b923173480803a9c6f759766","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime#readme","_id":"onetime@2.0.0","_shasum":"52aa8110e52fc5126ffc667bd8ec21c2ed209ce6","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"52aa8110e52fc5126ffc667bd8ec21c2ed209ce6","size":1958,"noattachment":false,"key":"/onetime/-/onetime-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/onetime-2.0.0.tgz_1476902515797_0.18329595238901675"},"directories":{},"publish_time":1476902516004,"_cnpm_publish_time":1476902516004,"_hasShrinkwrap":false},"1.1.0":{"name":"onetime","version":"1.1.0","description":"Only call a function once","license":"MIT","repository":{"type":"git","url":"https://github.com/sindresorhus/onetime"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=0.10.0"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["once","one","single","call","function","prevent"],"devDependencies":{"ava":"*","xo":"*"},"gitHead":"6fae2fb77b95b49719d1c270d8ba07d9515bdfe8","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime","_id":"onetime@1.1.0","_shasum":"a1f7838f8314c516f05ecefcbc4ccfe04b4ed789","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a1f7838f8314c516f05ecefcbc4ccfe04b4ed789","size":1868,"noattachment":false,"key":"/onetime/-/onetime-1.1.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1450398655390,"_cnpm_publish_time":1450398655390,"_hasShrinkwrap":false},"1.0.0":{"name":"onetime","version":"1.0.0","description":"Only call a function once. Unlike the module `once`, this one isn't naughty extending `Function.prototype`.","keywords":["once","one","single","call","function","prevent"],"license":"MIT","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"files":["index.js"],"repository":{"type":"git","url":"git://github.com/sindresorhus/onetime"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*"},"engines":{"node":">=0.10.0"},"gitHead":"a4aa1ce5291cc5f32ecb8f4b0a918b12cb47ea5e","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime","_id":"onetime@1.0.0","_shasum":"3a08a8e39d7816df52d34886374fb8ed8b651f62","_from":".","_npmVersion":"1.4.14","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"3a08a8e39d7816df52d34886374fb8ed8b651f62","size":1169,"noattachment":false,"key":"/onetime/-/onetime-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-1.0.0.tgz"},"directories":{},"publish_time":1407949431426,"_cnpm_publish_time":1407949431426,"_hasShrinkwrap":false},"0.1.1":{"name":"onetime","version":"0.1.1","description":"Only call a function once. Unlike the module `once`, this one isn't naughty extending `Function.prototype`.","keywords":["once","one","single","call","function","prevent"],"license":"MIT","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"files":["onetime.js"],"main":"onetime.js","repository":{"type":"git","url":"git://github.com/sindresorhus/onetime"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"*"},"engines":{"node":">=0.8.0"},"bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime","_id":"onetime@0.1.1","dist":{"shasum":"f4204dc15a47f80c43779340d093ad786c1bab21","size":1310,"noattachment":false,"key":"/onetime/-/onetime-0.1.1.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-0.1.1.tgz"},"_from":".","_npmVersion":"1.4.6","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1398897554004,"_cnpm_publish_time":1398897554004,"_hasShrinkwrap":false},"0.1.0":{"name":"onetime","version":"0.1.0","description":"Only call a function once. Unlike the module `once`, this one isn't naughty extending `Function.prototype`.","keywords":["once","one","single","call","function","prevent"],"license":"MIT","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"http://sindresorhus.com"},"files":["onetime.js"],"main":"onetime.js","repository":{"type":"git","url":"git://github.com/sindresorhus/onetime"},"scripts":{"test":"mocha"},"devDependencies":{"mocha":"~1.x"},"engines":{"node":">=0.8.0"},"readmeFilename":"readme.md","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime","_id":"onetime@0.1.0","dist":{"shasum":"971beb7a622f1396b9cf4ef7277262f2b01c8565","size":1508,"noattachment":false,"key":"/onetime/-/onetime-0.1.0.tgz","tarball":"http://name.csiicloud.com:7001/onetime/download/onetime-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1386969618951,"_cnpm_publish_time":1386969618951,"_hasShrinkwrap":false}},"readme":"# onetime\n\n> Ensure a function is only called once\n\nWhen called multiple times it will return the return value from the first call.\n\n*Unlike the module [once](https://github.com/isaacs/once), this one isn't naughty and extending `Function.prototype`.*\n\n## Install\n\n```\n$ npm install onetime\n```\n\n## Usage\n\n```js\nimport onetime from 'onetime';\n\nlet index = 0;\n\nconst foo = onetime(() => ++index);\n\nfoo(); //=> 1\nfoo(); //=> 1\nfoo(); //=> 1\n\nonetime.callCount(foo); //=> 3\n```\n\n```js\nimport onetime from 'onetime';\n\nconst foo = onetime(() => {}, {throw: true});\n\nfoo();\n\nfoo();\n//=> Error: Function `foo` can only be called once\n```\n\n## API\n\n### onetime(fn, options?)\n\nReturns a function that only calls `fn` once.\n\n#### fn\n\nType: `Function`\n\nFunction that should only be called once.\n\n#### options\n\nType: `object`\n\n##### throw\n\nType: `boolean`\\\nDefault: `false`\n\nThrow an error when called more than once.\n\n### onetime.callCount(fn)\n\nReturns a number representing how many times `fn` has been called.\n\nNote: It throws an error if you pass in a function that is not wrapped by `onetime`.\n\n```js\nimport onetime from 'onetime';\n\nconst foo = onetime(() => {});\n\nfoo();\nfoo();\nfoo();\n\nconsole.log(onetime.callCount(foo));\n//=> 3\n```\n\n#### fn\n\nType: `Function`\n\nFunction to get call count from.\n\n## onetime for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of onetime and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-onetime?utm_source=npm-onetime&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/onetime#readme","bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"license":"MIT"}