Browse Source

Remove tryParseFloat function

Since 3dbe4c92, this function does not only try to convert float values
but also converts empty string as null. Indeed its better to join this
functionality on the existing parseDynamic function which manages the
typing of all fields.
pull/471/head
Sergi Almacellas Abellana 7 years ago
parent
commit
ce6908745c
  1. 14
      papaparse.js

14
papaparse.js

@ -990,8 +990,12 @@
return true; return true;
else if (value === 'false' || value === 'FALSE') else if (value === 'false' || value === 'FALSE')
return false; return false;
else else if(FLOAT.test(value)) {
return tryParseFloat(value); return parseFloat(value);
}
else {
return (value === '' ? null : value);
}
} }
return value; return value;
} }
@ -1120,12 +1124,6 @@
return numWithN >= r.length / 2 ? '\r\n' : '\r'; return numWithN >= r.length / 2 ? '\r\n' : '\r';
} }
function tryParseFloat(val)
{
var isNumber = FLOAT.test(val);
return isNumber ? parseFloat(val) : (val === '' ? null : val);
}
function addError(type, code, msg, row) function addError(type, code, msg, row)
{ {
_results.errors.push({ _results.errors.push({

Loading…
Cancel
Save