source: node_modules/es-toolkit/dist/compat/object/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: 830 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5const get = require('./get.js');
6const isArrayLike = require('../predicate/isArrayLike.js');
7const isString = require('../predicate/isString.js');
8
9function at(object, ...paths) {
10 if (paths.length === 0) {
11 return [];
12 }
13 const allPaths = [];
14 for (let i = 0; i < paths.length; i++) {
15 const path = paths[i];
16 if (!isArrayLike.isArrayLike(path) || isString.isString(path)) {
17 allPaths.push(path);
18 continue;
19 }
20 for (let j = 0; j < path.length; j++) {
21 allPaths.push(path[j]);
22 }
23 }
24 const result = [];
25 for (let i = 0; i < allPaths.length; i++) {
26 result.push(get.get(object, allPaths[i]));
27 }
28 return result;
29}
30
31exports.at = at;
Note: See TracBrowser for help on using the repository browser.