source: trip-planner-front/node_modules/isstream/README.md@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1# isStream
2
3[![Build Status](https://secure.travis-ci.org/rvagg/isstream.png)](http://travis-ci.org/rvagg/isstream)
4
5**Test if an object is a `Stream`**
6
7[![NPM](https://nodei.co/npm/isstream.svg)](https://nodei.co/npm/isstream/)
8
9The missing `Stream.isStream(obj)`: determine if an object is standard Node.js `Stream`. Works for Node-core `Stream` objects (for 0.8, 0.10, 0.11, and in theory, older and newer versions) and all versions of **[readable-stream](https://github.com/isaacs/readable-stream)**.
10
11## Usage:
12
13```js
14var isStream = require('isstream')
15var Stream = require('stream')
16
17isStream(new Stream()) // true
18
19isStream({}) // false
20
21isStream(new Stream.Readable()) // true
22isStream(new Stream.Writable()) // true
23isStream(new Stream.Duplex()) // true
24isStream(new Stream.Transform()) // true
25isStream(new Stream.PassThrough()) // true
26```
27
28## But wait! There's more!
29
30You can also test for `isReadable(obj)`, `isWritable(obj)` and `isDuplex(obj)` to test for implementations of Streams2 (and Streams3) base classes.
31
32```js
33var isReadable = require('isstream').isReadable
34var isWritable = require('isstream').isWritable
35var isDuplex = require('isstream').isDuplex
36var Stream = require('stream')
37
38isReadable(new Stream()) // false
39isWritable(new Stream()) // false
40isDuplex(new Stream()) // false
41
42isReadable(new Stream.Readable()) // true
43isReadable(new Stream.Writable()) // false
44isReadable(new Stream.Duplex()) // true
45isReadable(new Stream.Transform()) // true
46isReadable(new Stream.PassThrough()) // true
47
48isWritable(new Stream.Readable()) // false
49isWritable(new Stream.Writable()) // true
50isWritable(new Stream.Duplex()) // true
51isWritable(new Stream.Transform()) // true
52isWritable(new Stream.PassThrough()) // true
53
54isDuplex(new Stream.Readable()) // false
55isDuplex(new Stream.Writable()) // false
56isDuplex(new Stream.Duplex()) // true
57isDuplex(new Stream.Transform()) // true
58isDuplex(new Stream.PassThrough()) // true
59```
60
61*Reminder: when implementing your own streams, please [use **readable-stream** rather than core streams](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).*
62
63
64## License
65
66**isStream** is Copyright (c) 2015 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.
Note: See TracBrowser for help on using the repository browser.