Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/binjospookie/math-interval-functions

A tiny (119 bytes) and blazing fast solution for operations on intervals.
https://github.com/binjospookie/math-interval-functions

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# math-interval-functions
![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript&label&labelColor=blue&color=555555)
![Version](https://badgen.net/npm/v/math-interval-functions)
![CI](https://github.com/binjospookie/math-interval-functions/workflows/Build/badge.svg)

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
```javascript
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
```