source: node_modules/es-toolkit/dist/compat/object/at.mjs@ a762898

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

Added visualizations

  • Property mode set to 100644
File size: 714 bytes
Line 
1import { get } from './get.mjs';
2import { isArrayLike } from '../predicate/isArrayLike.mjs';
3import { isString } from '../predicate/isString.mjs';
4
5function at(object, ...paths) {
6 if (paths.length === 0) {
7 return [];
8 }
9 const allPaths = [];
10 for (let i = 0; i < paths.length; i++) {
11 const path = paths[i];
12 if (!isArrayLike(path) || isString(path)) {
13 allPaths.push(path);
14 continue;
15 }
16 for (let j = 0; j < path.length; j++) {
17 allPaths.push(path[j]);
18 }
19 }
20 const result = [];
21 for (let i = 0; i < allPaths.length; i++) {
22 result.push(get(object, allPaths[i]));
23 }
24 return result;
25}
26
27export { at };
Note: See TracBrowser for help on using the repository browser.