Yang Guo | 4fd355c | 2019-09-19 08:59:03 | [diff] [blame^] | 1 | # readable-stream |
| 2 | |
| 3 | ***Node.js core streams for userland*** [](https://travis-ci.com/nodejs/readable-stream) |
| 4 | |
| 5 | |
| 6 | [](https://nodei.co/npm/readable-stream/) |
| 7 | [](https://nodei.co/npm/readable-stream/) |
| 8 | |
| 9 | |
| 10 | [](https://saucelabs.com/u/readabe-stream) |
| 11 | |
| 12 | ```bash |
| 13 | npm install --save readable-stream |
| 14 | ``` |
| 15 | |
| 16 | This package is a mirror of the streams implementations in Node.js. |
| 17 | |
| 18 | Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.15.3/docs/api/stream.html). |
| 19 | |
| 20 | If you want to guarantee a stable streams base, regardless of what version of |
| 21 | Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html). |
| 22 | |
| 23 | As of version 2.0.0 **readable-stream** uses semantic versioning. |
| 24 | |
| 25 | ## Version 3.x.x |
| 26 | |
| 27 | v3.x.x of `readable-stream` supports Node 6, 8, and 10, as well as |
| 28 | evergreen browsers, IE 11 and latest Safari. The breaking changes |
| 29 | introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/) |
| 30 | and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows: |
| 31 | |
| 32 | 1. Error codes: https://github.com/nodejs/node/pull/13310, |
| 33 | https://github.com/nodejs/node/pull/13291, |
| 34 | https://github.com/nodejs/node/pull/16589, |
| 35 | https://github.com/nodejs/node/pull/15042, |
| 36 | https://github.com/nodejs/node/pull/15665, |
| 37 | https://github.com/nodejs/readable-stream/pull/344 |
| 38 | 2. 'readable' have precedence over flowing |
| 39 | https://github.com/nodejs/node/pull/18994 |
| 40 | 3. make virtual methods errors consistent |
| 41 | https://github.com/nodejs/node/pull/18813 |
| 42 | 4. updated streams error handling |
| 43 | https://github.com/nodejs/node/pull/18438 |
| 44 | 5. writable.end should return this. |
| 45 | https://github.com/nodejs/node/pull/18780 |
| 46 | 6. readable continues to read when push('') |
| 47 | https://github.com/nodejs/node/pull/18211 |
| 48 | 7. add custom inspect to BufferList |
| 49 | https://github.com/nodejs/node/pull/17907 |
| 50 | 8. always defer 'readable' with nextTick |
| 51 | https://github.com/nodejs/node/pull/17979 |
| 52 | |
| 53 | ## Version 2.x.x |
| 54 | |
| 55 | v2.x.x of `readable-stream` supports all Node.js version from 0.8, as well as |
| 56 | evergreen browsers and IE 10 & 11. |
| 57 | |
| 58 | ### Big Thanks |
| 59 | |
| 60 | Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][sauce] |
| 61 | |
| 62 | # Usage |
| 63 | |
| 64 | You can swap your `require('stream')` with `require('readable-stream')` |
| 65 | without any changes, if you are just using one of the main classes and |
| 66 | functions. |
| 67 | |
| 68 | ```js |
| 69 | const { |
| 70 | Readable, |
| 71 | Writable, |
| 72 | Transform, |
| 73 | Duplex, |
| 74 | pipeline, |
| 75 | finished |
| 76 | } = require('readable-stream') |
| 77 | ```` |
| 78 | |
| 79 | Note that `require('stream')` will return `Stream`, while |
| 80 | `require('readable-stream')` will return `Readable`. We discourage using |
| 81 | whatever is exported directly, but rather use one of the properties as |
| 82 | shown in the example above. |
| 83 | |
| 84 | # Streams Working Group |
| 85 | |
| 86 | `readable-stream` is maintained by the Streams Working Group, which |
| 87 | oversees the development and maintenance of the Streams API within |
| 88 | Node.js. The responsibilities of the Streams Working Group include: |
| 89 | |
| 90 | * Addressing stream issues on the Node.js issue tracker. |
| 91 | * Authoring and editing stream documentation within the Node.js project. |
| 92 | * Reviewing changes to stream subclasses within the Node.js project. |
| 93 | * Redirecting changes to streams from the Node.js project to this |
| 94 | project. |
| 95 | * Assisting in the implementation of stream providers within Node.js. |
| 96 | * Recommending versions of `readable-stream` to be included in Node.js. |
| 97 | * Messaging about the future of streams to give the community advance |
| 98 | notice of changes. |
| 99 | |
| 100 | <a name="members"></a> |
| 101 | ## Team Members |
| 102 | |
| 103 | * **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) <[email protected]> |
| 104 | - Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242 |
| 105 | * **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) <[email protected]> |
| 106 | * **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <[email protected]> |
| 107 | - Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E |
| 108 | * **Irina Shestak** ([@lrlna](https://github.com/lrlna)) <[email protected]> |
| 109 | * **Yoshua Wyuts** ([@yoshuawuyts](https://github.com/yoshuawuyts)) <[email protected]> |
| 110 | |
| 111 | [sauce]: https://saucelabs.com |