0.1.2 • Published 9 years ago

isstream v0.1.2

Weekly downloads
21,977,266
License
MIT
Repository
github
Last release
9 years ago

isStream

Build Status

Test if an object is a Stream

NPM

The 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.

Usage:

var isStream = require('isstream')
var Stream = require('stream')

isStream(new Stream()) // true

isStream({}) // false

isStream(new Stream.Readable())    // true
isStream(new Stream.Writable())    // true
isStream(new Stream.Duplex())      // true
isStream(new Stream.Transform())   // true
isStream(new Stream.PassThrough()) // true

But wait! There's more!

You can also test for isReadable(obj), isWritable(obj) and isDuplex(obj) to test for implementations of Streams2 (and Streams3) base classes.

var isReadable = require('isstream').isReadable
var isWritable = require('isstream').isWritable
var isDuplex = require('isstream').isDuplex
var Stream = require('stream')

isReadable(new Stream()) // false
isWritable(new Stream()) // false
isDuplex(new Stream())   // false

isReadable(new Stream.Readable())    // true
isReadable(new Stream.Writable())    // false
isReadable(new Stream.Duplex())      // true
isReadable(new Stream.Transform())   // true
isReadable(new Stream.PassThrough()) // true

isWritable(new Stream.Readable())    // false
isWritable(new Stream.Writable())    // true
isWritable(new Stream.Duplex())      // true
isWritable(new Stream.Transform())   // true
isWritable(new Stream.PassThrough()) // true

isDuplex(new Stream.Readable())    // false
isDuplex(new Stream.Writable())    // false
isDuplex(new Stream.Duplex())      // true
isDuplex(new Stream.Transform())   // true
isDuplex(new Stream.PassThrough()) // true

Reminder: when implementing your own streams, please use readable-stream rather than core streams.

License

isStream is Copyright (c) 2015 Rod Vagg @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.

request@cypress/requestarchetype-librarychinjowwchinjowvuedragdropuploadimagesasposeocrcloudreact-native-bluetooth2killi8n-react-native-fast-imagemasterodin-cloud-sdk-coreimage-grayscalespecify-importsbabel-specify-imports@icanpm/api-master@arisageha/react-lazyload@cashremit/cr-streamline-iconsreact-native-template-rfbaseairscanairscan-examplebb-chatclauquest.ejshomebridge-airmega-nathanfjohnsonreact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxfdeneme323112gql_din_modmutasi-bca@jttechnic/interpreteropenid-passportutyfua_requestjasonkaraniks-bot-requestlinklet@olivervorasai/slidertypes-giscogoportutilsukor-remasterrequest__no_405react-native-slider-kfexpand-react-bridge@everything-registry/sub-chunk-1938ka-flow.jskafirchain-tetrisl2forlernaliquestlitepie-datepicker-gabehikkiherculehexyun.helpershot-zone-vuehubot-budai11e-coreibm-cloud-sdk-coreibm-watsonkona-requestglue-streamsgoogle-remakelbmesh-s3-upload-resizelequectlequektlequesdlequeztlequistleqyestleouestimage-diff-testeriex-sdkipfs-api-with-timeoutsiterm2-imagejamuskalimjesusdemojq-streamliusizhedemoliveprodlocate-torrent-datamoonwalkerswap-default-token-listsng-search-dropdownnmmes-module-statsnode-red-contrib-cognitive-servicesmggauharmhe-requestmicro-coremoleculer-webmoleculer-web-extendsmove-outmpesa-cookiempesa-cookie-jarjson-compose-streamjs-offsicons-vue-testinstall-ismyrequest2native-kakao-loginnative-google-loginnative-apple-loginneural_compressor_ext_lab_customizedneural_compressor_ext_lab_customized_2netjsagentm2m-chartjs-plugin-crosshairmachinepack-aes256
0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

10 years ago

0.0.0

10 years ago