time-merge
v1.0.3
Published
A Node.js utility to merge overlapping or near-continuous time ranges based on a threshold.
Maintainers
Readme
time-merge
A lightweight Node.js utility to merge overlapping or near-continuous time ranges based on a given threshold (in milliseconds).
Useful for merging active time intervals, event logs, or any timestamp ranges.
📦 Installation
Install the package from npm:
npm install time-merge📦 Usage
const { mergeTimeRanges } = require("time-merge");
const ranges = [
[1000, 2000],
[2500, 4000],
[3900, 4100],
[8000, 9000],
[9050, 9500]
];
const threshold = 200;
const result = mergeTimeRanges(ranges, threshold);
console.log(result);
// ✅ Expected Output:
// [
// [1000, 2000],
// [2500, 4100],
// [8000, 9500]
// ]