Immutable Discontinuous Range
Wrapper for the excellent npm package
This wrapper keeps the exact same API syntax as
- each method that mutates the range, instead returns a mutated clone,
- the range is also sorted after
.add()is used, instead of putting loose ranges at the end.
The immutability makes it fit better with a purely functional code style.
You need to install
drange yourself, so you can upgrade to newer
versions without me having to upgrade this wrapper too :)
yarn add drange drange-immutable# ornpm install --save drange drange-immutable
const range =// orconst range =
const hundred =console // [ 1-100 ]const split = hundredconsole // [ 1-49, 61-100 ]console // [ 1-100 ]// ^^ still the same.// Original drange would have// mutated 'hundred' too.