pushNestedArrayPaths.js 353 B

123456789101112131415
  1. 'use strict';
  2. module.exports = function pushNestedArrayPaths(paths, nestedArray, path) {
  3. if (nestedArray == null) {
  4. return;
  5. }
  6. for (let i = 0; i < nestedArray.length; ++i) {
  7. if (Array.isArray(nestedArray[i])) {
  8. pushNestedArrayPaths(paths, nestedArray[i], path + '.' + i);
  9. } else {
  10. paths.push(path + '.' + i);
  11. }
  12. }
  13. };