function resize (array, size, defaultValue) {
  // check the type of the arguments
  if (!Array.isArray(size)) {
    throw new TypeError('Array expected')
  }
  if (size.length === 0) {
    throw new Error('Resizing to scalar is not supported')
  }

  // check whether size contains positive integers
  size.forEach(function (value) {
    if (!isNumber(value) || !isInteger(value) || value < 0) {
      throw new TypeError('Invalid size, must contain positive integers ' +
        '(size: ' + format(size) + ')')
    }
  })

  // convert number to an array
  if (isNumber(array) || isBigNumber(array)) {
    array = [array]
  }

  // recursively resize the array
  const _defaultValue = (defaultValue !== undefined) ? defaultValue : 0
  _resize(array, size, 0, _defaultValue)

  return array
}
Resize a multi dimensional array. The resized array is returned.
@param {Array | number} array         Array to be resized
@param {number[]} size Array with the size of each dimension
@param {*} [defaultValue=0]  Value to be filled in new entries,
                             zero by default. Specify for example `null`,
                             to clearly see entries that are not explicitly
                             set.
@return {Array} array         The resized array