mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
[is-stream] introduce typings (#18285)
This commit is contained in:
committed by
Wesley Wigham
parent
ae0493cdc6
commit
379d9ca112
18
types/is-stream/index.d.ts
vendored
Normal file
18
types/is-stream/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for is-stream 1.1
|
||||
// Project: https://github.com/sindresorhus/is-stream#readme
|
||||
// Definitions by: BendingBender <https://github.com/me>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
import * as stream from "stream";
|
||||
|
||||
export = isStream;
|
||||
|
||||
declare function isStream(maybeStream: any): maybeStream is stream.Stream;
|
||||
|
||||
declare namespace isStream {
|
||||
function writable(maybeWritable: any): maybeWritable is stream.Writable;
|
||||
function readable(maybeReadable: any): maybeReadable is stream.Readable;
|
||||
function duplex(maybeDuplex: any): maybeDuplex is stream.Duplex;
|
||||
function transform(maybeTransform: any): maybeTransform is stream.Transform;
|
||||
}
|
||||
24
types/is-stream/is-stream-tests.ts
Normal file
24
types/is-stream/is-stream-tests.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import isStream = require('is-stream');
|
||||
import * as stream from 'stream';
|
||||
|
||||
const anyStream: any = new stream.Stream();
|
||||
|
||||
if (isStream(anyStream)) {
|
||||
const justStream: stream.Stream = anyStream;
|
||||
}
|
||||
|
||||
if (isStream.writable(anyStream)) {
|
||||
const writableStream: stream.Writable = anyStream;
|
||||
}
|
||||
|
||||
if (isStream.readable(anyStream)) {
|
||||
const readableStream: stream.Readable = anyStream;
|
||||
}
|
||||
|
||||
if (isStream.duplex(anyStream)) {
|
||||
const duplexStream: stream.Duplex = anyStream;
|
||||
}
|
||||
|
||||
if (isStream.transform(anyStream)) {
|
||||
const transformStream: stream.Transform = anyStream;
|
||||
}
|
||||
22
types/is-stream/tsconfig.json
Normal file
22
types/is-stream/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"is-stream-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/is-stream/tslint.json
Normal file
1
types/is-stream/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user