math-interval-functions

A tiny (119 bytes) and blazing fast solution for operations on intervals

Usage no npm install needed!

<script type="module">
  import mathIntervalFunctions from 'https://cdn.skypack.dev/math-interval-functions';
</script>

README

math-interval-functions

Typed with TypeScript Version CI

A tiny (119 bytes) and blazing fast solution for operations on intervals.

Installation

npm i math-interval-functions

Functions

inInterval

Check that value belongs to the interval.

Examples

inInterval({ interval: '(1,5)', value: 1 }); // false
inInterval({ interval: '[1,5)', value: 1 }); // true
inInterval({ interval: '[1,5)', value: 5 }); // false
inInterval({ interval: '[1,5]', value: 5 }); // true
inInterval({ interval: '(1,5]', value: 5 }); // true
inInterval({ interval: '(,5]', value: 5 }); // true
inInterval({ interval: '(,5]', value: 1 }); // true
inInterval({ interval: '123jkvb12h3b12h3', value: 1 }); // false
inInterval({ interval: '[-10,0]', value: -5 }); // true
inInterval({ interval: '[-10,0]', value: 1 }); // false

Addition

WIP

Subtraction

WIP

Multiplication

WIP

Division

WIP

Benchmarks

inInterval: 10,200,104 ops/sec