function broadcastTo (array, toSize) {
  let Asize = arraySize(array)
  if (deepStrictEqual(Asize, toSize)) {
    return array
  }
  checkBroadcastingRules(Asize, toSize)
  const broadcastedSize = broadcastSizes(Asize, toSize)
  const N = broadcastedSize.length
  const paddedSize = [...Array(N - Asize.length).fill(1), ...Asize]

  let A = clone(array)
  // reshape A if needed to make it ready for concat
  if (Asize.length < N) {
    A = reshape(A, paddedSize)
    Asize = arraySize(A)
  }

  // stretches the array on each dimension to make it the same size as index
  for (let dim = 0; dim < N; dim++) {
    if (Asize[dim] < broadcastedSize[dim]) {
      A = stretch(A, broadcastedSize[dim], dim)
      Asize = arraySize(A)
    }
  }
  return A
}
Broadcasts a single array to a certain size
@param {Array} array Array to be broadcasted
@param {number[]} toSize Size to broadcast the array
@returns {Array} The broadcasted array