@tothalex/cloud 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +19 -0
- package/src/abort.d.ts +69 -0
- package/src/assert.d.ts +39 -0
- package/src/buffer.d.ts +556 -0
- package/src/child_process.d.ts +447 -0
- package/src/crypto.d.ts +854 -0
- package/src/database.d.ts +0 -0
- package/src/dns.d.ts +99 -0
- package/src/events.d.ts +245 -0
- package/src/exceptions.d.ts +26 -0
- package/src/http.d.ts +325 -0
- package/src/index.d.ts +22 -0
- package/src/net.d.ts +488 -0
- package/src/os.d.ts +293 -0
- package/src/process.d.ts +379 -0
- package/src/stream.d.ts +366 -0
- package/src/string_decoder.d.ts +63 -0
- package/src/timers.d.ts +72 -0
- package/src/tty.d.ts +10 -0
- package/src/url.d.ts +774 -0
- package/src/util.d.ts +240 -0
- package/src/zlib.d.ts +149 -0
package/src/stream.d.ts
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
declare module "stream" {
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
|
|
5
|
+
class ReadableStreamInner
|
|
6
|
+
extends EventEmitter
|
|
7
|
+
implements QuickJS.ReadableStream
|
|
8
|
+
{
|
|
9
|
+
/**
|
|
10
|
+
* The `readable.read()` method reads data out of the internal buffer and
|
|
11
|
+
* returns it. If no data is available to be read, `null` is returned. By default,
|
|
12
|
+
* the data is returned as a `Buffer` object unless an encoding has been
|
|
13
|
+
* specified using the `readable.setEncoding()` method or the stream is operating
|
|
14
|
+
* in object mode.
|
|
15
|
+
*
|
|
16
|
+
* The optional `size` argument specifies a specific number of bytes to read. If
|
|
17
|
+
* `size` bytes are not available to be read, `null` will be returned _unless_ the
|
|
18
|
+
* stream has ended, in which case all of the data remaining in the internal buffer
|
|
19
|
+
* will be returned.
|
|
20
|
+
*
|
|
21
|
+
* If the `size` argument is not specified, all of the data contained in the
|
|
22
|
+
* internal buffer will be returned.
|
|
23
|
+
*
|
|
24
|
+
* The `size` argument must be less than or equal to 1 GiB.
|
|
25
|
+
*
|
|
26
|
+
* The `readable.read()` method should only be called on `Readable` streams
|
|
27
|
+
* operating in paused mode. In flowing mode, `readable.read()` is called
|
|
28
|
+
* automatically until the internal buffer is fully drained.
|
|
29
|
+
*
|
|
30
|
+
* ```js
|
|
31
|
+
* const readable = getReadableStreamSomehow();
|
|
32
|
+
*
|
|
33
|
+
* // 'readable' may be triggered multiple times as data is buffered in
|
|
34
|
+
* readable.on('readable', () => {
|
|
35
|
+
* let chunk;
|
|
36
|
+
* console.log('Stream is readable (new data received in buffer)');
|
|
37
|
+
* // Use a loop to make sure we read all currently available data
|
|
38
|
+
* while (null !== (chunk = readable.read())) {
|
|
39
|
+
* console.log(`Read ${chunk.length} bytes of data...`);
|
|
40
|
+
* }
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* // 'end' will be triggered once when there is no more data available
|
|
44
|
+
* readable.on('end', () => {
|
|
45
|
+
* console.log('Reached end of stream.');
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Each call to `readable.read()` returns a chunk of data, or `null`. The chunks
|
|
50
|
+
* are not concatenated. A `while` loop is necessary to consume all data
|
|
51
|
+
* currently in the buffer. When reading a large file `.read()` may return `null`,
|
|
52
|
+
* having consumed all buffered content so far, but there is still more data to
|
|
53
|
+
* come not yet buffered. In this case a new `'readable'` event will be emitted
|
|
54
|
+
* when there is more data in the buffer. Finally the `'end'` event will be
|
|
55
|
+
* emitted when there is no more data to come.
|
|
56
|
+
*
|
|
57
|
+
* Therefore to read a file's whole contents from a `readable`, it is necessary
|
|
58
|
+
* to collect chunks across multiple `'readable'` events:
|
|
59
|
+
*
|
|
60
|
+
* ```js
|
|
61
|
+
* const chunks = [];
|
|
62
|
+
*
|
|
63
|
+
* readable.on('readable', () => {
|
|
64
|
+
* let chunk;
|
|
65
|
+
* while (null !== (chunk = readable.read())) {
|
|
66
|
+
* chunks.push(chunk);
|
|
67
|
+
* }
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* readable.on('end', () => {
|
|
71
|
+
* const content = chunks.join('');
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* A `Readable` stream in object mode will always return a single item from
|
|
76
|
+
* a call to `readable.read(size)`, regardless of the value of the `size` argument.
|
|
77
|
+
*
|
|
78
|
+
* If the `readable.read()` method returns a chunk of data, a `'data'` event will
|
|
79
|
+
* also be emitted.
|
|
80
|
+
*
|
|
81
|
+
* Calling {@link read} after the `'end'` event has
|
|
82
|
+
* been emitted will return `null`. No runtime error will be raised.
|
|
83
|
+
* @param size Optional argument to specify how much data to read.
|
|
84
|
+
*/
|
|
85
|
+
read(size?: number): Buffer | null;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Destroy the stream. Optionally emit an `'error'` event, and emit a `'close'` event. After this call, the readable
|
|
89
|
+
* stream will release any internal resources and subsequent calls to `push()` will be ignored.
|
|
90
|
+
*
|
|
91
|
+
* Once `destroy()` has been called any further calls will be a no-op and no
|
|
92
|
+
* further errors except from `_destroy()` may be emitted as `'error'`.
|
|
93
|
+
*
|
|
94
|
+
* Implementors should not override this method, but instead implement `readable._destroy()`.
|
|
95
|
+
* @param error Error which will be passed as payload in `'error'` event
|
|
96
|
+
*/
|
|
97
|
+
destroy(error?: Error): this;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Event emitter
|
|
101
|
+
* The defined events on documents including:
|
|
102
|
+
* 1. close
|
|
103
|
+
* 2. data
|
|
104
|
+
* 3. end
|
|
105
|
+
* 4. error
|
|
106
|
+
* 5. readable
|
|
107
|
+
*/
|
|
108
|
+
addListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
109
|
+
addListener(event: "close", listener: () => void): this;
|
|
110
|
+
addListener(event: "data", listener: (chunk: Buffer) => void): this;
|
|
111
|
+
addListener(event: "end", listener: () => void): this;
|
|
112
|
+
addListener(event: "error", listener: (err: Error) => void): this;
|
|
113
|
+
addListener(event: "readable", listener: () => void): this;
|
|
114
|
+
emit(event: EventKey, ...args: any[]): boolean;
|
|
115
|
+
emit(event: "close"): boolean;
|
|
116
|
+
emit(event: "data", chunk: Buffer): boolean;
|
|
117
|
+
emit(event: "end"): boolean;
|
|
118
|
+
emit(event: "error", err: Error): boolean;
|
|
119
|
+
emit(event: "readable"): boolean;
|
|
120
|
+
on(event: EventKey, listener: (...args: any[]) => void): this;
|
|
121
|
+
on(event: "close", listener: () => void): this;
|
|
122
|
+
on(event: "data", listener: (chunk: Buffer) => void): this;
|
|
123
|
+
on(event: "end", listener: () => void): this;
|
|
124
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
125
|
+
on(event: "readable", listener: () => void): this;
|
|
126
|
+
once(event: EventKey, listener: (...args: any[]) => void): this;
|
|
127
|
+
once(event: "close", listener: () => void): this;
|
|
128
|
+
once(event: "data", listener: (chunk: Buffer) => void): this;
|
|
129
|
+
once(event: "end", listener: () => void): this;
|
|
130
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
131
|
+
once(event: "readable", listener: () => void): this;
|
|
132
|
+
prependListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
133
|
+
prependListener(event: "close", listener: () => void): this;
|
|
134
|
+
prependListener(event: "data", listener: (chunk: Buffer) => void): this;
|
|
135
|
+
prependListener(event: "end", listener: () => void): this;
|
|
136
|
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
137
|
+
prependListener(event: "readable", listener: () => void): this;
|
|
138
|
+
prependOnceListener(
|
|
139
|
+
event: EventKey,
|
|
140
|
+
listener: (...args: any[]) => void
|
|
141
|
+
): this;
|
|
142
|
+
prependOnceListener(event: "close", listener: () => void): this;
|
|
143
|
+
prependOnceListener(event: "data", listener: (chunk: Buffer) => void): this;
|
|
144
|
+
prependOnceListener(event: "end", listener: () => void): this;
|
|
145
|
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
146
|
+
prependOnceListener(event: "readable", listener: () => void): this;
|
|
147
|
+
removeListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
148
|
+
removeListener(event: "close", listener: () => void): this;
|
|
149
|
+
removeListener(event: "data", listener: (chunk: Buffer) => void): this;
|
|
150
|
+
removeListener(event: "end", listener: () => void): this;
|
|
151
|
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
152
|
+
removeListener(event: "readable", listener: () => void): this;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Calls `readable.destroy()`.
|
|
156
|
+
*/
|
|
157
|
+
[Symbol.dispose](): void;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
class WritableStreamInner
|
|
161
|
+
extends EventEmitter
|
|
162
|
+
implements QuickJS.WritableStream
|
|
163
|
+
{
|
|
164
|
+
/**
|
|
165
|
+
* The `writable.write()` method writes some data to the stream, and calls the
|
|
166
|
+
* supplied `callback` once the data has been fully handled. If an error
|
|
167
|
+
* occurs, the `callback` will be called with the error as its
|
|
168
|
+
* first argument. The `callback` is usually called asynchronously and before `'error'`
|
|
169
|
+
* is emitted.
|
|
170
|
+
*
|
|
171
|
+
* ```js
|
|
172
|
+
* function write(data, cb) {
|
|
173
|
+
* if (!stream.write(data)) {
|
|
174
|
+
* stream.once('drain', cb);
|
|
175
|
+
* } else {
|
|
176
|
+
* process.nextTick(cb);
|
|
177
|
+
* }
|
|
178
|
+
* }
|
|
179
|
+
*
|
|
180
|
+
* // Wait for cb to be called before doing any other write.
|
|
181
|
+
* write('hello', () => {
|
|
182
|
+
* console.log('Write completed, do more writes now.');
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*
|
|
186
|
+
* A `Writable` stream in object mode will always ignore the `encoding` argument.
|
|
187
|
+
* @since v0.9.4
|
|
188
|
+
* @param chunk Optional data to write. `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}.
|
|
189
|
+
* @param [encoding='utf8'] The encoding, if `chunk` is a string.
|
|
190
|
+
* @param callback Callback for when this chunk of data is flushed.
|
|
191
|
+
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
192
|
+
*/
|
|
193
|
+
write(
|
|
194
|
+
chunk:
|
|
195
|
+
| string
|
|
196
|
+
| Buffer
|
|
197
|
+
| QuickJS.ArrayBufferView
|
|
198
|
+
| ArrayBuffer
|
|
199
|
+
| SharedArrayBuffer,
|
|
200
|
+
callback?: (error?: Error | null) => void
|
|
201
|
+
): void;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Calling the `writable.end()` method signals that no more data will be written
|
|
205
|
+
* to the `Writable`.
|
|
206
|
+
*
|
|
207
|
+
* Calling the {@link write} method after calling {@link end} will raise an error.
|
|
208
|
+
*/
|
|
209
|
+
end(): this;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Event emitter
|
|
213
|
+
* The defined events on documents including:
|
|
214
|
+
* 1. close
|
|
215
|
+
* 2. error
|
|
216
|
+
* 3. finish
|
|
217
|
+
*/
|
|
218
|
+
addListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
219
|
+
addListener(event: "close", listener: () => void): this;
|
|
220
|
+
addListener(event: "error", listener: (err: Error) => void): this;
|
|
221
|
+
addListener(event: "finish", listener: () => void): this;
|
|
222
|
+
emit(event: EventKey, ...args: any[]): boolean;
|
|
223
|
+
emit(event: "close"): boolean;
|
|
224
|
+
emit(event: "error", err: Error): boolean;
|
|
225
|
+
emit(event: "finish"): boolean;
|
|
226
|
+
on(event: EventKey, listener: (...args: any[]) => void): this;
|
|
227
|
+
on(event: "close", listener: () => void): this;
|
|
228
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
229
|
+
on(event: "finish", listener: () => void): this;
|
|
230
|
+
once(event: EventKey, listener: (...args: any[]) => void): this;
|
|
231
|
+
once(event: "close", listener: () => void): this;
|
|
232
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
233
|
+
once(event: "finish", listener: () => void): this;
|
|
234
|
+
prependListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
235
|
+
prependListener(event: "close", listener: () => void): this;
|
|
236
|
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
237
|
+
prependListener(event: "finish", listener: () => void): this;
|
|
238
|
+
prependOnceListener(
|
|
239
|
+
event: EventKey,
|
|
240
|
+
listener: (...args: any[]) => void
|
|
241
|
+
): this;
|
|
242
|
+
prependOnceListener(event: "close", listener: () => void): this;
|
|
243
|
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
244
|
+
prependOnceListener(event: "finish", listener: () => void): this;
|
|
245
|
+
removeListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
246
|
+
removeListener(event: "close", listener: () => void): this;
|
|
247
|
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
248
|
+
removeListener(event: "finish", listener: () => void): this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
class DefaultReadableStream extends ReadableStreamInner {}
|
|
252
|
+
|
|
253
|
+
class DefaultWritableStream extends WritableStreamInner {}
|
|
254
|
+
|
|
255
|
+
class DefaultDuplexStream
|
|
256
|
+
extends DefaultReadableStream
|
|
257
|
+
implements DefaultWritableStream
|
|
258
|
+
{
|
|
259
|
+
/**
|
|
260
|
+
* The `writable.write()` method writes some data to the stream, and calls the
|
|
261
|
+
* supplied `callback` once the data has been fully handled. If an error
|
|
262
|
+
* occurs, the `callback` will be called with the error as its
|
|
263
|
+
* first argument. The `callback` is usually called asynchronously and before `'error'`
|
|
264
|
+
* is emitted.
|
|
265
|
+
*
|
|
266
|
+
* ```js
|
|
267
|
+
* function write(data, cb) {
|
|
268
|
+
* if (!stream.write(data)) {
|
|
269
|
+
* stream.once('drain', cb);
|
|
270
|
+
* } else {
|
|
271
|
+
* process.nextTick(cb);
|
|
272
|
+
* }
|
|
273
|
+
* }
|
|
274
|
+
*
|
|
275
|
+
* // Wait for cb to be called before doing any other write.
|
|
276
|
+
* write('hello', () => {
|
|
277
|
+
* console.log('Write completed, do more writes now.');
|
|
278
|
+
* });
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* A `Writable` stream in object mode will always ignore the `encoding` argument.
|
|
282
|
+
* @since v0.9.4
|
|
283
|
+
* @param chunk Optional data to write. `chunk` must be a {string}, {Buffer}, {TypedArray} or {DataView}.
|
|
284
|
+
* @param [encoding='utf8'] The encoding, if `chunk` is a string.
|
|
285
|
+
* @param callback Callback for when this chunk of data is flushed.
|
|
286
|
+
* @return `false` if the stream wishes for the calling code to wait for the `'drain'` event to be emitted before continuing to write additional data; otherwise `true`.
|
|
287
|
+
*/
|
|
288
|
+
write(
|
|
289
|
+
chunk:
|
|
290
|
+
| string
|
|
291
|
+
| Buffer
|
|
292
|
+
| QuickJS.ArrayBufferView
|
|
293
|
+
| ArrayBuffer
|
|
294
|
+
| SharedArrayBuffer,
|
|
295
|
+
callback?: (error?: Error | null) => void
|
|
296
|
+
): void;
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Calling the `writable.end()` method signals that no more data will be written
|
|
300
|
+
* to the `Writable`.
|
|
301
|
+
*
|
|
302
|
+
* Calling the {@link write} method after calling {@link end} will raise an error.
|
|
303
|
+
*/
|
|
304
|
+
end(): this;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Event emitter
|
|
308
|
+
* The defined events on documents including:
|
|
309
|
+
* 1. close
|
|
310
|
+
* 2. error
|
|
311
|
+
* 3. finish
|
|
312
|
+
*/
|
|
313
|
+
addListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
314
|
+
addListener(event: "close", listener: () => void): this;
|
|
315
|
+
addListener(event: "error", listener: (err: Error) => void): this;
|
|
316
|
+
addListener(event: "finish", listener: () => void): this;
|
|
317
|
+
emit(event: EventKey, ...args: any[]): boolean;
|
|
318
|
+
emit(event: "close"): boolean;
|
|
319
|
+
emit(event: "error", err: Error): boolean;
|
|
320
|
+
emit(event: "finish"): boolean;
|
|
321
|
+
on(event: EventKey, listener: (...args: any[]) => void): this;
|
|
322
|
+
on(event: "close", listener: () => void): this;
|
|
323
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
324
|
+
on(event: "finish", listener: () => void): this;
|
|
325
|
+
once(event: EventKey, listener: (...args: any[]) => void): this;
|
|
326
|
+
once(event: "close", listener: () => void): this;
|
|
327
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
328
|
+
once(event: "finish", listener: () => void): this;
|
|
329
|
+
prependListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
330
|
+
prependListener(event: "close", listener: () => void): this;
|
|
331
|
+
prependListener(event: "error", listener: (err: Error) => void): this;
|
|
332
|
+
prependListener(event: "finish", listener: () => void): this;
|
|
333
|
+
prependOnceListener(
|
|
334
|
+
event: EventKey,
|
|
335
|
+
listener: (...args: any[]) => void
|
|
336
|
+
): this;
|
|
337
|
+
prependOnceListener(event: "close", listener: () => void): this;
|
|
338
|
+
prependOnceListener(event: "error", listener: (err: Error) => void): this;
|
|
339
|
+
prependOnceListener(event: "finish", listener: () => void): this;
|
|
340
|
+
removeListener(event: EventKey, listener: (...args: any[]) => void): this;
|
|
341
|
+
removeListener(event: "close", listener: () => void): this;
|
|
342
|
+
removeListener(event: "error", listener: (err: Error) => void): this;
|
|
343
|
+
removeListener(event: "finish", listener: () => void): this;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
global {
|
|
347
|
+
namespace QuickJS {
|
|
348
|
+
interface ReadableStream extends EventEmitter {
|
|
349
|
+
read(size?: number): Buffer | null;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
interface WritableStream extends EventEmitter {
|
|
353
|
+
write(
|
|
354
|
+
chunk:
|
|
355
|
+
| string
|
|
356
|
+
| Buffer
|
|
357
|
+
| QuickJS.ArrayBufferView
|
|
358
|
+
| ArrayBuffer
|
|
359
|
+
| SharedArrayBuffer,
|
|
360
|
+
callback?: (err?: Error | null) => void
|
|
361
|
+
): void;
|
|
362
|
+
end(): this;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `string_decoder` module provides an API for decoding `Buffer` objects
|
|
3
|
+
* into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16
|
|
4
|
+
* characters. It can be accessed using:
|
|
5
|
+
*
|
|
6
|
+
* ```js
|
|
7
|
+
* const { StringDecoder } = require('string_decoder');
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* The following example shows the basic use of the `StringDecoder` class.
|
|
11
|
+
*
|
|
12
|
+
* ```js
|
|
13
|
+
* const { StringDecoder } = require('string_decoder');
|
|
14
|
+
* const decoder = new StringDecoder('utf8');
|
|
15
|
+
*
|
|
16
|
+
* const cent = Buffer.from([0xC2, 0xA2]);
|
|
17
|
+
* console.log(decoder.write(cent)); // Prints: ¢
|
|
18
|
+
*
|
|
19
|
+
* const euro = Buffer.from([0xE2, 0x82, 0xAC]);
|
|
20
|
+
* console.log(decoder.write(euro)); // Prints: €
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* When a `Buffer` instance is written to the `StringDecoder` instance, an
|
|
24
|
+
* internal buffer is used to ensure that the decoded string does not contain
|
|
25
|
+
* any incomplete multibyte characters. These are held in the buffer until the
|
|
26
|
+
* next call to `stringDecoder.write()` or until `stringDecoder.end()` is called.
|
|
27
|
+
*
|
|
28
|
+
* In the following example, the three UTF-8 encoded bytes of the European Euro
|
|
29
|
+
* symbol (`€`) are written over three separate operations:
|
|
30
|
+
*
|
|
31
|
+
* ```js
|
|
32
|
+
* const { StringDecoder } = require('string_decoder');
|
|
33
|
+
* const decoder = new StringDecoder('utf8');
|
|
34
|
+
*
|
|
35
|
+
* decoder.write(Buffer.from([0xE2]));
|
|
36
|
+
* decoder.write(Buffer.from([0x82]));
|
|
37
|
+
* console.log(decoder.end(Buffer.from([0xAC]))); // Prints: €
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
declare module "string_decoder" {
|
|
41
|
+
import { Buffer, BufferEncoding } from "buffer";
|
|
42
|
+
|
|
43
|
+
class StringDecoder {
|
|
44
|
+
constructor(encoding?: BufferEncoding);
|
|
45
|
+
/**
|
|
46
|
+
* Returns a decoded string, ensuring that any incomplete multibyte characters at
|
|
47
|
+
* the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the
|
|
48
|
+
* returned string and stored in an internal buffer for the next call to `stringDecoder.write()` or `stringDecoder.end()`.
|
|
49
|
+
* @param buffer The bytes to decode.
|
|
50
|
+
*/
|
|
51
|
+
write(buffer: string | Buffer | QuickJS.ArrayBufferView): string;
|
|
52
|
+
/**
|
|
53
|
+
* Returns any remaining input stored in the internal buffer as a string. Bytes
|
|
54
|
+
* representing incomplete UTF-8 and UTF-16 characters will be replaced with
|
|
55
|
+
* substitution characters appropriate for the character encoding.
|
|
56
|
+
*
|
|
57
|
+
* If the `buffer` argument is provided, one final call to `stringDecoder.write()` is performed before returning the remaining input.
|
|
58
|
+
* After `end()` is called, the `stringDecoder` object can be reused for new input.
|
|
59
|
+
* @param buffer The bytes to decode.
|
|
60
|
+
*/
|
|
61
|
+
end(buffer?: string | Buffer | QuickJS.ArrayBufferView): string;
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/timers.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
declare module "timers" {
|
|
2
|
+
export import setTimeout = globalThis.setTimeout;
|
|
3
|
+
export import clearTimeout = globalThis.clearTimeout;
|
|
4
|
+
export import setInterval = globalThis.setInterval;
|
|
5
|
+
export import clearInterval = globalThis.clearInterval;
|
|
6
|
+
export import setImmediate = globalThis.setImmediate;
|
|
7
|
+
|
|
8
|
+
global {
|
|
9
|
+
/**
|
|
10
|
+
* This object is created internally and is returned from `setTimeout()` and `setInterval()`. It can be passed to either `clearTimeout()` or `clearInterval()` in order to cancel the
|
|
11
|
+
* scheduled actions.
|
|
12
|
+
*/
|
|
13
|
+
class Timeout {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Schedules execution of a one-time `callback` after `delay` milliseconds.
|
|
17
|
+
*
|
|
18
|
+
* The `callback` will likely not be invoked in precisely `delay` milliseconds.
|
|
19
|
+
* LLRT makes no guarantees about the exact timing of when callbacks will fire,
|
|
20
|
+
* nor of their ordering. The callback will be called as close as possible to the
|
|
21
|
+
* time specified. The precision is limited to 4ms.
|
|
22
|
+
*
|
|
23
|
+
* @param callback The function to call when the timer elapses.
|
|
24
|
+
* @param [delay=4] The number of milliseconds to wait before calling the `callback`.
|
|
25
|
+
* @return for use with {@link clearTimeout}
|
|
26
|
+
*/
|
|
27
|
+
function setTimeout<TArgs extends any[]>(
|
|
28
|
+
callback: (...args: TArgs) => void,
|
|
29
|
+
ms?: number
|
|
30
|
+
): Timeout;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Cancels a `Timeout` object created by `setTimeout()`.
|
|
34
|
+
* @param timeout A `Timeout` object as returned by {@link setTimeout}.
|
|
35
|
+
*/
|
|
36
|
+
function clearTimeout(timeout: Timeout): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Schedules repeated execution of `callback` every `delay` milliseconds.
|
|
40
|
+
*
|
|
41
|
+
* The `callback` will likely not be invoked at precisely `delay` milliseconds.
|
|
42
|
+
* LLRT makes no guarantees about the exact timing of when callbacks will fire,
|
|
43
|
+
* nor of their ordering. The callback will be called as close as possible to the
|
|
44
|
+
* time specified. The precision is limited to 4ms.
|
|
45
|
+
*
|
|
46
|
+
* @param callback The function to call when the timer elapses.
|
|
47
|
+
* @param [delay=4] The number of milliseconds to wait before calling the `callback`.
|
|
48
|
+
* @return for use with {@link clearInterval}
|
|
49
|
+
*/
|
|
50
|
+
function setInterval<TArgs extends any[]>(
|
|
51
|
+
callback: (...args: TArgs) => void,
|
|
52
|
+
ms?: number
|
|
53
|
+
): Timeout;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Cancels a `Timeout` object created by `setInterval()`.
|
|
57
|
+
* @param timeout A `Timeout` object as returned by {@link setInterval}
|
|
58
|
+
*/
|
|
59
|
+
function clearInterval(interval: Timeout): void;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Schedules the "immediate" execution of the `callback` after I/O events'
|
|
63
|
+
* callbacks.
|
|
64
|
+
*
|
|
65
|
+
* @param callback The function to call at the end of this turn of the Node.js `Event Loop`
|
|
66
|
+
* @return for use with {@link clearImmediate}
|
|
67
|
+
*/
|
|
68
|
+
function setImmediate<TArgs extends any[]>(
|
|
69
|
+
callback: (...args: TArgs) => void
|
|
70
|
+
): void;
|
|
71
|
+
}
|
|
72
|
+
}
|
package/src/tty.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module 'tty' {
|
|
2
|
+
/**
|
|
3
|
+
* The `tty.isatty()` method returns `true` if the given `fd` is associated with
|
|
4
|
+
* a TTY and `false` if it is not, including whenever `fd` is not a non-negative
|
|
5
|
+
* integer.
|
|
6
|
+
* @since v0.5.8
|
|
7
|
+
* @param fd A numeric file descriptor
|
|
8
|
+
*/
|
|
9
|
+
function isatty(fd: number): boolean
|
|
10
|
+
}
|