From 0353c413e1216beb450f06ef4332c6538e25aacd Mon Sep 17 00:00:00 2001 From: Sergi Almacellas Abellana Date: Tue, 2 May 2017 09:55:09 +0200 Subject: [PATCH] Do not store functions on config as it breaks using async workers --- papaparse.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/papaparse.js b/papaparse.js index fdae808..2334d81 100644 --- a/papaparse.js +++ b/papaparse.js @@ -200,13 +200,6 @@ dynamicTyping = {}; } _config.dynamicTyping = dynamicTyping; - _config.shouldApplyDynamicTyping = function(field) { - // Cache function values to avoid calling it for each row - if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) { - _config.dynamicTyping[field] = _config.dynamicTypingFunction(field); - } - return (_config.dynamicTyping[field] || _config.dynamicTyping) === true - } if (_config.worker && Papa.WORKERS_SUPPORTED) { @@ -980,9 +973,17 @@ _results.data.splice(0, 1); } + function shouldApplyDynamicTyping(field) { + // Cache function values to avoid calling it for each row + if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) { + _config.dynamicTyping[field] = _config.dynamicTypingFunction(field); + } + return (_config.dynamicTyping[field] || _config.dynamicTyping) === true + } + function parseDynamic(field, value) { - if (_config.shouldApplyDynamicTyping(field)) + if (shouldApplyDynamicTyping(field)) { if (value === 'true' || value === 'TRUE') return true;