|
|
@ -163,7 +163,7 @@ |
|
|
|
queue.splice(0, 1); |
|
|
|
queue.splice(0, 1); |
|
|
|
parseNextFile(); |
|
|
|
parseNextFile(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -617,11 +617,11 @@ |
|
|
|
this._chunkError(); |
|
|
|
this._chunkError(); |
|
|
|
else |
|
|
|
else |
|
|
|
this._start += this._config.chunkSize; |
|
|
|
this._start += this._config.chunkSize; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._chunkLoaded = function() |
|
|
|
this._chunkLoaded = function() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (xhr.readyState != 4) |
|
|
|
if (xhr.readyState !== 4) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (xhr.status < 200 || xhr.status >= 400) |
|
|
|
if (xhr.status < 200 || xhr.status >= 400) |
|
|
@ -632,13 +632,13 @@ |
|
|
|
|
|
|
|
|
|
|
|
this._finished = !this._config.chunkSize || this._start > getFileSize(xhr); |
|
|
|
this._finished = !this._config.chunkSize || this._start > getFileSize(xhr); |
|
|
|
this.parseChunk(xhr.responseText); |
|
|
|
this.parseChunk(xhr.responseText); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._chunkError = function(errorMessage) |
|
|
|
this._chunkError = function(errorMessage) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var errorText = xhr.statusText || errorMessage; |
|
|
|
var errorText = xhr.statusText || errorMessage; |
|
|
|
this._sendError(new Error(errorText)); |
|
|
|
this._sendError(new Error(errorText)); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function getFileSize(xhr) |
|
|
|
function getFileSize(xhr) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -687,7 +687,7 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview)) |
|
|
|
if (!this._finished && (!this._config.preview || this._rowCount < this._config.preview)) |
|
|
|
this._readChunk(); |
|
|
|
this._readChunk(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._readChunk = function() |
|
|
|
this._readChunk = function() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -700,7 +700,7 @@ |
|
|
|
var txt = reader.readAsText(input, this._config.encoding); |
|
|
|
var txt = reader.readAsText(input, this._config.encoding); |
|
|
|
if (!usingAsyncReader) |
|
|
|
if (!usingAsyncReader) |
|
|
|
this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
|
|
|
|
this._chunkLoaded({ target: { result: txt } }); // mimic the async signature
|
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._chunkLoaded = function(event) |
|
|
|
this._chunkLoaded = function(event) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -708,12 +708,12 @@ |
|
|
|
this._start += this._config.chunkSize; |
|
|
|
this._start += this._config.chunkSize; |
|
|
|
this._finished = !this._config.chunkSize || this._start >= this._input.size; |
|
|
|
this._finished = !this._config.chunkSize || this._start >= this._input.size; |
|
|
|
this.parseChunk(event.target.result); |
|
|
|
this.parseChunk(event.target.result); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._chunkError = function() |
|
|
|
this._chunkError = function() |
|
|
|
{ |
|
|
|
{ |
|
|
|
this._sendError(reader.error); |
|
|
|
this._sendError(reader.error); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
FileStreamer.prototype = Object.create(ChunkStreamer.prototype); |
|
|
|
FileStreamer.prototype = Object.create(ChunkStreamer.prototype); |
|
|
@ -730,7 +730,7 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
remaining = s; |
|
|
|
remaining = s; |
|
|
|
return this._nextChunk(); |
|
|
|
return this._nextChunk(); |
|
|
|
} |
|
|
|
}; |
|
|
|
this._nextChunk = function() |
|
|
|
this._nextChunk = function() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (this._finished) return; |
|
|
|
if (this._finished) return; |
|
|
@ -739,7 +739,7 @@ |
|
|
|
remaining = size ? remaining.substr(size) : ''; |
|
|
|
remaining = size ? remaining.substr(size) : ''; |
|
|
|
this._finished = !remaining; |
|
|
|
this._finished = !remaining; |
|
|
|
return this.parseChunk(chunk); |
|
|
|
return this.parseChunk(chunk); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
StringStreamer.prototype = Object.create(StringStreamer.prototype); |
|
|
|
StringStreamer.prototype = Object.create(StringStreamer.prototype); |
|
|
|
StringStreamer.prototype.constructor = StringStreamer; |
|
|
|
StringStreamer.prototype.constructor = StringStreamer; |
|
|
@ -761,7 +761,7 @@ |
|
|
|
this._input.on('data', this._streamData); |
|
|
|
this._input.on('data', this._streamData); |
|
|
|
this._input.on('end', this._streamEnd); |
|
|
|
this._input.on('end', this._streamEnd); |
|
|
|
this._input.on('error', this._streamError); |
|
|
|
this._input.on('error', this._streamError); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._nextChunk = function() |
|
|
|
this._nextChunk = function() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -773,7 +773,7 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
parseOnData = true; |
|
|
|
parseOnData = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
this._streamData = bindFunction(function(chunk) |
|
|
|
this._streamData = bindFunction(function(chunk) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -977,7 +977,7 @@ |
|
|
|
if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) { |
|
|
|
if (_config.dynamicTypingFunction && _config.dynamicTyping[field] === undefined) { |
|
|
|
_config.dynamicTyping[field] = _config.dynamicTypingFunction(field); |
|
|
|
_config.dynamicTyping[field] = _config.dynamicTypingFunction(field); |
|
|
|
} |
|
|
|
} |
|
|
|
return (_config.dynamicTyping[field] || _config.dynamicTyping) === true |
|
|
|
return (_config.dynamicTyping[field] || _config.dynamicTyping) === true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parseDynamic(field, value) |
|
|
|
function parseDynamic(field, value) |
|
|
@ -1007,7 +1007,8 @@ |
|
|
|
{ |
|
|
|
{ |
|
|
|
var row = _config.header ? {} : []; |
|
|
|
var row = _config.header ? {} : []; |
|
|
|
|
|
|
|
|
|
|
|
for (var j = 0; j < _results.data[i].length; j++) |
|
|
|
var j; |
|
|
|
|
|
|
|
for (j = 0; j < _results.data[i].length; j++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var field = j; |
|
|
|
var field = j; |
|
|
|
var value = _results.data[i][j]; |
|
|
|
var value = _results.data[i][j]; |
|
|
@ -1062,8 +1063,8 @@ |
|
|
|
for (var j = 0; j < preview.data.length; j++) |
|
|
|
for (var j = 0; j < preview.data.length; j++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (skipEmptyLines && preview.data[j].length === 1 && preview.data[j][0].length === 0) { |
|
|
|
if (skipEmptyLines && preview.data[j].length === 1 && preview.data[j][0].length === 0) { |
|
|
|
emptyLinesCount++ |
|
|
|
emptyLinesCount++; |
|
|
|
continue |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
var fieldCount = preview.data[j].length; |
|
|
|
var fieldCount = preview.data[j].length; |
|
|
|
avgFieldCount += fieldCount; |
|
|
|
avgFieldCount += fieldCount; |
|
|
@ -1096,7 +1097,7 @@ |
|
|
|
return { |
|
|
|
return { |
|
|
|
successful: !!bestDelim, |
|
|
|
successful: !!bestDelim, |
|
|
|
bestDelimiter: bestDelim |
|
|
|
bestDelimiter: bestDelim |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function guessLineEndings(input) |
|
|
|
function guessLineEndings(input) |
|
|
@ -1175,7 +1176,7 @@ |
|
|
|
comments = false; |
|
|
|
comments = false; |
|
|
|
|
|
|
|
|
|
|
|
// Newline must be valid: \r, \n, or \r\n
|
|
|
|
// Newline must be valid: \r, \n, or \r\n
|
|
|
|
if (newline != '\n' && newline != '\r' && newline != '\r\n') |
|
|
|
if (newline !== '\n' && newline !== '\r' && newline !== '\r\n') |
|
|
|
newline = '\n'; |
|
|
|
newline = '\n'; |
|
|
|
|
|
|
|
|
|
|
|
// We're gonna need these at the Parser scope
|
|
|
|
// We're gonna need these at the Parser scope
|
|
|
@ -1238,6 +1239,7 @@ |
|
|
|
var nextDelim = input.indexOf(delim, cursor); |
|
|
|
var nextDelim = input.indexOf(delim, cursor); |
|
|
|
var nextNewline = input.indexOf(newline, cursor); |
|
|
|
var nextNewline = input.indexOf(newline, cursor); |
|
|
|
var quoteCharRegex = new RegExp(escapeChar.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') + quoteChar, 'g'); |
|
|
|
var quoteCharRegex = new RegExp(escapeChar.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&') + quoteChar, 'g'); |
|
|
|
|
|
|
|
var quoteSearch; |
|
|
|
|
|
|
|
|
|
|
|
// Parser loop
|
|
|
|
// Parser loop
|
|
|
|
for (;;) |
|
|
|
for (;;) |
|
|
@ -1246,7 +1248,7 @@ |
|
|
|
if (input[cursor] === quoteChar) |
|
|
|
if (input[cursor] === quoteChar) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Start our search for the closing quote where the cursor is
|
|
|
|
// Start our search for the closing quote where the cursor is
|
|
|
|
var quoteSearch = cursor; |
|
|
|
quoteSearch = cursor; |
|
|
|
|
|
|
|
|
|
|
|
// Skip the opening quote
|
|
|
|
// Skip the opening quote
|
|
|
|
cursor++; |
|
|
|
cursor++; |
|
|
@ -1405,7 +1407,7 @@ |
|
|
|
var spaceLength = 0; |
|
|
|
var spaceLength = 0; |
|
|
|
if (index !== -1) { |
|
|
|
if (index !== -1) { |
|
|
|
var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index); |
|
|
|
var textBetweenClosingQuoteAndIndex = input.substring(quoteSearch + 1, index); |
|
|
|
if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() == '') { |
|
|
|
if (textBetweenClosingQuoteAndIndex && textBetweenClosingQuoteAndIndex.trim() === '') { |
|
|
|
spaceLength = textBetweenClosingQuoteAndIndex.length; |
|
|
|
spaceLength = textBetweenClosingQuoteAndIndex.length; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1464,7 +1466,8 @@ |
|
|
|
function doStep() |
|
|
|
function doStep() |
|
|
|
{ |
|
|
|
{ |
|
|
|
step(returnable()); |
|
|
|
step(returnable()); |
|
|
|
data = [], errors = []; |
|
|
|
data = []; |
|
|
|
|
|
|
|
errors = []; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|