Socket
Book a DemoInstallSign in
Socket

simplify-ranges

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

simplify-ranges

Merge and normalize adjacent or overlapping integer ranges

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
286
-14.63%
Maintainers
1
Weekly downloads
 
Created
Source

simplify-ranges

Merge and normalize adjacent or overlapping integer ranges

Install

npm install simplify-ranges

Usage

import simplifyRanges from 'simplify-ranges';

const ranges = [[1, 2], [3, 4], [2, 3]];

console.log(simplifyRanges(ranges));
//=> [[1, 4]]

API

simplifyRanges(ranges: number[][], options?: object): number[][]

The function takes an array of closed integer ranges.

Normalizes reversed ranges by converting them from [3, 1] to [1, 3] and also supports negative numbers.

options

Type: object

separateTwoNumberRanges

Type: boolean
Default: false

Separate two-number ranges [[1, 2], [4, 5]] into individual ranges [[1, 1], [2, 2], [4, 4], [5, 5]].

This can be useful if you have special handling for single-number ranges.

Keywords

merge

FAQs

Package last updated on 23 Nov 2023

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