Browse Source

Do not store functions on config as it breaks using async workers

pull/288/merge
Sergi Almacellas Abellana 8 years ago
parent
commit
0353c413e1
  1. 17
      papaparse.js

17
papaparse.js

@ -200,13 +200,6 @@ @@ -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 @@ @@ -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;

Loading…
Cancel
Save