Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/semigradsky/math-interval-formatter
Format a math interval object
https://github.com/semigradsky/math-interval-formatter
Last synced: 19 days ago
JSON representation
Format a math interval object
- Host: GitHub
- URL: https://github.com/semigradsky/math-interval-formatter
- Owner: Semigradsky
- License: mit
- Created: 2015-02-17T12:54:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-02-24T10:17:18.000Z (over 9 years ago)
- Last Synced: 2024-08-08T21:11:05.058Z (3 months ago)
- Language: JavaScript
- Size: 97.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Math interval formatter [![Build Status](https://travis-ci.org/Semigradsky/math-interval-formatter.svg)](https://travis-ci.org/Semigradsky/math-interval-formatter) [![Dependency Status](https://david-dm.org/Semigradsky/math-interval-formatter.svg)](https://david-dm.org/Semigradsky/math-interval-formatter)
> Parse math interval object to string.
## Install
```sh
$ npm install --save math-interval-formatter
```## Usage
`format(interval, options)`
```js
var format = require('math-interval-formatter');var interval = {
from: {
value: -Math.PI,
included: true
},
to: {
value: Infinity,
included: false
}
};format(interval);
//=> '[-3.142,Infinity)'format(interval, {
format: 'pretty',
infiniteEndpoints: 'math',
numberFormat: '+0.0000'
});
//=> '[3.1416, +∞)'```
See tests for more details.
### Available options
- `format`
- 'default' //=> '[-10,10]'
- 'pretty' //=> '[-10, 10]'
- 'interval' //=> '[-10..10]'- `excludedEndpoints`
- 'parenthesis' //=> '(-10,10)'
- 'reversed' //=> ']-10,10['- `infiniteEndpoints`
- 'default' //=> '[0,Infinity)'
- 'none' //=> '[0,)'
- 'math' //=> '[0,∞)'- `numberFormat` // default '0.[000]'
- See available formats in [simple-number-formatter repo](https://github.com/Semigradsky/simple-number-formatter)## License
MIT © Dmitry Semigradsky