Skip to content

Commit c4f4cb3

Browse files
committed
Breaking: Remove pipe method (closes #107)
1 parent f0fea4d commit c4f4cb3

File tree

2 files changed

+0
-158
lines changed

2 files changed

+0
-158
lines changed

index.js

-27
Original file line numberDiff line numberDiff line change
@@ -134,33 +134,6 @@ File.prototype.clone = function(opt) {
134134
return file;
135135
};
136136

137-
File.prototype.pipe = function(stream, opt) {
138-
if (!opt) {
139-
opt = {};
140-
}
141-
if (typeof opt.end === 'undefined') {
142-
opt.end = true;
143-
}
144-
145-
if (this.isStream()) {
146-
return this.contents.pipe(stream, opt);
147-
}
148-
if (this.isBuffer()) {
149-
if (opt.end) {
150-
stream.end(this.contents);
151-
} else {
152-
stream.write(this.contents);
153-
}
154-
return stream;
155-
}
156-
157-
// Check if isNull
158-
if (opt.end) {
159-
stream.end();
160-
}
161-
return stream;
162-
};
163-
164137
File.prototype.inspect = function() {
165138
var inspect = [];
166139

test/File.js

-131
Original file line numberDiff line numberDiff line change
@@ -601,137 +601,6 @@ describe('File', function() {
601601
});
602602
});
603603

604-
describe('pipe()', function() {
605-
it('should write to stream with Buffer', function(done) {
606-
var options = {
607-
cwd: '/',
608-
base: '/test/',
609-
path: '/test/test.coffee',
610-
contents: new Buffer('test'),
611-
};
612-
var file = new File(options);
613-
var stream = new Stream.PassThrough();
614-
stream.on('data', function(chunk) {
615-
should.exist(chunk);
616-
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
617-
chunk.toString('utf8').should.equal(options.contents.toString('utf8'));
618-
});
619-
stream.on('end', function() {
620-
done();
621-
});
622-
var ret = file.pipe(stream);
623-
ret.should.equal(stream, 'should return the stream');
624-
});
625-
626-
it('should pipe to stream with Stream', function(done) {
627-
var testChunk = new Buffer('test');
628-
var options = {
629-
cwd: '/',
630-
base: '/test/',
631-
path: '/test/test.coffee',
632-
contents: new Stream.PassThrough(),
633-
};
634-
var file = new File(options);
635-
var stream = new Stream.PassThrough();
636-
stream.on('data', function(chunk) {
637-
should.exist(chunk);
638-
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
639-
chunk.toString('utf8').should.equal(testChunk.toString('utf8'));
640-
done();
641-
});
642-
var ret = file.pipe(stream);
643-
ret.should.equal(stream, 'should return the stream');
644-
645-
file.contents.write(testChunk);
646-
});
647-
648-
it('should do nothing with null', function(done) {
649-
var options = {
650-
cwd: '/',
651-
base: '/test/',
652-
path: '/test/test.coffee',
653-
contents: null,
654-
};
655-
var file = new File(options);
656-
var stream = new Stream.PassThrough();
657-
stream.on('data', function() {
658-
throw new Error('should not write');
659-
});
660-
stream.on('end', function() {
661-
done();
662-
});
663-
var ret = file.pipe(stream);
664-
ret.should.equal(stream, 'should return the stream');
665-
});
666-
667-
it('should write to stream with Buffer', function(done) {
668-
var options = {
669-
cwd: '/',
670-
base: '/test/',
671-
path: '/test/test.coffee',
672-
contents: new Buffer('test'),
673-
};
674-
var file = new File(options);
675-
var stream = new Stream.PassThrough();
676-
stream.on('data', function(chunk) {
677-
should.exist(chunk);
678-
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
679-
chunk.toString('utf8').should.equal(options.contents.toString('utf8'));
680-
done();
681-
});
682-
stream.on('end', function() {
683-
throw new Error('should not end');
684-
});
685-
var ret = file.pipe(stream, { end: false });
686-
ret.should.equal(stream, 'should return the stream');
687-
});
688-
689-
it('should pipe to stream with Stream', function(done) {
690-
var testChunk = new Buffer('test');
691-
var options = {
692-
cwd: '/',
693-
base: '/test/',
694-
path: '/test/test.coffee',
695-
contents: new Stream.PassThrough(),
696-
};
697-
var file = new File(options);
698-
var stream = new Stream.PassThrough();
699-
stream.on('data', function(chunk) {
700-
should.exist(chunk);
701-
(chunk instanceof Buffer).should.equal(true, 'should write as a buffer');
702-
chunk.toString('utf8').should.equal(testChunk.toString('utf8'));
703-
done();
704-
});
705-
stream.on('end', function() {
706-
throw new Error('should not end');
707-
});
708-
var ret = file.pipe(stream, { end: false });
709-
ret.should.equal(stream, 'should return the stream');
710-
711-
file.contents.write(testChunk);
712-
});
713-
714-
it('should do nothing with null', function(done) {
715-
var options = {
716-
cwd: '/',
717-
base: '/test/',
718-
path: '/test/test.coffee',
719-
contents: null,
720-
};
721-
var file = new File(options);
722-
var stream = new Stream.PassThrough();
723-
stream.on('data', function() {
724-
throw new Error('should not write');
725-
});
726-
stream.on('end', function() {
727-
throw new Error('should not end');
728-
});
729-
var ret = file.pipe(stream, { end: false });
730-
ret.should.equal(stream, 'should return the stream');
731-
process.nextTick(done);
732-
});
733-
});
734-
735604
describe('inspect()', function() {
736605
it('should return correct format when no contents and no path', function(done) {
737606
var file = new File();

0 commit comments

Comments
 (0)