MCPcopy Index your code
hub / github.com/josdejong/mathjs / recursiveMapWithIndex

Function recursiveMapWithIndex

src/utils/array.js:879–891  ·  view source on GitHub ↗
(value, depth)

Source from the content-addressed store, hash-verified

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

Callers 1

deepMapFunction · 0.85

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…