pax_global_header00006660000000000000000000000064140775067710014530gustar00rootroot0000000000000052 comment=fb8caed475b4107cee3c22be3252a904020eb2d4 is-stream-2.0.1/000077500000000000000000000000001407750677100134345ustar00rootroot00000000000000is-stream-2.0.1/.editorconfig000066400000000000000000000002571407750677100161150ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 is-stream-2.0.1/.gitattributes000066400000000000000000000000231407750677100163220ustar00rootroot00000000000000* text=auto eol=lf is-stream-2.0.1/.github/000077500000000000000000000000001407750677100147745ustar00rootroot00000000000000is-stream-2.0.1/.github/funding.yml000066400000000000000000000001631407750677100171510ustar00rootroot00000000000000github: sindresorhus open_collective: sindresorhus tidelift: npm/is-stream custom: https://sindresorhus.com/donate is-stream-2.0.1/.github/security.md000066400000000000000000000002631407750677100171660ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. is-stream-2.0.1/.github/workflows/000077500000000000000000000000001407750677100170315ustar00rootroot00000000000000is-stream-2.0.1/.github/workflows/main.yml000066400000000000000000000007021407750677100204770ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 14 - 12 - 10 - 8 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test is-stream-2.0.1/.gitignore000066400000000000000000000000271407750677100154230ustar00rootroot00000000000000node_modules yarn.lock is-stream-2.0.1/.npmrc000066400000000000000000000000231407750677100145470ustar00rootroot00000000000000package-lock=false is-stream-2.0.1/index.d.ts000066400000000000000000000033621407750677100153410ustar00rootroot00000000000000import * as stream from 'stream'; declare const isStream: { /** @returns Whether `stream` is a [`Stream`](https://nodejs.org/api/stream.html#stream_stream). @example ``` import * as fs from 'fs'; import isStream = require('is-stream'); isStream(fs.createReadStream('unicorn.png')); //=> true isStream({}); //=> false ``` */ (stream: unknown): stream is stream.Stream; /** @returns Whether `stream` is a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable). @example ``` import * as fs from 'fs'; import isStream = require('is-stream'); isStream.writable(fs.createWriteStrem('unicorn.txt')); //=> true ``` */ writable(stream: unknown): stream is stream.Writable; /** @returns Whether `stream` is a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable). @example ``` import * as fs from 'fs'; import isStream = require('is-stream'); isStream.readable(fs.createReadStream('unicorn.png')); //=> true ``` */ readable(stream: unknown): stream is stream.Readable; /** @returns Whether `stream` is a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex). @example ``` import {Duplex} from 'stream'; import isStream = require('is-stream'); isStream.duplex(new Duplex()); //=> true ``` */ duplex(stream: unknown): stream is stream.Duplex; /** @returns Whether `stream` is a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform). @example ``` import * as fs from 'fs'; import Stringify = require('streaming-json-stringify'); import isStream = require('is-stream'); isStream.transform(Stringify()); //=> true ``` */ transform(input: unknown): input is stream.Transform; }; export = isStream; is-stream-2.0.1/index.js000066400000000000000000000012451407750677100151030ustar00rootroot00000000000000'use strict'; const isStream = stream => stream !== null && typeof stream === 'object' && typeof stream.pipe === 'function'; isStream.writable = stream => isStream(stream) && stream.writable !== false && typeof stream._write === 'function' && typeof stream._writableState === 'object'; isStream.readable = stream => isStream(stream) && stream.readable !== false && typeof stream._read === 'function' && typeof stream._readableState === 'object'; isStream.duplex = stream => isStream.writable(stream) && isStream.readable(stream); isStream.transform = stream => isStream.duplex(stream) && typeof stream._transform === 'function'; module.exports = isStream; is-stream-2.0.1/index.test-d.ts000066400000000000000000000007121407750677100163120ustar00rootroot00000000000000import {expectType} from 'tsd'; import * as stream from 'stream'; import isStream = require('.'); const foo = ''; if (isStream(foo)) { expectType(foo); } if (isStream.writable(foo)) { expectType(foo); } if (isStream.readable(foo)) { expectType(foo); } if (isStream.duplex(foo)) { expectType(new stream.Duplex()); } if (isStream.transform(foo)) { expectType(foo); } is-stream-2.0.1/license000066400000000000000000000021351407750677100150020ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://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-2.0.1/package.json000066400000000000000000000013361407750677100157250ustar00rootroot00000000000000{ "name": "is-stream", "version": "2.0.1", "description": "Check if something is a Node.js stream", "license": "MIT", "repository": "sindresorhus/is-stream", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "stream", "type", "streams", "writable", "readable", "duplex", "transform", "check", "detect", "is" ], "devDependencies": { "@types/node": "^11.13.6", "ava": "^1.4.1", "tempy": "^0.3.0", "tsd": "^0.7.2", "xo": "^0.24.0" } } is-stream-2.0.1/readme.md000066400000000000000000000031251407750677100152140ustar00rootroot00000000000000# is-stream > Check if something is a [Node.js stream](https://nodejs.org/api/stream.html) ## Install ``` $ npm install is-stream ``` ## Usage ```js const fs = require('fs'); const isStream = require('is-stream'); isStream(fs.createReadStream('unicorn.png')); //=> true isStream({}); //=> false ``` ## API ### isStream(stream) Returns a `boolean` for whether it's a [`Stream`](https://nodejs.org/api/stream.html#stream_stream). #### isStream.writable(stream) Returns a `boolean` for whether it's a [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable). #### isStream.readable(stream) Returns a `boolean` for whether it's a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable). #### isStream.duplex(stream) Returns a `boolean` for whether it's a [`stream.Duplex`](https://nodejs.org/api/stream.html#stream_class_stream_duplex). #### isStream.transform(stream) Returns a `boolean` for whether it's a [`stream.Transform`](https://nodejs.org/api/stream.html#stream_class_stream_transform). ## Related - [is-file-stream](https://github.com/jamestalmage/is-file-stream) - Detect if a stream is a file stream ---
Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.
is-stream-2.0.1/test.js000066400000000000000000000051451407750677100147560ustar00rootroot00000000000000import fs from 'fs'; import Stream from 'stream'; import net from 'net'; import test from 'ava'; import tempy from 'tempy'; import isStream from '.'; test('isStream()', t => { t.true(isStream(new Stream.Stream())); t.true(isStream(new Stream.Readable())); t.true(isStream(new Stream.Writable())); t.true(isStream(new Stream.Duplex())); t.true(isStream(new Stream.Transform())); t.true(isStream(new Stream.PassThrough())); t.true(isStream(fs.createReadStream('test.js'))); t.true(isStream(fs.createWriteStream(tempy.file()))); t.true(isStream(new net.Socket())); t.false(isStream({})); t.false(isStream(null)); t.false(isStream(undefined)); t.false(isStream('')); }); test('isStream.writable()', t => { t.true(isStream.writable(new Stream.Writable())); t.true(isStream.writable(new Stream.Duplex())); t.true(isStream.writable(new Stream.Transform())); t.true(isStream.writable(new Stream.PassThrough())); t.true(isStream.writable(fs.createWriteStream(tempy.file()))); t.true(isStream.writable(new net.Socket())); t.false(isStream.writable(new Stream.Stream())); t.false(isStream.writable(new Stream.Readable())); t.false(isStream.writable(fs.createReadStream('test.js'))); }); test('isStream.readable()', t => { t.true(isStream.readable(new Stream.Readable())); t.true(isStream.readable(new Stream.Duplex())); t.true(isStream.readable(new Stream.Transform())); t.true(isStream.readable(new Stream.PassThrough())); t.true(isStream.readable(fs.createReadStream('test.js'))); t.true(isStream.readable(new net.Socket())); t.false(isStream.readable(new Stream.Stream())); t.false(isStream.readable(new Stream.Writable())); t.false(isStream.readable(fs.createWriteStream(tempy.file()))); }); test('isStream.duplex()', t => { t.true(isStream.duplex(new Stream.Duplex())); t.true(isStream.duplex(new Stream.Transform())); t.true(isStream.duplex(new Stream.PassThrough())); t.false(isStream.duplex(new Stream.Stream())); t.false(isStream.duplex(new Stream.Readable())); t.false(isStream.duplex(new Stream.Writable())); t.false(isStream.duplex(fs.createReadStream('test.js'))); t.false(isStream.duplex(fs.createWriteStream(tempy.file()))); }); test('isStream.transform()', t => { t.true(isStream.transform(new Stream.Transform())); t.true(isStream.transform(new Stream.PassThrough())); t.false(isStream.transform(new Stream.Duplex())); t.false(isStream.transform(new Stream.Stream())); t.false(isStream.transform(new Stream.Readable())); t.false(isStream.transform(new Stream.Writable())); t.false(isStream.transform(fs.createReadStream('test.js'))); t.false(isStream.transform(fs.createWriteStream(tempy.file()))); });