source: node_modules/es-toolkit/dist/function/once.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 237 bytes
RevLine 
[a762898]1function 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
13export { once };
Note: See TracBrowser for help on using the repository browser.