Browse Source

Avoid use of node stream in browser context.

pull/593/merge
Jeff Barnes 6 years ago committed by Sergi Almacellas Abellana
parent
commit
0e392e2f24
  1. 6
      Gruntfile.js
  2. 1
      package.json
  3. 12
      papaparse.js

6
Gruntfile.js

@ -2,6 +2,12 @@ module.exports = function(grunt) {
grunt.initConfig({ grunt.initConfig({
uglify: { uglify: {
options: { options: {
compress: {
global_defs: {
'PAPA_BROWSER_CONTEXT': true
},
dead_code: true
},
output: { output: {
comments: 'some', comments: 'some',
}, },

1
package.json

@ -35,6 +35,7 @@
}, },
"license": "MIT", "license": "MIT",
"main": "papaparse.js", "main": "papaparse.js",
"browser": "papaparse.min.js",
"devDependencies": { "devDependencies": {
"chai": "^4.2.0", "chai": "^4.2.0",
"connect": "^3.3.3", "connect": "^3.3.3",

12
papaparse.js

@ -81,7 +81,9 @@ if (!Array.isArray)
Papa.FileStreamer = FileStreamer; Papa.FileStreamer = FileStreamer;
Papa.StringStreamer = StringStreamer; Papa.StringStreamer = StringStreamer;
Papa.ReadableStreamStreamer = ReadableStreamStreamer; Papa.ReadableStreamStreamer = ReadableStreamStreamer;
Papa.DuplexStreamStreamer = DuplexStreamStreamer; if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
Papa.DuplexStreamStreamer = DuplexStreamStreamer;
}
if (global.jQuery) if (global.jQuery)
{ {
@ -241,7 +243,7 @@ if (!Array.isArray)
} }
var streamer = null; var streamer = null;
if (_input === Papa.NODE_STREAM_INPUT) if (_input === Papa.NODE_STREAM_INPUT && typeof PAPA_BROWSER_CONTEXT === 'undefined')
{ {
// create a node Duplex stream for use // create a node Duplex stream for use
// with .pipe // with .pipe
@ -982,8 +984,10 @@ if (!Array.isArray)
}); });
stream.once('finish', bindFunction(this._onWriteComplete, this)); stream.once('finish', bindFunction(this._onWriteComplete, this));
} }
DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype); if (typeof PAPA_BROWSER_CONTEXT === 'undefined') {
DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer; DuplexStreamStreamer.prototype = Object.create(ChunkStreamer.prototype);
DuplexStreamStreamer.prototype.constructor = DuplexStreamStreamer;
}
// Use one ParserHandle per entire CSV file or string // Use one ParserHandle per entire CSV file or string

Loading…
Cancel
Save