Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ranges-invert

codsen4.1kMIT6.0.19TypeScript support: included

Invert string index ranges

array, indexes, ranges, sort, string

readme

ranges-invert

Invert string index ranges

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 4.1.0 (npm i ranges-invert@4.1.0).

npm i ranges-invert

Quick Take

import { strict as assert } from "assert";

import { rInvert } from "ranges-invert";

assert.deepEqual(
  rInvert(
    [
      [3, 5],
      [5, 7],
    ],
    9, // string length needed to set the boundary
  ),
  [
    [0, 3],
    [7, 9],
  ],
);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

6.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

5.2.0 (2022-08-12)

Features

5.1.0 (2022-04-10)

Features

5.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

4.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

4.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

4.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

4.0.0 (2021-01-23)

Features

  • rewrite in TS and start using named exports (e8f27b9)

BREAKING CHANGES

  • previously: import rInvert from ... - now import { rInvert } from ...

3.0.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

2.1.22 (2019-10-02)

Performance Improvements

  • remove check-types-mini and ordinal numbers dependencies (e62326c)

2.1.0 (2019-06-01)

Features

  • If ranges exceed reference string length, result is cropped (as opposed to error) (c05d954)
  • null instead of ranges array produces whole input string (e3ff153)
  • opts.skipChecks and precautionary measures when it's on (b129666)

1.4.0 (2019-01-20)

  • Various documentation and setup tweaks after we migrated to monorepo
  • Setup refresh: updated dependencies and all config files using automated tools

1.1.0 (2018-10-25)

  • Updated all dependencies
  • Restored coveralls.io reporting
  • Restored unit test linting

1.0.0 (2018-06-09)

  • Initial release