source: node_modules/es-toolkit/dist/array/at.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: 488 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5function at(arr, indices) {
6 const result = new Array(indices.length);
7 const length = arr.length;
8 for (let i = 0; i < indices.length; i++) {
9 let index = indices[i];
10 index = Number.isInteger(index) ? index : Math.trunc(index) || 0;
11 if (index < 0) {
12 index += length;
13 }
14 result[i] = arr[index];
15 }
16 return result;
17}
18
19exports.at = at;
Note: See TracBrowser for help on using the repository browser.