source: node_modules/es-toolkit/dist/function/before.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: 311 bytes
Line 
1function before(n, func) {
2 if (!Number.isInteger(n) || n < 0) {
3 throw new Error('n must be a non-negative integer.');
4 }
5 let counter = 0;
6 return (...args) => {
7 if (++counter < n) {
8 return func(...args);
9 }
10 return undefined;
11 };
12}
13
14export { before };
Note: See TracBrowser for help on using the repository browser.