# set-of-ranges

> A library of set whose members are defined as ranges.

Latest version **1.0.2** (published 2022-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install set-of-ranges
pnpm add set-of-ranges
yarn add set-of-ranges
bun add set-of-ranges
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-05-29 |
| First published | 2022-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | unicoder |
| Keywords | set, range |

## Links

- npm: https://www.npmjs.com/package/set-of-ranges
- Repository: https://github.com/UniCoderGroup/set-of-ranges
- Homepage: https://github.com/UniCoderGroup/set-of-ranges#readme
- Issues: https://github.com/UniCoderGroup/set-of-ranges/issues
- npm.io page: https://npm.io/package/set-of-ranges

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-05-29
- 1.0.0 — 2022-05-22

## README

# Set of ranges

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/unicodergroup/set-of-ranges/Node.js%20CI?label=CI)[![codecov](https://codecov.io/gh/UniCoderGroup/set-of-ranges/branch/main/graph/badge.svg?token=AYNTXWT16R)](https://codecov.io/gh/UniCoderGroup/set-of-ranges)

## Install

```sh
npm i set-of-ranges
```

## Usage

1. import

   ```typescript
   import { RangeSet } from "set-of-ranges";
   ```

2. construct

   ```typescript
   let rs = new RangeSet("(10,20][40,infinity)");
   //or
   let ranges = [
     {
       value: 1,
       equal: true,
     },
     {
       value: 2,
       equal: false,
     },
   ]; // or = parseRanges("[1,2)");
   let rs = new RangeSet(ranges);
   ```

   > If construct with a string, it will use parseRanges to parse the string to Ranges.

   > When use `parseRanges`, spaces and lower/uppercases are ignored.
   > When input is not allowed, it throws an error.

3. operate

   ```typescript
   import { parseRanges, RangeSet, stringifyRanges } from "set-of-ranges";
   let rs1: RangeSet, rs2: RangeSet, rs3: RangeSet;
   rs1.union(rs2); // ============= rs1 = operate(truthTable_union, rs1, rs2);
   rs1.intersection(rs2); // ====== rs1 = operate(truthTable_intersection, rs1, rs2);

   // You can also do operation to more than 2 ranges.
   rs1.union(rs2, rs3); // ========== rs1 = operate(truthTable_union, rs1, operate(truthTable_union, rs4, rs3));

   // You can use a customized truth table, too.
   rs1.operate(
     [
       [false, false],
       [false, true],
     ],
     rs2
   );
   ```

   > **TruthTable**
   >
   > Copied from sourcecode.
   >
   > ```typescript
   > export type OperateTruthTable = [
   >   //          R:true    R:false
   >   /*L:true */ [boolean, boolean],
   >   /*L:flase*/ [boolean, boolean]
   > ];
   > ```

4. output

   ```typescript
   import { RangeSet, stringifyRanges } from "set-of-ranges";
   let rs1 = new RangeSet("(10  ,20][ 40,infinity )");
   console.log(stringifyRanges(rs1)); //=> "(10,20][40,infinity)"
   ```

## Authors

[**\_Kerman**](https://kermanx.github.io/) @ [_UniCoderGroup_](https://unicodergroup.github.io/)

## License

MIT License

---
_Source: https://npm.io/package/set-of-ranges · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
