-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
41 lines (34 loc) · 1.77 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { Duplex, Readable, Writable } from 'stream'
declare namespace StreamTree {
type Callback = (error?: Error) => void
type WritableCallback = (writable: Writable) => Promise<void>
type WritableStreamTreeFilter = (writable: WritableStreamTree) => Promise<boolean>
interface TreeNode {
childNode: TreeNode[]
parentNode: TreeNode
stream: any
}
interface ReadableStreamTree {
node: TreeNode
finish(callback?: Callback): Readable
pipe(stream: Duplex): ReadableStreamTree
piped(parent: ReadableStreamTree): void
split(children?: number): ReadableStreamTree[]
}
interface WritableStreamTree {
node: TreeNode
finish(callback?: Callback, pipe?: ReadableStreamTree): Writable
joinReadable(siblings: number): [WritableStreamTree, ReadableStreamTree[]]
joinWritable(siblings: Writable[], callback?: Callback[]): WritableStreamTree
pipeFrom(stream: Duplex): WritableStreamTree
pipedFrom(parent: WritableStreamTree): void
}
const readable: (stream: Readable) => ReadableStreamTree
const writable: (stream: Writable) => WritableStreamTree
const writer: (writeCallback: WritableCallback | WritableCallback[]) => WritableStreamTreeFilter
const pumpReadable: <X extends unknown>(stream: ReadableStreamTree, resolveValue: X) => Promise<X>
const pumpWritable: <X extends unknown>(stream: WritableStreamTree, resolveValue: X, readable?: ReadableStreamTree) => Promise<X>
const finishReadable: <X extends unknown>(stream: ReadableStreamTree, resolve: (x: X) => void, reject: (err: Error) => void, resolveValue?: X) => Readable
const finishWritable: <X extends unknown>(stream: WritableStreamTree, resolve: (x: X) => void, reject: (err: Error) => void, resolveValue?: X, readable?: ReadableStreamTree) => Writable
}
export = StreamTree