Convert an array of exclusions and keep only from / to

The method will always check if from if lower than to and will swap if required.

invert(exclusions: Array, options: object)
Parameters
exclusions (Array = [])
options (object = {})
Name Description
options.from number (default Number.NEGATIVE_INFINITY) Specify min value of zones (after inversion)
options.to number (default Number.POSITIVE_INFINITY) Specify max value of zones (after inversion)

Normalize an array of zones:

  • ensure than from < to
  • merge overlapping zones

The method will always check if from if lower than to and will swap if required.

normalize(zones: Array, options: object)
Parameters
zones (Array = [])
options (object = {})
Name Description
options.from number (default Number.NEGATIVE_INFINITY) Specify min value of a zone
options.to number (default Number.POSITIVE_INFINITY) Specify max value of a zone

zonesWithPoints

src/zonesWithPoints.js

Add the number of points per zone to reach a specified total

zonesWithPoints(zones: Array, numberOfPoints: number?, options: object)
Parameters
zones (Array = [])
numberOfPoints (number?) Total number of points to distribute between zones
options (object = {})
Name Description
options.from number (default Number.NEGATIVE_INFINITY) Specify min value of a zone
options.to number (default Number.POSITIVE_INFINITY) Specify max value of a zone