@types/node 18.19.77 → 18.19.79

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 v18.19/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for node (https://nodejs.org/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v18.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Fri, 28 Feb 2025 21:02:17 GMT
11
+ * Last updated: Mon, 03 Mar 2025 18:02:26 GMT
12
12
  * Dependencies: [undici-types](https://npmjs.com/package/undici-types)
13
13
 
14
14
  # Credits
@@ -1,4 +1,6 @@
1
1
  declare module "buffer" {
2
+ type ImplicitArrayBuffer<T extends WithImplicitCoercion<ArrayBufferLike>> = T extends
3
+ { valueOf(): infer V extends ArrayBufferLike } ? V : T;
2
4
  global {
3
5
  interface BufferConstructor {
4
6
  // see buffer.d.ts for implementation shared with all TypeScript versions
@@ -24,7 +26,7 @@ declare module "buffer" {
24
26
  * @param array The octets to store.
25
27
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
26
28
  */
27
- new(array: Uint8Array): Buffer<ArrayBuffer>;
29
+ new(array: ArrayLike<number>): Buffer<ArrayBuffer>;
28
30
  /**
29
31
  * Produces a Buffer backed by the same allocated memory as
30
32
  * the given {ArrayBuffer}/{SharedArrayBuffer}.
@@ -33,20 +35,6 @@ declare module "buffer" {
33
35
  * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
34
36
  */
35
37
  new<TArrayBuffer extends ArrayBufferLike = ArrayBuffer>(arrayBuffer: TArrayBuffer): Buffer<TArrayBuffer>;
36
- /**
37
- * Allocates a new buffer containing the given {array} of octets.
38
- *
39
- * @param array The octets to store.
40
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
41
- */
42
- new(array: readonly any[]): Buffer<ArrayBuffer>;
43
- /**
44
- * Copies the passed {buffer} data onto a new {Buffer} instance.
45
- *
46
- * @param buffer The buffer to copy.
47
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
48
- */
49
- new(buffer: Buffer): Buffer<ArrayBuffer>;
50
38
  /**
51
39
  * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
52
40
  * Array entries outside that range will be truncated to fit into it.
@@ -57,41 +45,116 @@ declare module "buffer" {
57
45
  * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
58
46
  * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
59
47
  * ```
60
- *
61
- * If `array` is an `Array`\-like object (that is, one with a `length` property of
48
+ * If `array` is an `Array`-like object (that is, one with a `length` property of
62
49
  * type `number`), it is treated as if it is an array, unless it is a `Buffer` or
63
- * 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()`.
50
+ * a `Uint8Array`. This means all other `TypedArray` variants get treated as an
51
+ * `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
52
+ * `Buffer.copyBytesFrom()`.
64
53
  *
65
54
  * A `TypeError` will be thrown if `array` is not an `Array` or another type
66
55
  * appropriate for `Buffer.from()` variants.
67
56
  *
68
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
57
+ * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal
58
+ * `Buffer` pool like `Buffer.allocUnsafe()` does.
69
59
  * @since v5.10.0
70
60
  */
71
- from<TArrayBuffer extends ArrayBufferLike>(
72
- arrayBuffer: WithImplicitCoercion<TArrayBuffer>,
73
- byteOffset?: number,
74
- length?: number,
75
- ): Buffer<TArrayBuffer>;
61
+ from(array: WithImplicitCoercion<ArrayLike<number>>): Buffer<ArrayBuffer>;
76
62
  /**
77
- * Creates a new Buffer using the passed {data}
78
- * @param data data to create a new Buffer
63
+ * This creates a view of the `ArrayBuffer` without copying the underlying
64
+ * memory. For example, when passed a reference to the `.buffer` property of a
65
+ * `TypedArray` instance, the newly created `Buffer` will share the same
66
+ * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
67
+ *
68
+ * ```js
69
+ * import { Buffer } from 'node:buffer';
70
+ *
71
+ * const arr = new Uint16Array(2);
72
+ *
73
+ * arr[0] = 5000;
74
+ * arr[1] = 4000;
75
+ *
76
+ * // Shares memory with `arr`.
77
+ * const buf = Buffer.from(arr.buffer);
78
+ *
79
+ * console.log(buf);
80
+ * // Prints: <Buffer 88 13 a0 0f>
81
+ *
82
+ * // Changing the original Uint16Array changes the Buffer also.
83
+ * arr[1] = 6000;
84
+ *
85
+ * console.log(buf);
86
+ * // Prints: <Buffer 88 13 70 17>
87
+ * ```
88
+ * The optional `byteOffset` and `length` arguments specify a memory range within
89
+ * the `arrayBuffer` that will be shared by the `Buffer`.
90
+ *
91
+ * ```js
92
+ * import { Buffer } from 'node:buffer';
93
+ *
94
+ * const ab = new ArrayBuffer(10);
95
+ * const buf = Buffer.from(ab, 0, 2);
96
+ *
97
+ * console.log(buf.length);
98
+ * // Prints: 2
99
+ * ```
100
+ *
101
+ * A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer` or a
102
+ * `SharedArrayBuffer` or another type appropriate for `Buffer.from()`
103
+ * variants.
104
+ *
105
+ * It is important to remember that a backing `ArrayBuffer` can cover a range
106
+ * of memory that extends beyond the bounds of a `TypedArray` view. A new
107
+ * `Buffer` created using the `buffer` property of a `TypedArray` may extend
108
+ * beyond the range of the `TypedArray`:
109
+ *
110
+ * ```js
111
+ * import { Buffer } from 'node:buffer';
112
+ *
113
+ * const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements
114
+ * const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements
115
+ * console.log(arrA.buffer === arrB.buffer); // true
116
+ *
117
+ * const buf = Buffer.from(arrB.buffer);
118
+ * console.log(buf);
119
+ * // Prints: <Buffer 63 64 65 66>
120
+ * ```
121
+ * @since v5.10.0
122
+ * @param arrayBuffer An `ArrayBuffer`, `SharedArrayBuffer`, for example the
123
+ * `.buffer` property of a `TypedArray`.
124
+ * @param byteOffset Index of first byte to expose. **Default:** `0`.
125
+ * @param length Number of bytes to expose. **Default:**
126
+ * `arrayBuffer.byteLength - byteOffset`.
79
127
  */
80
- from(data: Uint8Array | readonly number[]): Buffer<ArrayBuffer>;
81
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer<ArrayBuffer>;
128
+ from<TArrayBuffer extends WithImplicitCoercion<ArrayBufferLike>>(
129
+ arrayBuffer: TArrayBuffer,
130
+ byteOffset?: number,
131
+ length?: number,
132
+ ): Buffer<ImplicitArrayBuffer<TArrayBuffer>>;
82
133
  /**
83
- * Creates a new Buffer containing the given JavaScript string {str}.
84
- * If provided, the {encoding} parameter identifies the character encoding.
85
- * If not provided, {encoding} defaults to 'utf8'.
134
+ * Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
135
+ * the character encoding to be used when converting `string` into bytes.
136
+ *
137
+ * ```js
138
+ * import { Buffer } from 'node:buffer';
139
+ *
140
+ * const buf1 = Buffer.from('this is a tést');
141
+ * const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
142
+ *
143
+ * console.log(buf1.toString());
144
+ * // Prints: this is a tést
145
+ * console.log(buf2.toString());
146
+ * // Prints: this is a tést
147
+ * console.log(buf1.toString('latin1'));
148
+ * // Prints: this is a tést
149
+ * ```
150
+ *
151
+ * A `TypeError` will be thrown if `string` is not a string or another type
152
+ * appropriate for `Buffer.from()` variants.
153
+ * @since v5.10.0
154
+ * @param string A string to encode.
155
+ * @param encoding The encoding of `string`. **Default:** `'utf8'`.
86
156
  */
87
- from(
88
- str:
89
- | WithImplicitCoercion<string>
90
- | {
91
- [Symbol.toPrimitive](hint: "string"): string;
92
- },
93
- encoding?: BufferEncoding,
94
- ): Buffer<ArrayBuffer>;
157
+ from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer<ArrayBuffer>;
95
158
  /**
96
159
  * Creates a new Buffer using the passed {data}
97
160
  * @param values to create a new Buffer
@@ -382,4 +445,10 @@ declare module "buffer" {
382
445
  subarray(start?: number, end?: number): Buffer<TArrayBuffer>;
383
446
  }
384
447
  }
448
+ /** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
449
+ var SlowBuffer: {
450
+ /** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
451
+ new(size: number): Buffer<ArrayBuffer>;
452
+ prototype: Buffer;
453
+ };
385
454
  }
node v18.19/buffer.d.ts CHANGED
@@ -104,11 +104,6 @@ declare module "buffer" {
104
104
  * @param toEnc To target encoding.
105
105
  */
106
106
  export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
107
- export const SlowBuffer: {
108
- /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
109
- new(size: number): Buffer;
110
- prototype: Buffer;
111
- };
112
107
  /**
113
108
  * Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
114
109
  * a prior call to `URL.createObjectURL()`.
@@ -216,7 +211,10 @@ declare module "buffer" {
216
211
  }
217
212
  export import atob = globalThis.atob;
218
213
  export import btoa = globalThis.btoa;
219
-
214
+ export type WithImplicitCoercion<T> =
215
+ | T
216
+ | { valueOf(): T }
217
+ | (T extends string ? { [Symbol.toPrimitive](hint: "string"): T } : never);
220
218
  global {
221
219
  namespace NodeJS {
222
220
  export { BufferEncoding };
@@ -234,11 +232,6 @@ declare module "buffer" {
234
232
  | "latin1"
235
233
  | "binary"
236
234
  | "hex";
237
- type WithImplicitCoercion<T> =
238
- | T
239
- | {
240
- valueOf(): T;
241
- };
242
235
  /**
243
236
  * Raw data is stored in instances of the Buffer class.
244
237
  * 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.
node v18.19/crypto.d.ts CHANGED
@@ -669,9 +669,10 @@ declare module "crypto" {
669
669
  */
670
670
  type: KeyObjectType;
671
671
  }
672
- type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm" | "chacha20-poly1305";
672
+ type CipherCCMTypes = "aes-128-ccm" | "aes-192-ccm" | "aes-256-ccm";
673
673
  type CipherGCMTypes = "aes-128-gcm" | "aes-192-gcm" | "aes-256-gcm";
674
674
  type CipherOCBTypes = "aes-128-ocb" | "aes-192-ocb" | "aes-256-ocb";
675
+ type CipherChaCha20Poly1305Types = "chacha20-poly1305";
675
676
  type BinaryLike = string | NodeJS.ArrayBufferView;
676
677
  type CipherKey = BinaryLike | KeyObject;
677
678
  interface CipherCCMOptions extends stream.TransformOptions {
@@ -683,6 +684,10 @@ declare module "crypto" {
683
684
  interface CipherOCBOptions extends stream.TransformOptions {
684
685
  authTagLength: number;
685
686
  }
687
+ interface CipherChaCha20Poly1305Options extends stream.TransformOptions {
688
+ /** @default 16 */
689
+ authTagLength?: number | undefined;
690
+ }
686
691
  /**
687
692
  * Creates and returns a `Cipher` object that uses the given `algorithm` and `password`.
688
693
  *
@@ -720,6 +725,14 @@ declare module "crypto" {
720
725
  /** @deprecated since v10.0.0 use `createCipheriv()` */
721
726
  function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
722
727
  /** @deprecated since v10.0.0 use `createCipheriv()` */
728
+ function createCipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): CipherOCB;
729
+ /** @deprecated since v10.0.0 use `createCipheriv()` */
730
+ function createCipher(
731
+ algorithm: CipherChaCha20Poly1305Types,
732
+ password: BinaryLike,
733
+ options?: CipherChaCha20Poly1305Options,
734
+ ): CipherChaCha20Poly1305;
735
+ /** @deprecated since v10.0.0 use `createCipheriv()` */
723
736
  function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
724
737
  /**
725
738
  * Creates and returns a `Cipher` object, with the given `algorithm`, `key` and
@@ -769,6 +782,12 @@ declare module "crypto" {
769
782
  iv: BinaryLike,
770
783
  options?: CipherGCMOptions,
771
784
  ): CipherGCM;
785
+ function createCipheriv(
786
+ algorithm: CipherChaCha20Poly1305Types,
787
+ key: CipherKey,
788
+ iv: BinaryLike,
789
+ options?: CipherChaCha20Poly1305Options,
790
+ ): CipherChaCha20Poly1305;
772
791
  function createCipheriv(
773
792
  algorithm: string,
774
793
  key: CipherKey,
@@ -968,6 +987,15 @@ declare module "crypto" {
968
987
  ): this;
969
988
  getAuthTag(): Buffer;
970
989
  }
990
+ interface CipherChaCha20Poly1305 extends Cipher {
991
+ setAAD(
992
+ buffer: NodeJS.ArrayBufferView,
993
+ options: {
994
+ plaintextLength: number;
995
+ },
996
+ ): this;
997
+ getAuthTag(): Buffer;
998
+ }
971
999
  /**
972
1000
  * Creates and returns a `Decipher` object that uses the given `algorithm` and `password` (key).
973
1001
  *
@@ -994,6 +1022,14 @@ declare module "crypto" {
994
1022
  /** @deprecated since v10.0.0 use `createDecipheriv()` */
995
1023
  function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
996
1024
  /** @deprecated since v10.0.0 use `createDecipheriv()` */
1025
+ function createDecipher(algorithm: CipherOCBTypes, password: BinaryLike, options: CipherOCBOptions): DecipherOCB;
1026
+ /** @deprecated since v10.0.0 use `createDecipheriv()` */
1027
+ function createDecipher(
1028
+ algorithm: CipherChaCha20Poly1305Types,
1029
+ password: BinaryLike,
1030
+ options?: CipherChaCha20Poly1305Options,
1031
+ ): DecipherChaCha20Poly1305;
1032
+ /** @deprecated since v10.0.0 use `createDecipheriv()` */
997
1033
  function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
998
1034
  /**
999
1035
  * Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`).
@@ -1042,6 +1078,12 @@ declare module "crypto" {
1042
1078
  iv: BinaryLike,
1043
1079
  options?: CipherGCMOptions,
1044
1080
  ): DecipherGCM;
1081
+ function createDecipheriv(
1082
+ algorithm: CipherChaCha20Poly1305Types,
1083
+ key: CipherKey,
1084
+ iv: BinaryLike,
1085
+ options?: CipherChaCha20Poly1305Options,
1086
+ ): DecipherChaCha20Poly1305;
1045
1087
  function createDecipheriv(
1046
1088
  algorithm: string,
1047
1089
  key: CipherKey,
@@ -1226,6 +1268,15 @@ declare module "crypto" {
1226
1268
  },
1227
1269
  ): this;
1228
1270
  }
1271
+ interface DecipherChaCha20Poly1305 extends Decipher {
1272
+ setAuthTag(buffer: NodeJS.ArrayBufferView): this;
1273
+ setAAD(
1274
+ buffer: NodeJS.ArrayBufferView,
1275
+ options: {
1276
+ plaintextLength: number;
1277
+ },
1278
+ ): this;
1279
+ }
1229
1280
  interface PrivateKeyInput {
1230
1281
  key: string | Buffer;
1231
1282
  format?: KeyFormat | undefined;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/node",
3
- "version": "18.19.77",
3
+ "version": "18.19.79",
4
4
  "description": "TypeScript definitions for node",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node",
6
6
  "license": "MIT",
@@ -220,6 +220,6 @@
220
220
  "undici-types": "~5.26.4"
221
221
  },
222
222
  "peerDependencies": {},
223
- "typesPublisherContentHash": "ed4669ceee92a67988e040c8a7e8d5dba7817925d88881bb428ff13268f75869",
223
+ "typesPublisherContentHash": "4413da7f29f5e0b4c3cacc7710d6e31782ca3471ece6f3716fb0904e092fb4d3",
224
224
  "typeScriptVersion": "5.0"
225
225
  }
@@ -24,7 +24,7 @@ declare module "buffer" {
24
24
  * @param array The octets to store.
25
25
  * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
26
26
  */
27
- new(array: Uint8Array): Buffer;
27
+ new(array: ArrayLike<number>): Buffer;
28
28
  /**
29
29
  * Produces a Buffer backed by the same allocated memory as
30
30
  * the given {ArrayBuffer}/{SharedArrayBuffer}.
@@ -33,20 +33,6 @@ declare module "buffer" {
33
33
  * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
34
34
  */
35
35
  new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
36
- /**
37
- * Allocates a new buffer containing the given {array} of octets.
38
- *
39
- * @param array The octets to store.
40
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
41
- */
42
- new(array: readonly any[]): Buffer;
43
- /**
44
- * Copies the passed {buffer} data onto a new {Buffer} instance.
45
- *
46
- * @param buffer The buffer to copy.
47
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
48
- */
49
- new(buffer: Buffer): Buffer;
50
36
  /**
51
37
  * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
52
38
  * Array entries outside that range will be truncated to fit into it.
@@ -57,16 +43,85 @@ declare module "buffer" {
57
43
  * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
58
44
  * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
59
45
  * ```
60
- *
61
- * If `array` is an `Array`\-like object (that is, one with a `length` property of
46
+ * If `array` is an `Array`-like object (that is, one with a `length` property of
62
47
  * type `number`), it is treated as if it is an array, unless it is a `Buffer` or
63
- * 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()`.
48
+ * a `Uint8Array`. This means all other `TypedArray` variants get treated as an
49
+ * `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use
50
+ * `Buffer.copyBytesFrom()`.
64
51
  *
65
52
  * A `TypeError` will be thrown if `array` is not an `Array` or another type
66
53
  * appropriate for `Buffer.from()` variants.
67
54
  *
68
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
55
+ * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal
56
+ * `Buffer` pool like `Buffer.allocUnsafe()` does.
57
+ * @since v5.10.0
58
+ */
59
+ from(array: WithImplicitCoercion<ArrayLike<number>>): Buffer;
60
+ /**
61
+ * This creates a view of the `ArrayBuffer` without copying the underlying
62
+ * memory. For example, when passed a reference to the `.buffer` property of a
63
+ * `TypedArray` instance, the newly created `Buffer` will share the same
64
+ * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`.
65
+ *
66
+ * ```js
67
+ * import { Buffer } from 'node:buffer';
68
+ *
69
+ * const arr = new Uint16Array(2);
70
+ *
71
+ * arr[0] = 5000;
72
+ * arr[1] = 4000;
73
+ *
74
+ * // Shares memory with `arr`.
75
+ * const buf = Buffer.from(arr.buffer);
76
+ *
77
+ * console.log(buf);
78
+ * // Prints: <Buffer 88 13 a0 0f>
79
+ *
80
+ * // Changing the original Uint16Array changes the Buffer also.
81
+ * arr[1] = 6000;
82
+ *
83
+ * console.log(buf);
84
+ * // Prints: <Buffer 88 13 70 17>
85
+ * ```
86
+ * The optional `byteOffset` and `length` arguments specify a memory range within
87
+ * the `arrayBuffer` that will be shared by the `Buffer`.
88
+ *
89
+ * ```js
90
+ * import { Buffer } from 'node:buffer';
91
+ *
92
+ * const ab = new ArrayBuffer(10);
93
+ * const buf = Buffer.from(ab, 0, 2);
94
+ *
95
+ * console.log(buf.length);
96
+ * // Prints: 2
97
+ * ```
98
+ *
99
+ * A `TypeError` will be thrown if `arrayBuffer` is not an `ArrayBuffer` or a
100
+ * `SharedArrayBuffer` or another type appropriate for `Buffer.from()`
101
+ * variants.
102
+ *
103
+ * It is important to remember that a backing `ArrayBuffer` can cover a range
104
+ * of memory that extends beyond the bounds of a `TypedArray` view. A new
105
+ * `Buffer` created using the `buffer` property of a `TypedArray` may extend
106
+ * beyond the range of the `TypedArray`:
107
+ *
108
+ * ```js
109
+ * import { Buffer } from 'node:buffer';
110
+ *
111
+ * const arrA = Uint8Array.from([0x63, 0x64, 0x65, 0x66]); // 4 elements
112
+ * const arrB = new Uint8Array(arrA.buffer, 1, 2); // 2 elements
113
+ * console.log(arrA.buffer === arrB.buffer); // true
114
+ *
115
+ * const buf = Buffer.from(arrB.buffer);
116
+ * console.log(buf);
117
+ * // Prints: <Buffer 63 64 65 66>
118
+ * ```
69
119
  * @since v5.10.0
120
+ * @param arrayBuffer An `ArrayBuffer`, `SharedArrayBuffer`, for example the
121
+ * `.buffer` property of a `TypedArray`.
122
+ * @param byteOffset Index of first byte to expose. **Default:** `0`.
123
+ * @param length Number of bytes to expose. **Default:**
124
+ * `arrayBuffer.byteLength - byteOffset`.
70
125
  */
71
126
  from(
72
127
  arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
@@ -74,24 +129,30 @@ declare module "buffer" {
74
129
  length?: number,
75
130
  ): Buffer;
76
131
  /**
77
- * Creates a new Buffer using the passed {data}
78
- * @param data data to create a new Buffer
79
- */
80
- from(data: Uint8Array | readonly number[]): Buffer;
81
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
82
- /**
83
- * Creates a new Buffer containing the given JavaScript string {str}.
84
- * If provided, the {encoding} parameter identifies the character encoding.
85
- * If not provided, {encoding} defaults to 'utf8'.
132
+ * Creates a new `Buffer` containing `string`. The `encoding` parameter identifies
133
+ * the character encoding to be used when converting `string` into bytes.
134
+ *
135
+ * ```js
136
+ * import { Buffer } from 'node:buffer';
137
+ *
138
+ * const buf1 = Buffer.from('this is a tést');
139
+ * const buf2 = Buffer.from('7468697320697320612074c3a97374', 'hex');
140
+ *
141
+ * console.log(buf1.toString());
142
+ * // Prints: this is a tést
143
+ * console.log(buf2.toString());
144
+ * // Prints: this is a tést
145
+ * console.log(buf1.toString('latin1'));
146
+ * // Prints: this is a tést
147
+ * ```
148
+ *
149
+ * A `TypeError` will be thrown if `string` is not a string or another type
150
+ * appropriate for `Buffer.from()` variants.
151
+ * @since v5.10.0
152
+ * @param string A string to encode.
153
+ * @param encoding The encoding of `string`. **Default:** `'utf8'`.
86
154
  */
87
- from(
88
- str:
89
- | WithImplicitCoercion<string>
90
- | {
91
- [Symbol.toPrimitive](hint: "string"): string;
92
- },
93
- encoding?: BufferEncoding,
94
- ): Buffer;
155
+ from(string: WithImplicitCoercion<string>, encoding?: BufferEncoding): Buffer;
95
156
  /**
96
157
  * Creates a new Buffer using the passed {data}
97
158
  * @param values to create a new Buffer
@@ -382,4 +443,10 @@ declare module "buffer" {
382
443
  subarray(start?: number, end?: number): Buffer;
383
444
  }
384
445
  }
446
+ /** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
447
+ var SlowBuffer: {
448
+ /** @deprecated Use `Buffer.allocUnsafeSlow()` instead. */
449
+ new(size: number): Buffer;
450
+ prototype: Buffer;
451
+ };
385
452
  }