Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ranges-merge

Package Overview
Dependencies
Maintainers
1
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ranges-merge

Merge and sort string index ranges

  • 9.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
134K
decreased by-18.77%
Maintainers
1
Weekly downloads
 
Created

What is ranges-merge?

The 'ranges-merge' npm package is used to merge and sort ranges of numbers or strings. It is particularly useful for tasks that involve handling multiple ranges and ensuring they are combined and ordered correctly.

What are ranges-merge's main functionalities?

Merging overlapping ranges

This feature allows you to merge overlapping ranges into a single range. In the example, the ranges [1, 5] and [3, 7] overlap and are merged into [1, 7].

const { mergeRanges } = require('ranges-merge');
const ranges = [[1, 5], [3, 7], [8, 10]];
const merged = mergeRanges(ranges);
console.log(merged); // Output: [[1, 7], [8, 10]]

Sorting ranges

This feature sorts the ranges in ascending order. In the example, the ranges are sorted to be in the order [1, 3], [5, 7], and [8, 10].

const { mergeRanges } = require('ranges-merge');
const ranges = [[5, 7], [1, 3], [8, 10]];
const merged = mergeRanges(ranges);
console.log(merged); // Output: [[1, 3], [5, 7], [8, 10]]

Handling non-overlapping ranges

This feature ensures that non-overlapping ranges are kept separate. In the example, the ranges do not overlap and are returned as they are.

const { mergeRanges } = require('ranges-merge');
const ranges = [[1, 2], [3, 4], [5, 6]];
const merged = mergeRanges(ranges);
console.log(merged); // Output: [[1, 2], [3, 4], [5, 6]]

Other packages similar to ranges-merge

Keywords

FAQs

Package last updated on 21 May 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc