Skip to content

Commit

Permalink
refactor(string-utils): simplify looksLikeNumber condition
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed May 30, 2021
1 parent 20e01de commit ed50d11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export function looksLikeNumber (x: null | undefined | number | string): boolean
// hexadecimal.
if (/^0x[0-9a-f]+$/i.test(x)) return true
// don't treat 0123 as a number; as it drops the leading '0'.
if (x.length > 1 && x[0] === '0' && x[1] !== '.') return false
if (/^0[^.]/.test(x)) return false
return /^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x)
}

0 comments on commit ed50d11

Please sign in to comment.