{"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"},"bugs":{"url":"https://github.com/sindresorhus/onetime/issues"},"homepage":"https://github.com/sindresorhus/onetime","_id":"onetime@0.1.0","dist":{"shasum":"971beb7a622f1396b9cf4ef7277262f2b01c8565","tarball":"http://registry-npm.ywwl.com/onetime/download/onetime-0.1.0.tgz","integrity":"sha512-ooCyps9+028xrQdZS6a/ClweDcU7Jnh0UbLWWxpBpQwfZSbly6A1TtvNrm3VWqq7ADeA4rC8nCrtxcp5Om6nrg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhlF94zETR7MrZCWOsz8OPGmy5TaoRbIjQybvdCmT9+AIgLas8VlD8bFYqr3FhUze27fjx7ynodXJs3uQzazbCg/k="}],"size":1508,"noattachment":false,"key":"/onetime/-/onetime-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.17","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"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":1386969618951,"_cnpm_publish_time":1386969618951,"dist-tags":{"latest":"8.0.0"}}