src/utils/array.js
function _unsqueeze (array, dims, dim) {
  let i, ii

  if (Array.isArray(array)) {
    const next = dim + 1
    for (i = 0, ii = array.length; i < ii; i++) {
      array[i] = _unsqueeze(array[i], dims, next)
    }
  } else {
    for (let d = dim; d < dims; d++) {
      array = [array]
    }
  }

  return array
}
function _unsqueeze (array, dims, dim) {
  let i, ii

  if (Array.isArray(array)) {
    const next = dim + 1
    for (i = 0, ii = array.length; i < ii; i++) {
      array[i] = _unsqueeze(array[i], dims, next)
    }
  } else {
    for (let d = dim; d < dims; d++) {
      array = [array]
    }
  }

  return array
}
function _unsqueeze ( array , dims , dim ) { let i , ii if ( Array . isArray ( array ) ) { const next = dim + 1 for ( i = 0 , ii = array . length ; i < ii ; i ++ ) { array [ i ] = _unsqueeze ( array [ i ] , dims , next ) } } else { for ( let d = dim ; d < dims ; d ++ ) { array = [ array ] } } return array }
Recursively unsqueeze a multi dimensional array
@param {Array} array
@param {number} dims Required number of dimensions
@param {number} dim  Current dimension
@returns {Array | *} Returns the squeezed array
@private
Recursively unsqueeze a multi dimensional array