@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/ts4.8/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,23 +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
|
-
? {} : NodeBlob;
|
|
174
|
-
|
|
217
|
+
type __Blob = typeof globalThis extends { onmessage: any; Blob: infer T } ? T : NodeBlob;
|
|
175
218
|
global {
|
|
219
|
+
namespace NodeJS {
|
|
220
|
+
export { BufferEncoding };
|
|
221
|
+
}
|
|
176
222
|
// Buffer class
|
|
177
|
-
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';
|
|
178
235
|
type WithImplicitCoercion<T> =
|
|
179
236
|
| T
|
|
180
237
|
| {
|
|
@@ -236,7 +293,7 @@ declare module 'buffer' {
|
|
|
236
293
|
* Array entries outside that range will be truncated to fit into it.
|
|
237
294
|
*
|
|
238
295
|
* ```js
|
|
239
|
-
* import { Buffer } from 'buffer';
|
|
296
|
+
* import { Buffer } from 'node:buffer';
|
|
240
297
|
*
|
|
241
298
|
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
|
242
299
|
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
|
@@ -248,7 +305,11 @@ declare module 'buffer' {
|
|
|
248
305
|
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
|
|
249
306
|
* @since v5.10.0
|
|
250
307
|
*/
|
|
251
|
-
from(
|
|
308
|
+
from(
|
|
309
|
+
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
|
310
|
+
byteOffset?: number,
|
|
311
|
+
length?: number,
|
|
312
|
+
): Buffer;
|
|
252
313
|
/**
|
|
253
314
|
* Creates a new Buffer using the passed {data}
|
|
254
315
|
* @param data data to create a new Buffer
|
|
@@ -266,7 +327,7 @@ declare module 'buffer' {
|
|
|
266
327
|
| {
|
|
267
328
|
[Symbol.toPrimitive](hint: 'string'): string;
|
|
268
329
|
},
|
|
269
|
-
encoding?: BufferEncoding
|
|
330
|
+
encoding?: BufferEncoding,
|
|
270
331
|
): Buffer;
|
|
271
332
|
/**
|
|
272
333
|
* Creates a new Buffer using the passed {data}
|
|
@@ -277,7 +338,7 @@ declare module 'buffer' {
|
|
|
277
338
|
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
|
278
339
|
*
|
|
279
340
|
* ```js
|
|
280
|
-
* import { Buffer } from 'buffer';
|
|
341
|
+
* import { Buffer } from 'node:buffer';
|
|
281
342
|
*
|
|
282
343
|
* Buffer.isBuffer(Buffer.alloc(10)); // true
|
|
283
344
|
* Buffer.isBuffer(Buffer.from('foo')); // true
|
|
@@ -293,7 +354,7 @@ declare module 'buffer' {
|
|
|
293
354
|
* or `false` otherwise.
|
|
294
355
|
*
|
|
295
356
|
* ```js
|
|
296
|
-
* import { Buffer } from 'buffer';
|
|
357
|
+
* import { Buffer } from 'node:buffer';
|
|
297
358
|
*
|
|
298
359
|
* console.log(Buffer.isEncoding('utf8'));
|
|
299
360
|
* // Prints: true
|
|
@@ -322,7 +383,7 @@ declare module 'buffer' {
|
|
|
322
383
|
* string.
|
|
323
384
|
*
|
|
324
385
|
* ```js
|
|
325
|
-
* import { Buffer } from 'buffer';
|
|
386
|
+
* import { Buffer } from 'node:buffer';
|
|
326
387
|
*
|
|
327
388
|
* const str = '\u00bd + \u00bc = \u00be';
|
|
328
389
|
*
|
|
@@ -340,7 +401,10 @@ declare module 'buffer' {
|
|
|
340
401
|
* @param [encoding='utf8'] If `string` is a string, this is its encoding.
|
|
341
402
|
* @return The number of bytes contained within `string`.
|
|
342
403
|
*/
|
|
343
|
-
byteLength(
|
|
404
|
+
byteLength(
|
|
405
|
+
string: string | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
|
406
|
+
encoding?: BufferEncoding,
|
|
407
|
+
): number;
|
|
344
408
|
/**
|
|
345
409
|
* Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
|
|
346
410
|
*
|
|
@@ -354,7 +418,7 @@ declare module 'buffer' {
|
|
|
354
418
|
* truncated to `totalLength`.
|
|
355
419
|
*
|
|
356
420
|
* ```js
|
|
357
|
-
* import { Buffer } from 'buffer';
|
|
421
|
+
* import { Buffer } from 'node:buffer';
|
|
358
422
|
*
|
|
359
423
|
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
|
360
424
|
*
|
|
@@ -380,11 +444,28 @@ declare module 'buffer' {
|
|
|
380
444
|
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
|
381
445
|
*/
|
|
382
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;
|
|
383
464
|
/**
|
|
384
465
|
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
|
385
466
|
*
|
|
386
467
|
* ```js
|
|
387
|
-
* import { Buffer } from 'buffer';
|
|
468
|
+
* import { Buffer } from 'node:buffer';
|
|
388
469
|
*
|
|
389
470
|
* const buf1 = Buffer.from('1234');
|
|
390
471
|
* const buf2 = Buffer.from('0123');
|
|
@@ -402,7 +483,7 @@ declare module 'buffer' {
|
|
|
402
483
|
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
|
403
484
|
*
|
|
404
485
|
* ```js
|
|
405
|
-
* import { Buffer } from 'buffer';
|
|
486
|
+
* import { Buffer } from 'node:buffer';
|
|
406
487
|
*
|
|
407
488
|
* const buf = Buffer.alloc(5);
|
|
408
489
|
*
|
|
@@ -410,12 +491,12 @@ declare module 'buffer' {
|
|
|
410
491
|
* // Prints: <Buffer 00 00 00 00 00>
|
|
411
492
|
* ```
|
|
412
493
|
*
|
|
413
|
-
* 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.
|
|
414
495
|
*
|
|
415
496
|
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
|
416
497
|
*
|
|
417
498
|
* ```js
|
|
418
|
-
* import { Buffer } from 'buffer';
|
|
499
|
+
* import { Buffer } from 'node:buffer';
|
|
419
500
|
*
|
|
420
501
|
* const buf = Buffer.alloc(5, 'a');
|
|
421
502
|
*
|
|
@@ -427,7 +508,7 @@ declare module 'buffer' {
|
|
|
427
508
|
* initialized by calling `buf.fill(fill, encoding)`.
|
|
428
509
|
*
|
|
429
510
|
* ```js
|
|
430
|
-
* import { Buffer } from 'buffer';
|
|
511
|
+
* import { Buffer } from 'node:buffer';
|
|
431
512
|
*
|
|
432
513
|
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
|
433
514
|
*
|
|
@@ -447,13 +528,13 @@ declare module 'buffer' {
|
|
|
447
528
|
*/
|
|
448
529
|
alloc(size: number, fill?: string | Buffer | number, encoding?: BufferEncoding): Buffer;
|
|
449
530
|
/**
|
|
450
|
-
* 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.
|
|
451
532
|
*
|
|
452
533
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
453
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.
|
|
454
535
|
*
|
|
455
536
|
* ```js
|
|
456
|
-
* import { Buffer } from 'buffer';
|
|
537
|
+
* import { Buffer } from 'node:buffer';
|
|
457
538
|
*
|
|
458
539
|
* const buf = Buffer.allocUnsafe(10);
|
|
459
540
|
*
|
|
@@ -484,15 +565,15 @@ declare module 'buffer' {
|
|
|
484
565
|
*/
|
|
485
566
|
allocUnsafe(size: number): Buffer;
|
|
486
567
|
/**
|
|
487
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `
|
|
488
|
-
*
|
|
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.
|
|
489
570
|
*
|
|
490
571
|
* The underlying memory for `Buffer` instances created in this way is _not_
|
|
491
572
|
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
|
492
573
|
* such `Buffer` instances with zeroes.
|
|
493
574
|
*
|
|
494
575
|
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
|
495
|
-
* allocations under 4
|
|
576
|
+
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
|
496
577
|
* allows applications to avoid the garbage collection overhead of creating many
|
|
497
578
|
* individually allocated `Buffer` instances. This approach improves both
|
|
498
579
|
* performance and memory usage by eliminating the need to track and clean up as
|
|
@@ -504,7 +585,7 @@ declare module 'buffer' {
|
|
|
504
585
|
* then copying out the relevant bits.
|
|
505
586
|
*
|
|
506
587
|
* ```js
|
|
507
|
-
* import { Buffer } from 'buffer';
|
|
588
|
+
* import { Buffer } from 'node:buffer';
|
|
508
589
|
*
|
|
509
590
|
* // Need to keep around a few small chunks of memory.
|
|
510
591
|
* const store = [];
|
|
@@ -542,7 +623,7 @@ declare module 'buffer' {
|
|
|
542
623
|
* written. However, partially encoded characters will not be written.
|
|
543
624
|
*
|
|
544
625
|
* ```js
|
|
545
|
-
* import { Buffer } from 'buffer';
|
|
626
|
+
* import { Buffer } from 'node:buffer';
|
|
546
627
|
*
|
|
547
628
|
* const buf = Buffer.alloc(256);
|
|
548
629
|
*
|
|
@@ -578,7 +659,7 @@ declare module 'buffer' {
|
|
|
578
659
|
* as {@link constants.MAX_STRING_LENGTH}.
|
|
579
660
|
*
|
|
580
661
|
* ```js
|
|
581
|
-
* import { Buffer } from 'buffer';
|
|
662
|
+
* import { Buffer } from 'node:buffer';
|
|
582
663
|
*
|
|
583
664
|
* const buf1 = Buffer.allocUnsafe(26);
|
|
584
665
|
*
|
|
@@ -615,7 +696,7 @@ declare module 'buffer' {
|
|
|
615
696
|
* In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
|
|
616
697
|
*
|
|
617
698
|
* ```js
|
|
618
|
-
* import { Buffer } from 'buffer';
|
|
699
|
+
* import { Buffer } from 'node:buffer';
|
|
619
700
|
*
|
|
620
701
|
* const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
|
|
621
702
|
* const json = JSON.stringify(buf);
|
|
@@ -642,7 +723,7 @@ declare module 'buffer' {
|
|
|
642
723
|
* Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
|
|
643
724
|
*
|
|
644
725
|
* ```js
|
|
645
|
-
* import { Buffer } from 'buffer';
|
|
726
|
+
* import { Buffer } from 'node:buffer';
|
|
646
727
|
*
|
|
647
728
|
* const buf1 = Buffer.from('ABC');
|
|
648
729
|
* const buf2 = Buffer.from('414243', 'hex');
|
|
@@ -666,7 +747,7 @@ declare module 'buffer' {
|
|
|
666
747
|
* * `-1` is returned if `target` should come _after_`buf` when sorted.
|
|
667
748
|
*
|
|
668
749
|
* ```js
|
|
669
|
-
* import { Buffer } from 'buffer';
|
|
750
|
+
* import { Buffer } from 'node:buffer';
|
|
670
751
|
*
|
|
671
752
|
* const buf1 = Buffer.from('ABC');
|
|
672
753
|
* const buf2 = Buffer.from('BCD');
|
|
@@ -690,7 +771,7 @@ declare module 'buffer' {
|
|
|
690
771
|
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
|
|
691
772
|
*
|
|
692
773
|
* ```js
|
|
693
|
-
* import { Buffer } from 'buffer';
|
|
774
|
+
* import { Buffer } from 'node:buffer';
|
|
694
775
|
*
|
|
695
776
|
* const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
|
696
777
|
* const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
|
|
@@ -711,7 +792,13 @@ declare module 'buffer' {
|
|
|
711
792
|
* @param [sourceStart=0] The offset within `buf` at which to begin comparison.
|
|
712
793
|
* @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
|
|
713
794
|
*/
|
|
714
|
-
compare(
|
|
795
|
+
compare(
|
|
796
|
+
target: Uint8Array,
|
|
797
|
+
targetStart?: number,
|
|
798
|
+
targetEnd?: number,
|
|
799
|
+
sourceStart?: number,
|
|
800
|
+
sourceEnd?: number,
|
|
801
|
+
): -1 | 0 | 1;
|
|
715
802
|
/**
|
|
716
803
|
* Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
|
|
717
804
|
*
|
|
@@ -720,7 +807,7 @@ declare module 'buffer' {
|
|
|
720
807
|
* different function arguments.
|
|
721
808
|
*
|
|
722
809
|
* ```js
|
|
723
|
-
* import { Buffer } from 'buffer';
|
|
810
|
+
* import { Buffer } from 'node:buffer';
|
|
724
811
|
*
|
|
725
812
|
* // Create two `Buffer` instances.
|
|
726
813
|
* const buf1 = Buffer.allocUnsafe(26);
|
|
@@ -741,7 +828,7 @@ declare module 'buffer' {
|
|
|
741
828
|
* ```
|
|
742
829
|
*
|
|
743
830
|
* ```js
|
|
744
|
-
* import { Buffer } from 'buffer';
|
|
831
|
+
* import { Buffer } from 'node:buffer';
|
|
745
832
|
*
|
|
746
833
|
* // Create a `Buffer` and copy data from one region to an overlapping region
|
|
747
834
|
* // within the same `Buffer`.
|
|
@@ -774,7 +861,7 @@ declare module 'buffer' {
|
|
|
774
861
|
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
|
775
862
|
*
|
|
776
863
|
* ```js
|
|
777
|
-
* import { Buffer } from 'buffer';
|
|
864
|
+
* import { Buffer } from 'node:buffer';
|
|
778
865
|
*
|
|
779
866
|
* const buf = Buffer.from('buffer');
|
|
780
867
|
*
|
|
@@ -812,7 +899,7 @@ declare module 'buffer' {
|
|
|
812
899
|
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
|
813
900
|
*
|
|
814
901
|
* ```js
|
|
815
|
-
* import { Buffer } from 'buffer';
|
|
902
|
+
* import { Buffer } from 'node:buffer';
|
|
816
903
|
*
|
|
817
904
|
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
|
818
905
|
* // from the original `Buffer`.
|
|
@@ -839,7 +926,7 @@ declare module 'buffer' {
|
|
|
839
926
|
* end of `buf` rather than the beginning.
|
|
840
927
|
*
|
|
841
928
|
* ```js
|
|
842
|
-
* import { Buffer } from 'buffer';
|
|
929
|
+
* import { Buffer } from 'node:buffer';
|
|
843
930
|
*
|
|
844
931
|
* const buf = Buffer.from('buffer');
|
|
845
932
|
*
|
|
@@ -866,7 +953,7 @@ declare module 'buffer' {
|
|
|
866
953
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
867
954
|
*
|
|
868
955
|
* ```js
|
|
869
|
-
* import { Buffer } from 'buffer';
|
|
956
|
+
* import { Buffer } from 'node:buffer';
|
|
870
957
|
*
|
|
871
958
|
* const buf = Buffer.allocUnsafe(8);
|
|
872
959
|
*
|
|
@@ -887,7 +974,7 @@ declare module 'buffer' {
|
|
|
887
974
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
888
975
|
*
|
|
889
976
|
* ```js
|
|
890
|
-
* import { Buffer } from 'buffer';
|
|
977
|
+
* import { Buffer } from 'node:buffer';
|
|
891
978
|
*
|
|
892
979
|
* const buf = Buffer.allocUnsafe(8);
|
|
893
980
|
*
|
|
@@ -908,7 +995,7 @@ declare module 'buffer' {
|
|
|
908
995
|
* This function is also available under the `writeBigUint64BE` alias.
|
|
909
996
|
*
|
|
910
997
|
* ```js
|
|
911
|
-
* import { Buffer } from 'buffer';
|
|
998
|
+
* import { Buffer } from 'node:buffer';
|
|
912
999
|
*
|
|
913
1000
|
* const buf = Buffer.allocUnsafe(8);
|
|
914
1001
|
*
|
|
@@ -932,7 +1019,7 @@ declare module 'buffer' {
|
|
|
932
1019
|
* Writes `value` to `buf` at the specified `offset` as little-endian
|
|
933
1020
|
*
|
|
934
1021
|
* ```js
|
|
935
|
-
* import { Buffer } from 'buffer';
|
|
1022
|
+
* import { Buffer } from 'node:buffer';
|
|
936
1023
|
*
|
|
937
1024
|
* const buf = Buffer.allocUnsafe(8);
|
|
938
1025
|
*
|
|
@@ -961,7 +1048,7 @@ declare module 'buffer' {
|
|
|
961
1048
|
* This function is also available under the `writeUintLE` alias.
|
|
962
1049
|
*
|
|
963
1050
|
* ```js
|
|
964
|
-
* import { Buffer } from 'buffer';
|
|
1051
|
+
* import { Buffer } from 'node:buffer';
|
|
965
1052
|
*
|
|
966
1053
|
* const buf = Buffer.allocUnsafe(6);
|
|
967
1054
|
*
|
|
@@ -989,7 +1076,7 @@ declare module 'buffer' {
|
|
|
989
1076
|
* This function is also available under the `writeUintBE` alias.
|
|
990
1077
|
*
|
|
991
1078
|
* ```js
|
|
992
|
-
* import { Buffer } from 'buffer';
|
|
1079
|
+
* import { Buffer } from 'node:buffer';
|
|
993
1080
|
*
|
|
994
1081
|
* const buf = Buffer.allocUnsafe(6);
|
|
995
1082
|
*
|
|
@@ -1015,7 +1102,7 @@ declare module 'buffer' {
|
|
|
1015
1102
|
* when `value` is anything other than a signed integer.
|
|
1016
1103
|
*
|
|
1017
1104
|
* ```js
|
|
1018
|
-
* import { Buffer } from 'buffer';
|
|
1105
|
+
* import { Buffer } from 'node:buffer';
|
|
1019
1106
|
*
|
|
1020
1107
|
* const buf = Buffer.allocUnsafe(6);
|
|
1021
1108
|
*
|
|
@@ -1036,7 +1123,7 @@ declare module 'buffer' {
|
|
|
1036
1123
|
* signed integer.
|
|
1037
1124
|
*
|
|
1038
1125
|
* ```js
|
|
1039
|
-
* import { Buffer } from 'buffer';
|
|
1126
|
+
* import { Buffer } from 'node:buffer';
|
|
1040
1127
|
*
|
|
1041
1128
|
* const buf = Buffer.allocUnsafe(6);
|
|
1042
1129
|
*
|
|
@@ -1058,7 +1145,7 @@ declare module 'buffer' {
|
|
|
1058
1145
|
* This function is also available under the `readBigUint64BE` alias.
|
|
1059
1146
|
*
|
|
1060
1147
|
* ```js
|
|
1061
|
-
* import { Buffer } from 'buffer';
|
|
1148
|
+
* import { Buffer } from 'node:buffer';
|
|
1062
1149
|
*
|
|
1063
1150
|
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1064
1151
|
*
|
|
@@ -1080,7 +1167,7 @@ declare module 'buffer' {
|
|
|
1080
1167
|
* This function is also available under the `readBigUint64LE` alias.
|
|
1081
1168
|
*
|
|
1082
1169
|
* ```js
|
|
1083
|
-
* import { Buffer } from 'buffer';
|
|
1170
|
+
* import { Buffer } from 'node:buffer';
|
|
1084
1171
|
*
|
|
1085
1172
|
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
|
1086
1173
|
*
|
|
@@ -1121,7 +1208,7 @@ declare module 'buffer' {
|
|
|
1121
1208
|
* This function is also available under the `readUintLE` alias.
|
|
1122
1209
|
*
|
|
1123
1210
|
* ```js
|
|
1124
|
-
* import { Buffer } from 'buffer';
|
|
1211
|
+
* import { Buffer } from 'node:buffer';
|
|
1125
1212
|
*
|
|
1126
1213
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1127
1214
|
*
|
|
@@ -1145,7 +1232,7 @@ declare module 'buffer' {
|
|
|
1145
1232
|
* This function is also available under the `readUintBE` alias.
|
|
1146
1233
|
*
|
|
1147
1234
|
* ```js
|
|
1148
|
-
* import { Buffer } from 'buffer';
|
|
1235
|
+
* import { Buffer } from 'node:buffer';
|
|
1149
1236
|
*
|
|
1150
1237
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1151
1238
|
*
|
|
@@ -1169,7 +1256,7 @@ declare module 'buffer' {
|
|
|
1169
1256
|
* supporting up to 48 bits of accuracy.
|
|
1170
1257
|
*
|
|
1171
1258
|
* ```js
|
|
1172
|
-
* import { Buffer } from 'buffer';
|
|
1259
|
+
* import { Buffer } from 'node:buffer';
|
|
1173
1260
|
*
|
|
1174
1261
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1175
1262
|
*
|
|
@@ -1186,7 +1273,7 @@ declare module 'buffer' {
|
|
|
1186
1273
|
* supporting up to 48 bits of accuracy.
|
|
1187
1274
|
*
|
|
1188
1275
|
* ```js
|
|
1189
|
-
* import { Buffer } from 'buffer';
|
|
1276
|
+
* import { Buffer } from 'node:buffer';
|
|
1190
1277
|
*
|
|
1191
1278
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
|
1192
1279
|
*
|
|
@@ -1208,7 +1295,7 @@ declare module 'buffer' {
|
|
|
1208
1295
|
* This function is also available under the `readUint8` alias.
|
|
1209
1296
|
*
|
|
1210
1297
|
* ```js
|
|
1211
|
-
* import { Buffer } from 'buffer';
|
|
1298
|
+
* import { Buffer } from 'node:buffer';
|
|
1212
1299
|
*
|
|
1213
1300
|
* const buf = Buffer.from([1, -2]);
|
|
1214
1301
|
*
|
|
@@ -1234,7 +1321,7 @@ declare module 'buffer' {
|
|
|
1234
1321
|
* This function is also available under the `readUint16LE` alias.
|
|
1235
1322
|
*
|
|
1236
1323
|
* ```js
|
|
1237
|
-
* import { Buffer } from 'buffer';
|
|
1324
|
+
* import { Buffer } from 'node:buffer';
|
|
1238
1325
|
*
|
|
1239
1326
|
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1240
1327
|
*
|
|
@@ -1260,7 +1347,7 @@ declare module 'buffer' {
|
|
|
1260
1347
|
* This function is also available under the `readUint16BE` alias.
|
|
1261
1348
|
*
|
|
1262
1349
|
* ```js
|
|
1263
|
-
* import { Buffer } from 'buffer';
|
|
1350
|
+
* import { Buffer } from 'node:buffer';
|
|
1264
1351
|
*
|
|
1265
1352
|
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
|
1266
1353
|
*
|
|
@@ -1284,7 +1371,7 @@ declare module 'buffer' {
|
|
|
1284
1371
|
* This function is also available under the `readUint32LE` alias.
|
|
1285
1372
|
*
|
|
1286
1373
|
* ```js
|
|
1287
|
-
* import { Buffer } from 'buffer';
|
|
1374
|
+
* import { Buffer } from 'node:buffer';
|
|
1288
1375
|
*
|
|
1289
1376
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1290
1377
|
*
|
|
@@ -1308,7 +1395,7 @@ declare module 'buffer' {
|
|
|
1308
1395
|
* This function is also available under the `readUint32BE` alias.
|
|
1309
1396
|
*
|
|
1310
1397
|
* ```js
|
|
1311
|
-
* import { Buffer } from 'buffer';
|
|
1398
|
+
* import { Buffer } from 'node:buffer';
|
|
1312
1399
|
*
|
|
1313
1400
|
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
|
1314
1401
|
*
|
|
@@ -1330,7 +1417,7 @@ declare module 'buffer' {
|
|
|
1330
1417
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1331
1418
|
*
|
|
1332
1419
|
* ```js
|
|
1333
|
-
* import { Buffer } from 'buffer';
|
|
1420
|
+
* import { Buffer } from 'node:buffer';
|
|
1334
1421
|
*
|
|
1335
1422
|
* const buf = Buffer.from([-1, 5]);
|
|
1336
1423
|
*
|
|
@@ -1351,7 +1438,7 @@ declare module 'buffer' {
|
|
|
1351
1438
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1352
1439
|
*
|
|
1353
1440
|
* ```js
|
|
1354
|
-
* import { Buffer } from 'buffer';
|
|
1441
|
+
* import { Buffer } from 'node:buffer';
|
|
1355
1442
|
*
|
|
1356
1443
|
* const buf = Buffer.from([0, 5]);
|
|
1357
1444
|
*
|
|
@@ -1370,7 +1457,7 @@ declare module 'buffer' {
|
|
|
1370
1457
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1371
1458
|
*
|
|
1372
1459
|
* ```js
|
|
1373
|
-
* import { Buffer } from 'buffer';
|
|
1460
|
+
* import { Buffer } from 'node:buffer';
|
|
1374
1461
|
*
|
|
1375
1462
|
* const buf = Buffer.from([0, 5]);
|
|
1376
1463
|
*
|
|
@@ -1387,7 +1474,7 @@ declare module 'buffer' {
|
|
|
1387
1474
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1388
1475
|
*
|
|
1389
1476
|
* ```js
|
|
1390
|
-
* import { Buffer } from 'buffer';
|
|
1477
|
+
* import { Buffer } from 'node:buffer';
|
|
1391
1478
|
*
|
|
1392
1479
|
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1393
1480
|
*
|
|
@@ -1406,7 +1493,7 @@ declare module 'buffer' {
|
|
|
1406
1493
|
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
|
1407
1494
|
*
|
|
1408
1495
|
* ```js
|
|
1409
|
-
* import { Buffer } from 'buffer';
|
|
1496
|
+
* import { Buffer } from 'node:buffer';
|
|
1410
1497
|
*
|
|
1411
1498
|
* const buf = Buffer.from([0, 0, 0, 5]);
|
|
1412
1499
|
*
|
|
@@ -1421,7 +1508,7 @@ declare module 'buffer' {
|
|
|
1421
1508
|
* Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
|
|
1422
1509
|
*
|
|
1423
1510
|
* ```js
|
|
1424
|
-
* import { Buffer } from 'buffer';
|
|
1511
|
+
* import { Buffer } from 'node:buffer';
|
|
1425
1512
|
*
|
|
1426
1513
|
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1427
1514
|
*
|
|
@@ -1438,7 +1525,7 @@ declare module 'buffer' {
|
|
|
1438
1525
|
* Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
|
|
1439
1526
|
*
|
|
1440
1527
|
* ```js
|
|
1441
|
-
* import { Buffer } from 'buffer';
|
|
1528
|
+
* import { Buffer } from 'node:buffer';
|
|
1442
1529
|
*
|
|
1443
1530
|
* const buf = Buffer.from([1, 2, 3, 4]);
|
|
1444
1531
|
*
|
|
@@ -1453,7 +1540,7 @@ declare module 'buffer' {
|
|
|
1453
1540
|
* Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
|
|
1454
1541
|
*
|
|
1455
1542
|
* ```js
|
|
1456
|
-
* import { Buffer } from 'buffer';
|
|
1543
|
+
* import { Buffer } from 'node:buffer';
|
|
1457
1544
|
*
|
|
1458
1545
|
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1459
1546
|
*
|
|
@@ -1470,7 +1557,7 @@ declare module 'buffer' {
|
|
|
1470
1557
|
* Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
|
|
1471
1558
|
*
|
|
1472
1559
|
* ```js
|
|
1473
|
-
* import { Buffer } from 'buffer';
|
|
1560
|
+
* import { Buffer } from 'node:buffer';
|
|
1474
1561
|
*
|
|
1475
1562
|
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
1476
1563
|
*
|
|
@@ -1487,7 +1574,7 @@ declare module 'buffer' {
|
|
|
1487
1574
|
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
|
|
1488
1575
|
*
|
|
1489
1576
|
* ```js
|
|
1490
|
-
* import { Buffer } from 'buffer';
|
|
1577
|
+
* import { Buffer } from 'node:buffer';
|
|
1491
1578
|
*
|
|
1492
1579
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1493
1580
|
*
|
|
@@ -1509,7 +1596,7 @@ declare module 'buffer' {
|
|
|
1509
1596
|
* between UTF-16 little-endian and UTF-16 big-endian:
|
|
1510
1597
|
*
|
|
1511
1598
|
* ```js
|
|
1512
|
-
* import { Buffer } from 'buffer';
|
|
1599
|
+
* import { Buffer } from 'node:buffer';
|
|
1513
1600
|
*
|
|
1514
1601
|
* const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
|
|
1515
1602
|
* buf.swap16(); // Convert to big-endian UTF-16 text.
|
|
@@ -1523,7 +1610,7 @@ declare module 'buffer' {
|
|
|
1523
1610
|
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
|
|
1524
1611
|
*
|
|
1525
1612
|
* ```js
|
|
1526
|
-
* import { Buffer } from 'buffer';
|
|
1613
|
+
* import { Buffer } from 'node:buffer';
|
|
1527
1614
|
*
|
|
1528
1615
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1529
1616
|
*
|
|
@@ -1549,7 +1636,7 @@ declare module 'buffer' {
|
|
|
1549
1636
|
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
|
|
1550
1637
|
*
|
|
1551
1638
|
* ```js
|
|
1552
|
-
* import { Buffer } from 'buffer';
|
|
1639
|
+
* import { Buffer } from 'node:buffer';
|
|
1553
1640
|
*
|
|
1554
1641
|
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
|
1555
1642
|
*
|
|
@@ -1578,7 +1665,7 @@ declare module 'buffer' {
|
|
|
1578
1665
|
* This function is also available under the `writeUint8` alias.
|
|
1579
1666
|
*
|
|
1580
1667
|
* ```js
|
|
1581
|
-
* import { Buffer } from 'buffer';
|
|
1668
|
+
* import { Buffer } from 'node:buffer';
|
|
1582
1669
|
*
|
|
1583
1670
|
* const buf = Buffer.allocUnsafe(4);
|
|
1584
1671
|
*
|
|
@@ -1608,7 +1695,7 @@ declare module 'buffer' {
|
|
|
1608
1695
|
* This function is also available under the `writeUint16LE` alias.
|
|
1609
1696
|
*
|
|
1610
1697
|
* ```js
|
|
1611
|
-
* import { Buffer } from 'buffer';
|
|
1698
|
+
* import { Buffer } from 'node:buffer';
|
|
1612
1699
|
*
|
|
1613
1700
|
* const buf = Buffer.allocUnsafe(4);
|
|
1614
1701
|
*
|
|
@@ -1636,7 +1723,7 @@ declare module 'buffer' {
|
|
|
1636
1723
|
* This function is also available under the `writeUint16BE` alias.
|
|
1637
1724
|
*
|
|
1638
1725
|
* ```js
|
|
1639
|
-
* import { Buffer } from 'buffer';
|
|
1726
|
+
* import { Buffer } from 'node:buffer';
|
|
1640
1727
|
*
|
|
1641
1728
|
* const buf = Buffer.allocUnsafe(4);
|
|
1642
1729
|
*
|
|
@@ -1664,7 +1751,7 @@ declare module 'buffer' {
|
|
|
1664
1751
|
* This function is also available under the `writeUint32LE` alias.
|
|
1665
1752
|
*
|
|
1666
1753
|
* ```js
|
|
1667
|
-
* import { Buffer } from 'buffer';
|
|
1754
|
+
* import { Buffer } from 'node:buffer';
|
|
1668
1755
|
*
|
|
1669
1756
|
* const buf = Buffer.allocUnsafe(4);
|
|
1670
1757
|
*
|
|
@@ -1691,7 +1778,7 @@ declare module 'buffer' {
|
|
|
1691
1778
|
* This function is also available under the `writeUint32BE` alias.
|
|
1692
1779
|
*
|
|
1693
1780
|
* ```js
|
|
1694
|
-
* import { Buffer } from 'buffer';
|
|
1781
|
+
* import { Buffer } from 'node:buffer';
|
|
1695
1782
|
*
|
|
1696
1783
|
* const buf = Buffer.allocUnsafe(4);
|
|
1697
1784
|
*
|
|
@@ -1719,7 +1806,7 @@ declare module 'buffer' {
|
|
|
1719
1806
|
* `value` is interpreted and written as a two's complement signed integer.
|
|
1720
1807
|
*
|
|
1721
1808
|
* ```js
|
|
1722
|
-
* import { Buffer } from 'buffer';
|
|
1809
|
+
* import { Buffer } from 'node:buffer';
|
|
1723
1810
|
*
|
|
1724
1811
|
* const buf = Buffer.allocUnsafe(2);
|
|
1725
1812
|
*
|
|
@@ -1742,7 +1829,7 @@ declare module 'buffer' {
|
|
|
1742
1829
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1743
1830
|
*
|
|
1744
1831
|
* ```js
|
|
1745
|
-
* import { Buffer } from 'buffer';
|
|
1832
|
+
* import { Buffer } from 'node:buffer';
|
|
1746
1833
|
*
|
|
1747
1834
|
* const buf = Buffer.allocUnsafe(2);
|
|
1748
1835
|
*
|
|
@@ -1764,7 +1851,7 @@ declare module 'buffer' {
|
|
|
1764
1851
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1765
1852
|
*
|
|
1766
1853
|
* ```js
|
|
1767
|
-
* import { Buffer } from 'buffer';
|
|
1854
|
+
* import { Buffer } from 'node:buffer';
|
|
1768
1855
|
*
|
|
1769
1856
|
* const buf = Buffer.allocUnsafe(2);
|
|
1770
1857
|
*
|
|
@@ -1786,7 +1873,7 @@ declare module 'buffer' {
|
|
|
1786
1873
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1787
1874
|
*
|
|
1788
1875
|
* ```js
|
|
1789
|
-
* import { Buffer } from 'buffer';
|
|
1876
|
+
* import { Buffer } from 'node:buffer';
|
|
1790
1877
|
*
|
|
1791
1878
|
* const buf = Buffer.allocUnsafe(4);
|
|
1792
1879
|
*
|
|
@@ -1808,7 +1895,7 @@ declare module 'buffer' {
|
|
|
1808
1895
|
* The `value` is interpreted and written as a two's complement signed integer.
|
|
1809
1896
|
*
|
|
1810
1897
|
* ```js
|
|
1811
|
-
* import { Buffer } from 'buffer';
|
|
1898
|
+
* import { Buffer } from 'node:buffer';
|
|
1812
1899
|
*
|
|
1813
1900
|
* const buf = Buffer.allocUnsafe(4);
|
|
1814
1901
|
*
|
|
@@ -1828,7 +1915,7 @@ declare module 'buffer' {
|
|
|
1828
1915
|
* undefined when `value` is anything other than a JavaScript number.
|
|
1829
1916
|
*
|
|
1830
1917
|
* ```js
|
|
1831
|
-
* import { Buffer } from 'buffer';
|
|
1918
|
+
* import { Buffer } from 'node:buffer';
|
|
1832
1919
|
*
|
|
1833
1920
|
* const buf = Buffer.allocUnsafe(4);
|
|
1834
1921
|
*
|
|
@@ -1848,7 +1935,7 @@ declare module 'buffer' {
|
|
|
1848
1935
|
* undefined when `value` is anything other than a JavaScript number.
|
|
1849
1936
|
*
|
|
1850
1937
|
* ```js
|
|
1851
|
-
* import { Buffer } from 'buffer';
|
|
1938
|
+
* import { Buffer } from 'node:buffer';
|
|
1852
1939
|
*
|
|
1853
1940
|
* const buf = Buffer.allocUnsafe(4);
|
|
1854
1941
|
*
|
|
@@ -1868,7 +1955,7 @@ declare module 'buffer' {
|
|
|
1868
1955
|
* other than a JavaScript number.
|
|
1869
1956
|
*
|
|
1870
1957
|
* ```js
|
|
1871
|
-
* import { Buffer } from 'buffer';
|
|
1958
|
+
* import { Buffer } from 'node:buffer';
|
|
1872
1959
|
*
|
|
1873
1960
|
* const buf = Buffer.allocUnsafe(8);
|
|
1874
1961
|
*
|
|
@@ -1888,7 +1975,7 @@ declare module 'buffer' {
|
|
|
1888
1975
|
* other than a JavaScript number.
|
|
1889
1976
|
*
|
|
1890
1977
|
* ```js
|
|
1891
|
-
* import { Buffer } from 'buffer';
|
|
1978
|
+
* import { Buffer } from 'node:buffer';
|
|
1892
1979
|
*
|
|
1893
1980
|
* const buf = Buffer.allocUnsafe(8);
|
|
1894
1981
|
*
|
|
@@ -1908,7 +1995,7 @@ declare module 'buffer' {
|
|
|
1908
1995
|
* the entire `buf` will be filled:
|
|
1909
1996
|
*
|
|
1910
1997
|
* ```js
|
|
1911
|
-
* import { Buffer } from 'buffer';
|
|
1998
|
+
* import { Buffer } from 'node:buffer';
|
|
1912
1999
|
*
|
|
1913
2000
|
* // Fill a `Buffer` with the ASCII character 'h'.
|
|
1914
2001
|
*
|
|
@@ -1916,6 +2003,12 @@ declare module 'buffer' {
|
|
|
1916
2003
|
*
|
|
1917
2004
|
* console.log(b.toString());
|
|
1918
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>
|
|
1919
2012
|
* ```
|
|
1920
2013
|
*
|
|
1921
2014
|
* `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
|
|
@@ -1926,7 +2019,7 @@ declare module 'buffer' {
|
|
|
1926
2019
|
* then only the bytes of that character that fit into `buf` are written:
|
|
1927
2020
|
*
|
|
1928
2021
|
* ```js
|
|
1929
|
-
* import { Buffer } from 'buffer';
|
|
2022
|
+
* import { Buffer } from 'node:buffer';
|
|
1930
2023
|
*
|
|
1931
2024
|
* // Fill a `Buffer` with character that takes up two bytes in UTF-8.
|
|
1932
2025
|
*
|
|
@@ -1938,7 +2031,7 @@ declare module 'buffer' {
|
|
|
1938
2031
|
* fill data remains, an exception is thrown:
|
|
1939
2032
|
*
|
|
1940
2033
|
* ```js
|
|
1941
|
-
* import { Buffer } from 'buffer';
|
|
2034
|
+
* import { Buffer } from 'node:buffer';
|
|
1942
2035
|
*
|
|
1943
2036
|
* const buf = Buffer.allocUnsafe(5);
|
|
1944
2037
|
*
|
|
@@ -1950,7 +2043,7 @@ declare module 'buffer' {
|
|
|
1950
2043
|
* // Throws an exception.
|
|
1951
2044
|
* ```
|
|
1952
2045
|
* @since v0.5.0
|
|
1953
|
-
* @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`.
|
|
1954
2047
|
* @param [offset=0] Number of bytes to skip before starting to fill `buf`.
|
|
1955
2048
|
* @param [end=buf.length] Where to stop filling `buf` (not inclusive).
|
|
1956
2049
|
* @param [encoding='utf8'] The encoding for `value` if `value` is a string.
|
|
@@ -1967,7 +2060,7 @@ declare module 'buffer' {
|
|
|
1967
2060
|
* value between `0` and `255`.
|
|
1968
2061
|
*
|
|
1969
2062
|
* ```js
|
|
1970
|
-
* import { Buffer } from 'buffer';
|
|
2063
|
+
* import { Buffer } from 'node:buffer';
|
|
1971
2064
|
*
|
|
1972
2065
|
* const buf = Buffer.from('this is a buffer');
|
|
1973
2066
|
*
|
|
@@ -2000,7 +2093,7 @@ declare module 'buffer' {
|
|
|
2000
2093
|
* behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
|
|
2001
2094
|
*
|
|
2002
2095
|
* ```js
|
|
2003
|
-
* import { Buffer } from 'buffer';
|
|
2096
|
+
* import { Buffer } from 'node:buffer';
|
|
2004
2097
|
*
|
|
2005
2098
|
* const b = Buffer.from('abcdef');
|
|
2006
2099
|
*
|
|
@@ -2031,7 +2124,7 @@ declare module 'buffer' {
|
|
|
2031
2124
|
* rather than the first occurrence.
|
|
2032
2125
|
*
|
|
2033
2126
|
* ```js
|
|
2034
|
-
* import { Buffer } from 'buffer';
|
|
2127
|
+
* import { Buffer } from 'node:buffer';
|
|
2035
2128
|
*
|
|
2036
2129
|
* const buf = Buffer.from('this buffer is a buffer');
|
|
2037
2130
|
*
|
|
@@ -2066,7 +2159,7 @@ declare module 'buffer' {
|
|
|
2066
2159
|
* This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
|
|
2067
2160
|
*
|
|
2068
2161
|
* ```js
|
|
2069
|
-
* import { Buffer } from 'buffer';
|
|
2162
|
+
* import { Buffer } from 'node:buffer';
|
|
2070
2163
|
*
|
|
2071
2164
|
* const b = Buffer.from('abcdef');
|
|
2072
2165
|
*
|
|
@@ -2099,7 +2192,7 @@ declare module 'buffer' {
|
|
|
2099
2192
|
* of `buf`.
|
|
2100
2193
|
*
|
|
2101
2194
|
* ```js
|
|
2102
|
-
* import { Buffer } from 'buffer';
|
|
2195
|
+
* import { Buffer } from 'node:buffer';
|
|
2103
2196
|
*
|
|
2104
2197
|
* // Log the entire contents of a `Buffer`.
|
|
2105
2198
|
*
|
|
@@ -2123,7 +2216,7 @@ declare module 'buffer' {
|
|
|
2123
2216
|
* Equivalent to `buf.indexOf() !== -1`.
|
|
2124
2217
|
*
|
|
2125
2218
|
* ```js
|
|
2126
|
-
* import { Buffer } from 'buffer';
|
|
2219
|
+
* import { Buffer } from 'node:buffer';
|
|
2127
2220
|
*
|
|
2128
2221
|
* const buf = Buffer.from('this is a buffer');
|
|
2129
2222
|
*
|
|
@@ -2153,7 +2246,7 @@ declare module 'buffer' {
|
|
|
2153
2246
|
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
|
|
2154
2247
|
*
|
|
2155
2248
|
* ```js
|
|
2156
|
-
* import { Buffer } from 'buffer';
|
|
2249
|
+
* import { Buffer } from 'node:buffer';
|
|
2157
2250
|
*
|
|
2158
2251
|
* const buf = Buffer.from('buffer');
|
|
2159
2252
|
*
|
|
@@ -2176,7 +2269,7 @@ declare module 'buffer' {
|
|
|
2176
2269
|
* called automatically when a `Buffer` is used in a `for..of` statement.
|
|
2177
2270
|
*
|
|
2178
2271
|
* ```js
|
|
2179
|
-
* import { Buffer } from 'buffer';
|
|
2272
|
+
* import { Buffer } from 'node:buffer';
|
|
2180
2273
|
*
|
|
2181
2274
|
* const buf = Buffer.from('buffer');
|
|
2182
2275
|
*
|
|
@@ -2219,7 +2312,7 @@ declare module 'buffer' {
|
|
|
2219
2312
|
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2220
2313
|
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2221
2314
|
* @since v15.13.0, v14.17.0
|
|
2222
|
-
* @
|
|
2315
|
+
* @legacy Use `Buffer.from(data, 'base64')` instead.
|
|
2223
2316
|
* @param data The Base64-encoded input string.
|
|
2224
2317
|
*/
|
|
2225
2318
|
function atob(data: string): string;
|
|
@@ -2235,11 +2328,10 @@ declare module 'buffer' {
|
|
|
2235
2328
|
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
|
2236
2329
|
* **and binary data should be performed using `Buffer.from(str, 'base64')` and`buf.toString('base64')`.**
|
|
2237
2330
|
* @since v15.13.0, v14.17.0
|
|
2238
|
-
* @
|
|
2331
|
+
* @legacy Use `buf.toString('base64')` instead.
|
|
2239
2332
|
* @param data An ASCII (Latin1) string.
|
|
2240
2333
|
*/
|
|
2241
2334
|
function btoa(data: string): string;
|
|
2242
|
-
|
|
2243
2335
|
interface Blob extends __Blob {}
|
|
2244
2336
|
/**
|
|
2245
2337
|
* `Blob` class is a global reference for `require('node:buffer').Blob`
|