@kmamal/interval
v0.0.2
Published
interval
Readme
@kmamal/interval
An interval is represented as a [ start, end ] pair. Intervals are closed, meaning both endpoints are included: [ start, end ] covers every value x where start <= x <= end.
If you need an open (or half-open) interval, use from(). It nudges each open endpoint by the smallest representable amount so the boundary value itself is excluded:
const { from } = require('@kmamal/interval')
from(1, 2) // [ 1, 2 ] closed
from(1, 2, { openStart: true }) // ( 1, 2 ] start excluded
from(1, 2, { openEnd: true }) // [ 1, 2 ) end excluded
from(1, 2, { openStart: true, openEnd: true }) // ( 1, 2 ) both excluded