function rotate(array, n) {
  asserts.assert(array.length != null);

  if (array.length) {
    n %= array.length;
    if (n > 0) {
      Array.prototype.unshift.apply(array, array.splice(-n, n));
    } else if (n < 0) {
      Array.prototype.push.apply(array, array.splice(0, -n));
    }
  }
  return array;
}
Rotates an array in-place. After calling this method, the element at
index i will be the element previously at index (i - n) %
array.length, for all values of i between 0 and array.length - 1,
inclusive.

For example, suppose list comprises [t, a, n, k, s]. After invoking
rotate(array, 1) (or rotate(array, -4)), array will comprise [s, t, a, n, k].

@param {!Array<T>} array The array to rotate.
@param {number} n The amount to rotate.
@return {!Array<T>} The array.
@template T