(options)
| 25472 | } |
| 25473 | |
| 25474 | function Writable(options) { |
| 25475 | Duplex = Duplex || require('./_stream_duplex'); |
| 25476 | |
| 25477 | // Writable ctor is applied to Duplexes, too. |
| 25478 | // `realHasInstance` is necessary because using plain `instanceof` |
| 25479 | // would return false, as no `_writableState` property is attached. |
| 25480 | |
| 25481 | // Trying to use the custom `instanceof` for Writable here will also break the |
| 25482 | // Node.js LazyTransform implementation, which has a non-trivial getter for |
| 25483 | // `_writableState` that would lead to infinite recursion. |
| 25484 | if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { |
| 25485 | return new Writable(options); |
| 25486 | } |
| 25487 | |
| 25488 | this._writableState = new WritableState(options, this); |
| 25489 | |
| 25490 | // legacy. |
| 25491 | this.writable = true; |
| 25492 | |
| 25493 | if (options) { |
| 25494 | if (typeof options.write === 'function') this._write = options.write; |
| 25495 | |
| 25496 | if (typeof options.writev === 'function') this._writev = options.writev; |
| 25497 | } |
| 25498 | |
| 25499 | Stream.call(this); |
| 25500 | } |
| 25501 | |
| 25502 | // Otherwise people can pipe Writable streams, which is just wrong. |
| 25503 | Writable.prototype.pipe = function () { |
nothing calls this directly
no outgoing calls
no test coverage detected