code: function _validate (array, size, dim) {
    let i
    const len = array.length
  
    if (len !== size[dim]) {
      throw new DimensionError(len, size[dim])
    }
  
    if (dim < size.length - 1) {
      // recursively validate each child array
      const dimNext = dim + 1
      for (i = 0; i < len; i++) {
        const child = array[i]
        if (!Array.isArray(child)) {
          throw new DimensionError(size.length - 1, size.length, '<')
        }
        _validate(array[i], size, dimNext)
      }
    } else {
      // last dimension. none of the childs may be an array
      for (i = 0; i < len; i++) {
        if (Array.isArray(array[i])) {
          throw new DimensionError(size.length + 1, size.length, '>')
        }
      }
    }
  }
docs: Recursively 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
  @param {number} dim   Current dimension
  @throws DimensionError
  @private