outersections

0.0.4 • Public • Published

outersections Build Status Coverage Status

It Calculates “Outersections” of ranges.

Given a list of ranges:

Ranges

it calculates the "Outersection" intervals (Hatched area, with no intersections between the A,B,C date ranges).

Stackoverflow discussion

Install

$ npm install --save outersections

Usage

const outersections = require('outersections');
 
let ranges = [
    {begin: new Date(2017, 0, 1), end: new Date(2017, 0, 10)},
    {begin: new Date(2017, 0, 20), end: new Date(2017, 0, 30)},
    {begin: new Date(2017, 0, 1), end: new Date(2017, 0, 7)},
    {begin: new Date(2017, 0, 25), end: new Date(2017, 1, 5)}
];
 
outersections(ranges);
//=> [{ begin: Date(2017, 0, 10), end: Date(2017, 0, 20) }]
 
 
const ranges = [
    {begin: 1, end: 10},
    {begin: 20, end: 30},
    {begin: 1, end: 7},
    {begin: 25, end: 35}
];
 
outersections(ranges);
//=> [{begin: 10, end: 20}]
 

API

outersections(ranges)

input

Type: Array

Array of ranges

License

MIT © Danilo Sampaio

Package Sidebar

Install

npm i outersections

Weekly Downloads

2

Version

0.0.4

License

MIT

Last publish

Collaborators

  • danilosampaio