math-interval-formatter

1.0.0 • Public • Published

Math interval formatter Build Status Dependency Status

Parse math interval object to string.

Install

$ npm install --save math-interval-formatter

Usage

format(interval, options)

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]'

License

MIT © Dmitry Semigradsky

Package Sidebar

Install

npm i math-interval-formatter

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • semigradsky