Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danilosampaio/outersections
It Calculates “Outersections” of ranges.
https://github.com/danilosampaio/outersections
intersection ranges set-theory
Last synced: about 1 month ago
JSON representation
It Calculates “Outersections” of ranges.
- Host: GitHub
- URL: https://github.com/danilosampaio/outersections
- Owner: danilosampaio
- License: mit
- Created: 2017-04-26T02:21:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-05-06T01:09:48.000Z (over 7 years ago)
- Last Synced: 2024-10-12T09:12:48.846Z (2 months ago)
- Topics: intersection, ranges, set-theory
- Language: JavaScript
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# outersections [![Build Status](https://travis-ci.org/danilosampaio/outersections.svg?branch=master)](https://travis-ci.org/danilosampaio/outersections) [![Coverage Status](https://coveralls.io/repos/github/danilosampaio/outersections/badge.svg?branch=master)](https://coveralls.io/github/danilosampaio/outersections?branch=master)
> It Calculates “Outersections” of ranges.
Given a list of ranges:
![Ranges](/outersection.png?raw=true "Ranges")
it calculates the "Outersection" intervals (Hatched area, with no intersections between the A,B,C date ranges).
[Stackoverflow discussion](http://stackoverflow.com/questions/43592891/how-to-calculate-outersections-from-sets-of-date-range)
## Install
```
$ npm install --save outersections
```## Usage
```js
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](http://github.com/danilosampaio)