@types/node 18.11.5 → 20.2.5
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.
- node/README.md +2 -2
- node/assert.d.ts +86 -75
- node/async_hooks.d.ts +66 -37
- node/buffer.d.ts +193 -100
- node/child_process.d.ts +82 -56
- node/cluster.d.ts +12 -12
- node/console.d.ts +5 -5
- node/crypto.d.ts +233 -235
- node/dgram.d.ts +15 -15
- node/diagnostics_channel.d.ts +59 -21
- node/dns/promises.d.ts +50 -6
- node/dns.d.ts +26 -17
- node/domain.d.ts +4 -4
- node/events.d.ts +111 -65
- node/fs/promises.d.ts +99 -47
- node/fs.d.ts +244 -73
- node/globals.d.ts +6 -3
- node/http.d.ts +265 -148
- node/http2.d.ts +42 -47
- node/https.d.ts +53 -153
- node/index.d.ts +2 -1
- node/inspector.d.ts +10 -3
- node/module.d.ts +6 -4
- node/net.d.ts +32 -15
- node/os.d.ts +27 -16
- node/package.json +9 -4
- node/path.d.ts +4 -4
- node/perf_hooks.d.ts +28 -15
- node/process.d.ts +49 -46
- node/punycode.d.ts +1 -1
- node/querystring.d.ts +5 -5
- node/readline/promises.d.ts +65 -63
- node/readline.d.ts +32 -159
- node/repl.d.ts +20 -20
- node/stream/consumers.d.ts +1 -1
- node/stream.d.ts +950 -869
- node/string_decoder.d.ts +6 -6
- node/test.d.ts +877 -139
- node/timers/promises.d.ts +26 -1
- node/timers.d.ts +125 -4
- node/tls.d.ts +120 -29
- node/trace_events.d.ts +20 -9
- node/ts4.8/assert.d.ts +86 -75
- node/ts4.8/async_hooks.d.ts +66 -37
- node/ts4.8/buffer.d.ts +193 -101
- node/ts4.8/child_process.d.ts +82 -56
- node/ts4.8/cluster.d.ts +12 -12
- node/ts4.8/console.d.ts +5 -5
- node/ts4.8/crypto.d.ts +230 -233
- node/ts4.8/dgram.d.ts +15 -15
- node/ts4.8/diagnostics_channel.d.ts +59 -21
- node/ts4.8/dns/promises.d.ts +50 -6
- node/ts4.8/dns.d.ts +26 -17
- node/ts4.8/domain.d.ts +4 -4
- node/ts4.8/events.d.ts +111 -65
- node/ts4.8/fs/promises.d.ts +97 -46
- node/ts4.8/fs.d.ts +244 -73
- node/ts4.8/globals.d.ts +21 -12
- node/ts4.8/http.d.ts +265 -148
- node/ts4.8/http2.d.ts +42 -47
- node/ts4.8/https.d.ts +53 -153
- node/ts4.8/inspector.d.ts +10 -3
- node/ts4.8/module.d.ts +6 -4
- node/ts4.8/net.d.ts +33 -16
- node/ts4.8/os.d.ts +27 -16
- node/ts4.8/path.d.ts +4 -4
- node/ts4.8/perf_hooks.d.ts +28 -15
- node/ts4.8/process.d.ts +49 -46
- node/ts4.8/punycode.d.ts +1 -1
- node/ts4.8/querystring.d.ts +5 -5
- node/ts4.8/readline/promises.d.ts +65 -63
- node/ts4.8/readline.d.ts +32 -159
- node/ts4.8/repl.d.ts +20 -20
- node/ts4.8/stream/consumers.d.ts +1 -1
- node/ts4.8/stream.d.ts +192 -140
- node/ts4.8/string_decoder.d.ts +6 -6
- node/ts4.8/test.d.ts +877 -139
- node/ts4.8/timers/promises.d.ts +26 -1
- node/ts4.8/timers.d.ts +125 -4
- node/ts4.8/tls.d.ts +120 -29
- node/ts4.8/trace_events.d.ts +20 -9
- node/ts4.8/tty.d.ts +4 -5
- node/ts4.8/url.d.ts +46 -42
- node/ts4.8/util.d.ts +325 -123
- node/ts4.8/v8.d.ts +253 -14
- node/ts4.8/vm.d.ts +417 -32
- node/ts4.8/wasi.d.ts +13 -19
- node/ts4.8/worker_threads.d.ts +38 -34
- node/ts4.8/zlib.d.ts +11 -11
- node/tty.d.ts +4 -5
- node/url.d.ts +46 -42
- node/util.d.ts +325 -123
- node/v8.d.ts +253 -14
- node/vm.d.ts +417 -32
- node/wasi.d.ts +13 -19
- node/worker_threads.d.ts +38 -34
- node/zlib.d.ts +11 -11
node/buffer.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* recommended to explicitly reference it via an import or require statement.
|
|
11
11
|
*
|
|
12
12
|
* ```js
|
|
13
|
-
* import { Buffer } from 'buffer';
|
|
13
|
+
* import { Buffer } from 'node:buffer';
|
|
14
14
|
*
|
|
15
15
|
* // Creates a zero-filled Buffer of length 10.
|
|
16
16
|
* const buf1 = Buffer.alloc(10);
|
|
@@ -41,11 +41,29 @@
|
|
|
41
41
|
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
|
42
42
|
* const buf7 = Buffer.from('tést', 'latin1');
|
|
43
43
|
* ```
|
|
44
|
-
* @see [source](https://github.com/nodejs/node/blob/
|
|
44
|
+
* @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/buffer.js)
|
|
45
45
|
*/
|
|
46
46
|
declare module 'buffer' {
|
|
47
47
|
import { BinaryLike } from 'node:crypto';
|
|
48
48
|
import { ReadableStream as WebReadableStream } from 'node:stream/web';
|
|
49
|
+
/**
|
|
50
|
+
* This function returns `true` if `input` contains only valid UTF-8-encoded data,
|
|
51
|
+
* including the case in which `input` is empty.
|
|
52
|
+
*
|
|
53
|
+
* Throws if the `input` is a detached array buffer.
|
|
54
|
+
* @since v19.4.0, v18.14.0
|
|
55
|
+
* @param input The input to validate.
|
|
56
|
+
*/
|
|
57
|
+
export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* This function returns `true` if `input` contains only valid ASCII-encoded data,
|
|
60
|
+
* including the case in which `input` is empty.
|
|
61
|
+
*
|
|
62
|
+
* Throws if the `input` is a detached array buffer.
|
|
63
|
+
* @since v19.6.0, v18.15.0
|
|
64
|
+
* @param input The input to validate.
|
|
65
|
+
*/
|
|
66
|
+
export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
|
|
49
67
|
export const INSPECT_MAX_BYTES: number;
|
|
50
68
|
export const kMaxLength: number;
|
|
51
69
|
export const kStringMaxLength: number;
|
|
@@ -67,7 +85,7 @@ declare module 'buffer' {
|
|
|
67
85
|
* sequence cannot be adequately represented in the target encoding. For instance:
|
|
68
86
|
*
|
|
69
87
|
* ```js
|
|
70
|
-
* import { Buffer, transcode } from 'buffer';
|
|
88
|
+
* import { Buffer, transcode } from 'node:buffer';
|
|
71
89
|
*
|
|
72
90
|
* const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
|
|
73
91
|
* console.log(newBuf.toString('ascii'));
|
|
@@ -158,22 +176,62 @@ declare module 'buffer' {
|
|
|
158
176
|
*/
|
|
159
177
|
text(): Promise<string>;
|
|
160
178
|
/**
|
|
161
|
-
* Returns a new
|
|
179
|
+
* Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
|
|
162
180
|
* @since v16.7.0
|
|
163
181
|
*/
|
|
164
182
|
stream(): WebReadableStream;
|
|
165
183
|
}
|
|
184
|
+
export interface FileOptions {
|
|
185
|
+
/**
|
|
186
|
+
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
|
|
187
|
+
* converted to the platform native line-ending as specified by `require('node:os').EOL`.
|
|
188
|
+
*/
|
|
189
|
+
endings?: 'native' | 'transparent';
|
|
190
|
+
/** The File content-type. */
|
|
191
|
+
type?: string;
|
|
192
|
+
/** The last modified date of the file. `Default`: Date.now(). */
|
|
193
|
+
lastModified?: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.
|
|
197
|
+
* @since v19.2.0, v18.13.0
|
|
198
|
+
*/
|
|
199
|
+
export class File extends Blob {
|
|
200
|
+
constructor(sources: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions);
|
|
201
|
+
/**
|
|
202
|
+
* The name of the `File`.
|
|
203
|
+
* @since v19.2.0, v18.13.0
|
|
204
|
+
*/
|
|
205
|
+
readonly name: string;
|
|
206
|
+
/**
|
|
207
|
+
* The last modified date of the `File`.
|
|
208
|
+
* @since v19.2.0, v18.13.0
|
|
209
|
+
*/
|
|
210
|
+
readonly lastModified: number;
|
|
211
|
+
}
|
|
166
212
|
export import atob = globalThis.atob;
|
|
167
213
|
export import btoa = globalThis.btoa;
|
|
168
|
-
|
|
169
214
|
import { Blob as NodeBlob } from 'buffer';
|
|
170
215
|
// This conditional type will be the existing global Blob in a browser, or
|
|
171
216
|
// the copy below in a Node environment.
|
|
172
|
-
type __Blob = typeof globalThis extends { onmessage: any
|
|
173
|
-
? T : NodeBlob;
|
|
217
|
+
type __Blob = typeof globalThis extends { onmessage: any; Blob: infer T } ? T : NodeBlob;
|
|
174
218
|
global {
|
|
219
|
+
namespace NodeJS {
|
|
220
|
+
export { BufferEncoding };
|
|
221
|
+
}
|
|
175
222
|
// Buffer class
|
|
176
|
-
type BufferEncoding =
|
|
223
|
+
type BufferEncoding =
|
|
224
|
+
| 'ascii'
|
|
225
|
+
| 'utf8'
|
|
226
|
+
| 'utf-8'
|
|
227
|
+
| 'utf16le'
|
|
228
|
+
| 'ucs2'
|
|
229
|
+
| 'ucs-2'
|
|
230
|
+
| 'base64'
|
|
231
|
+
| 'base64url'
|
|
232
|
+
| 'latin1'
|
|
233
|
+
| 'binary'
|
|
234
|
+
| 'hex';
|
|
177
235
|
type WithImplicitCoercion<T> =
|
|
178
236
|
| T
|
|
179
237
|
| {
|
|
@@ -235,7 +293,7 @@ declare module 'buffer' {
|
|
|
235
293
|
* Array entries outside that range will be truncated to fit into it.
|
|
236
294
|
*
|
|
237
295
|
* ```js
|
|
238
|
-
* import { Buffer } from 'buffer';
|
|
296
|
+
* import { Buffer } from 'node:buffer';
|
|
239
297
|
*
|
|
240
298
|
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
|
241
299
|
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
|
@@ -247,7 +305,11 @@ declare module 'buffer' {
|
|
|
247
305
|
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
|
|
248
306
|
* @since v5.10.0
|
|
249
307
|
*/
|
|
250
|
-
from(
|
|
308
|
+
from(
|
|
309
|
+
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
|
310
|
+
byteOffset?: number,
|
|
311
|
+
length?: number,
|
|
312
|
+
): Buffer;
|
|
251
313
|
/**
|
|
252
314
|
* Creates a new Buffer using the passed {data}
|
|
253
315
|
* @param data data to create a new Buffer
|
|
@@ -265,7 +327,7 @@ declare module 'buffer' {
|
|
|
265
327
|
| {
|
|
266
328
|
[Symbol.toPrimitive](hint: 'string'): string;
|
|
267
329
|
},
|
|
268
|
-
encoding?: BufferEncoding
|
|
330
|
+
encoding?: BufferEncoding,
|
|
269
331
|
): Buffer;
|
|
270
332
|
/**
|
|
271
333
|
* Creates a new Buffer using the passed {data}
|
|
@@ -276,7 +338,7 @@ declare module 'buffer' {
|
|
|
276
338
|
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
|
277
339
|
*
|
|
278
340
|
* ```js
|
|
279
|
-
* import { Buffer } from 'buffer';
|
|
341
|
+
* import { Buffer } from 'node:buffer';
|
|
280
342
|
*
|
|
281
343
|
* Buffer.isBuffer(Buffer.alloc(10)); // true
|
|
282
344
|
* Buffer.isBuffer(Buffer.from('foo')); // true
|
|
@@ -292,7 +354,7 @@ declare module 'buffer' {
|
|
|
292
354
|
* or `false` otherwise.
|
|
293
355
|
*
|
|
294
356
|
* ```js
|
|
295
|
-
* import { Buffer } from 'buffer';
|
|
357
|
+
* import { Buffer } from 'node:buffer';
|
|
296
358
|
*
|
|
297
359
|
* console.log(Buffer.isEncoding('utf8'));
|
|
298
360
|
* // Prints: true
|
|
@@ -321,7 +383,7 @@ declare module 'buffer' {
|
|
|
321
383
|
* string.
|
|
322
384
|
*
|
|
323
385
|
* ```js
|
|
324
|
-
* import { Buffer } from 'buffer';
|
|
386
|
+
* import { Buffer } from 'node:buffer';
|
|
325
387
|
*
|
|
326
388
|
* const str = '\u00bd + \u00bc = \u00be';
|
|
327
389
|
*
|
|
@@ -339,7 +401,10 @@ declare module 'buffer' {
|
|
|
339
401
|
* @param [encoding='utf8'] If `string` is a string, this is its encoding.
|
|
340
402
|
* @return The number of bytes contained within `string`.
|
|
341
403
|
*/
|
|
342
|
-
byteLength(
|
|
404
|
+
byteLength(
|
|
405
|
+
string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
|
406
|
+
encoding?: BufferEncoding,
|
|
407
|
+
): number;
|
|
343
408
|
/**
|
|
344
409
|
* Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
|
|
345
410
|
*
|
|
@@ -353,7 +418,7 @@ declare module 'buffer' {
|
|
|
353
418
|
* truncated to `totalLength`.
|
|
354
419
|
*
|
|
355
420
|
* ```js
|
|
356
|
-
* import { Buffer } from 'buffer';
|
|
421
|
+
* import { Buffer } from 'node:buffer';
|
|
357
422
|
*
|
|
358
423
|
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
|
359
424
|
*
|
|
@@ -379,11 +444,28 @@ declare module 'buffer' {
|
|
|
379
444
|
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
|
380
445
|
*/
|
|
381
446
|
concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
|
|
447
|
+
/**
|
|
448
|
+
* Copies the underlying memory of `view` into a new `Buffer`.
|
|
449
|
+
*
|
|
450
|
+
* ```js
|
|
451
|
+
* const u16 = new Uint16Array([0, 0xffff]);
|
|
452
|
+
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
|
453
|
+
* u16[1] = 0;
|
|
454
|
+
* console.log(buf.length); // 2
|
|
455
|
+
* console.log(buf[0]); // 255
|
|
456
|
+
* console.log(buf[1]); // 255
|
|
457
|
+
* ```
|
|
458
|
+
* @since v19.8.0
|
|
459
|
+
* @param view The {TypedArray} to copy.
|
|
460
|
+
* @param [offset=': 0'] The starting offset within `view`.
|
|
461
|
+
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
|
462
|
+
*/
|
|
463
|
+
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
|
|
382
464
|
/**
|
|
383
465
|
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
|
384
466
|
*
|
|
385
467
|
* ```js
|
|
386
|
-
* import { Buffer } from 'buffer';
|
|
468
|
+
* import { Buffer } from 'node:buffer';
|
|
387
469
|
*
|
|
388
470
|
* const buf1 = Buffer.from('1234');
|
|
389
471
|
* const buf2 = Buffer.from('0123');
|
|
@@ -401,7 +483,7 @@ declare module 'buffer' {
|
|
|
401
483
|
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
|
402
484
|
*
|
|
403
485
|
* ```js
|
|
404
|
-
* import { Buffer } from 'buffer';
|
|
486
|
+
* import { Buffer } from 'node:buffer';
|
|
405
487
|
*
|
|
406
488
|
* const buf = Buffer.alloc(5);
|
|
407
489
|
*
|
|
@@ -409,12 +491,12 @@ declare module 'buffer' {
|
|
|
409
491
|
* // Prints: <Buffer 00 00 00 00 00>
|
|
410
492
|
* ```
|
|
411
493
|
*
|
|
412
|
-
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
494
|
+
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
|
413
495
|
*
|
|
414
496
|
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
|
415
497
|
*
|
|
416
498
|
* ```js
|
|
417
|
-
* import { Buffer } from 'buffer';
|
|
499
|
+
* import { Buffer } from 'node:buffer';
|
|
418
500
|
*
|
|
419
501
|
* const buf = Buffer.alloc(5, 'a');
|
|
420
502
|
*
|
|
@@ -426,7 +508,7 @@ declare module 'buffer' {
|
|
|
426
508
|
* initialized by calling `buf.fill(fill, encoding)`.
|
|
427
509
|
*
|
|
428
510
|
* ```js
|
|
429
|
-
* import { Buffer } from 'buffer';
|
|
511
|
+
* import { Buffer } from 'node:buffer';
|
|
430
512
|
*
|
|
431
513
|
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
|
432
514
|
*
|
|
@@ -446,13 +528,13 @@ declare module 'buffer' {
|
|
|
446
528
|
*/
|
|
447
529
|
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
|
448
530
|
/**
|
|
449
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
531
|
+
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
|
450
532
|
*
|
|
451
533
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
452
534
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
|
453
535
|
*
|
|
454
536
|
* ```js
|
|
455
|
-
* import { Buffer } from 'buffer';
|
|
537
|
+
* import { Buffer } from 'node:buffer';
|
|
456
538
|
*
|
|
457
539
|
* const buf = Buffer.allocUnsafe(10);
|
|
458
540
|
*
|
|
@@ -483,15 +565,15 @@ declare module 'buffer' {
|
|
|
483
565
|
*/
|
|
484
566
|
allocUnsafe(size: number): Buffer;
|
|
485
567
|
/**
|
|
486
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
487
|
-
*
|
|
568
|
+
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
|
569
|
+
* `size` is 0.
|
|
488
570
|
*
|
|
489
571
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
490
572
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
|
491
573
|
* such `Buffer` instances with zeroes.
|
|
492
574
|
*
|
|
493
575
|
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
|
494
|
-
* allocations under 4
|
|
576
|
+
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
|
495
577
|
* allows applications to avoid the garbage collection overhead of creating many
|
|
496
578
|
* individually allocated `Buffer` instances. This approach improves both
|
|
497
579
|
* performance and memory usage by eliminating the need to track and clean up as
|
|
@@ -503,7 +585,7 @@ declare module 'buffer' {
|
|
|
503
585
|
* then copying out the relevant bits.
|
|
504
586
|
*
|
|
505
587
|
* ```js
|
|
506
|
-
* import { Buffer } from 'buffer';
|
|
588
|
+
* import { Buffer } from 'node:buffer';
|
|
507
589
|
*
|
|
508
590
|
* // Need to keep around a few small chunks of memory.
|
|
509
591
|
* const store = [];
|
|
@@ -541,7 +623,7 @@ declare module 'buffer' {
|
|
|
541
623
|
* written. However, partially encoded characters will not be written.
|
|
542
624
|
*
|
|
543
625
|
* ```js
|
|
544
|
-
* import { Buffer } from 'buffer';
|
|
626
|
+
* import { Buffer } from 'node:buffer';
|
|
545
627
|
*
|
|
546
628
|
* const buf = Buffer.alloc(256);
|
|
547
629
|
*
|
|
@@ -577,7 +659,7 @@ declare module 'buffer' {
|
|
|
577
659
|
* as {@link constants.MAX_STRING_LENGTH}.
|
|
578
660
|
*
|
|
579
661
|
* ```js
|
|
580
|
-
* import { Buffer } from 'buffer';
|
|
662
|
+
* import { Buffer } from 'node:buffer';
|
|
581
663
|
*
|
|
582
664
|
* const buf1 = Buffer.allocUnsafe(26);
|
|
583
665
|
*
|
|
@@ -614,7 +696,7 @@ declare module 'buffer' {
|
|
|
614
696
|
* In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
|
|
615
697
|
*
|
|
616
698
|
* ```js
|
|
617
|
-
* import { Buffer } from 'buffer';
|
|
699
|
+
* import { Buffer } from 'node:buffer';
|
|
618
700
|
*
|
|
619
701
|
* const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
|
|
620
702
|
* const json = JSON.stringify(buf);
|
|
@@ -641,7 +723,7 @@ declare module 'buffer' {
|
|
|
641
723
|
* Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
|
|
642
724
|
*
|
|
643
725
|
* ```js
|
|
644
|
-
* import { Buffer } from 'buffer';
|
|
726
|
+
* import { Buffer } from 'node:buffer';
|
|
645
727
|
*
|
|
646
728
|
* const buf1 = Buffer.from('ABC');
|
|
647
729
|
* const buf2 = Buffer.from('414243', 'hex');
|
|
@@ -665,7 +747,7 @@ declare module 'buffer' {
|
|
|
665
747
|
* * `-1` is returned if `target` should come _after_`buf` when sorted.
|
|
666
748
|
*
|
|
667
749
|
* ```js
|
|
668
|
-
* import { Buffer } from 'buffer';
|
|
750
|
+
* import { Buffer } from 'node:buffer';
|
|
669
751
|
*
|
|
670
752
|
* const buf1 = Buffer.from('ABC');
|
|
671
753
|
* const buf2 = Buffer.from('BCD');
|
|
@@ -689,7 +771,7 @@ declare module 'buffer' {
|
|
|
689
771
|
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
|
|
690
772
|
*
|
|
691
773
|
* ```js
|
|
692
|
-
* import { Buffer } from 'buffer';
|
|
774
|
+
* import { Buffer } from 'node:buffer';
|
|
693
775
|
*
|
|
694
776
|
* const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
695
777
|
* const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
|
|
@@ -710,7 +792,13 @@ declare module 'buffer' {
|
|
|
710
792
|
* @param [sourceStart=0] The offset within `buf` at which to begin comparison.
|
|
711
793
|
* @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
|
|
712
794
|
*/
|
|
713
|
-
compare(
|
|
795
|
+
compare(
|
|
796
|
+
target: Uint8Array,
|
|
797
|
+
targetStart?: number,
|
|
798
|
+
targetEnd?: number,
|
|
799
|
+
sourceStart?: number,
|
|
800
|
+
sourceEnd?: number,
|
|
801
|
+
): -1 | 0 | 1;
|
|
714
802
|
/**
|
|
715
803
|
* Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
|
|
716
804
|
*
|
|
@@ -719,7 +807,7 @@ declare module 'buffer' {
|
|
|
719
807
|
* different function arguments.
|
|
720
808
|
*
|
|
721
809
|
* ```js
|
|
722
|
-
* import { Buffer } from 'buffer';
|
|
810
|
+
* import { Buffer } from 'node:buffer';
|
|
723
811
|
*
|
|
724
812
|
* // Create two `Buffer` instances.
|
|
725
813
|
* const buf1 = Buffer.allocUnsafe(26);
|
|
@@ -740,7 +828,7 @@ declare module 'buffer' {
|
|
|
740
828
|
* ```
|
|
741
829
|
*
|
|
742
830
|
* ```js
|
|
743
|
-
* import { Buffer } from 'buffer';
|
|
831
|
+
* import { Buffer } from 'node:buffer';
|
|
744
832
|
*
|
|
745
833
|
* // Create a `Buffer` and copy data from one region to an overlapping region
|
|
746
834
|
* // within the same `Buffer`.
|
|
@@ -773,7 +861,7 @@ declare module 'buffer' {
|
|
|
773
861
|
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
|
774
862
|
*
|
|
775
863
|
* ```js
|
|
776
|
-
* import { Buffer } from 'buffer';
|
|
864
|
+
* import { Buffer } from 'node:buffer';
|
|
777
865
|
*
|
|
778
866
|
* const buf = Buffer.from('buffer');
|
|
779
867
|
*
|
|
@@ -811,7 +899,7 @@ declare module 'buffer' {
|
|
|
811
899
|
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
|
812
900
|
*
|
|
813
901
|
* ```js
|
|
814
|
-
* import { Buffer } from 'buffer';
|
|
902
|
+
* import { Buffer } from 'node:buffer';
|
|
815
903
|
*
|
|
816
904
|
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
|
817
905
|
* // from the original `Buffer`.
|
|
@@ -838,7 +926,7 @@ declare module 'buffer' {
|
|
|
838
926
|
* end of `buf` rather than the beginning.
|
|
839
927
|
*
|
|
840
928
|
* ```js
|
|
841
|
-
* import { Buffer } from 'buffer';
|
|
929
|
+
* import { Buffer } from 'node:buffer';
|
|
842
930
|
*
|
|
843
931
|
* const buf = Buffer.from('buffer');
|
|
844
932
|
*
|
|
@@ -865,7 +953,7 @@ declare module 'buffer' {
|
|
|
865
953
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
866
954
|
*
|
|
867
955
|
* ```js
|
|
868
|
-
* import { Buffer } from 'buffer';
|
|
956
|
+
* import { Buffer } from 'node:buffer';
|
|
869
957
|
*
|
|
870
958
|
* const buf = Buffer.allocUnsafe(8);
|
|
871
959
|
*
|
|
@@ -886,7 +974,7 @@ declare module 'buffer' {
|
|
|
886
974
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
887
975
|
*
|
|
888
976
|
* ```js
|
|
889
|
-
* import { Buffer } from 'buffer';
|
|
977
|
+
* import { Buffer } from 'node:buffer';
|
|
890
978
|
*
|
|
891
979
|
* const buf = Buffer.allocUnsafe(8);
|
|
892
980
|
*
|
|
@@ -907,7 +995,7 @@ declare module 'buffer' {
|
|
|
907
995
|
* This function is also available under the `writeBigUint64BE` alias.
|
|
908
996
|
*
|
|
909
997
|
* ```js
|
|
910
|
-
* import { Buffer } from 'buffer';
|
|
998
|
+
* import { Buffer } from 'node:buffer';
|
|
911
999
|
*
|
|
912
1000
|
* const buf = Buffer.allocUnsafe(8);
|
|
913
1001
|
*
|
|
@@ -931,7 +1019,7 @@ declare module 'buffer' {
|
|
|
931
1019
|
* Writes `value` to `buf` at the specified `offset` as little-endian
|
|
932
1020
|
*
|
|
933
1021
|
* ```js
|
|
934
|
-
* import { Buffer } from 'buffer';
|
|
1022
|
+
* import { Buffer } from 'node:buffer';
|
|
935
1023
|
*
|
|
936
1024
|
* const buf = Buffer.allocUnsafe(8);
|
|
937
1025
|
*
|
|
@@ -960,7 +1048,7 @@ declare module 'buffer' {
|
|
|
960
1048
|
* This function is also available under the `writeUintLE` alias.
|
|
961
1049
|
*
|
|
962
1050
|
* ```js
|
|
963
|
-
* import { Buffer } from 'buffer';
|
|
1051
|
+
* import { Buffer } from 'node:buffer';
|
|
964
1052
|
*
|
|
965
1053
|
* const buf = Buffer.allocUnsafe(6);
|
|
966
1054
|
*
|
|
@@ -988,7 +1076,7 @@ declare module 'buffer' {
|
|
|
988
1076
|
* This function is also available under the `writeUintBE` alias.
|
|
989
1077
|
*
|
|
990
1078
|
* ```js
|
|
991
|
-
* import { Buffer } from 'buffer';
|
|
1079
|
+
* import { Buffer } from 'node:buffer';
|
|
992
1080
|
*
|
|
993
1081
|
* const buf = Buffer.allocUnsafe(6);
|
|
994
1082
|
*
|
|
@@ -1014,7 +1102,7 @@ declare module 'buffer' {
|
|
|
1014
1102
|
* when `value` is anything other than a signed integer.
|
|
1015
1103
|
*
|
|
1016
1104
|
* ```js
|
|
1017
|
-
* import { Buffer } from 'buffer';
|
|
1105
|
+
* import { Buffer } from 'node:buffer';
|
|
1018
1106
|
*
|
|
1019
1107
|
* const buf = Buffer.allocUnsafe(6);
|
|
1020
1108
|
*
|
|
@@ -1035,7 +1123,7 @@ declare module 'buffer' {
|
|
|
1035
1123
|
* signed integer.
|
|
1036
1124
|
*
|
|
1037
1125
|
* ```js
|
|
1038
|
-
* import { Buffer } from 'buffer';
|
|
1126
|
+
* import { Buffer } from 'node:buffer';
|
|
1039
1127
|
*
|
|
1040
1128
|
* const buf = Buffer.allocUnsafe(6);
|
|
1041
1129
|
*
|
|
@@ -1057,7 +1145,7 @@ declare module 'buffer' {
|
|
|
1057
1145
|
* This function is also available under the `readBigUint64BE` alias.
|
|
1058
1146
|
*
|
|
1059
1147
|
* ```js
|
|
1060
|
-
* import { Buffer } from 'buffer';
|
|
1148
|
+
* import { Buffer } from 'node:buffer';
|
|
1061
1149
|
*
|
|
1062
1150
|
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1063
1151
|
*
|
|
@@ -1079,7 +1167,7 @@ declare module 'buffer' {
|
|
|
1079
1167
|
* This function is also available under the `readBigUint64LE` alias.
|
|
1080
1168
|
*
|
|
1081
1169
|
* ```js
|
|
1082
|
-
* import { Buffer } from 'buffer';
|
|
1170
|
+
* import { Buffer } from 'node:buffer';
|
|
1083
1171
|
*
|
|
1084
1172
|
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1085
1173
|
*
|
|
@@ -1120,7 +1208,7 @@ declare module 'buffer' {
|
|
|
1120
1208
|
* This function is also available under the `readUintLE` alias.
|
|
1121
1209
|
*
|
|
1122
1210
|
* ```js
|
|
1123
|
-
* import { Buffer } from 'buffer';
|
|
1211
|
+
* import { Buffer } from 'node:buffer';
|
|
1124
1212
|
*
|
|
1125
1213
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1126
1214
|
*
|
|
@@ -1144,7 +1232,7 @@ declare module 'buffer' {
|
|
|
1144
1232
|
* This function is also available under the `readUintBE` alias.
|
|
1145
1233
|
*
|
|
1146
1234
|
* ```js
|
|
1147
|
-
* import { Buffer } from 'buffer';
|
|
1235
|
+
* import { Buffer } from 'node:buffer';
|
|
1148
1236
|
*
|
|
1149
1237
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1150
1238
|
*
|
|
@@ -1168,7 +1256,7 @@ declare module 'buffer' {
|
|
|
1168
1256
|
* supporting up to 48 bits of accuracy.
|
|
1169
1257
|
*
|
|
1170
1258
|
* ```js
|
|
1171
|
-
* import { Buffer } from 'buffer';
|
|
1259
|
+
* import { Buffer } from 'node:buffer';
|
|
1172
1260
|
*
|
|
1173
1261
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1174
1262
|
*
|
|
@@ -1185,7 +1273,7 @@ declare module 'buffer' {
|
|
|
1185
1273
|
* supporting up to 48 bits of accuracy.
|
|
1186
1274
|
*
|
|
1187
1275
|
* ```js
|
|
1188
|
-
* import { Buffer } from 'buffer';
|
|
1276
|
+
* import { Buffer } from 'node:buffer';
|
|
1189
1277
|
*
|
|
1190
1278
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1191
1279
|
*
|
|
@@ -1207,7 +1295,7 @@ declare module 'buffer' {
|
|
|
1207
1295
|
* This function is also available under the `readUint8` alias.
|
|
1208
1296
|
*
|
|
1209
1297
|
* ```js
|
|
1210
|
-
* import { Buffer } from 'buffer';
|
|
1298
|
+
* import { Buffer } from 'node:buffer';
|
|
1211
1299
|
*
|
|
1212
1300
|
* const buf = Buffer.from([1, -2]);
|
|
1213
1301
|
*
|
|
@@ -1233,7 +1321,7 @@ declare module 'buffer' {
|
|
|
1233
1321
|
* This function is also available under the `readUint16LE` alias.
|
|
1234
1322
|
*
|
|
1235
1323
|
* ```js
|
|
1236
|
-
* import { Buffer } from 'buffer';
|
|
1324
|
+
* import { Buffer } from 'node:buffer';
|
|
1237
1325
|
*
|
|
1238
1326
|
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1239
1327
|
*
|
|
@@ -1259,7 +1347,7 @@ declare module 'buffer' {
|
|
|
1259
1347
|
* This function is also available under the `readUint16BE` alias.
|
|
1260
1348
|
*
|
|
1261
1349
|
* ```js
|
|
1262
|
-
* import { Buffer } from 'buffer';
|
|
1350
|
+
* import { Buffer } from 'node:buffer';
|
|
1263
1351
|
*
|
|
1264
1352
|
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1265
1353
|
*
|
|
@@ -1283,7 +1371,7 @@ declare module 'buffer' {
|
|
|
1283
1371
|
* This function is also available under the `readUint32LE` alias.
|
|
1284
1372
|
*
|
|
1285
1373
|
* ```js
|
|
1286
|
-
* import { Buffer } from 'buffer';
|
|
1374
|
+
* import { Buffer } from 'node:buffer';
|
|
1287
1375
|
*
|
|
1288
1376
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1289
1377
|
*
|
|
@@ -1307,7 +1395,7 @@ declare module 'buffer' {
|
|
|
1307
1395
|
* This function is also available under the `readUint32BE` alias.
|
|
1308
1396
|
*
|
|
1309
1397
|
* ```js
|
|
1310
|
-
* import { Buffer } from 'buffer';
|
|
1398
|
+
* import { Buffer } from 'node:buffer';
|
|
1311
1399
|
*
|
|
1312
1400
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1313
1401
|
*
|
|
@@ -1329,7 +1417,7 @@ declare module 'buffer' {
|
|
|
1329
1417
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1330
1418
|
*
|
|
1331
1419
|
* ```js
|
|
1332
|
-
* import { Buffer } from 'buffer';
|
|
1420
|
+
* import { Buffer } from 'node:buffer';
|
|
1333
1421
|
*
|
|
1334
1422
|
* const buf = Buffer.from([-1, 5]);
|
|
1335
1423
|
*
|
|
@@ -1350,7 +1438,7 @@ declare module 'buffer' {
|
|
|
1350
1438
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1351
1439
|
*
|
|
1352
1440
|
* ```js
|
|
1353
|
-
* import { Buffer } from 'buffer';
|
|
1441
|
+
* import { Buffer } from 'node:buffer';
|
|
1354
1442
|
*
|
|
1355
1443
|
* const buf = Buffer.from([0, 5]);
|
|
1356
1444
|
*
|
|
@@ -1369,7 +1457,7 @@ declare module 'buffer' {
|
|
|
1369
1457
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1370
1458
|
*
|
|
1371
1459
|
* ```js
|
|
1372
|
-
* import { Buffer } from 'buffer';
|
|
1460
|
+
* import { Buffer } from 'node:buffer';
|
|
1373
1461
|
*
|
|
1374
1462
|
* const buf = Buffer.from([0, 5]);
|
|
1375
1463
|
*
|
|
@@ -1386,7 +1474,7 @@ declare module 'buffer' {
|
|
|
1386
1474
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1387
1475
|
*
|
|
1388
1476
|
* ```js
|
|
1389
|
-
* import { Buffer } from 'buffer';
|
|
1477
|
+
* import { Buffer } from 'node:buffer';
|
|
1390
1478
|
*
|
|
1391
1479
|
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1392
1480
|
*
|
|
@@ -1405,7 +1493,7 @@ declare module 'buffer' {
|
|
|
1405
1493
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1406
1494
|
*
|
|
1407
1495
|
* ```js
|
|
1408
|
-
* import { Buffer } from 'buffer';
|
|
1496
|
+
* import { Buffer } from 'node:buffer';
|
|
1409
1497
|
*
|
|
1410
1498
|
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1411
1499
|
*
|
|
@@ -1420,7 +1508,7 @@ declare module 'buffer' {
|
|
|
1420
1508
|
* Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
|
|
1421
1509
|
*
|
|
1422
1510
|
* ```js
|
|
1423
|
-
* import { Buffer } from 'buffer';
|
|
1511
|
+
* import { Buffer } from 'node:buffer';
|
|
1424
1512
|
*
|
|
1425
1513
|
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1426
1514
|
*
|
|
@@ -1437,7 +1525,7 @@ declare module 'buffer' {
|
|
|
1437
1525
|
* Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
|
|
1438
1526
|
*
|
|
1439
1527
|
* ```js
|
|
1440
|
-
* import { Buffer } from 'buffer';
|
|
1528
|
+
* import { Buffer } from 'node:buffer';
|
|
1441
1529
|
*
|
|
1442
1530
|
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1443
1531
|
*
|
|
@@ -1452,7 +1540,7 @@ declare module 'buffer' {
|
|
|
1452
1540
|
* Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
|
|
1453
1541
|
*
|
|
1454
1542
|
* ```js
|
|
1455
|
-
* import { Buffer } from 'buffer';
|
|
1543
|
+
* import { Buffer } from 'node:buffer';
|
|
1456
1544
|
*
|
|
1457
1545
|
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1458
1546
|
*
|
|
@@ -1469,7 +1557,7 @@ declare module 'buffer' {
|
|
|
1469
1557
|
* Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
|
|
1470
1558
|
*
|
|
1471
1559
|
* ```js
|
|
1472
|
-
* import { Buffer } from 'buffer';
|
|
1560
|
+
* import { Buffer } from 'node:buffer';
|
|
1473
1561
|
*
|
|
1474
1562
|
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1475
1563
|
*
|
|
@@ -1486,7 +1574,7 @@ declare module 'buffer' {
|
|
|
1486
1574
|
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
|
|
1487
1575
|
*
|
|
1488
1576
|
* ```js
|
|
1489
|
-
* import { Buffer } from 'buffer';
|
|
1577
|
+
* import { Buffer } from 'node:buffer';
|
|
1490
1578
|
*
|
|
1491
1579
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1492
1580
|
*
|
|
@@ -1508,7 +1596,7 @@ declare module 'buffer' {
|
|
|
1508
1596
|
* between UTF-16 little-endian and UTF-16 big-endian:
|
|
1509
1597
|
*
|
|
1510
1598
|
* ```js
|
|
1511
|
-
* import { Buffer } from 'buffer';
|
|
1599
|
+
* import { Buffer } from 'node:buffer';
|
|
1512
1600
|
*
|
|
1513
1601
|
* const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
|
|
1514
1602
|
* buf.swap16(); // Convert to big-endian UTF-16 text.
|
|
@@ -1522,7 +1610,7 @@ declare module 'buffer' {
|
|
|
1522
1610
|
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
|
|
1523
1611
|
*
|
|
1524
1612
|
* ```js
|
|
1525
|
-
* import { Buffer } from 'buffer';
|
|
1613
|
+
* import { Buffer } from 'node:buffer';
|
|
1526
1614
|
*
|
|
1527
1615
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1528
1616
|
*
|
|
@@ -1548,7 +1636,7 @@ declare module 'buffer' {
|
|
|
1548
1636
|
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
|
|
1549
1637
|
*
|
|
1550
1638
|
* ```js
|
|
1551
|
-
* import { Buffer } from 'buffer';
|
|
1639
|
+
* import { Buffer } from 'node:buffer';
|
|
1552
1640
|
*
|
|
1553
1641
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1554
1642
|
*
|
|
@@ -1577,7 +1665,7 @@ declare module 'buffer' {
|
|
|
1577
1665
|
* This function is also available under the `writeUint8` alias.
|
|
1578
1666
|
*
|
|
1579
1667
|
* ```js
|
|
1580
|
-
* import { Buffer } from 'buffer';
|
|
1668
|
+
* import { Buffer } from 'node:buffer';
|
|
1581
1669
|
*
|
|
1582
1670
|
* const buf = Buffer.allocUnsafe(4);
|
|
1583
1671
|
*
|
|
@@ -1607,7 +1695,7 @@ declare module 'buffer' {
|
|
|
1607
1695
|
* This function is also available under the `writeUint16LE` alias.
|
|
1608
1696
|
*
|
|
1609
1697
|
* ```js
|
|
1610
|
-
* import { Buffer } from 'buffer';
|
|
1698
|
+
* import { Buffer } from 'node:buffer';
|
|
1611
1699
|
*
|
|
1612
1700
|
* const buf = Buffer.allocUnsafe(4);
|
|
1613
1701
|
*
|
|
@@ -1635,7 +1723,7 @@ declare module 'buffer' {
|
|
|
1635
1723
|
* This function is also available under the `writeUint16BE` alias.
|
|
1636
1724
|
*
|
|
1637
1725
|
* ```js
|
|
1638
|
-
* import { Buffer } from 'buffer';
|
|
1726
|
+
* import { Buffer } from 'node:buffer';
|
|
1639
1727
|
*
|
|
1640
1728
|
* const buf = Buffer.allocUnsafe(4);
|
|
1641
1729
|
*
|
|
@@ -1663,7 +1751,7 @@ declare module 'buffer' {
|
|
|
1663
1751
|
* This function is also available under the `writeUint32LE` alias.
|
|
1664
1752
|
*
|
|
1665
1753
|
* ```js
|
|
1666
|
-
* import { Buffer } from 'buffer';
|
|
1754
|
+
* import { Buffer } from 'node:buffer';
|
|
1667
1755
|
*
|
|
1668
1756
|
* const buf = Buffer.allocUnsafe(4);
|
|
1669
1757
|
*
|
|
@@ -1690,7 +1778,7 @@ declare module 'buffer' {
|
|
|
1690
1778
|
* This function is also available under the `writeUint32BE` alias.
|
|
1691
1779
|
*
|
|
1692
1780
|
* ```js
|
|
1693
|
-
* import { Buffer } from 'buffer';
|
|
1781
|
+
* import { Buffer } from 'node:buffer';
|
|
1694
1782
|
*
|
|
1695
1783
|
* const buf = Buffer.allocUnsafe(4);
|
|
1696
1784
|
*
|
|
@@ -1718,7 +1806,7 @@ declare module 'buffer' {
|
|
|
1718
1806
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
1719
1807
|
*
|
|
1720
1808
|
* ```js
|
|
1721
|
-
* import { Buffer } from 'buffer';
|
|
1809
|
+
* import { Buffer } from 'node:buffer';
|
|
1722
1810
|
*
|
|
1723
1811
|
* const buf = Buffer.allocUnsafe(2);
|
|
1724
1812
|
*
|
|
@@ -1741,7 +1829,7 @@ declare module 'buffer' {
|
|
|
1741
1829
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1742
1830
|
*
|
|
1743
1831
|
* ```js
|
|
1744
|
-
* import { Buffer } from 'buffer';
|
|
1832
|
+
* import { Buffer } from 'node:buffer';
|
|
1745
1833
|
*
|
|
1746
1834
|
* const buf = Buffer.allocUnsafe(2);
|
|
1747
1835
|
*
|
|
@@ -1763,7 +1851,7 @@ declare module 'buffer' {
|
|
|
1763
1851
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1764
1852
|
*
|
|
1765
1853
|
* ```js
|
|
1766
|
-
* import { Buffer } from 'buffer';
|
|
1854
|
+
* import { Buffer } from 'node:buffer';
|
|
1767
1855
|
*
|
|
1768
1856
|
* const buf = Buffer.allocUnsafe(2);
|
|
1769
1857
|
*
|
|
@@ -1785,7 +1873,7 @@ declare module 'buffer' {
|
|
|
1785
1873
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1786
1874
|
*
|
|
1787
1875
|
* ```js
|
|
1788
|
-
* import { Buffer } from 'buffer';
|
|
1876
|
+
* import { Buffer } from 'node:buffer';
|
|
1789
1877
|
*
|
|
1790
1878
|
* const buf = Buffer.allocUnsafe(4);
|
|
1791
1879
|
*
|
|
@@ -1807,7 +1895,7 @@ declare module 'buffer' {
|
|
|
1807
1895
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1808
1896
|
*
|
|
1809
1897
|
* ```js
|
|
1810
|
-
* import { Buffer } from 'buffer';
|
|
1898
|
+
* import { Buffer } from 'node:buffer';
|
|
1811
1899
|
*
|
|
1812
1900
|
* const buf = Buffer.allocUnsafe(4);
|
|
1813
1901
|
*
|
|
@@ -1827,7 +1915,7 @@ declare module 'buffer' {
|
|
|
1827
1915
|
* undefined when `value` is anything other than a JavaScript number.
|
|
1828
1916
|
*
|
|
1829
1917
|
* ```js
|
|
1830
|
-
* import { Buffer } from 'buffer';
|
|
1918
|
+
* import { Buffer } from 'node:buffer';
|
|
1831
1919
|
*
|
|
1832
1920
|
* const buf = Buffer.allocUnsafe(4);
|
|
1833
1921
|
*
|
|
@@ -1847,7 +1935,7 @@ declare module 'buffer' {
|
|
|
1847
1935
|
* undefined when `value` is anything other than a JavaScript number.
|
|
1848
1936
|
*
|
|
1849
1937
|
* ```js
|
|
1850
|
-
* import { Buffer } from 'buffer';
|
|
1938
|
+
* import { Buffer } from 'node:buffer';
|
|
1851
1939
|
*
|
|
1852
1940
|
* const buf = Buffer.allocUnsafe(4);
|
|
1853
1941
|
*
|
|
@@ -1867,7 +1955,7 @@ declare module 'buffer' {
|
|
|
1867
1955
|
* other than a JavaScript number.
|
|
1868
1956
|
*
|
|
1869
1957
|
* ```js
|
|
1870
|
-
* import { Buffer } from 'buffer';
|
|
1958
|
+
* import { Buffer } from 'node:buffer';
|
|
1871
1959
|
*
|
|
1872
1960
|
* const buf = Buffer.allocUnsafe(8);
|
|
1873
1961
|
*
|
|
@@ -1887,7 +1975,7 @@ declare module 'buffer' {
|
|
|
1887
1975
|
* other than a JavaScript number.
|
|
1888
1976
|
*
|
|
1889
1977
|
* ```js
|
|
1890
|
-
* import { Buffer } from 'buffer';
|
|
1978
|
+
* import { Buffer } from 'node:buffer';
|
|
1891
1979
|
*
|
|
1892
1980
|
* const buf = Buffer.allocUnsafe(8);
|
|
1893
1981
|
*
|
|
@@ -1907,7 +1995,7 @@ declare module 'buffer' {
|
|
|
1907
1995
|
* the entire `buf` will be filled:
|
|
1908
1996
|
*
|
|
1909
1997
|
* ```js
|
|
1910
|
-
* import { Buffer } from 'buffer';
|
|
1998
|
+
* import { Buffer } from 'node:buffer';
|
|
1911
1999
|
*
|
|
1912
2000
|
* // Fill a `Buffer` with the ASCII character 'h'.
|
|
1913
2001
|
*
|
|
@@ -1915,6 +2003,12 @@ declare module 'buffer' {
|
|
|
1915
2003
|
*
|
|
1916
2004
|
* console.log(b.toString());
|
|
1917
2005
|
* // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
|
2006
|
+
*
|
|
2007
|
+
* // Fill a buffer with empty string
|
|
2008
|
+
* const c = Buffer.allocUnsafe(5).fill('');
|
|
2009
|
+
*
|
|
2010
|
+
* console.log(c.fill(''));
|
|
2011
|
+
* // Prints: <Buffer 00 00 00 00 00>
|
|
1918
2012
|
* ```
|
|
1919
2013
|
*
|
|
1920
2014
|
* `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
|
|
@@ -1925,7 +2019,7 @@ declare module 'buffer' {
|
|
|
1925
2019
|
* then only the bytes of that character that fit into `buf` are written:
|
|
1926
2020
|
*
|
|
1927
2021
|
* ```js
|
|
1928
|
-
* import { Buffer } from 'buffer';
|
|
2022
|
+
* import { Buffer } from 'node:buffer';
|
|
1929
2023
|
*
|
|
1930
2024
|
* // Fill a `Buffer` with character that takes up two bytes in UTF-8.
|
|
1931
2025
|
*
|
|
@@ -1937,7 +2031,7 @@ declare module 'buffer' {
|
|
|
1937
2031
|
* fill data remains, an exception is thrown:
|
|
1938
2032
|
*
|
|
1939
2033
|
* ```js
|
|
1940
|
-
* import { Buffer } from 'buffer';
|
|
2034
|
+
* import { Buffer } from 'node:buffer';
|
|
1941
2035
|
*
|
|
1942
2036
|
* const buf = Buffer.allocUnsafe(5);
|
|
1943
2037
|
*
|
|
@@ -1949,7 +2043,7 @@ declare module 'buffer' {
|
|
|
1949
2043
|
* // Throws an exception.
|
|
1950
2044
|
* ```
|
|
1951
2045
|
* @since v0.5.0
|
|
1952
|
-
* @param value The value with which to fill `buf`.
|
|
2046
|
+
* @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`.
|
|
1953
2047
|
* @param [offset=0] Number of bytes to skip before starting to fill `buf`.
|
|
1954
2048
|
* @param [end=buf.length] Where to stop filling `buf` (not inclusive).
|
|
1955
2049
|
* @param [encoding='utf8'] The encoding for `value` if `value` is a string.
|
|
@@ -1966,7 +2060,7 @@ declare module 'buffer' {
|
|
|
1966
2060
|
* value between `0` and `255`.
|
|
1967
2061
|
*
|
|
1968
2062
|
* ```js
|
|
1969
|
-
* import { Buffer } from 'buffer';
|
|
2063
|
+
* import { Buffer } from 'node:buffer';
|
|
1970
2064
|
*
|
|
1971
2065
|
* const buf = Buffer.from('this is a buffer');
|
|
1972
2066
|
*
|
|
@@ -1999,7 +2093,7 @@ declare module 'buffer' {
|
|
|
1999
2093
|
* behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
|
|
2000
2094
|
*
|
|
2001
2095
|
* ```js
|
|
2002
|
-
* import { Buffer } from 'buffer';
|
|
2096
|
+
* import { Buffer } from 'node:buffer';
|
|
2003
2097
|
*
|
|
2004
2098
|
* const b = Buffer.from('abcdef');
|
|
2005
2099
|
*
|
|
@@ -2030,7 +2124,7 @@ declare module 'buffer' {
|
|
|
2030
2124
|
* rather than the first occurrence.
|
|
2031
2125
|
*
|
|
2032
2126
|
* ```js
|
|
2033
|
-
* import { Buffer } from 'buffer';
|
|
2127
|
+
* import { Buffer } from 'node:buffer';
|
|
2034
2128
|
*
|
|
2035
2129
|
* const buf = Buffer.from('this buffer is a buffer');
|
|
2036
2130
|
*
|
|
@@ -2065,7 +2159,7 @@ declare module 'buffer' {
|
|
|
2065
2159
|
* This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
|
|
2066
2160
|
*
|
|
2067
2161
|
* ```js
|
|
2068
|
-
* import { Buffer } from 'buffer';
|
|
2162
|
+
* import { Buffer } from 'node:buffer';
|
|
2069
2163
|
*
|
|
2070
2164
|
* const b = Buffer.from('abcdef');
|
|
2071
2165
|
*
|
|
@@ -2098,7 +2192,7 @@ declare module 'buffer' {
|
|
|
2098
2192
|
* of `buf`.
|
|
2099
2193
|
*
|
|
2100
2194
|
* ```js
|
|
2101
|
-
* import { Buffer } from 'buffer';
|
|
2195
|
+
* import { Buffer } from 'node:buffer';
|
|
2102
2196
|
*
|
|
2103
2197
|
* // Log the entire contents of a `Buffer`.
|
|
2104
2198
|
*
|
|
@@ -2122,7 +2216,7 @@ declare module 'buffer' {
|
|
|
2122
2216
|
* Equivalent to `buf.indexOf() !== -1`.
|
|
2123
2217
|
*
|
|
2124
2218
|
* ```js
|
|
2125
|
-
* import { Buffer } from 'buffer';
|
|
2219
|
+
* import { Buffer } from 'node:buffer';
|
|
2126
2220
|
*
|
|
2127
2221
|
* const buf = Buffer.from('this is a buffer');
|
|
2128
2222
|
*
|
|
@@ -2152,7 +2246,7 @@ declare module 'buffer' {
|
|
|
2152
2246
|
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
|
|
2153
2247
|
*
|
|
2154
2248
|
* ```js
|
|
2155
|
-
* import { Buffer } from 'buffer';
|
|
2249
|
+
* import { Buffer } from 'node:buffer';
|
|
2156
2250
|
*
|
|
2157
2251
|
* const buf = Buffer.from('buffer');
|
|
2158
2252
|
*
|
|
@@ -2175,7 +2269,7 @@ declare module 'buffer' {
|
|
|
2175
2269
|
* called automatically when a `Buffer` is used in a `for..of` statement.
|
|
2176
2270
|
*
|
|
2177
2271
|
* ```js
|
|
2178
|
-
* import { Buffer } from 'buffer';
|
|
2272
|
+
* import { Buffer } from 'node:buffer';
|
|
2179
2273
|
*
|
|
2180
2274
|
* const buf = Buffer.from('buffer');
|
|
2181
2275
|
*
|
|
@@ -2218,7 +2312,7 @@ declare module 'buffer' {
|
|
|
2218
2312
|
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2219
2313
|
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2220
2314
|
* @since v15.13.0, v14.17.0
|
|
2221
|
-
* @
|
|
2315
|
+
* @legacy Use `Buffer.from(data, 'base64')` instead.
|
|
2222
2316
|
* @param data The Base64-encoded input string.
|
|
2223
2317
|
*/
|
|
2224
2318
|
function atob(data: string): string;
|
|
@@ -2234,11 +2328,10 @@ declare module 'buffer' {
|
|
|
2234
2328
|
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2235
2329
|
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2236
2330
|
* @since v15.13.0, v14.17.0
|
|
2237
|
-
* @
|
|
2331
|
+
* @legacy Use `buf.toString('base64')` instead.
|
|
2238
2332
|
* @param data An ASCII (Latin1) string.
|
|
2239
2333
|
*/
|
|
2240
2334
|
function btoa(data: string): string;
|
|
2241
|
-
|
|
2242
2335
|
interface Blob extends __Blob {}
|
|
2243
2336
|
/**
|
|
2244
2337
|
* `Blob` class is a global reference for `require('node:buffer').Blob`
|