From ce6908745c55f3b8f696a49b0ac74ffdf53064f4 Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 13 Mar 2018 11:16:35 +0100 Subject: [PATCH] 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. --- papaparse.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/papaparse.js b/papaparse.js index 6c2a415..790adeb 100755 --- a/papaparse.js +++ b/papaparse.js @@ -990,8 +990,12 @@ return true; else if (value === 'false' || value === 'FALSE') return false; - else - return tryParseFloat(value); + else if(FLOAT.test(value)) { + return parseFloat(value); + } + else { + return (value === '' ? null : value); + } } return value; } @@ -1120,12 +1124,6 @@ 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) { _results.errors.push({