Browse Source

Change to use more explicit identifier to indicate node stream

pull/494/head
Trevor Harwell 7 years ago
parent
commit
31cfdf8ab3
  1. 6
      papaparse.js
  2. 2
      tests/node-tests.js

6
papaparse.js

@ -58,6 +58,7 @@ @@ -58,6 +58,7 @@
Papa.BAD_DELIMITERS = ['\r', '\n', '"', Papa.BYTE_ORDER_MARK];
Papa.WORKERS_SUPPORTED = !IS_WORKER && !!global.Worker;
Papa.SCRIPT_PATH = null; // Must be set by your code if you use workers and this lib is loaded asynchronously
Papa.NODE_STREAM_INPUT = {};
// Configurable chunk sizes for local and remote files, respectively
Papa.LocalChunkSize = 1024 * 1024 * 10; // 10 MB
@ -229,7 +230,7 @@ @@ -229,7 +230,7 @@
}
var streamer = null;
if (_input === null && typeof streamModule !== 'undefined')
if (_input === Papa.NODE_STREAM_INPUT)
{
// create a node Duplex stream for use
// with .pipe
@ -865,7 +866,8 @@ @@ -865,7 +866,8 @@
// streamModule from node must exist
// for this to run
var duplexStream = new streamModule.Duplex({
var stream = require('stream');
var duplexStream = new stream.Duplex({
readableObjectMode: true,
decodeStrings: false,
read: function(size) {

2
tests/node-tests.js

@ -62,7 +62,7 @@ describe('PapaParse', function() { @@ -62,7 +62,7 @@ describe('PapaParse', function() {
it('piped streaming CSV should be correctly parsed', function(done) {
var data = [];
fs.createReadStream(__dirname + '/long-sample.csv', 'utf8')
.pipe(Papa.parse(null))
.pipe(Papa.parse(Papa.NODE_STREAM_INPUT))
.on('data', function(item) {
data.push(item);
})

Loading…
Cancel
Save