New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rangr

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rangr

Manage ranges and overlaps between them

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

logo

build status coverage status npm version language

rangr is a tool to manage ranges and sets. It's inspired from the LeetCode's Merge Interval problem.

⚠️ NOT ready for production use.

Usage

import Rangr from 'rangr';

const range: Rangr = new Rangr([ [1,3], [2,6], [8,10], [15,18] ]);
console.log(range.toString());
// [1,6],[8,10],[15,18]

range.add([ [ 10, 11 ], [11, 20] ]);
console.log(range.toString());
// [1,6],[8,20]

Features

Array output

To get ranges as an array, use .toArray() method provided.

Example:

const range: Rangr = new Rangr([ [1,3], [2,6] ]);
const arr = range.toArray(); // [ [ 1, 6 ] ]

Iterable output

To get ranges as an iterable, use .toIterable() method provided.

Example:

const range: Rangr = new Rangr([ [1,3], [2,6] ]);
const rangeIterator = range.toIterable();

rangeIterator.next(); // { value: [ 1, 6 ], done: false }
rangeIterator.next(); // { value: undefined, done: true }

Support for ESM and CommonJS

rangr supports both ECMAScript Modules and CommonJS using Conditional Exports provided by Node.js.

CommonJS

const Rangr = require('rangr');

ESM

import Rangr from 'rangr';

Contributions

The package is not very performant in managing th ranges and lacks a rich API. Contributions in the form of issues and PRs are welcome! 🙌🏽

Install

npm i rangr

Test

npm test

License

MIT License

Keywords

range

FAQs

Package last updated on 01 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts