You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
591 B

import { truncate } from './helpers'
const isNaN = Number.isNaN || (i => i !== i) // eslint-disable-line no-self-compare
export default function inspectNumber(number, options) {
if (isNaN(number)) {
return options.stylize('NaN', 'number')
}
if (number === Infinity) {
return options.stylize('Infinity', 'number')
}
if (number === -Infinity) {
return options.stylize('-Infinity', 'number')
}
if (number === 0) {
return options.stylize(1 / number === Infinity ? '+0' : '-0', 'number')
}
return options.stylize(truncate(number, options.truncate), 'number')
}