{"_id":"one-time","_rev":"67763","name":"one-time","description":"Run the supplied function exactly one time (once)","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"time":{"modified":"2021-06-03T10:22:32.000Z","created":"2014-09-15T10:45:54.598Z","1.0.0":"2019-05-05T23:29:58.711Z","0.0.4":"2015-03-25T13:09:48.793Z","0.0.3":"2015-01-19T20:15:56.604Z","0.0.2":"2014-10-13T19:49:32.592Z","0.0.1":"2014-09-15T11:13:21.368Z","0.0.0":"2014-09-15T10:45:54.598Z"},"users":{},"author":{"name":"Arnout Kazemier"},"repository":{"type":"git","url":"git+https://github.com/3rd-Eden/one-time.git"},"versions":{"1.0.0":{"name":"one-time","version":"1.0.0","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"test:runner":"mocha test.js","test:watch":"npm run test:runner -- --watch","test":"nyc --reporter=text --reporter=json-summary npm run test:runner"},"repository":{"type":"git","url":"git+https://github.com/3rd-Eden/one-time.git"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","devDependencies":{"assume":"^2.2.0","mocha":"^6.1.4","nyc":"^14.1.0"},"dependencies":{"fn.name":"1.x.x"},"gitHead":"aa7ced4ad6c65b1f5433b4c9fefb3b809adee5fc","bugs":{"url":"https://github.com/3rd-Eden/one-time/issues"},"homepage":"https://github.com/3rd-Eden/one-time#readme","_id":"one-time@1.0.0","_npmVersion":"6.4.0","_nodeVersion":"8.11.4","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"dist":{"shasum":"e06bc174aed214ed58edede573b433bbf827cb45","size":2690,"noattachment":false,"key":"/one-time/-/one-time-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-1.0.0.tgz"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/one-time_1.0.0_1557098998565_0.8127709342319505"},"_hasShrinkwrap":false,"publish_time":1557098998711,"_cnpm_publish_time":1557098998711},"0.0.4":{"name":"one-time","version":"0.0.4","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"100%":"istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100","test":"mocha test.js","watch":"mocha --watch test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js"},"repository":{"type":"git","url":"https://github.com/unshiftio/one-time"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","devDependencies":{"assume":"1.2.x","istanbul":"0.3.x","mocha":"2.2.x","pre-commit":"1.0.x"},"gitHead":"51c3cfdd7ab8d4ffcc3b0d927e914beb88d5c360","bugs":{"url":"https://github.com/unshiftio/one-time/issues"},"homepage":"https://github.com/unshiftio/one-time","_id":"one-time@0.0.4","_shasum":"f8cdf77884826fe4dff93e3a9cc37b1e4480742e","_from":".","_npmVersion":"2.3.0","_nodeVersion":"0.10.35","_npmUser":{"name":"3rdeden","email":"npm@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"dist":{"shasum":"f8cdf77884826fe4dff93e3a9cc37b1e4480742e","size":3092,"noattachment":false,"key":"/one-time/-/one-time-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-0.0.4.tgz"},"directories":{},"publish_time":1427288988793,"_cnpm_publish_time":1427288988793,"_hasShrinkwrap":false},"0.0.3":{"name":"one-time","version":"0.0.3","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"test":"node test.js","coverage":"istanbul cover test.js","test-travis":"istanbul cover test.js --report lcovonly"},"repository":{"type":"git","url":"https://github.com/unshiftio/one-time"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","devDependencies":{"istanbul":"0.3.x","pre-commit":"0.0.x"},"gitHead":"e941dfed83d19daa08bbaa5d0f7e817a13d5541a","bugs":{"url":"https://github.com/unshiftio/one-time/issues"},"homepage":"https://github.com/unshiftio/one-time","_id":"one-time@0.0.3","_shasum":"37323dc8d24785b35a6c041aa362f4e14a1ec03d","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"dist":{"shasum":"37323dc8d24785b35a6c041aa362f4e14a1ec03d","size":1954,"noattachment":false,"key":"/one-time/-/one-time-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-0.0.3.tgz"},"directories":{},"publish_time":1421698556604,"_cnpm_publish_time":1421698556604,"_hasShrinkwrap":false},"0.0.2":{"name":"one-time","version":"0.0.2","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"test":"node test.js","coverage":"istanbul cover test.js","test-travis":"istanbul cover test.js --report lcovonly"},"repository":{"type":"git","url":"https://github.com/unshiftio/one-time"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","devDependencies":{"istanbul":"0.3.x","pre-commit":"0.0.x"},"gitHead":"840cee42dc6c6fb13ee0e6cd2339f4fdaed0fd32","bugs":{"url":"https://github.com/unshiftio/one-time/issues"},"homepage":"https://github.com/unshiftio/one-time","_id":"one-time@0.0.2","_shasum":"a34b178c5dfe556c68a52dff106f257ac15dadd1","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"dist":{"shasum":"a34b178c5dfe556c68a52dff106f257ac15dadd1","size":1797,"noattachment":false,"key":"/one-time/-/one-time-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-0.0.2.tgz"},"directories":{},"publish_time":1413229772592,"_cnpm_publish_time":1413229772592,"_hasShrinkwrap":false},"0.0.1":{"name":"one-time","version":"0.0.1","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"test":"node test.js"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","devDependencies":{"pre-commit":"0.0.x"},"gitHead":"438d60ed0794709badd79ef043cca6acbf745bcc","_id":"one-time@0.0.1","_shasum":"374dd8ac73713d1395bc272b61d4aed6076f6d78","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"dist":{"shasum":"374dd8ac73713d1395bc272b61d4aed6076f6d78","size":1193,"noattachment":false,"key":"/one-time/-/one-time-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-0.0.1.tgz"},"directories":{},"publish_time":1410779601368,"_cnpm_publish_time":1410779601368,"_hasShrinkwrap":false},"0.0.0":{"name":"one-time","version":"0.0.0","description":"Run the supplied function exactly one time (once)","main":"index.js","scripts":{"test":"node test.js"},"keywords":["once","function","single","one","one-time","execution","nope"],"author":{"name":"Arnout Kazemier"},"license":"MIT","_id":"one-time@0.0.0","_shasum":"7ae97cde5f1f96bc46111645c1e769d0ec552f67","_from":".","_npmVersion":"1.4.27","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":"npm@3rd-Eden.com"},{"name":"unshiftio","email":""},{"name":"v1","email":"info@3rd-Eden.com"}],"dist":{"shasum":"7ae97cde5f1f96bc46111645c1e769d0ec552f67","size":985,"noattachment":false,"key":"/one-time/-/one-time-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/one-time/download/one-time-0.0.0.tgz"},"directories":{},"publish_time":1410777954598,"_cnpm_publish_time":1410777954598,"_hasShrinkwrap":false}},"readme":"# one-time\n\nCall the supplied function exactly one time. This prevents double callback\nexecution. This module can be used on both Node.js, React-Native, or browsers\nusing Browserify. No magical ES5/6 methods used unlike the `once` module does\n(except for the async version).\n\n## Installation\n\nThis module is published to the public npm registry and can be installed\nby running:\n\n```sh\nnpm install --save one-time\n```\n\n## Usage (normal)\n\nSimply supply the function with the function that should only be called one\ntime:\n\n```js\nvar one = require('one-time');\n\nfunction load(file, fn) {\n  fn = one(fn);\n\n  eventemitter.once('load', fn);\n  eventemitter.once('error', fn);\n\n  // do stuff\n  eventemitter.emit('error', new Error('Failed to load, but still finished'));\n  eventemitter.emit('load');\n}\n\nfunction example(fn) {\n  fn = one(fn);\n\n  fn();\n  fn('also receives all arguments');\n  fn('it returns the same value') === 'bar';\n  fn('never');\n  fn('gonna');\n  fn('give');\n  fn('you');\n  fn('up');\n}\n\nexample(function () {\n  return 'bar'\n});\n```\n\n## Usage (async)\n\nThe same pattern is available for **async** functions as well, for that you\nshould import that `one-time/async` version instead. This one is optimized\nfor **async** and **await** support. It following exactly the same as the\nnormal version but assumes it's an `async function () {}` that it's wrapping\ninstead of a regular function, and it will return an `async function() {}`\ninstead of a regular function.\n\n```js\nimport one from 'one-time/async';\n\nconst fn = one(async function () {\n  return await example();\n});\n\nawait fn();\nawait fn();\nawait fn();\n```\n\n### Why not `once`?\n\nThe main reason is that `once` cannot be used in a browser environment unless\nit's ES5 compatible. For a module as simple as this I find that unacceptable. In\naddition to that it super heavy on the dependency side. So it's totally not\nsuitable to be used in client side applications.\n\nIn addition to that we make sure that your code stays easy to debug as returned\nfunctions are named in the same way as your supplied functions. Making heap\ninspection and stack traces easier to understand.\n\n## License\n\n[MIT](LICENSE)\n","_attachments":{},"homepage":"https://github.com/3rd-Eden/one-time#readme","bugs":{"url":"https://github.com/3rd-Eden/one-time/issues"},"license":"MIT"}