pax_global_header00006660000000000000000000000064127031233010014502gustar00rootroot0000000000000052 comment=e21d73f1028c189d16150cea52641059b0936310 is-stream-1.1.0/000077500000000000000000000000001270312330100134055ustar00rootroot00000000000000is-stream-1.1.0/.editorconfig000066400000000000000000000002761270312330100160670ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 is-stream-1.1.0/.gitattributes000066400000000000000000000000141270312330100162730ustar00rootroot00000000000000* text=auto is-stream-1.1.0/.gitignore000066400000000000000000000000151270312330100153710ustar00rootroot00000000000000node_modules is-stream-1.1.0/.travis.yml000066400000000000000000000001151270312330100155130ustar00rootroot00000000000000sudo: false language: node_js node_js: - '5' - '4' - '0.12' - '0.10' is-stream-1.1.0/index.js000066400000000000000000000014401270312330100150510ustar00rootroot00000000000000'use strict'; var isStream = module.exports = function (stream) { return stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'; }; isStream.writable = function (stream) { return isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object'; }; isStream.readable = function (stream) { return isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object'; }; isStream.duplex = function (stream) { return isStream.writable(stream) && isStream.readable(stream); }; isStream.transform = function (stream) { return isStream.duplex(stream) && typeof stream._transform === 'function' && typeof stream._transformState === 'object'; }; is-stream-1.1.0/license000066400000000000000000000021371270312330100147550ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-stream-1.1.0/package.json000066400000000000000000000012131270312330100156700ustar00rootroot00000000000000{ "name": "is-stream", "version": "1.1.0", "description": "Check if something is a Node.js stream", "license": "MIT", "repository": "sindresorhus/is-stream", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "stream", "type", "streams", "writable", "readable", "duplex", "transform", "check", "detect", "is" ], "devDependencies": { "ava": "*", "tempfile": "^1.1.0", "xo": "*" } } is-stream-1.1.0/readme.md000066400000000000000000000012301270312330100151600ustar00rootroot00000000000000# is-stream [![Build Status](https://travis-ci.org/sindresorhus/is-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/is-stream) > Check if something is a [Node.js stream](https://nodejs.org/api/stream.html) ## Install ``` $ npm install --save is-stream ``` ## Usage ```js const fs = require('fs'); const isStream = require('is-stream'); isStream(fs.createReadStream('unicorn.png')); //=> true isStream({}); //=> false ``` ## API ### isStream(stream) #### isStream.writable(stream) #### isStream.readable(stream) #### isStream.duplex(stream) #### isStream.transform(stream) ## License MIT © [Sindre Sorhus](https://sindresorhus.com) is-stream-1.1.0/test.js000066400000000000000000000044241270312330100147260ustar00rootroot00000000000000import fs from 'fs'; import Stream from 'stream'; import net from 'net'; import test from 'ava'; import tempfile from 'tempfile'; import m from './'; test('isStream()', t => { t.true(m(new Stream.Stream())); t.true(m(new Stream.Readable())); t.true(m(new Stream.Writable())); t.true(m(new Stream.Duplex())); t.true(m(new Stream.Transform())); t.true(m(new Stream.PassThrough())); t.true(m(fs.createReadStream('test.js'))); t.true(m(fs.createWriteStream(tempfile()))); t.true(m(new net.Socket())); t.false(m({})); t.false(m(null)); t.false(m(undefined)); t.false(m('')); }); test('isStream.writable()', t => { t.true(m.writable(new Stream.Writable())); t.true(m.writable(new Stream.Duplex())); t.true(m.writable(new Stream.Transform())); t.true(m.writable(new Stream.PassThrough())); t.true(m.writable(fs.createWriteStream(tempfile()))); t.false(m.writable(new Stream.Stream())); t.false(m.writable(new Stream.Readable())); t.false(m.writable(fs.createReadStream('test.js'))); t.false(m.writable(new net.Socket())); }); test('isStream.readable()', t => { t.true(m.readable(new Stream.Readable())); t.true(m.readable(new Stream.Duplex())); t.true(m.readable(new Stream.Transform())); t.true(m.readable(new Stream.PassThrough())); t.true(m.readable(fs.createReadStream('test.js'))); t.false(m.readable(new Stream.Stream())); t.false(m.readable(new Stream.Writable())); t.false(m.readable(fs.createWriteStream(tempfile()))); t.false(m.readable(new net.Socket())); }); test('isStream.duplex()', t => { t.true(m.duplex(new Stream.Duplex())); t.true(m.duplex(new Stream.Transform())); t.true(m.duplex(new Stream.PassThrough())); t.false(m.duplex(new Stream.Stream())); t.false(m.duplex(new Stream.Readable())); t.false(m.duplex(new Stream.Writable())); t.false(m.duplex(fs.createReadStream('test.js'))); t.false(m.duplex(fs.createWriteStream(tempfile()))); }); test('isStream.transform()', t => { t.true(m.transform(new Stream.Transform())); t.true(m.transform(new Stream.PassThrough())); t.false(m.transform(new Stream.Duplex())); t.false(m.transform(new Stream.Stream())); t.false(m.transform(new Stream.Readable())); t.false(m.transform(new Stream.Writable())); t.false(m.transform(fs.createReadStream('test.js'))); t.false(m.transform(fs.createWriteStream(tempfile()))); });