(options, stream)
| 24227 | } |
| 24228 | |
| 24229 | function ReadableState(options, stream) { |
| 24230 | Duplex = Duplex || require('./_stream_duplex'); |
| 24231 | |
| 24232 | options = options || {}; |
| 24233 | |
| 24234 | // object stream flag. Used to make read(n) ignore n and to |
| 24235 | // make all the buffer merging and length checks go away |
| 24236 | this.objectMode = !!options.objectMode; |
| 24237 | |
| 24238 | if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; |
| 24239 | |
| 24240 | // the point at which it stops calling _read() to fill the buffer |
| 24241 | // Note: 0 is a valid value, means "don't call _read preemptively ever" |
| 24242 | var hwm = options.highWaterMark; |
| 24243 | var defaultHwm = this.objectMode ? 16 : 16 * 1024; |
| 24244 | this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; |
| 24245 | |
| 24246 | // cast to ints. |
| 24247 | this.highWaterMark = ~~this.highWaterMark; |
| 24248 | |
| 24249 | // A linked list is used to store data chunks instead of an array because the |
| 24250 | // linked list can remove elements from the beginning faster than |
| 24251 | // array.shift() |
| 24252 | this.buffer = new BufferList(); |
| 24253 | this.length = 0; |
| 24254 | this.pipes = null; |
| 24255 | this.pipesCount = 0; |
| 24256 | this.flowing = null; |
| 24257 | this.ended = false; |
| 24258 | this.endEmitted = false; |
| 24259 | this.reading = false; |
| 24260 | |
| 24261 | // a flag to be able to tell if the onwrite cb is called immediately, |
| 24262 | // or on a later tick. We set this to true at first, because any |
| 24263 | // actions that shouldn't happen until "later" should generally also |
| 24264 | // not happen before the first write call. |
| 24265 | this.sync = true; |
| 24266 | |
| 24267 | // whenever we return null, then we set a flag to say |
| 24268 | // that we're awaiting a 'readable' event emission. |
| 24269 | this.needReadable = false; |
| 24270 | this.emittedReadable = false; |
| 24271 | this.readableListening = false; |
| 24272 | this.resumeScheduled = false; |
| 24273 | |
| 24274 | // Crypto is kind of old and crusty. Historically, its default string |
| 24275 | // encoding is 'binary' so we have to make this configurable. |
| 24276 | // Everything else in the universe uses 'utf8', though. |
| 24277 | this.defaultEncoding = options.defaultEncoding || 'utf8'; |
| 24278 | |
| 24279 | // when piping, we only care about 'readable' events that happen |
| 24280 | // after read()ing all the bytes and not getting any pushback. |
| 24281 | this.ranOut = false; |
| 24282 | |
| 24283 | // the number of writers that are awaiting a drain event in .pipe()s |
| 24284 | this.awaitDrain = 0; |
| 24285 | |
| 24286 | // if true, a maybeReadMore has been scheduled |
nothing calls this directly
no outgoing calls
no test coverage detected