function validate(array, size) {
  var isScalar = size.length === 0;

  if (isScalar) {
    // scalar
    if (Array.isArray(array)) {
      throw new _error_DimensionError__WEBPACK_IMPORTED_MODULE_2___default.a(array.length, 0);
    }
  } else {
    // array
    _validate(array, size, 0);
  }
}
Validate whether each element in a multi dimensional array has
a size corresponding to the provided size array.
@param {Array} array    Array to be validated
@param {number[]} size  Array with the size of each dimension
@throws DimensionError