{"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":{"integrity":"sha512-t2j1nTo7vb2m/ZQAq5rcWjQgAglF/2rnvlO0cxkZ1GFOSEt0sQBHaytm5tC1ZNUlmKZAp5XF44kolGL9W/XJ2w==","shasum":"7fc4d348742091d2510328455a556cf137e16d75","tarball":"http://registry-npm.ywwl.com/onetime/download/onetime-3.0.0.tgz","fileCount":4,"unpackedSize":3798,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcRJXlCRA9TVsSAnZWagAAKKkP/jZDW6DTGZu4c6tLTFPc\nGHyKtLQvDOeo8WECIMrmK4QsId/RgJmlEHSjxEnWm0mXaM5A5GbrtARfl92U\nhUurfEdm1lkLljrmRZxMJ3/NFMMhAuRjXYsZ2LP45anqxEwreEspp59iL36b\nxSpi6uDDspYxleIgCmeXY5cSq/I7aXx1j42oCJzgznWSuVCBn5/S7g3sTZan\nwHfGMLi0jg733ccG8SgnNUgKCJuUEjMgWm8geS6Ks2I9gxJItipl2yYqo50S\n65nYEo94T9Q+bIz3hoyBLj25+ajT6oAtj1OQWI4XqBGEcKLPKyrjdwRc1uLB\nv7wUdoIwerc1Qm7mLqEiSLGabsH+CXOG/G1d3rFbYeZqKDapWhEP9S1ZAOzx\n+Rk5UJnw9AENOK5jfx32BvShAzAoyNj/ZYWMsQyIgQ6kORXoh/1pRBv1nRnK\n3p2TvSFwIEvEGPvwMz3bWCjAt4FZlDu34x80J5h7YxjUuEKuE5h0Omup2UcR\nXwXbob7oytHDtbJ5kSljeIWXe7+SHGAGa944nU5LWo5T0T/9jCohBzOe25h+\nh8ue2KvarQPkO7JUHHUIQMvqpv3spQ2k7yPh8mKl/MSUTQVShF3CbzG52CHw\ngvkbCRX1SSVEG3nnb9EO4yJIlTdF6xAS7k1saJyz/wTN0nyFZqV69jB/lEPg\nkD2W\r\n=NG+A\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD7OSQ2HkJ60qXDmnLyemFFVaHTwpb2cJKAuQRoQZwmrgIhAIvvBuB9aLhCqVG894cmVR/WfIY0G++1NDbQ8tTkhfeF"}],"size":1987,"noattachment":false,"key":"/onetime/-/onetime-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/onetime_3.0.0_1547998692929_0.8925190275053334"},"_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":1547998693275,"_cnpm_publish_time":1547998693275,"dist-tags":{"latest":"8.0.0"}}