lengths = (segments, bezier) => {
  let sum = 0
  const lengths = [0]
  let previous = valueAt(0, bezier)
  for (let index = 1; index <= segments; index++) {
    const current = valueAt(index / segments, bezier)
    sum += distanceBetween(current, previous)
    lengths.push(sum)
    previous = current
  }
  return lengths
}
Divides the bezier curve into line segments and returns the cumulative length of those segments as an array.
Utility function used to calculate the curve's approximate length and determine the equivalence between arc length and time.

@example
const b = bezier.create([[0, 0], [0, 10]]);
const totalLength = lengths(100, b).pop(); // the last element of the array is the curve's approximate length

@param {Number} segments the number of segments to use when approximating the curve length.
@param {Object} bezier a bezier curve.
@returns an array containing the cumulative length of the segments.