{"_id":"@cjser/onetime__v6_0_0","name":"@cjser/onetime__v6_0_0","dist-tags":{"latest":"6.0.0-cjser.2"},"versions":{"6.0.0-cjser.2":{"name":"@cjser/onetime__v6_0_0","version":"6.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":{"require":"./dist-cjser/index.cjs","default":"./index.js"},"engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["once","function","one","onetime","func","fn","single","call","called","prevent"],"dependencies":{"@cjser/mimic-fn__v4_0_0":"4.0.0-cjser.2"},"devDependencies":{"ava":"^3.15.0","tsd":"^0.14.0","xo":"^0.38.2"},"main":"./dist-cjser/index.cjs","cjser":{"sourceVersion":"6.0.0","cjserVersion":2,"original":{"name":"onetime","version":"6.0.0","exports":"./index.js","repository":"sindresorhus/onetime","dependencies":{"mimic-fn":"^4.0.0"},"files":["index.js","index.d.ts"],"scripts":{"test":"xo && ava && tsd"}}},"_id":"@cjser/onetime__v6_0_0@6.0.0-cjser.2","gitHead":"a4bef54d7d22d3d9a6b84528457938d84cd65fe7","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-gSXa5rBfIGQU8yggxev3LGQavUbp1ewYYAwCtZYoIVvNUIcqwGFDR1Q6VrehW1WrGhfuP6KcDSUbHxxH3qF0Aw==","shasum":"f80a3291561a89f8acf555cedb2670d296c7206b","tarball":"https://registry.npmjs.org/@cjser/onetime__v6_0_0/-/onetime__v6_0_0-6.0.0-cjser.2.tgz","fileCount":6,"unpackedSize":9634,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEvWE+fOdncfc1BTT/I11dpxFDTw4tt24I6IT7PrZ2aqAiEAhQsaUV9pipUlNKT1RkwX/c+tnyrhkIiaqIYvduv9haI="}]},"_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__v6_0_0_6.0.0-cjser.2_1778159278301_0.6211983466151876"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-07T13:07:58.143Z","6.0.0-cjser.2":"2026-05-07T13:07:58.437Z","modified":"2026-05-07T13:07:58.737Z"},"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```\n$ npm 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\nFunction 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\nFunction to get call count from.\n\n## onetime for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of onetime and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-onetime?utm_source=npm-onetime&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)\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-7ffa900dd03d492de5b6e5b34a6d8420"}