function unsqueeze(array, dims, outer, arraySize) {
  var s = arraySize || size(array); // unsqueeze outer dimensions

  if (outer) {
    for (var i = 0; i < outer; i++) {
      array = [array];
      s.unshift(1);
    }
  } // unsqueeze inner dimensions


  array = _unsqueeze(array, dims, 0);

  while (s.length < dims) {
    s.push(1);
  }

  return array;
}
Unsqueeze a multi dimensional array: add dimensions when missing

Paramter `size` will be mutated to match the new, unqueezed matrix size.

@param {Array} array
@param {number} dims       Desired number of dimensions of the array
@param {number} [outer]    Number of outer dimensions to be added
@param {Array} [arraySize] Current size of array.
@returns {Array} returns the array itself
@private