"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.transpose = transpose;

/**
 * Switches rows and columns of a two dimensional array.
 */
function transpose(xy) {
  const maxX = xy.length;
  const maxY = Math.max(...xy.map(y => y.length));
  const yx = [];
  let yi = 0;

  for (; yi < maxY; yi++) {
    let xi = 0;
    const x = [];

    for (; xi < maxX; xi++) {
      const y = xy[xi];

      if (yi < y.length) {
        x.push(y[yi]);
      }
    }

    yx.push(x);
  }

  return yx;
}
//# sourceMappingURL=transpose.js.map