{"_id":"function-once","_rev":"3757942","name":"function-once","description":"Wraps a function so that it's only ever executed once.","dist-tags":{"latest":"3.0.1"},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"time":{"modified":"2025-03-18T07:12:32.000Z","created":"2023-08-09T17:14:14.039Z","3.0.1":"2025-01-17T00:28:22.343Z","3.0.0":"2023-08-09T17:14:14.039Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/fabiospampinato/function-once.git"},"versions":{"3.0.1":{"name":"function-once","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/function-once.git"},"description":"Wraps a function so that it's only ever executed once.","license":"MIT","version":"3.0.1","type":"module","main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["once","function","call"],"devDependencies":{"fava":"^0.3.4","tsex":"^4.0.2","typescript":"^5.7.3"},"_id":"function-once@3.0.1","gitHead":"06f643f3b2c28a0a0da8915677f3ae8d4dffc138","bugs":{"url":"https://github.com/fabiospampinato/function-once/issues"},"homepage":"https://github.com/fabiospampinato/function-once#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"shasum":"162b9ad8800f53b2e4a1c8d752d8054b4b05423a","size":1650,"noattachment":false,"key":"/function-once/-/function-once-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/function-once/download/function-once-3.0.1.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/function-once_3.0.1_1737073702155_0.6480382974256995"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-01-17T00:28:22.343Z","publish_time":1737073702343,"_source_registry_name":"default","_cnpm_publish_time":1737073702343},"3.0.0":{"name":"function-once","repository":{"type":"git","url":"git+https://github.com/fabiospampinato/function-once.git"},"description":"Wraps a function so that it's only ever executed once.","version":"3.0.0","type":"module","main":"dist/index.js","exports":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"clean":"tsex clean","compile":"tsex compile","compile:watch":"tsex compile --watch","test":"tsex test","test:watch":"tsex test --watch","prepublishOnly":"tsex prepare"},"keywords":["once","function","call"],"devDependencies":{"fava":"^0.2.1","tsex":"^3.0.1","typescript":"^5.1.6"},"gitHead":"d847bbd0a94f01c7e60b5ffa4d802b43757c2722","bugs":{"url":"https://github.com/fabiospampinato/function-once/issues"},"homepage":"https://github.com/fabiospampinato/function-once#readme","_id":"function-once@3.0.0","_nodeVersion":"18.12.0","_npmVersion":"8.19.2","dist":{"shasum":"91bcf26cdad943feb1fa6cebd04c7e2837ab6c53","size":1982,"noattachment":false,"key":"/function-once/-/function-once-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/function-once/download/function-once-3.0.0.tgz"},"_npmUser":{"name":"fabiospampinato","email":"spampinabio@gmail.com"},"directories":{},"maintainers":[{"name":"fabiospampinato","email":"spampinabio@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/function-once_3.0.0_1691601253877_0.9103195283911292"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-08-09T17:14:14.039Z","publish_time":1691601254039,"_source_registry_name":"default","_cnpm_publish_time":1691601254039}},"readme":"# Function Once\n\nWraps a function so that it's only ever executed once.\n\nNote: `this` is always set to `undefined` and only functions that don't accept any arguments are supported, as using those with a function that's only ever executed once is practically just a footgun. If you need different `this` or different arguments you should probably use memoization instead.\n\n## Install\n\n```sh\nnpm install function-once\n```\n\n## Usage\n\n```ts\nimport once from 'function-once';\n\n// Let's make sure a function is at most executed only once\n\nconst rand = once (() => Math.random ());\n\nrand (); // => 0.3344627371267874\nrand (); // => 0.3344627371267874\n```\n\n## License\n\nMIT © Fabio Spampinato\n","_attachments":{},"homepage":"https://github.com/fabiospampinato/function-once#readme","bugs":{"url":"https://github.com/fabiospampinato/function-once/issues"},"license":"MIT"}