{"_id":"@cjser/onetime__v7_0_0","name":"@cjser/onetime__v7_0_0","dist-tags":{"latest":"7.0.0-cjser.2"},"versions":{"7.0.0-cjser.2":{"name":"@cjser/onetime__v7_0_0","version":"7.0.0-cjser.2","description":"Ensure a function is only called once","license":"MIT","repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","require":"./dist-cjser/index.cjs","default":"./index.js"},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"@cjser/mimic-function":"5.0.1-cjser.2"},"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"7.0.0","cjserVersion":2,"original":{"name":"onetime","version":"7.0.0","exports":{"types":"./index.d.ts","default":"./index.js"},"repository":"sindresorhus/onetime","dependencies":{"mimic-function":"^5.0.0"},"files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsd"}}},"_id":"@cjser/onetime__v7_0_0@7.0.0-cjser.2","gitHead":"0168e4aac54a1a9ca6f921419fa5ed9edb53ef4a","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-k6hwOZNmcJQpSHR1ntbwNemNF/OYZEl/29Ck+wDTBVvs+gpbtK7eK6ATjFdERNzd9ltbE6jvmOMcKZad9w9jVw==","shasum":"be06f37a9c19d14307945f3759f4f0aa34ddbc1f","tarball":"https://registry.npmjs.org/@cjser/onetime__v7_0_0/-/onetime__v7_0_0-7.0.0-cjser.2.tgz","fileCount":6,"unpackedSize":9240,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIHLcpdk75yUJH1So60QgmvoRjzUv4jn1RvynXVQHEsbHAiEA7Q+qeFpSF40WZ1DhrUPgxEXE3QLNm9A9Ei1cci9Ygs4="}]},"_npmUser":{"name":"nanahira","email":"nanahira@momobako.com"},"directories":{},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/onetime__v7_0_0_7.0.0-cjser.2_1778130807357_0.12744290376986744"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T05:13:27.278Z","7.0.0-cjser.2":"2026-05-07T05:13:27.515Z","modified":"2026-05-07T05:13:27.767Z"},"maintainers":[{"name":"nanahira","email":"nanahira@momobako.com"}],"description":"Ensure a function is only called once","keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"repository":{"type":"git","url":"https://code.moenext.com/3rdeye/cjser.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","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\n## cjser\n\nThis package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.\nOriginal repository: https://github.com/sindresorhus/onetime\n","readmeFilename":"readme.md","_rev":"1-0fd2a57dfa32df56477806ce97c5a8b5"}