source:
node_modules/es-toolkit/dist/function/once.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 237 bytes | |
| Rev | Line | |
|---|---|---|
| [a762898] | 1 | function once(func) { |
| 2 | let called = false; | |
| 3 | let cache; | |
| 4 | return function (...args) { | |
| 5 | if (!called) { | |
| 6 | called = true; | |
| 7 | cache = func(...args); | |
| 8 | } | |
| 9 | return cache; | |
| 10 | }; | |
| 11 | } | |
| 12 | ||
| 13 | export { once }; |
Note:
See TracBrowser
for help on using the repository browser.
