mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Add type definitions to stream-mock
This commit is contained in:
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// Type definitions for stream-mock 1.2.0
|
||||
// Project: https://github.com/BastienAr/stream-mock
|
||||
// Definitions by: Ivan Kerin <https://github.com/ivank>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import {
|
||||
Readable,
|
||||
ReadableOptions,
|
||||
WritableOptions,
|
||||
Writable,
|
||||
Duplex,
|
||||
DuplexOptions
|
||||
} from "stream";
|
||||
|
||||
export class ReadableMock extends Readable {
|
||||
constructor(source: any[], opts?: ReadableOptions);
|
||||
}
|
||||
export class WritableMock extends Writable {
|
||||
data: any;
|
||||
flatData: any;
|
||||
}
|
||||
export class DuplexMock extends Duplex {
|
||||
data: any;
|
||||
flatData: any;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { ReadableMock, WritableMock, DuplexMock } from "stream-mock";
|
||||
|
||||
const reader = new ReadableMock(["a", "b"], { objectMode: true });
|
||||
const writer = new WritableMock({ objectMode: true });
|
||||
const duplex = new DuplexMock({
|
||||
readableObjectMode: true,
|
||||
writableObjectMode: true
|
||||
});
|
||||
|
||||
reader.pipe(duplex).pipe(writer);
|
||||
|
||||
writer.on("finish", () => {
|
||||
console.log(duplex.data, duplex.flatData);
|
||||
console.log(writer.data, writer.flatData);
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "stream-mock-tests.ts"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user