Closed gbiryukov closed 7 years ago
So it will be great if deeply minified tcomb-form will work correctly
I agree, the new version behaves differently though
// old
function isNumeric(value) {
const n = parseFloat(value)
return (value - n + 1) >= 0
}
// new
function isNumeric2(value) {
const n = parseFloat(value)
return typeof n === 'number' && isFinite(n)
}
console.log(isNumeric('a')) // false
console.log(isNumeric('1')) // true
console.log(isNumeric('1.2')) // true
console.log(isNumeric('1.2a')) // false
console.log(isNumeric('1.a2')) // false
console.log(isNumeric('1a2')) // false
console.log(isNumeric2('a')) // false
console.log(isNumeric2('1')) // true
console.log(isNumeric2('1.2')) // true
console.log(isNumeric2('1.2a')) // true (!)
console.log(isNumeric2('1.a2')) // true (!)
console.log(isNumeric2('1a2')) // true (!)
Yep, my bad! I've added tests to ensure that changes will be completely compatible with current implementation and updated the fix
Looks good, thanks for the tests. I'll release a patch asap
Patch released
👍
See #380 for more details