File tree Expand file tree Collapse file tree 2 files changed +41
-4
lines changed
Expand file tree Collapse file tree 2 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 11// All of the fs methods we want exposed on fq
22// This should pass the Grep Test (http://jamie-wong.com/2013/07/12/grep-test/)
3-
4- var FQReadStream = require ( './stream' ) ;
3+
4+ var stream = require ( './stream' ) ;
55
66module . exports = function ( FQ ) {
77
@@ -165,9 +165,11 @@ module.exports = function (FQ) {
165165 this . execQueue ( ) ;
166166 } ;
167167
168+ FQ . prototype . ReadStream = stream . ReadStream ;
169+
168170 FQ . prototype . createReadStream = function ( path , options ) {
169171
170- var readStream = new FQReadStream ( path , options ) ;
172+ var readStream = new this . ReadStream ( path , options ) ;
171173
172174 this . addToQueue ( function ( fs , cb ) {
173175
@@ -181,4 +183,22 @@ module.exports = function (FQ) {
181183 return readStream ;
182184 } ;
183185
186+ FQ . prototype . WriteStream = stream . WriteStream ;
187+
188+ FQ . prototype . createWriteStream = function ( path , options ) {
189+
190+ var writeStream = new this . WriteStream ( path , options ) ;
191+
192+ this . addToQueue ( function ( fs , cb ) {
193+
194+ writeStream . on ( 'close' , cb ) ;
195+
196+ writeStream . open ( ) ;
197+ } ) ;
198+
199+ this . execQueue ( ) ;
200+
201+ return writeStream ;
202+ } ;
203+
184204} ;
Original file line number Diff line number Diff line change 11var fs = require ( 'fs' ) ;
22var util = require ( 'util' ) ;
33
4+ var fq = exports ;
5+
46util . inherits ( FQReadStream , fs . ReadStream ) ;
7+ fq . ReadStream = FQReadStream ;
58
69function FQReadStream ( path , options ) {
710
@@ -16,4 +19,18 @@ function FQReadStream(path, options) {
1619 return this ;
1720}
1821
19- module . exports = FQReadStream ;
22+ util . inherits ( FQWriteStream , fs . WriteStream ) ;
23+ fq . WriteStream = FQWriteStream ;
24+
25+ function FQWriteStream ( path , options ) {
26+
27+ // temporarily change our #open method so the ReadStream initializer doesn't open the file
28+ var open = this . open ;
29+ this . open = function ( ) { } ;
30+
31+ fs . WriteStream . call ( this , path , options ) ;
32+
33+ this . open = open ;
34+
35+ return this ;
36+ }
You can’t perform that action at this time.
0 commit comments