v4.0.0
❗️ Breaking Changes
-
The string parser no longer accepts unbounded and negative ranges by default. To parse strings possibly containing unbound/negative ranges (eg
10-
,(-5)-0
), you need to manually pass an option to enable them.const userInput = '-5, 10-15, 30, 45-'; const pagesInMyDoc = [[1, 100]]; const mr = new MultiRange(userInput, { parseUnbounded: true }).intersect(pagesInMyDoc);
Note that this affects only the string parser. Array/number initializers always accept unbounded/negative ranges, just as before.
const mr = new MultiRange([[-5, 3], [10, Inifinity]]); // This is always valid
New
- The constructor now takes an optional
options
parameter, with which you can modify the parsing strategy. See above. MultiRange
is now exported also as the default export of the module. You can useimport MR from 'multi-integer-range'
instead ofimport { MultiRange as MR } from 'multi-integer-range'
.- Iterator shimming: The type of
Symbol.iterator
is no longer strictly checked usingtypeof
. This means polyfilled symbols (using core-js or such) will enableMultiRange.prototype[Symbol.iterator]
, andfor ... of
loops will correctly transpile to ES5 using Babel or TypeScript (>=2.3 with--downlevelIteration
). - Used ES2015 in the documentation.