@types/node 20.16.9 → 20.16.11
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 v20.16/README.md +1 -1
- node v20.16/buffer.buffer.d.ts +385 -0
- node v20.16/buffer.d.ts +7 -381
- node v20.16/events.d.ts +1 -1
- node v20.16/globals.d.ts +0 -14
- node v20.16/globals.typedarray.d.ts +21 -0
- node v20.16/index.d.ts +5 -1
- node v20.16/net.d.ts +6 -0
- node v20.16/package.json +9 -2
- node v20.16/ts5.6/buffer.buffer.d.ts +385 -0
- node v20.16/ts5.6/globals.typedarray.d.ts +19 -0
- node v20.16/ts5.6/index.d.ts +92 -0
node v20.16/buffer.d.ts
CHANGED
@@ -262,113 +262,15 @@ declare module "buffer" {
|
|
262
262
|
| {
|
263
263
|
valueOf(): T;
|
264
264
|
};
|
265
|
-
// `WithArrayBufferLike` is a backwards-compatible workaround for the addition of a `TArrayBuffer` type parameter to
|
266
|
-
// `Uint8Array` to ensure that `Buffer` remains assignment-compatible with `Uint8Array`, but without the added
|
267
|
-
// complexity involved with making `Buffer` itself generic as that would require re-introducing `"typesVersions"` to
|
268
|
-
// the NodeJS types. It is likely this interface will become deprecated in the future once `Buffer` does become generic.
|
269
|
-
interface WithArrayBufferLike<TArrayBuffer extends ArrayBufferLike> {
|
270
|
-
readonly buffer: TArrayBuffer;
|
271
|
-
}
|
272
265
|
/**
|
273
266
|
* Raw data is stored in instances of the Buffer class.
|
274
267
|
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
275
268
|
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
|
276
269
|
*/
|
277
270
|
interface BufferConstructor {
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
* @param str String to store in buffer.
|
282
|
-
* @param encoding encoding to use, optional. Default is 'utf8'
|
283
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
284
|
-
*/
|
285
|
-
new(str: string, encoding?: BufferEncoding): Buffer;
|
286
|
-
/**
|
287
|
-
* Allocates a new buffer of {size} octets.
|
288
|
-
*
|
289
|
-
* @param size count of octets to allocate.
|
290
|
-
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
291
|
-
*/
|
292
|
-
new(size: number): Buffer;
|
293
|
-
/**
|
294
|
-
* Allocates a new buffer containing the given {array} of octets.
|
295
|
-
*
|
296
|
-
* @param array The octets to store.
|
297
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
298
|
-
*/
|
299
|
-
new(array: Uint8Array): Buffer;
|
300
|
-
/**
|
301
|
-
* Produces a Buffer backed by the same allocated memory as
|
302
|
-
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
303
|
-
*
|
304
|
-
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
305
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
306
|
-
*/
|
307
|
-
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
308
|
-
/**
|
309
|
-
* Allocates a new buffer containing the given {array} of octets.
|
310
|
-
*
|
311
|
-
* @param array The octets to store.
|
312
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
313
|
-
*/
|
314
|
-
new(array: readonly any[]): Buffer;
|
315
|
-
/**
|
316
|
-
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
317
|
-
*
|
318
|
-
* @param buffer The buffer to copy.
|
319
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
320
|
-
*/
|
321
|
-
new(buffer: Buffer): Buffer;
|
322
|
-
/**
|
323
|
-
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
324
|
-
* Array entries outside that range will be truncated to fit into it.
|
325
|
-
*
|
326
|
-
* ```js
|
327
|
-
* import { Buffer } from 'node:buffer';
|
328
|
-
*
|
329
|
-
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
330
|
-
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
331
|
-
* ```
|
332
|
-
*
|
333
|
-
* If `array` is an `Array`\-like object (that is, one with a `length` property of
|
334
|
-
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
335
|
-
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
|
336
|
-
*
|
337
|
-
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
338
|
-
* appropriate for `Buffer.from()` variants.
|
339
|
-
*
|
340
|
-
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
341
|
-
* @since v5.10.0
|
342
|
-
*/
|
343
|
-
from(
|
344
|
-
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
345
|
-
byteOffset?: number,
|
346
|
-
length?: number,
|
347
|
-
): Buffer;
|
348
|
-
/**
|
349
|
-
* Creates a new Buffer using the passed {data}
|
350
|
-
* @param data data to create a new Buffer
|
351
|
-
*/
|
352
|
-
from(data: Uint8Array | readonly number[]): Buffer;
|
353
|
-
from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
|
354
|
-
/**
|
355
|
-
* Creates a new Buffer containing the given JavaScript string {str}.
|
356
|
-
* If provided, the {encoding} parameter identifies the character encoding.
|
357
|
-
* If not provided, {encoding} defaults to 'utf8'.
|
358
|
-
*/
|
359
|
-
from(
|
360
|
-
str:
|
361
|
-
| WithImplicitCoercion<string>
|
362
|
-
| {
|
363
|
-
[Symbol.toPrimitive](hint: "string"): string;
|
364
|
-
},
|
365
|
-
encoding?: BufferEncoding,
|
366
|
-
): Buffer;
|
367
|
-
/**
|
368
|
-
* Creates a new Buffer using the passed {data}
|
369
|
-
* @param values to create a new Buffer
|
370
|
-
*/
|
371
|
-
of(...items: number[]): Buffer;
|
271
|
+
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
|
272
|
+
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
|
273
|
+
|
372
274
|
/**
|
373
275
|
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
374
276
|
*
|
@@ -440,62 +342,6 @@ declare module "buffer" {
|
|
440
342
|
string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
441
343
|
encoding?: BufferEncoding,
|
442
344
|
): number;
|
443
|
-
/**
|
444
|
-
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
445
|
-
*
|
446
|
-
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
447
|
-
*
|
448
|
-
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
449
|
-
* in `list` by adding their lengths.
|
450
|
-
*
|
451
|
-
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
452
|
-
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
453
|
-
* truncated to `totalLength`.
|
454
|
-
*
|
455
|
-
* ```js
|
456
|
-
* import { Buffer } from 'node:buffer';
|
457
|
-
*
|
458
|
-
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
459
|
-
*
|
460
|
-
* const buf1 = Buffer.alloc(10);
|
461
|
-
* const buf2 = Buffer.alloc(14);
|
462
|
-
* const buf3 = Buffer.alloc(18);
|
463
|
-
* const totalLength = buf1.length + buf2.length + buf3.length;
|
464
|
-
*
|
465
|
-
* console.log(totalLength);
|
466
|
-
* // Prints: 42
|
467
|
-
*
|
468
|
-
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
469
|
-
*
|
470
|
-
* console.log(bufA);
|
471
|
-
* // Prints: <Buffer 00 00 00 00 ...>
|
472
|
-
* console.log(bufA.length);
|
473
|
-
* // Prints: 42
|
474
|
-
* ```
|
475
|
-
*
|
476
|
-
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
477
|
-
* @since v0.7.11
|
478
|
-
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
479
|
-
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
480
|
-
*/
|
481
|
-
concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
|
482
|
-
/**
|
483
|
-
* Copies the underlying memory of `view` into a new `Buffer`.
|
484
|
-
*
|
485
|
-
* ```js
|
486
|
-
* const u16 = new Uint16Array([0, 0xffff]);
|
487
|
-
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
488
|
-
* u16[1] = 0;
|
489
|
-
* console.log(buf.length); // 2
|
490
|
-
* console.log(buf[0]); // 255
|
491
|
-
* console.log(buf[1]); // 255
|
492
|
-
* ```
|
493
|
-
* @since v19.8.0
|
494
|
-
* @param view The {TypedArray} to copy.
|
495
|
-
* @param [offset=0] The starting offset within `view`.
|
496
|
-
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
497
|
-
*/
|
498
|
-
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
|
499
345
|
/**
|
500
346
|
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
501
347
|
*
|
@@ -514,135 +360,6 @@ declare module "buffer" {
|
|
514
360
|
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
515
361
|
*/
|
516
362
|
compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
|
517
|
-
/**
|
518
|
-
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
519
|
-
*
|
520
|
-
* ```js
|
521
|
-
* import { Buffer } from 'node:buffer';
|
522
|
-
*
|
523
|
-
* const buf = Buffer.alloc(5);
|
524
|
-
*
|
525
|
-
* console.log(buf);
|
526
|
-
* // Prints: <Buffer 00 00 00 00 00>
|
527
|
-
* ```
|
528
|
-
*
|
529
|
-
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
530
|
-
*
|
531
|
-
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
532
|
-
*
|
533
|
-
* ```js
|
534
|
-
* import { Buffer } from 'node:buffer';
|
535
|
-
*
|
536
|
-
* const buf = Buffer.alloc(5, 'a');
|
537
|
-
*
|
538
|
-
* console.log(buf);
|
539
|
-
* // Prints: <Buffer 61 61 61 61 61>
|
540
|
-
* ```
|
541
|
-
*
|
542
|
-
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
543
|
-
* initialized by calling `buf.fill(fill, encoding)`.
|
544
|
-
*
|
545
|
-
* ```js
|
546
|
-
* import { Buffer } from 'node:buffer';
|
547
|
-
*
|
548
|
-
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
549
|
-
*
|
550
|
-
* console.log(buf);
|
551
|
-
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
552
|
-
* ```
|
553
|
-
*
|
554
|
-
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
555
|
-
* contents will never contain sensitive data from previous allocations, including
|
556
|
-
* data that might not have been allocated for `Buffer`s.
|
557
|
-
*
|
558
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
559
|
-
* @since v5.10.0
|
560
|
-
* @param size The desired length of the new `Buffer`.
|
561
|
-
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
562
|
-
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
563
|
-
*/
|
564
|
-
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
|
565
|
-
/**
|
566
|
-
* 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.
|
567
|
-
*
|
568
|
-
* The underlying memory for `Buffer` instances created in this way is _not_
|
569
|
-
* _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.
|
570
|
-
*
|
571
|
-
* ```js
|
572
|
-
* import { Buffer } from 'node:buffer';
|
573
|
-
*
|
574
|
-
* const buf = Buffer.allocUnsafe(10);
|
575
|
-
*
|
576
|
-
* console.log(buf);
|
577
|
-
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
578
|
-
*
|
579
|
-
* buf.fill(0);
|
580
|
-
*
|
581
|
-
* console.log(buf);
|
582
|
-
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
583
|
-
* ```
|
584
|
-
*
|
585
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
586
|
-
*
|
587
|
-
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
588
|
-
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
589
|
-
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
590
|
-
*
|
591
|
-
* Use of this pre-allocated internal memory pool is a key difference between
|
592
|
-
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
593
|
-
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
594
|
-
* than or equal to half `Buffer.poolSize`. The
|
595
|
-
* difference is subtle but can be important when an application requires the
|
596
|
-
* additional performance that `Buffer.allocUnsafe()` provides.
|
597
|
-
* @since v5.10.0
|
598
|
-
* @param size The desired length of the new `Buffer`.
|
599
|
-
*/
|
600
|
-
allocUnsafe(size: number): Buffer;
|
601
|
-
/**
|
602
|
-
* 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
|
603
|
-
* `size` is 0.
|
604
|
-
*
|
605
|
-
* The underlying memory for `Buffer` instances created in this way is _not_
|
606
|
-
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
607
|
-
* such `Buffer` instances with zeroes.
|
608
|
-
*
|
609
|
-
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
610
|
-
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
611
|
-
* allows applications to avoid the garbage collection overhead of creating many
|
612
|
-
* individually allocated `Buffer` instances. This approach improves both
|
613
|
-
* performance and memory usage by eliminating the need to track and clean up as
|
614
|
-
* many individual `ArrayBuffer` objects.
|
615
|
-
*
|
616
|
-
* However, in the case where a developer may need to retain a small chunk of
|
617
|
-
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
618
|
-
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
619
|
-
* then copying out the relevant bits.
|
620
|
-
*
|
621
|
-
* ```js
|
622
|
-
* import { Buffer } from 'node:buffer';
|
623
|
-
*
|
624
|
-
* // Need to keep around a few small chunks of memory.
|
625
|
-
* const store = [];
|
626
|
-
*
|
627
|
-
* socket.on('readable', () => {
|
628
|
-
* let data;
|
629
|
-
* while (null !== (data = readable.read())) {
|
630
|
-
* // Allocate for retained data.
|
631
|
-
* const sb = Buffer.allocUnsafeSlow(10);
|
632
|
-
*
|
633
|
-
* // Copy the data into the new allocation.
|
634
|
-
* data.copy(sb, 0, 0, 10);
|
635
|
-
*
|
636
|
-
* store.push(sb);
|
637
|
-
* }
|
638
|
-
* });
|
639
|
-
* ```
|
640
|
-
*
|
641
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
642
|
-
* @since v5.12.0
|
643
|
-
* @param size The desired length of the new `Buffer`.
|
644
|
-
*/
|
645
|
-
allocUnsafeSlow(size: number): Buffer;
|
646
363
|
/**
|
647
364
|
* This is the size (in bytes) of pre-allocated internal `Buffer` instances used
|
648
365
|
* for pooling. This value may be modified.
|
@@ -650,7 +367,10 @@ declare module "buffer" {
|
|
650
367
|
*/
|
651
368
|
poolSize: number;
|
652
369
|
}
|
653
|
-
interface Buffer
|
370
|
+
interface Buffer {
|
371
|
+
// see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
|
372
|
+
// see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
|
373
|
+
|
654
374
|
/**
|
655
375
|
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
|
656
376
|
* not contain enough space to fit the entire string, only part of `string` will be
|
@@ -887,100 +607,6 @@ declare module "buffer" {
|
|
887
607
|
* @return The number of bytes copied.
|
888
608
|
*/
|
889
609
|
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
890
|
-
/**
|
891
|
-
* Returns a new `Buffer` that references the same memory as the original, but
|
892
|
-
* offset and cropped by the `start` and `end` indices.
|
893
|
-
*
|
894
|
-
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
895
|
-
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
896
|
-
*
|
897
|
-
* ```js
|
898
|
-
* import { Buffer } from 'node:buffer';
|
899
|
-
*
|
900
|
-
* const buf = Buffer.from('buffer');
|
901
|
-
*
|
902
|
-
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
903
|
-
* copiedBuf[0]++;
|
904
|
-
* console.log(copiedBuf.toString());
|
905
|
-
* // Prints: cuffer
|
906
|
-
*
|
907
|
-
* console.log(buf.toString());
|
908
|
-
* // Prints: buffer
|
909
|
-
*
|
910
|
-
* // With buf.slice(), the original buffer is modified.
|
911
|
-
* const notReallyCopiedBuf = buf.slice();
|
912
|
-
* notReallyCopiedBuf[0]++;
|
913
|
-
* console.log(notReallyCopiedBuf.toString());
|
914
|
-
* // Prints: cuffer
|
915
|
-
* console.log(buf.toString());
|
916
|
-
* // Also prints: cuffer (!)
|
917
|
-
* ```
|
918
|
-
* @since v0.3.0
|
919
|
-
* @deprecated Use `subarray` instead.
|
920
|
-
* @param [start=0] Where the new `Buffer` will start.
|
921
|
-
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
922
|
-
*/
|
923
|
-
slice(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
|
924
|
-
/**
|
925
|
-
* Returns a new `Buffer` that references the same memory as the original, but
|
926
|
-
* offset and cropped by the `start` and `end` indices.
|
927
|
-
*
|
928
|
-
* Specifying `end` greater than `buf.length` will return the same result as
|
929
|
-
* that of `end` equal to `buf.length`.
|
930
|
-
*
|
931
|
-
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
932
|
-
*
|
933
|
-
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
934
|
-
*
|
935
|
-
* ```js
|
936
|
-
* import { Buffer } from 'node:buffer';
|
937
|
-
*
|
938
|
-
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
939
|
-
* // from the original `Buffer`.
|
940
|
-
*
|
941
|
-
* const buf1 = Buffer.allocUnsafe(26);
|
942
|
-
*
|
943
|
-
* for (let i = 0; i < 26; i++) {
|
944
|
-
* // 97 is the decimal ASCII value for 'a'.
|
945
|
-
* buf1[i] = i + 97;
|
946
|
-
* }
|
947
|
-
*
|
948
|
-
* const buf2 = buf1.subarray(0, 3);
|
949
|
-
*
|
950
|
-
* console.log(buf2.toString('ascii', 0, buf2.length));
|
951
|
-
* // Prints: abc
|
952
|
-
*
|
953
|
-
* buf1[0] = 33;
|
954
|
-
*
|
955
|
-
* console.log(buf2.toString('ascii', 0, buf2.length));
|
956
|
-
* // Prints: !bc
|
957
|
-
* ```
|
958
|
-
*
|
959
|
-
* Specifying negative indexes causes the slice to be generated relative to the
|
960
|
-
* end of `buf` rather than the beginning.
|
961
|
-
*
|
962
|
-
* ```js
|
963
|
-
* import { Buffer } from 'node:buffer';
|
964
|
-
*
|
965
|
-
* const buf = Buffer.from('buffer');
|
966
|
-
*
|
967
|
-
* console.log(buf.subarray(-6, -1).toString());
|
968
|
-
* // Prints: buffe
|
969
|
-
* // (Equivalent to buf.subarray(0, 5).)
|
970
|
-
*
|
971
|
-
* console.log(buf.subarray(-6, -2).toString());
|
972
|
-
* // Prints: buff
|
973
|
-
* // (Equivalent to buf.subarray(0, 4).)
|
974
|
-
*
|
975
|
-
* console.log(buf.subarray(-5, -2).toString());
|
976
|
-
* // Prints: uff
|
977
|
-
* // (Equivalent to buf.subarray(1, 4).)
|
978
|
-
* ```
|
979
|
-
* @since v3.0.0
|
980
|
-
* @param [start=0] Where the new `Buffer` will start.
|
981
|
-
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
982
|
-
*/
|
983
|
-
subarray(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
|
984
610
|
/**
|
985
611
|
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
986
612
|
*
|
node v20.16/events.d.ts
CHANGED
@@ -396,7 +396,7 @@ declare module "events" {
|
|
396
396
|
* ```
|
397
397
|
* @since v15.4.0
|
398
398
|
* @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
|
399
|
-
* @param
|
399
|
+
* @param eventTargets Zero or more {EventTarget} or {EventEmitter} instances. If none are specified, `n` is set as the default max for all newly created {EventTarget} and {EventEmitter}
|
400
400
|
* objects.
|
401
401
|
*/
|
402
402
|
static setMaxListeners(n?: number, ...eventTargets: Array<EventTarget | NodeJS.EventEmitter>): void;
|
node v20.16/globals.d.ts
CHANGED
@@ -400,20 +400,6 @@ declare global {
|
|
400
400
|
unref(): this;
|
401
401
|
}
|
402
402
|
|
403
|
-
type TypedArray =
|
404
|
-
| Uint8Array
|
405
|
-
| Uint8ClampedArray
|
406
|
-
| Uint16Array
|
407
|
-
| Uint32Array
|
408
|
-
| Int8Array
|
409
|
-
| Int16Array
|
410
|
-
| Int32Array
|
411
|
-
| BigUint64Array
|
412
|
-
| BigInt64Array
|
413
|
-
| Float32Array
|
414
|
-
| Float64Array;
|
415
|
-
type ArrayBufferView = TypedArray | DataView;
|
416
|
-
|
417
403
|
interface Require {
|
418
404
|
(id: string): any;
|
419
405
|
resolve: RequireResolve;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
export {}; // Make this a module
|
2
|
+
|
3
|
+
declare global {
|
4
|
+
namespace NodeJS {
|
5
|
+
type TypedArray<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
6
|
+
| Uint8Array<TArrayBuffer>
|
7
|
+
| Uint8ClampedArray<TArrayBuffer>
|
8
|
+
| Uint16Array<TArrayBuffer>
|
9
|
+
| Uint32Array<TArrayBuffer>
|
10
|
+
| Int8Array<TArrayBuffer>
|
11
|
+
| Int16Array<TArrayBuffer>
|
12
|
+
| Int32Array<TArrayBuffer>
|
13
|
+
| BigUint64Array<TArrayBuffer>
|
14
|
+
| BigInt64Array<TArrayBuffer>
|
15
|
+
| Float32Array<TArrayBuffer>
|
16
|
+
| Float64Array<TArrayBuffer>;
|
17
|
+
type ArrayBufferView<TArrayBuffer extends ArrayBufferLike = ArrayBufferLike> =
|
18
|
+
| TypedArray<TArrayBuffer>
|
19
|
+
| DataView<TArrayBuffer>;
|
20
|
+
}
|
21
|
+
}
|
node v20.16/index.d.ts
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
* IN THE SOFTWARE.
|
23
23
|
*/
|
24
24
|
|
25
|
-
// NOTE: These definitions support NodeJS and TypeScript
|
25
|
+
// NOTE: These definitions support NodeJS and TypeScript 5.7+.
|
26
26
|
|
27
27
|
// Reference required types from the default lib:
|
28
28
|
/// <reference lib="es2020" />
|
@@ -30,6 +30,10 @@
|
|
30
30
|
/// <reference lib="esnext.intl" />
|
31
31
|
/// <reference lib="esnext.bigint" />
|
32
32
|
|
33
|
+
// Definitions specific to TypeScript 5.7+
|
34
|
+
/// <reference path="globals.typedarray.d.ts" />
|
35
|
+
/// <reference path="buffer.buffer.d.ts" />
|
36
|
+
|
33
37
|
// Base definitions for all NodeJS modules that are not specific to any version of TypeScript:
|
34
38
|
/// <reference path="assert.d.ts" />
|
35
39
|
/// <reference path="assert/strict.d.ts" />
|
node v20.16/net.d.ts
CHANGED
@@ -532,6 +532,12 @@ declare module "net" {
|
|
532
532
|
* @since v16.5.0
|
533
533
|
*/
|
534
534
|
keepAliveInitialDelay?: number | undefined;
|
535
|
+
/**
|
536
|
+
* Optionally overrides all `net.Socket`s' `readableHighWaterMark` and `writableHighWaterMark`.
|
537
|
+
* @default See [stream.getDefaultHighWaterMark()](https://nodejs.org/docs/latest-v20.x/api/stream.html#streamgetdefaulthighwatermarkobjectmode).
|
538
|
+
* @since v18.17.0, v20.1.0
|
539
|
+
*/
|
540
|
+
highWaterMark?: number | undefined;
|
535
541
|
}
|
536
542
|
interface DropArgument {
|
537
543
|
localAddress?: string;
|
node v20.16/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@types/node",
|
3
|
-
"version": "20.16.
|
3
|
+
"version": "20.16.11",
|
4
4
|
"description": "TypeScript definitions for node",
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
|
6
6
|
"license": "MIT",
|
@@ -203,6 +203,13 @@
|
|
203
203
|
],
|
204
204
|
"main": "",
|
205
205
|
"types": "index.d.ts",
|
206
|
+
"typesVersions": {
|
207
|
+
"<=5.6": {
|
208
|
+
"*": [
|
209
|
+
"ts5.6/*"
|
210
|
+
]
|
211
|
+
}
|
212
|
+
},
|
206
213
|
"repository": {
|
207
214
|
"type": "git",
|
208
215
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
@@ -212,6 +219,6 @@
|
|
212
219
|
"dependencies": {
|
213
220
|
"undici-types": "~6.19.2"
|
214
221
|
},
|
215
|
-
"typesPublisherContentHash": "
|
222
|
+
"typesPublisherContentHash": "2d053bead5900334005cf78f342594831ce0d4551db7ce966ba310fad5084b80",
|
216
223
|
"typeScriptVersion": "4.8"
|
217
224
|
}
|