Browse Source

fixed support for aborting parsing

pull/178/head
John MacAslan 10 years ago
parent
commit
208b229a3a
  1. 8
      papaparse.js
  2. 5
      tests/test-cases.js

8
papaparse.js

@ -390,7 +390,7 @@ @@ -390,7 +390,7 @@
var results = this._handle.parse(aggregate, this._baseIndex, !this._finished);
if (this._handle.paused())
if (this._handle.paused() || this._handle.aborted())
return;
var lastIndex = results.meta.cursor;
@ -658,6 +658,7 @@ @@ -658,6 +658,7 @@
var _input; // The input being parsed
var _parser; // The core parser being used
var _paused = false; // Whether we are paused or not
var _aborted = false; // Whether the parser has aborted or not
var _delimiterError; // Temporary state between delimiter detection and processing results
var _fields = []; // Fields are from the header row of the input, if there is one
var _results = { // The last results returned from the parser
@ -743,8 +744,13 @@ @@ -743,8 +744,13 @@
self.streamer.parseChunk(_input);
};
this.aborted = function () {
return _aborted;
}
this.abort = function()
{
_aborted = true;
_parser.abort();
if (isFunction(_config.complete))
_config.complete(_results);

5
tests/test-cases.js

@ -1227,10 +1227,9 @@ var CUSTOM_TESTS = [ @@ -1227,10 +1227,9 @@ var CUSTOM_TESTS = [
step: function(response, handle) {
updates.push(response.data[0]);
handle.abort();
},
complete: function() {
callback(updates);
}
},
chunkSize: 6
});
}
},

Loading…
Cancel
Save