function orientLinearRings(
  flatCoordinates,
  offset,
  ends,
  stride,
  right,
) {
  right = right !== undefined ? right : false;
  for (let i = 0, ii = ends.length; i < ii; ++i) {
    const end = ends[i];
    const isClockwise = linearRingIsClockwise(
      flatCoordinates,
      offset,
      end,
      stride,
    );
    const reverse =
      i === 0
        ? (right && isClockwise) || (!right && !isClockwise)
        : (right && !isClockwise) || (!right && isClockwise);
    if (reverse) {
      reverseCoordinates(flatCoordinates, offset, end, stride);
    }
    offset = end;
  }
  return offset;
}
Orient coordinates in a flat array of linear rings.  By default, rings
are oriented following the left-hand rule (clockwise for exterior and
counter-clockwise for interior rings).  To orient according to the
right-hand rule, use the `right` argument.

@param {Array<number>} flatCoordinates Flat coordinates.
@param {number} offset Offset.
@param {Array<number>} ends Ends.
@param {number} stride Stride.
@param {boolean} [right] Follow the right-hand rule for orientation.
@return {number} End.