code: function getFlatVertexCount(positions, size, startIndex = 0, endIndex) {
    endIndex = endIndex || positions.length;
    if (startIndex >= endIndex) {
      return 0;
    }
    return (
      (isFlatRingClosed(positions, size, startIndex, endIndex) ? 0 : 1) +
      (endIndex - startIndex) / size
    );
  }
docs: Counts the number of vertices in a simple flat array, closes the polygon if needed.
  @param {Array} positions - array of numbers
  @param {Number} size - size of a position, 2 (xy) or 3 (xyz)
  @param {Number} [startIndex] - start index of the path in the positions array
  @param {Number} [endIndex] - end index of the path in the positions array
  @returns {Number} vertex count