Browse Source

Fixed a streaming bug that truncated last line

pull/33/head 2.0.3
Matthew Holt 11 years ago
parent
commit
68d8798c14
  1. 26
      jquery.parse.js
  2. 4
      jquery.parse.min.js
  3. 4
      parse.jquery.json

26
jquery.parse.js

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
/*
Papa Parse
v2.0.2
v2.0.3
https://github.com/mholt/jquery.parse
*/
@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
$.fn.parse = function(options)
{
var config = options.config ? options.config : {};
var config = options.config || {};
var queue = [];
this.each(function(idx)
@ -147,15 +147,21 @@ @@ -147,15 +147,21 @@
var text = partialLine + event.target.result;
partialLine = "";
var lastLineEnd = text.lastIndexOf("\n");
if (lastLineEnd < 0)
lastLineEnd = text.lastIndexOf("\r");
if (lastLineEnd > -1)
// If we're maxing out the chunk size, we probably cut a line
// in half. However: doing these operations if the whole file
// fits in one chunk will leave off the last line, which is bad.
if (text >= settings.chunkSize)
{
partialLine = text.substring(lastLineEnd + 1); // skip the line ending character
text = text.substring(0, lastLineEnd);
var lastLineEnd = text.lastIndexOf("\n");
if (lastLineEnd < 0)
lastLineEnd = text.lastIndexOf("\r");
if (lastLineEnd > -1)
{
partialLine = text.substring(lastLineEnd + 1); // skip the line ending character
text = text.substring(0, lastLineEnd);
}
}
var results = parser.parse(text);

4
jquery.parse.min.js vendored

File diff suppressed because one or more lines are too long

4
parse.jquery.json

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
{
"name": "parse",
"version": "2.0.2",
"version": "2.0.3",
"title": "Papa Parse",
"description": "Papa is a powerful CSV (delimited text) parser that gracefully handles large files and malformed input.",
"description": "Papa is a powerful CSV (delimited text) parser that streams handles large files and gracefully handles malformed input.",
"keywords": [
"csv",
"parse",

Loading…
Cancel
Save