WXL
3 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
declare module "node:stream/consumers" {
    import { Blob, NonSharedBuffer } from "node:buffer";
    import { ReadableStream } from "node:stream/web";
    /**
     * ```js
     * import { arrayBuffer } from 'node:stream/consumers';
     * import { Readable } from 'node:stream';
     * import { TextEncoder } from 'node:util';
     *
     * const encoder = new TextEncoder();
     * const dataArray = encoder.encode('hello world from consumers!');
     *
     * const readable = Readable.from(dataArray);
     * const data = await arrayBuffer(readable);
     * console.log(`from readable: ${data.byteLength}`);
     * // Prints: from readable: 76
     * ```
     * @since v16.7.0
     * @returns Fulfills with an `ArrayBuffer` containing the full contents of the stream.
     */
    function arrayBuffer(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<ArrayBuffer>;
    /**
     * ```js
     * import { blob } from 'node:stream/consumers';
     *
     * const dataBlob = new Blob(['hello world from consumers!']);
     *
     * const readable = dataBlob.stream();
     * const data = await blob(readable);
     * console.log(`from readable: ${data.size}`);
     * // Prints: from readable: 27
     * ```
     * @since v16.7.0
     * @returns Fulfills with a `Blob` containing the full contents of the stream.
     */
    function blob(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<Blob>;
    /**
     * ```js
     * import { buffer } from 'node:stream/consumers';
     * import { Readable } from 'node:stream';
     * import { Buffer } from 'node:buffer';
     *
     * const dataBuffer = Buffer.from('hello world from consumers!');
     *
     * const readable = Readable.from(dataBuffer);
     * const data = await buffer(readable);
     * console.log(`from readable: ${data.length}`);
     * // Prints: from readable: 27
     * ```
     * @since v16.7.0
     * @returns Fulfills with a `Buffer` containing the full contents of the stream.
     */
    function buffer(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<NonSharedBuffer>;
    /**
     * ```js
     * import { bytes } from 'node:stream/consumers';
     * import { Readable } from 'node:stream';
     * import { Buffer } from 'node:buffer';
     *
     * const dataBuffer = Buffer.from('hello world from consumers!');
     *
     * const readable = Readable.from(dataBuffer);
     * const data = await bytes(readable);
     * console.log(`from readable: ${data.length}`);
     * // Prints: from readable: 27
     * ```
     * @since v25.6.0
     * @returns Fulfills with a `Uint8Array` containing the full contents of the stream.
     */
    function bytes(
        stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>,
    ): Promise<NodeJS.NonSharedUint8Array>;
    /**
     * ```js
     * import { json } from 'node:stream/consumers';
     * import { Readable } from 'node:stream';
     *
     * const items = Array.from(
     *   {
     *     length: 100,
     *   },
     *   () => ({
     *     message: 'hello world from consumers!',
     *   }),
     * );
     *
     * const readable = Readable.from(JSON.stringify(items));
     * const data = await json(readable);
     * console.log(`from readable: ${data.length}`);
     * // Prints: from readable: 100
     * ```
     * @since v16.7.0
     * @returns Fulfills with the contents of the stream parsed as a
     * UTF-8 encoded string that is then passed through `JSON.parse()`.
     */
    function json(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<unknown>;
    /**
     * ```js
     * import { text } from 'node:stream/consumers';
     * import { Readable } from 'node:stream';
     *
     * const readable = Readable.from('Hello world from consumers!');
     * const data = await text(readable);
     * console.log(`from readable: ${data.length}`);
     * // Prints: from readable: 27
     * ```
     * @since v16.7.0
     * @returns Fulfills with the contents of the stream parsed as a UTF-8 encoded string.
     */
    function text(stream: ReadableStream | NodeJS.ReadableStream | AsyncIterable<any>): Promise<string>;
}
declare module "stream/consumers" {
    export * from "node:stream/consumers";
}