@types/node 16.18.111 → 16.18.113

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 v16.18/buffer.d.ts CHANGED
@@ -188,109 +188,15 @@ declare module "buffer" {
188
188
  | {
189
189
  valueOf(): T;
190
190
  };
191
- // `WithArrayBufferLike` is a backwards-compatible workaround for the addition of a `TArrayBuffer` type parameter to
192
- // `Uint8Array` to ensure that `Buffer` remains assignment-compatible with `Uint8Array`, but without the added
193
- // complexity involved with making `Buffer` itself generic as that would require re-introducing `"typesVersions"` to
194
- // the NodeJS types. It is likely this interface will become deprecated in the future once `Buffer` does become generic.
195
- interface WithArrayBufferLike<TArrayBuffer extends ArrayBufferLike> {
196
- readonly buffer: TArrayBuffer;
197
- }
198
191
  /**
199
192
  * Raw data is stored in instances of the Buffer class.
200
193
  * 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.
201
194
  * Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
202
195
  */
203
196
  interface BufferConstructor {
204
- /**
205
- * Allocates a new buffer containing the given {str}.
206
- *
207
- * @param str String to store in buffer.
208
- * @param encoding encoding to use, optional. Default is 'utf8'
209
- * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
210
- */
211
- new(str: string, encoding?: BufferEncoding): Buffer;
212
- /**
213
- * Allocates a new buffer of {size} octets.
214
- *
215
- * @param size count of octets to allocate.
216
- * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
217
- */
218
- new(size: number): Buffer;
219
- /**
220
- * Allocates a new buffer containing the given {array} of octets.
221
- *
222
- * @param array The octets to store.
223
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
224
- */
225
- new(array: Uint8Array): Buffer;
226
- /**
227
- * Produces a Buffer backed by the same allocated memory as
228
- * the given {ArrayBuffer}/{SharedArrayBuffer}.
229
- *
230
- * @param arrayBuffer The ArrayBuffer with which to share memory.
231
- * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
232
- */
233
- new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
234
- /**
235
- * Allocates a new buffer containing the given {array} of octets.
236
- *
237
- * @param array The octets to store.
238
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
239
- */
240
- new(array: readonly any[]): Buffer;
241
- /**
242
- * Copies the passed {buffer} data onto a new {Buffer} instance.
243
- *
244
- * @param buffer The buffer to copy.
245
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
246
- */
247
- new(buffer: Buffer): Buffer;
248
- /**
249
- * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
250
- * Array entries outside that range will be truncated to fit into it.
251
- *
252
- * ```js
253
- * import { Buffer } from 'node:buffer';
254
- *
255
- * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
256
- * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
257
- * ```
258
- *
259
- * A `TypeError` will be thrown if `array` is not an `Array` or another type
260
- * appropriate for `Buffer.from()` variants.
261
- *
262
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
263
- * @since v5.10.0
264
- */
265
- from(
266
- arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
267
- byteOffset?: number,
268
- length?: number,
269
- ): Buffer;
270
- /**
271
- * Creates a new Buffer using the passed {data}
272
- * @param data data to create a new Buffer
273
- */
274
- from(data: Uint8Array | readonly number[]): Buffer;
275
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
276
- /**
277
- * Creates a new Buffer containing the given JavaScript string {str}.
278
- * If provided, the {encoding} parameter identifies the character encoding.
279
- * If not provided, {encoding} defaults to 'utf8'.
280
- */
281
- from(
282
- str:
283
- | WithImplicitCoercion<string>
284
- | {
285
- [Symbol.toPrimitive](hint: "string"): string;
286
- },
287
- encoding?: BufferEncoding,
288
- ): Buffer;
289
- /**
290
- * Creates a new Buffer using the passed {data}
291
- * @param values to create a new Buffer
292
- */
293
- of(...items: number[]): Buffer;
197
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
198
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
199
+
294
200
  /**
295
201
  * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
296
202
  *
@@ -362,45 +268,6 @@ declare module "buffer" {
362
268
  string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
363
269
  encoding?: BufferEncoding,
364
270
  ): number;
365
- /**
366
- * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
367
- *
368
- * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
369
- *
370
- * If `totalLength` is not provided, it is calculated from the `Buffer` instances
371
- * in `list` by adding their lengths.
372
- *
373
- * If `totalLength` is provided, it is coerced to an unsigned integer. If the
374
- * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
375
- * truncated to `totalLength`.
376
- *
377
- * ```js
378
- * import { Buffer } from 'node:buffer';
379
- *
380
- * // Create a single `Buffer` from a list of three `Buffer` instances.
381
- *
382
- * const buf1 = Buffer.alloc(10);
383
- * const buf2 = Buffer.alloc(14);
384
- * const buf3 = Buffer.alloc(18);
385
- * const totalLength = buf1.length + buf2.length + buf3.length;
386
- *
387
- * console.log(totalLength);
388
- * // Prints: 42
389
- *
390
- * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
391
- *
392
- * console.log(bufA);
393
- * // Prints: <Buffer 00 00 00 00 ...>
394
- * console.log(bufA.length);
395
- * // Prints: 42
396
- * ```
397
- *
398
- * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
399
- * @since v0.7.11
400
- * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
401
- * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
402
- */
403
- concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
404
271
  /**
405
272
  * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
406
273
  *
@@ -419,136 +286,6 @@ declare module "buffer" {
419
286
  * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
420
287
  */
421
288
  compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
422
- /**
423
- * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
424
- *
425
- * ```js
426
- * import { Buffer } from 'node:buffer';
427
- *
428
- * const buf = Buffer.alloc(5);
429
- *
430
- * console.log(buf);
431
- * // Prints: <Buffer 00 00 00 00 00>
432
- * ```
433
- *
434
- * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
435
- *
436
- * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
437
- *
438
- * ```js
439
- * import { Buffer } from 'node:buffer';
440
- *
441
- * const buf = Buffer.alloc(5, 'a');
442
- *
443
- * console.log(buf);
444
- * // Prints: <Buffer 61 61 61 61 61>
445
- * ```
446
- *
447
- * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
448
- * initialized by calling `buf.fill(fill, encoding)`.
449
- *
450
- * ```js
451
- * import { Buffer } from 'node:buffer';
452
- *
453
- * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
454
- *
455
- * console.log(buf);
456
- * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
457
- * ```
458
- *
459
- * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
460
- * contents will never contain sensitive data from previous allocations, including
461
- * data that might not have been allocated for `Buffer`s.
462
- *
463
- * A `TypeError` will be thrown if `size` is not a number.
464
- * @since v5.10.0
465
- * @param size The desired length of the new `Buffer`.
466
- * @param [fill=0] A value to pre-fill the new `Buffer` with.
467
- * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
468
- */
469
- alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
470
- /**
471
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
472
- *
473
- * The underlying memory for `Buffer` instances created in this way is _not_
474
- * _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.
475
- *
476
- * ```js
477
- * import { Buffer } from 'node:buffer';
478
- *
479
- * const buf = Buffer.allocUnsafe(10);
480
- *
481
- * console.log(buf);
482
- * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
483
- *
484
- * buf.fill(0);
485
- *
486
- * console.log(buf);
487
- * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
488
- * ```
489
- *
490
- * A `TypeError` will be thrown if `size` is not a number.
491
- *
492
- * The `Buffer` module pre-allocates an internal `Buffer` instance of
493
- * size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`, `Buffer.concat()`, and the
494
- * deprecated `new Buffer(size)` constructor only when `size` is less than or equal
495
- * to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
496
- *
497
- * Use of this pre-allocated internal memory pool is a key difference between
498
- * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
499
- * 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
500
- * than or equal to half `Buffer.poolSize`. The
501
- * difference is subtle but can be important when an application requires the
502
- * additional performance that `Buffer.allocUnsafe()` provides.
503
- * @since v5.10.0
504
- * @param size The desired length of the new `Buffer`.
505
- */
506
- allocUnsafe(size: number): Buffer;
507
- /**
508
- * Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown. A zero-length `Buffer` is created if
509
- * `size` is 0.
510
- *
511
- * The underlying memory for `Buffer` instances created in this way is _not_
512
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
513
- * such `Buffer` instances with zeroes.
514
- *
515
- * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
516
- * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
517
- * allows applications to avoid the garbage collection overhead of creating many
518
- * individually allocated `Buffer` instances. This approach improves both
519
- * performance and memory usage by eliminating the need to track and clean up as
520
- * many individual `ArrayBuffer` objects.
521
- *
522
- * However, in the case where a developer may need to retain a small chunk of
523
- * memory from a pool for an indeterminate amount of time, it may be appropriate
524
- * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
525
- * then copying out the relevant bits.
526
- *
527
- * ```js
528
- * import { Buffer } from 'node:buffer';
529
- *
530
- * // Need to keep around a few small chunks of memory.
531
- * const store = [];
532
- *
533
- * socket.on('readable', () => {
534
- * let data;
535
- * while (null !== (data = readable.read())) {
536
- * // Allocate for retained data.
537
- * const sb = Buffer.allocUnsafeSlow(10);
538
- *
539
- * // Copy the data into the new allocation.
540
- * data.copy(sb, 0, 0, 10);
541
- *
542
- * store.push(sb);
543
- * }
544
- * });
545
- * ```
546
- *
547
- * A `TypeError` will be thrown if `size` is not a number.
548
- * @since v5.12.0
549
- * @param size The desired length of the new `Buffer`.
550
- */
551
- allocUnsafeSlow(size: number): Buffer;
552
289
  /**
553
290
  * This is the size (in bytes) of pre-allocated internal `Buffer` instances used
554
291
  * for pooling. This value may be modified.
@@ -556,7 +293,10 @@ declare module "buffer" {
556
293
  */
557
294
  poolSize: number;
558
295
  }
559
- interface Buffer extends Uint8Array {
296
+ interface Buffer {
297
+ // see buffer.buffer.d.ts for implementation specific to TypeScript 5.7 and later
298
+ // see ts5.6/buffer.buffer.d.ts for implementation specific to TypeScript 5.6 and earlier
299
+
560
300
  /**
561
301
  * 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
562
302
  * not contain enough space to fit the entire string, only part of `string` will be
@@ -793,100 +533,6 @@ declare module "buffer" {
793
533
  * @return The number of bytes copied.
794
534
  */
795
535
  copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
796
- /**
797
- * Returns a new `Buffer` that references the same memory as the original, but
798
- * offset and cropped by the `start` and `end` indices.
799
- *
800
- * This method is not compatible with the `Uint8Array.prototype.slice()`,
801
- * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
802
- *
803
- * ```js
804
- * import { Buffer } from 'node:buffer';
805
- *
806
- * const buf = Buffer.from('buffer');
807
- *
808
- * const copiedBuf = Uint8Array.prototype.slice.call(buf);
809
- * copiedBuf[0]++;
810
- * console.log(copiedBuf.toString());
811
- * // Prints: cuffer
812
- *
813
- * console.log(buf.toString());
814
- * // Prints: buffer
815
- *
816
- * // With buf.slice(), the original buffer is modified.
817
- * const notReallyCopiedBuf = buf.slice();
818
- * notReallyCopiedBuf[0]++;
819
- * console.log(notReallyCopiedBuf.toString());
820
- * // Prints: cuffer
821
- * console.log(buf.toString());
822
- * // Also prints: cuffer (!)
823
- * ```
824
- * @since v0.3.0
825
- * @deprecated Use `subarray` instead.
826
- * @param [start=0] Where the new `Buffer` will start.
827
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
828
- */
829
- slice(start?: number, end?: number): Buffer & WithArrayBufferLike<ArrayBuffer>;
830
- /**
831
- * Returns a new `Buffer` that references the same memory as the original, but
832
- * offset and cropped by the `start` and `end` indices.
833
- *
834
- * Specifying `end` greater than `buf.length` will return the same result as
835
- * that of `end` equal to `buf.length`.
836
- *
837
- * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
838
- *
839
- * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
840
- *
841
- * ```js
842
- * import { Buffer } from 'node:buffer';
843
- *
844
- * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
845
- * // from the original `Buffer`.
846
- *
847
- * const buf1 = Buffer.allocUnsafe(26);
848
- *
849
- * for (let i = 0; i < 26; i++) {
850
- * // 97 is the decimal ASCII value for 'a'.
851
- * buf1[i] = i + 97;
852
- * }
853
- *
854
- * const buf2 = buf1.subarray(0, 3);
855
- *
856
- * console.log(buf2.toString('ascii', 0, buf2.length));
857
- * // Prints: abc
858
- *
859
- * buf1[0] = 33;
860
- *
861
- * console.log(buf2.toString('ascii', 0, buf2.length));
862
- * // Prints: !bc
863
- * ```
864
- *
865
- * Specifying negative indexes causes the slice to be generated relative to the
866
- * end of `buf` rather than the beginning.
867
- *
868
- * ```js
869
- * import { Buffer } from 'node:buffer';
870
- *
871
- * const buf = Buffer.from('buffer');
872
- *
873
- * console.log(buf.subarray(-6, -1).toString());
874
- * // Prints: buffe
875
- * // (Equivalent to buf.subarray(0, 5).)
876
- *
877
- * console.log(buf.subarray(-6, -2).toString());
878
- * // Prints: buff
879
- * // (Equivalent to buf.subarray(0, 4).)
880
- *
881
- * console.log(buf.subarray(-5, -2).toString());
882
- * // Prints: uff
883
- * // (Equivalent to buf.subarray(1, 4).)
884
- * ```
885
- * @since v3.0.0
886
- * @param [start=0] Where the new `Buffer` will start.
887
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
888
- */
889
- subarray(start?: number, end?: number): Buffer & WithArrayBufferLike<this["buffer"]>;
890
536
  /**
891
537
  * Writes `value` to `buf` at the specified `offset` as big-endian.
892
538
  *
node v16.18/events.d.ts CHANGED
@@ -303,7 +303,7 @@ declare module "events" {
303
303
  * ```
304
304
  * @since v15.4.0
305
305
  * @param n A non-negative number. The maximum number of listeners per `EventTarget` event.
306
- * @param eventsTargets 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}
306
+ * @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}
307
307
  * objects.
308
308
  */
309
309
  static setMaxListeners(n?: number, ...eventTargets: Array<DOMEventTarget | NodeJS.EventEmitter>): void;
@@ -224,20 +224,6 @@ declare namespace NodeJS {
224
224
  unref(): this;
225
225
  }
226
226
 
227
- type TypedArray =
228
- | Uint8Array
229
- | Uint8ClampedArray
230
- | Uint16Array
231
- | Uint32Array
232
- | Int8Array
233
- | Int16Array
234
- | Int32Array
235
- | BigUint64Array
236
- | BigInt64Array
237
- | Float32Array
238
- | Float64Array;
239
- type ArrayBufferView = TypedArray | DataView;
240
-
241
227
  interface Require {
242
228
  (id: string): any;
243
229
  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 v16.18/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 4.9+.
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" />
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "16.18.111",
3
+ "version": "16.18.113",
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",
@@ -210,6 +217,6 @@
210
217
  },
211
218
  "scripts": {},
212
219
  "dependencies": {},
213
- "typesPublisherContentHash": "695b15dada90139e7b7288801affaa6ee9bb9602189ec574e64ab886a3061550",
220
+ "typesPublisherContentHash": "1e0f18d2dfeb3fd68763b84d37a7c2dc4a5f7bd87a74300d4179ed6538be4477",
214
221
  "typeScriptVersion": "4.8"
215
222
  }