source: node_modules/es-toolkit/dist/compat/util/times.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: 351 bytes
RevLine 
[a762898]1import { toInteger } from './toInteger.mjs';
2
3function times(n, getValue) {
4 n = toInteger(n);
5 if (n < 1 || !Number.isSafeInteger(n)) {
6 return [];
7 }
8 const result = new Array(n);
9 for (let i = 0; i < n; i++) {
10 result[i] = typeof getValue === 'function' ? getValue(i) : i;
11 }
12 return result;
13}
14
15export { times };
Note: See TracBrowser for help on using the repository browser.