import { matchHex, matchInteger } from '../../../../deps'
import { isSymbol } from '../../../primitive/symbol'
import isNumber from './isNumber'
/**
* @name isNumberish
* @alias isNumberLike
* @since 5.0.0-beta.6
* @version 5.0.1 <- added isSymbol check to avoid testing symbol
* @memberOf is
*
* @NOTE this was old test, is used in funwithflags, and other cli environments
* @NOTE this is helpful when casting strings to numbers
*
* @param {number | string | *} x numberish to check
* @return {boolean} x isNumberish
*
* {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Grammar_and_types#Integers mozilla-integers-hex}
* @see {@link mozilla-integers-hex}
* @see is/number
* @see cast/number
*
* @example
*
* isNumberish('10') //=> true
* isNumberish(10) //=> true
* isNumberish('10.01') //=> true
*
*/
export default function isNumberish(x: any): x is number | Number {
if (isSymbol(x)) {
return false
} else if (isNumber(x)) {
return true
} else if (matchHex.test(x)) {
return true
} else {
return matchInteger.test(x)
}
}