Merge pull request #13 from thlorenz/consistent-stream-implementation

using readable stream no matter what node version
This commit is contained in:
Mathias Buus 2014-04-03 02:27:43 +02:00
commit d661f7f913
2 changed files with 7 additions and 8 deletions

View file

@ -1,10 +1,9 @@
var stream = require('stream');
var util = require('util'); var util = require('util');
var bl = require('bl'); var bl = require('bl');
var headers = require('./headers'); var headers = require('./headers');
var Writable = stream.Writable || require('readable-stream').Writable; var Writable = require('readable-stream').Writable;
var PassThrough = stream.PassThrough || require('readable-stream').PassThrough; var PassThrough = require('readable-stream').PassThrough;
var noop = function() {}; var noop = function() {};

10
pack.js
View file

@ -1,10 +1,10 @@
var stream = require('stream');
var util = require('util'); var util = require('util');
var eos = require('end-of-stream'); var eos = require('end-of-stream');
var headers = require('./headers'); var headers = require('./headers');
var Readable = stream.Readable || require('readable-stream').Readable; var Readable = require('readable-stream').Readable;
var Writable = stream.Writable || require('readable-stream').Writable; var Writable = require('readable-stream').Writable;
var PassThrough = require('readable-stream').PassThrough;
var END_OF_TAR = new Buffer(1024); var END_OF_TAR = new Buffer(1024);
END_OF_TAR.fill(0); END_OF_TAR.fill(0);
@ -86,7 +86,7 @@ Pack.prototype.entry = function(header, buffer, callback) {
} }
this._encode(header); this._encode(header);
this._stream = stream; this._stream = new PassThrough();
var sink = new Sink(this); var sink = new Sink(this);
@ -174,4 +174,4 @@ Pack.prototype._read = function(n) {
drain(); drain();
}; };
module.exports = Pack; module.exports = Pack;