|
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 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const get = require('./get.js');
|
|---|
| 6 | const isArrayLike = require('../predicate/isArrayLike.js');
|
|---|
| 7 | const isString = require('../predicate/isString.js');
|
|---|
| 8 |
|
|---|
| 9 | function 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 |
|
|---|
| 31 | exports.at = at;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.