{"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":{"integrity":"sha512-0RaJAdwj6KznGJJdJNHmjCUmtsURmC1SLoTzoa9qI5LY8hODas/vjVlEUL19xaSSZfualrMh4myK0dNhVSgDJA==","shasum":"eae9df4c4e114f4fe194167bc14cce2d71939606","tarball":"http://registry-npm.ywwl.com/onetime/download/onetime-5.0.0.tgz","fileCount":5,"unpackedSize":5264,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcggSKCRA9TVsSAnZWagAAcroP/0nvOtQL8JNaCBWgt82Y\nrwN3R4G7THTdkAWVlOSwP4icxL5JJAY2O6e2zetTtsh0283pbE0MEVAby3ul\nV+2p/uZk9eCRB5SHBmt0gC6z0FXjJ1+lWEnwE9I0Vl2VtkLlpQu3oX6uWLef\nuvY5BcLGTj/xa8sDXlLIURgVrOE/I+yXaYmd0KBoA3CQfaMpnSk2txFq8gO1\nu51gvc954fIGuzQLy4vJ4A9RbCMaDP9fVmBS9G+YcZBVec5g/WzMtQska/D2\ni9XkJvTyTuyMGlU5lyDsu/V2PGKXM8O3peqmCsTcnF6YtFbURUclwX81hlSn\nyeH6NZTmPfg6TLixRNl9KhR7u1jV+o8kWNUY6PYjMtjw5bDECTVs7l8Y4oiX\n0CqKygv+h6T7Os6eu+gWTOix30OqEejxinc60x88DiuOzuCI07X8/YX0QQfB\nebVImZO4k2Vv+J2sqgjDjnz9gU16pGqdeCkYACaxPWbkM4/rByUfIXlwiubu\nkZSM/JxKwG+MYj5zj3ld/XMFj3YzLLjgmHbe1oIKNg4Kf9sHQDg5Idh5irU3\nEzpFioQTVodjIPuuLL2qNhQTUYcaPSL9oL8fbTrhOYmBbe0r50vzokpc2O17\nTjgVG5MBt5nbyRYAtztr2iqctPeXkQAP5+nzsCu5HZ4hvVOAFEHZo4/bT1OA\nP37m\r\n=XBd0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDz8Yt+6+27rHmmb6vzE3S+W2+PaQUeK8wO9biW3use4wIgeQoCkdFhqDpO4iHcQX9YYhFy5yJjccnoN8tKtIsrkII="}],"size":2425,"noattachment":false,"key":"/onetime/-/onetime-5.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_5.0.0_1552024713328_0.24572920152994504"},"_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```sh\nnpm 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\nThe function 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\nThe function to get call count from.\n","publish_time":1552024713472,"_cnpm_publish_time":1552024713472,"dist-tags":{"latest":"8.0.0"}}