New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

merge-ranges

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-ranges

Merge overlapping ranges

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-16.73%
Maintainers
1
Weekly downloads
 
Created
Source

merge-ranges

Merge overlapping numerical ranges GitHub version Build Status

Install

npm install --save merge-ranges

Usage

var mergeRanges = require('merge-ranges');

console.log(mergeRanges([
  [1, 3],
  [11, 14],
  [2, 7],
  [9, 12],
  [15, 19]
]));
//=> [ [1, 7], [9, 14], [15, 19] ]

Ranges are sorted by lowest start number.

Examples

Date ranges

var dates = [
  [new Date('Sat, 08 Aug 2015 06:04:50 +0000'), new Date('Wed, 12 Aug 2015 06:04:50 +0000')],
  [new Date('Mon, 07 Sep 2015 06:04:50 +0000'), new Date('Sun, 13 Sep 2015 06:04:50 +0000')],
  [new Date('Mon, 10 Aug 2015 06:04:50 +0000'), new Date('Fri, 14 Aug 2015 06:04:50 +0000')]
];

console.log(mergeRanges(dates));
//=> [
  [ Sat Aug 08 2015 06:04:50 +0000, Fri Aug 14 2015 06:04:50 +0000 ],
  [ Mon Sep 07 2015 06:04:50 +0000, Sun Sep 13 2015 06:04:50 +0000 ]
]

License

MIT © James Warwood

Keywords

FAQs

Package last updated on 19 Aug 2015

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