math-interval-2
v1.1.0
Published
Create math intervals like '(-∞, 100]' and test values
Downloads
39
Maintainers
Readme
math-interval
Please have look at wikipedia if you don't know what it means.
Install
yarn add math-interval-2
or npm install --save math-interval-2
Big thanks to @npm
for finding math-interval
"too similar" to an existing package, that's why I had to suffix -2
Usage
import { MathInterval } from 'math-interval-2'
const interval = MathInterval.closedOpen(1, 5);
interval.contains(1) // true
interval.contains(3) // true
interval.contains(5) // false
const another = MathInterval.openClosed(4, 10);
interval.isConnectedTo(another) // true;
interval.encloses(another) // false
iterval.span(another) // [1, 10]
iterval.intersection(another) // (4, 5]
For more, please check tests and docs
Date support
For now you have to convert it to number with date.getTime()
, see Date.prototype.getTime(), you can track the direct date support via #5.