function deepMap (array, callback, skipIndex = false) {
  if (array.length === 0) {
    return []
  }

  if (skipIndex) {
    return recursiveMap(array)
  }
  const index = []

  return recursiveMapWithIndex(array, 0)

  function recursiveMapWithIndex (value, depth) {
    if (Array.isArray(value)) {
      const N = value.length
      const result = Array(N)
      for (let i = 0; i < N; i++) {
        index[depth] = i
        result[i] = recursiveMapWithIndex(value[i], depth + 1)
      }
      return result
    } else {
      return callback(value, index.slice(0, depth), array)
    }
  }
  function recursiveMap (value) {
    if (Array.isArray(value)) {
      const N = value.length
      const result = Array(N)
      for (let i = 0; i < N; i++) {
        result[i] = recursiveMap(value[i])
      }
      return result
    } else {
      return callback(value)
    }
  }
}
Recursively maps over each element of nested array using a provided callback function.

@param {Array} array - The array to be mapped.
@param {Function} callback - The function to execute on each element, taking three arguments:
  - `value` (any): The current element being processed in the array.
  - `index` (Array<number>): The index of the current element being processed in the array.
  - `array` (Array): The array `deepMap` was called upon.
@param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
@returns {Array} A new array with each element being the result of the callback function.