Skip to content

v4.0.0

Compare
Choose a tag to compare
@smikitky smikitky released this 15 Jul 05:50
· 125 commits to master since this release

❗️ 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 use import MR from 'multi-integer-range' instead of import { MultiRange as MR } from 'multi-integer-range'.
  • Iterator shimming: The type of Symbol.iterator is no longer strictly checked using typeof. This means polyfilled symbols (using core-js or such) will enable MultiRange.prototype[Symbol.iterator], and for ... of loops will correctly transpile to ES5 using Babel or TypeScript (>=2.3 with --downlevelIteration).
  • Used ES2015 in the documentation.