From 311caa2f52a292aae98ca500af7e6f0c26b251ae Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 15 Jul 2014 12:18:15 -0600 Subject: [PATCH] Complete callback only executed once after all files --- papaparse.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/papaparse.js b/papaparse.js index b42dbd4..b69f575 100644 --- a/papaparse.js +++ b/papaparse.js @@ -49,12 +49,7 @@ && $(this).attr('type').toLowerCase() == "file" && global.FileReader; - if (!supported) - return true; // continue to next input element - - var instanceConfig = $.extend({}, config); - - if (!this.files || this.files.length == 0) + if (!supported || !this.files || this.files.length == 0) return true; // continue to next input element for (var i = 0; i < this.files.length; i++) @@ -62,13 +57,14 @@ queue.push({ file: this.files[i], inputElem: this, - instanceConfig: instanceConfig + instanceConfig: $.extend({}, config) }); } }); - parseNextFile(); - return this; // chainability + parseNextFile(); // begin parsing + return this; // maintains chainability + function parseNextFile() { @@ -373,7 +369,7 @@ - + // NOTE/TODO: Many of the functions of NetworkStreamer and FileStreamer are the same. Consolidate? function NetworkStreamer(config) { config = config || {}; @@ -469,7 +465,7 @@ } var results = handle.parse(aggregate); - aggregate = ""; // very important to reset each time a chunk is parsed + aggregate = ""; if (IS_WORKER) { @@ -584,7 +580,7 @@ } var results = handle.parse(aggregate); - aggregate = ""; // very important to reset each time a chunk is parsed + aggregate = ""; if (IS_WORKER) {