(value, depth)
| 877 | return recursiveMapWithIndex(array, 0) |
| 878 | |
| 879 | function recursiveMapWithIndex (value, depth) { |
| 880 | if (Array.isArray(value)) { |
| 881 | const N = value.length |
| 882 | const result = Array(N) |
| 883 | for (let i = 0; i < N; i++) { |
| 884 | index[depth] = i |
| 885 | result[i] = recursiveMapWithIndex(value[i], depth + 1) |
| 886 | } |
| 887 | return result |
| 888 | } else { |
| 889 | return callback(value, index.slice(0, depth), array) |
| 890 | } |
| 891 | } |
| 892 | function recursiveMap (value) { |
| 893 | if (Array.isArray(value)) { |
| 894 | const N = value.length |