code: function flipImageData (data, width, height) {
    const numComponents = data.length / (width * height)
    for (let y = 0; y < height / 2; y++) {
      for (let x = 0; x < width; x++) {
        for (let c = 0; c < numComponents; c++) {
          const i = (y * width + x) * numComponents + c
          const flippedI = ((height - y - 1) * width + x) * numComponents + c
          const tmp = data[i]
          data[i] = data[flippedI]
          data[flippedI] = tmp
        }
      }
    }
  }
docs: Flipping array buffer in place