repl.txt (5560B)
1 2 {{alias}}( [options] ) 3 Returns a transform stream. 4 5 If a transform function is not provided, the returned stream will be a 6 simple pass through stream. 7 8 Parameters 9 ---------- 10 options: Object (optional) 11 Options. 12 13 options.transform: Function (optional) 14 Callback to invoke upon receiving a new chunk. 15 16 options.flush: Function (optional) 17 Callback to invoke after receiving all chunks and prior to a stream 18 closing. 19 20 options.objectMode: boolean (optional) 21 Specifies whether a stream should operate in "objectMode". Default: 22 false. 23 24 options.highWaterMark: integer (optional) 25 Specifies the maximum number of bytes to store in an internal buffer 26 before ceasing to push downstream. 27 28 options.allowHalfOpen: boolean (optional) 29 Specifies whether a stream should remain open even if one side ends. 30 Default: false. 31 32 options.decodeStrings: boolean (optional) 33 Specifies whether to decode strings into Buffer objects when writing. 34 Default: true. 35 36 Returns 37 ------- 38 stream: TransformStream 39 Transform stream. 40 41 Examples 42 -------- 43 > var s = {{alias}}(); 44 > s.write( 'a' ); 45 > s.write( 'b' ); 46 > s.write( 'c' ); 47 > s.end(); 48 49 50 {{alias}}.factory( [options] ) 51 Returns a function for creating transform streams. 52 53 Parameters 54 ---------- 55 options: Object (optional) 56 Options. 57 58 options.objectMode: boolean (optional) 59 Specifies whether a stream should operate in "objectMode". Default: 60 false. 61 62 options.highWaterMark: integer (optional) 63 Specifies the maximum number of bytes to store in an internal buffer 64 before ceasing to push downstream. 65 66 options.allowHalfOpen: boolean (optional) 67 Specifies whether a stream should remain open even if one side ends. 68 Default: false. 69 70 options.decodeStrings: boolean (optional) 71 Specifies whether to decode strings into Buffer objects when writing. 72 Default: true. 73 74 Returns 75 ------- 76 createStream( transform[, flush] ): Function 77 Function for creating transform streams. 78 79 Examples 80 -------- 81 > var opts = { 'highWaterMark': 64 }; 82 > var createStream = {{alias}}.factory( opts ); 83 > function fcn( chunk, enc, cb ) { cb( null, chunk.toString()+'-beep' ); }; 84 > var s = createStream( fcn ); 85 > s.write( 'a' ); 86 > s.write( 'b' ); 87 > s.write( 'c' ); 88 > s.end(); 89 90 91 {{alias}}.objectMode( [options] ) 92 Returns an "objectMode" transform stream. 93 94 Parameters 95 ---------- 96 options: Object (optional) 97 Options. 98 99 options.transform: Function (optional) 100 Callback to invoke upon receiving a new chunk. 101 102 options.flush: Function (optional) 103 Callback to invoke after receiving all chunks and prior to a stream 104 closing. 105 106 options.highWaterMark: integer (optional) 107 Specifies the maximum number of bytes to store in an internal buffer 108 before ceasing to push downstream. 109 110 options.allowHalfOpen: boolean (optional) 111 Specifies whether a stream should remain open even if one side ends. 112 Default: false. 113 114 options.decodeStrings: boolean (optional) 115 Specifies whether to decode strings into Buffer objects when writing. 116 Default: true. 117 118 Returns 119 ------- 120 stream: TransformStream 121 Transform stream operating in "objectMode". 122 123 Examples 124 -------- 125 > var s = {{alias}}.objectMode(); 126 > s.write( { 'value': 'a' } ); 127 > s.write( { 'value': 'b' } ); 128 > s.write( { 'value': 'c' } ); 129 > s.end(); 130 131 132 {{alias}}.ctor( [options] ) 133 Returns a custom transform stream constructor. 134 135 If provided `transform` and `flush` options, these methods are bound to the 136 constructor prototype. 137 138 If not provided a transform function, the returned constructor creates 139 simple pass through streams. 140 141 The returned constructor accepts the same options as the constructor 142 factory, *except* for the `transform` and `flush` options, which are not 143 supported. 144 145 Any options provided to the constructor *override* options provided to the 146 constructor factory. 147 148 Parameters 149 ---------- 150 options: Object (optional) 151 Options. 152 153 options.transform: Function (optional) 154 Callback to invoke upon receiving a new chunk. 155 156 options.flush: Function (optional) 157 Callback to invoke after receiving all chunks and prior to a stream 158 closing. 159 160 options.objectMode: boolean (optional) 161 Specifies whether a stream should operate in "objectMode". Default: 162 false. 163 164 options.highWaterMark: integer (optional) 165 Specifies the maximum number of bytes to store in an internal buffer 166 before ceasing to push downstream. 167 168 options.allowHalfOpen: boolean (optional) 169 Specifies whether a stream should remain open even if one side ends. 170 Default: false. 171 172 options.decodeStrings: boolean (optional) 173 Specifies whether to decode strings into Buffer objects when writing. 174 Default: true. 175 176 Returns 177 ------- 178 ctor: Function 179 Custom transform stream constructor. 180 181 Examples 182 -------- 183 > function fcn( chunk, enc, cb ) { cb( null, chunk.toString()+'-beep' ); }; 184 > var opts = { 'highWaterMark': 64, 'transform': fcn }; 185 > var customStream = {{alias}}.ctor( opts ); 186 > var s = customStream(); 187 > s.write( 'a' ); 188 > s.write( 'b' ); 189 > s.write( 'c' ); 190 > s.end(); 191 192 See Also 193 -------- 194