mirror of https://github.com/abpframework/abp.git
2 changed files with 21 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||
import { isNumber } from '../utils/number-utils'; |
|||
|
|||
describe('Number Utils', () => { |
|||
describe('#isNumber', () => { |
|||
it('should return true if input is a numeric expression', () => { |
|||
expect(isNumber(0)).toBe(true); |
|||
expect(isNumber(0.15)).toBe(true); |
|||
expect(isNumber(2e8)).toBe(true); |
|||
expect(isNumber(Infinity)).toBe(true); |
|||
|
|||
expect(isNumber('0')).toBe(true); |
|||
expect(isNumber('0.15')).toBe(true); |
|||
expect(isNumber('2e8')).toBe(true); |
|||
expect(isNumber('Infinity')).toBe(true); |
|||
}); |
|||
}); |
|||
}); |
|||
@ -0,0 +1,4 @@ |
|||
export function isNumber(value: string | number): boolean { |
|||
/* tslint:disable-next-line:triple-equals */ |
|||
return value == Number(value); |
|||
} |
|||
Loading…
Reference in new issue