All files / src/detectors number.ts

100% Statements 11/11
100% Branches 10/10
100% Functions 1/1
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26      408x 180x 1x     179x 1x     178x 1x     177x 142x     35x     228x    
import { ValueType } from '../types';
 
export function detectNumber(value: any): ValueType {
	if (typeof value === 'number') {
		if (value === Number.POSITIVE_INFINITY) {
			return ValueType.POSITIVE_INFINITY;
		}
 
		if (value === Number.NEGATIVE_INFINITY) {
			return ValueType.NEGATIVE_INFINITY;
		}
 
		if (Number.isNaN(value)) {
			return ValueType.NAN;
		}
 
		if (Number.isInteger(value)) {
			return ValueType.INT;
		}
 
		return ValueType.FLOAT;
	}
 
	return ValueType.UNKNOWN;
}