source: node_modules/es-toolkit/dist/function/before.js

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

Added visualizations

  • Property mode set to 100644
File size: 406 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function before(n, func) {
6 if (!Number.isInteger(n) || n < 0) {
7 throw new Error('n must be a non-negative integer.');
8 }
9 let counter = 0;
10 return (...args) => {
11 if (++counter < n) {
12 return func(...args);
13 }
14 return undefined;
15 };
16}
17
18exports.before = before;
Note: See TracBrowser for help on using the repository browser.