codemod 2.0.0-alpha.1 → 2.0.0-alpha.3

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.
Files changed (102) hide show
  1. package/README.md +56 -2
  2. package/codemod +17 -30
  3. package/package.json +80 -10
  4. package/register.d.mts +2 -0
  5. package/register.mjs +67 -0
  6. package/runtime/addon.d.mts +114 -0
  7. package/runtime/addon.mjs +55 -0
  8. package/runtime/ast-grep.d.mts +20 -0
  9. package/runtime/ast-grep.mjs +82 -0
  10. package/runtime/context.d.mts +49 -0
  11. package/runtime/context.mjs +59 -0
  12. package/runtime/hooks.d.mts +2 -0
  13. package/runtime/hooks.mjs +7 -0
  14. package/runtime/host.d.mts +121 -0
  15. package/runtime/host.mjs +450 -0
  16. package/runtime/llm.d.mts +2 -0
  17. package/runtime/llm.mjs +5 -0
  18. package/runtime/metrics.d.mts +9 -0
  19. package/runtime/metrics.mjs +42 -0
  20. package/runtime/modules.d.mts +3 -0
  21. package/runtime/modules.mjs +17 -0
  22. package/runtime/orchestrator-version.d.mts +2 -0
  23. package/runtime/orchestrator-version.mjs +3 -0
  24. package/runtime/orchestrator.d.mts +261 -0
  25. package/runtime/orchestrator.mjs +879 -0
  26. package/runtime/runtime.d.mts +15 -0
  27. package/runtime/runtime.mjs +40 -0
  28. package/runtime/workflow.d.mts +19 -0
  29. package/runtime/workflow.mjs +126 -0
  30. package/testing/index.d.mts +157 -0
  31. package/testing/index.mjs +648 -0
  32. package/types/index.d.ts +8 -0
  33. package/types/langs/angular.d.ts +5 -0
  34. package/types/langs/c.d.ts +5 -0
  35. package/types/langs/c_sharp.d.ts +5 -0
  36. package/types/langs/cpp.d.ts +5 -0
  37. package/types/langs/css.d.ts +5 -0
  38. package/types/langs/elixir.d.ts +5 -0
  39. package/types/langs/go.d.ts +5 -0
  40. package/types/langs/html.d.ts +5 -0
  41. package/types/langs/java.d.ts +5 -0
  42. package/types/langs/javascript.d.ts +5 -0
  43. package/types/langs/json.d.ts +5 -0
  44. package/types/langs/kotlin.d.ts +5 -0
  45. package/types/langs/package.json +3 -0
  46. package/types/langs/php.d.ts +5 -0
  47. package/types/langs/python.d.ts +5 -0
  48. package/types/langs/ruby.d.ts +5 -0
  49. package/types/langs/rust.d.ts +5 -0
  50. package/types/langs/scala.d.ts +5 -0
  51. package/types/langs/toml.d.ts +5 -0
  52. package/types/langs/tsx.d.ts +5 -0
  53. package/types/langs/typescript.d.ts +5 -0
  54. package/types/langs/xml.d.ts +5 -0
  55. package/types/langs/yaml.d.ts +5 -0
  56. package/types/llm.d.ts +6 -0
  57. package/types/llrt/abort.d.ts +69 -0
  58. package/types/llrt/assert.d.ts +39 -0
  59. package/types/llrt/async_hooks.d.ts +210 -0
  60. package/types/llrt/buffer.d.ts +1186 -0
  61. package/types/llrt/child_process.d.ts +447 -0
  62. package/types/llrt/console.d.ts +210 -0
  63. package/types/llrt/crypto.d.ts +854 -0
  64. package/types/llrt/dgram.d.ts +381 -0
  65. package/types/llrt/dns.d.ts +124 -0
  66. package/types/llrt/dom-events.d.ts +51 -0
  67. package/types/llrt/events.d.ts +245 -0
  68. package/types/llrt/exceptions.d.ts +26 -0
  69. package/types/llrt/fetch.d.ts +332 -0
  70. package/types/llrt/fs/promises.d.ts +554 -0
  71. package/types/llrt/fs.d.ts +360 -0
  72. package/types/llrt/globals.d.ts +23 -0
  73. package/types/llrt/https.d.ts +27 -0
  74. package/types/llrt/index.d.ts +33 -0
  75. package/types/llrt/module.d.ts +285 -0
  76. package/types/llrt/navigator.d.ts +9 -0
  77. package/types/llrt/net.d.ts +488 -0
  78. package/types/llrt/os.d.ts +293 -0
  79. package/types/llrt/path.d.ts +150 -0
  80. package/types/llrt/perf_hooks.d.ts +23 -0
  81. package/types/llrt/process.d.ts +502 -0
  82. package/types/llrt/stream/web.d.ts +526 -0
  83. package/types/llrt/stream.d.ts +366 -0
  84. package/types/llrt/string_decoder.d.ts +63 -0
  85. package/types/llrt/timers.d.ts +72 -0
  86. package/types/llrt/timezone.d.ts +101 -0
  87. package/types/llrt/tty.d.ts +11 -0
  88. package/types/llrt/url.d.ts +774 -0
  89. package/types/llrt/util.d.ts +240 -0
  90. package/types/llrt/zlib.d.ts +177 -0
  91. package/types/main.d.ts +5 -0
  92. package/types/metrics.d.ts +5 -0
  93. package/types/modules/ast-grep.d.ts +634 -0
  94. package/types/modules/langs.d.ts +87 -0
  95. package/types/modules/llm.d.ts +23 -0
  96. package/types/modules/metrics.d.ts +107 -0
  97. package/types/modules/runtime.d.ts +66 -0
  98. package/types/modules/workflow.d.ts +915 -0
  99. package/types/runtime.d.ts +6 -0
  100. package/types/workflow.d.ts +5 -0
  101. package/vite.d.mts +7 -0
  102. package/vite.mjs +32 -0
@@ -0,0 +1,1186 @@
1
+ /**
2
+ * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
3
+ * LLRT APIs support `Buffer`s.
4
+ *
5
+ * The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and
6
+ * extends it with methods that cover additional use cases. LLRT APIs accept
7
+ * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.
8
+ *
9
+ * While the `Buffer` class is available within the global scope, it is still
10
+ * recommended to explicitly reference it via an import or require statement.
11
+ *
12
+ * ```js
13
+ * import { Buffer } from 'buffer';
14
+ *
15
+ * // Creates a zero-filled Buffer of length 10.
16
+ * const buf1 = Buffer.alloc(10);
17
+ *
18
+ * // Creates a Buffer of length 10,
19
+ * // filled with bytes which all have the value `1`.
20
+ * const buf2 = Buffer.alloc(10, 1);
21
+ *
22
+ * // Creates a Buffer containing the bytes [1, 2, 3].
23
+ * const buf4 = Buffer.from([1, 2, 3]);
24
+ *
25
+ * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
26
+ * // are all truncated using `(value & 255)` to fit into the range 0–255.
27
+ * const buf5 = Buffer.from([257, 257.5, -255, '1']);
28
+ *
29
+ * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
30
+ * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
31
+ * // [116, 195, 169, 115, 116] (in decimal notation)
32
+ * const buf6 = Buffer.from('tést');
33
+ *
34
+ * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
35
+ * const buf7 = Buffer.from('tést', 'latin1');
36
+ * ```
37
+ */
38
+ declare module "buffer" {
39
+ export const constants: {
40
+ MAX_LENGTH: number;
41
+ MAX_STRING_LENGTH: number;
42
+ };
43
+ export type BufferEncoding =
44
+ | "hex"
45
+ | "base64"
46
+ | "utf-8"
47
+ | "utf8"
48
+ | "unicode-1-1-utf8"
49
+ | "ucs2"
50
+ | "ucs-2"
51
+ | "utf-16le"
52
+ | "utf16le"
53
+ | "utf-16"
54
+ | "utf16"
55
+ | "utf-16be"
56
+ | "utf16be"
57
+ | "windows-1252"
58
+ | "ansi_x3.4-1968"
59
+ | "ascii"
60
+ | "cp1252"
61
+ | "cp819"
62
+ | "csisolatin1"
63
+ | "ibm819"
64
+ | "iso-8859-1"
65
+ | "iso-ir-100"
66
+ | "iso8859-1"
67
+ | "iso88591"
68
+ | "iso_8859-1"
69
+ | "iso_8859-1:1987"
70
+ | "l1"
71
+ | "latin1"
72
+ | "us-ascii"
73
+ | "x-cp1252";
74
+ type WithImplicitCoercion<T> =
75
+ | T
76
+ | {
77
+ valueOf(): T;
78
+ };
79
+ interface BufferConstructor {
80
+ /**
81
+ * Returns the byte length of a string when encoded using `encoding`.
82
+ * This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
83
+ * for the encoding that is used to convert the string into bytes.
84
+ *
85
+ * ```js
86
+ * import { Buffer } from 'buffer';
87
+ *
88
+ * const str = '\u00bd + \u00bc = \u00be';
89
+ *
90
+ * console.log(`${str}: ${str.length} characters, ` +
91
+ * `${Buffer.byteLength(str, 'utf8')} bytes`);
92
+ * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
93
+ * ```
94
+ *
95
+ * When `string` is a
96
+ * `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
97
+ * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
98
+ * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
99
+ * @param string A value to calculate the length of.
100
+ * @param [encoding='utf8'] If `string` is a string, this is its encoding.
101
+ * @return The number of bytes contained within `string`.
102
+ */
103
+ byteLength(
104
+ string:
105
+ | string
106
+ | Buffer
107
+ | QuickJS.ArrayBufferView
108
+ | ArrayBuffer
109
+ | SharedArrayBuffer,
110
+ encoding?: BufferEncoding
111
+ ): number;
112
+ /**
113
+ * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
114
+ *
115
+ * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
116
+ *
117
+ * If `totalLength` is not provided, it is calculated from the `Buffer` instances
118
+ * in `list` by adding their lengths.
119
+ *
120
+ * If `totalLength` is provided, it is coerced to an unsigned integer. If the
121
+ * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
122
+ * truncated to `totalLength`.
123
+ *
124
+ * ```js
125
+ * import { Buffer } from 'buffer';
126
+ *
127
+ * // Create a single `Buffer` from a list of three `Buffer` instances.
128
+ *
129
+ * const buf1 = Buffer.alloc(10);
130
+ * const buf2 = Buffer.alloc(14);
131
+ * const buf3 = Buffer.alloc(18);
132
+ * const totalLength = buf1.length + buf2.length + buf3.length;
133
+ *
134
+ * console.log(totalLength);
135
+ * // Prints: 42
136
+ *
137
+ * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
138
+ *
139
+ * console.log(bufA);
140
+ * // Prints: <Buffer 00 00 00 00 ...>
141
+ * console.log(bufA.length);
142
+ * // Prints: 42
143
+ * ```
144
+ *
145
+ * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
146
+ * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
147
+ */
148
+ concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
149
+ /**
150
+ * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
151
+ */
152
+ from(
153
+ arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
154
+ byteOffset?: number,
155
+ length?: number
156
+ ): Buffer;
157
+ /**
158
+ * Creates a new Buffer using the passed {data}
159
+ * @param data data to create a new Buffer
160
+ */
161
+ from(data: Uint8Array | readonly number[]): Buffer;
162
+ from(
163
+ data: WithImplicitCoercion<Uint8Array | readonly number[] | string>
164
+ ): Buffer;
165
+ /**
166
+ * Creates a new Buffer containing the given JavaScript string {str}.
167
+ * If provided, the {encoding} parameter identifies the character encoding.
168
+ * If not provided, {encoding} defaults to 'utf8'.
169
+ */
170
+ from(
171
+ str:
172
+ | WithImplicitCoercion<string>
173
+ | {
174
+ [Symbol.toPrimitive](hint: "string"): string;
175
+ },
176
+ encoding?: BufferEncoding
177
+ ): Buffer;
178
+ /**
179
+ * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
180
+ *
181
+ * ```js
182
+ * import { Buffer } from 'buffer';
183
+ *
184
+ * Buffer.isBuffer(Buffer.alloc(10)); // true
185
+ * Buffer.isBuffer(Buffer.from('foo')); // true
186
+ * Buffer.isBuffer('a string'); // false
187
+ * Buffer.isBuffer([]); // false
188
+ * Buffer.isBuffer(new Uint8Array(1024)); // false
189
+ * ```
190
+ */
191
+ isBuffer(obj: any): obj is Buffer;
192
+ /**
193
+ * Returns `true` if `encoding` is the name of a supported character encoding,
194
+ * or `false` otherwise.
195
+ *
196
+ * ```js
197
+ * import { Buffer } from 'buffer';
198
+ *
199
+ * console.log(Buffer.isEncoding('utf8'));
200
+ * // Prints: true
201
+ *
202
+ * console.log(Buffer.isEncoding('hex'));
203
+ * // Prints: true
204
+ *
205
+ * console.log(Buffer.isEncoding('utf/8'));
206
+ * // Prints: false
207
+ *
208
+ * console.log(Buffer.isEncoding(''));
209
+ * // Prints: false
210
+ * ```
211
+ * @param encoding A character encoding name to check.
212
+ */
213
+ isEncoding(encoding: string): encoding is BufferEncoding;
214
+ /**
215
+ * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be zero-filled.
216
+ *
217
+ * ```js
218
+ * import { Buffer } from 'buffer';
219
+ *
220
+ * const buf = Buffer.alloc(5);
221
+ *
222
+ * console.log(buf);
223
+ * // Prints: <Buffer 00 00 00 00 00>
224
+ * ```
225
+ *
226
+ * If `fill` is specified, the allocated `Buffer` will be initialized by calling `Buffer.alloc(size, fill)`.
227
+ *
228
+ * ```js
229
+ * import { Buffer } from 'buffer';
230
+ *
231
+ * const buf = Buffer.alloc(5, 'a');
232
+ *
233
+ * console.log(buf);
234
+ * // Prints: <Buffer 61 61 61 61 61>
235
+ * ```
236
+ *
237
+ * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
238
+ * initialized by calling `Buffer.aloc(size, fill, encoding)`.
239
+ *
240
+ * ```js
241
+ * import { Buffer } from 'buffer';
242
+ *
243
+ * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
244
+ *
245
+ * console.log(buf);
246
+ * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
247
+ * ```
248
+ *
249
+ * @param size The desired length of the new `Buffer`.
250
+ * @param [fill=0] A value to pre-fill the new `Buffer` with.
251
+ * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
252
+ */
253
+ alloc(
254
+ size: number,
255
+ fill?: string | Uint8Array | number,
256
+ encoding?: BufferEncoding
257
+ ): Buffer;
258
+ /**
259
+ * Allocates a new `Buffer` of `size` bytes.
260
+ *
261
+ * The underlying memory for `Buffer` instances created in this way is _not_
262
+ * _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.
263
+ *
264
+ * ```js
265
+ * import { Buffer } from 'buffer';
266
+ *
267
+ * const buf = Buffer.allocUnsafe(10);
268
+ *
269
+ * console.log(buf);
270
+ * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
271
+ *
272
+ * buf.fill(0);
273
+ *
274
+ * console.log(buf);
275
+ * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
276
+ * ```
277
+ *
278
+ * A `TypeError` will be thrown if `size` is not a number.
279
+ *
280
+ * @param size The desired length of the new `Buffer`.
281
+ */
282
+ allocUnsafe(size: number): Buffer;
283
+ /**
284
+ * Allocates a new `Buffer` of `size` bytes.
285
+ *
286
+ * The underlying memory for `Buffer` instances created in this way is _not_
287
+ * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
288
+ * such `Buffer` instances with zeroes.
289
+ *
290
+ * ```js
291
+ * import { Buffer } from 'buffer';
292
+ *
293
+ * // Need to keep around a few small chunks of memory.
294
+ * const store = [];
295
+ *
296
+ * socket.on('readable', () => {
297
+ * let data;
298
+ * while (null !== (data = readable.read())) {
299
+ * // Allocate for retained data.
300
+ * const sb = Buffer.allocUnsafeSlow(10);
301
+ *
302
+ * // Copy the data into the new allocation.
303
+ * data.copy(sb, 0, 0, 10);
304
+ *
305
+ * store.push(sb);
306
+ * }
307
+ * });
308
+ * ```
309
+ *
310
+ * A `TypeError` will be thrown if `size` is not a number.
311
+ *
312
+ * @param size The desired length of the new `Buffer`.
313
+ */
314
+ allocUnsafeSlow(size: number): Buffer;
315
+ }
316
+ interface Buffer extends Uint8Array {
317
+ /**
318
+ * 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
319
+ * not contain enough space to fit the entire string, only part of `string` will be
320
+ * written. However, partially encoded characters will not be written.
321
+ *
322
+ * ```js
323
+ * import { Buffer } from 'buffer';
324
+ *
325
+ * const buf = Buffer.alloc(256);
326
+ *
327
+ * const len = buf.write('\u00bd + \u00bc = \u00be', 0);
328
+ *
329
+ * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
330
+ * // Prints: 12 bytes: ½ + ¼ = ¾
331
+ *
332
+ * const buffer = Buffer.alloc(10);
333
+ *
334
+ * const length = buffer.write('abcd', 8);
335
+ *
336
+ * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
337
+ * // Prints: 2 bytes : ab
338
+ * ```
339
+ * @param string String to write to `buf`.
340
+ * @param [offset=0] Number of bytes to skip before starting to write `string`.
341
+ * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
342
+ * @param [encoding='utf8'] The character encoding of `string`.
343
+ * @return Number of bytes written.
344
+ */
345
+ write(string: string, encoding?: BufferEncoding): number;
346
+ write(string: string, offset: number, encoding?: BufferEncoding): number;
347
+ write(
348
+ string: string,
349
+ offset: number,
350
+ length: number,
351
+ encoding?: BufferEncoding
352
+ ): number;
353
+ /**
354
+ * Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.
355
+ *
356
+ * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
357
+ * then each invalid byte is replaced with the replacement character `U+FFFD`.
358
+ *
359
+ * ```js
360
+ * import { Buffer } from 'node:buffer';
361
+ *
362
+ * const buf1 = Buffer.allocUnsafe(26);
363
+ *
364
+ * for (let i = 0; i < 26; i++) {
365
+ * // 97 is the decimal ASCII value for 'a'.
366
+ * buf1[i] = i + 97;
367
+ * }
368
+ *
369
+ * console.log(buf1.toString('utf8'));
370
+ * // Prints: abcdefghijklmnopqrstuvwxyz
371
+ * console.log(buf1.toString('utf8', 0, 5));
372
+ * // Prints: abcde
373
+ *
374
+ * const buf2 = Buffer.from('tést');
375
+ *
376
+ * console.log(buf2.toString('hex'));
377
+ * // Prints: 74c3a97374
378
+ * console.log(buf2.toString('utf8', 0, 3));
379
+ * // Prints: té
380
+ * console.log(buf2.toString(undefined, 0, 3));
381
+ * // Prints: té
382
+ * ```
383
+ * @param [encoding='utf8'] The character encoding to use.
384
+ * @param [start=0] The byte offset to start decoding at.
385
+ * @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
386
+ */
387
+ toString(encoding?: BufferEncoding, start?: number, end?: number): string;
388
+ /**
389
+ * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
390
+ *
391
+ * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
392
+ * for all TypedArrays, including `Buffer`s, although it takes
393
+ * different function arguments.
394
+ *
395
+ * ```js
396
+ * import { Buffer } from 'buffer';
397
+ *
398
+ * // Create two `Buffer` instances.
399
+ * const buf1 = Buffer.allocUnsafe(26);
400
+ * const buf2 = Buffer.allocUnsafe(26).fill('!');
401
+ *
402
+ * for (let i = 0; i < 26; i++) {
403
+ * // 97 is the decimal ASCII value for 'a'.
404
+ * buf1[i] = i + 97;
405
+ * }
406
+ *
407
+ * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
408
+ * buf1.copy(buf2, 8, 16, 20);
409
+ * // This is equivalent to:
410
+ * // buf2.set(buf1.subarray(16, 20), 8);
411
+ *
412
+ * console.log(buf2.toString('ascii', 0, 25));
413
+ * // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
414
+ * ```
415
+ *
416
+ * ```js
417
+ * import { Buffer } from 'buffer';
418
+ *
419
+ * // Create a `Buffer` and copy data from one region to an overlapping region
420
+ * // within the same `Buffer`.
421
+ *
422
+ * const buf = Buffer.allocUnsafe(26);
423
+ *
424
+ * for (let i = 0; i < 26; i++) {
425
+ * // 97 is the decimal ASCII value for 'a'.
426
+ * buf[i] = i + 97;
427
+ * }
428
+ *
429
+ * buf.copy(buf, 0, 4, 10);
430
+ *
431
+ * console.log(buf.toString());
432
+ * // Prints: efghijghijklmnopqrstuvwxyz
433
+ * ```
434
+ * @param target A `Buffer` or {@link Uint8Array} to copy into.
435
+ * @param [targetStart=0] The offset within `target` at which to begin writing.
436
+ * @param [sourceStart=0] The offset within `buf` from which to begin copying.
437
+ * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
438
+ * @return The number of bytes copied.
439
+ */
440
+ copy(
441
+ target: Uint8Array,
442
+ targetStart?: number,
443
+ sourceStart?: number,
444
+ sourceEnd?: number
445
+ ): number;
446
+ /**
447
+ * Returns a new `Buffer` that references the same memory as the original, but
448
+ * offset and cropped by the `start` and `end` indices.
449
+ *
450
+ * Specifying `end` greater than `buf.length` will return the same result as
451
+ * that of `end` equal to `buf.length`.
452
+ *
453
+ * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
454
+ *
455
+ * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
456
+ *
457
+ * ```js
458
+ * import { Buffer } from 'buffer';
459
+ *
460
+ * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
461
+ * // from the original `Buffer`.
462
+ *
463
+ * const buf1 = Buffer.alloc(26);
464
+ *
465
+ * for (let i = 0; i < 26; i++) {
466
+ * // 97 is the decimal ASCII value for 'a'.
467
+ * buf1[i] = i + 97;
468
+ * }
469
+ *
470
+ * const buf2 = buf1.subarray(0, 3);
471
+ *
472
+ * console.log(buf2.toString('ascii', 0, buf2.length));
473
+ * // Prints: abc
474
+ *
475
+ * buf1[0] = 33;
476
+ *
477
+ * console.log(buf2.toString('ascii', 0, buf2.length));
478
+ * // Prints: !bc
479
+ * ```
480
+ *
481
+ * Specifying negative indexes causes the slice to be generated relative to the
482
+ * end of `buf` rather than the beginning.
483
+ *
484
+ * ```js
485
+ * import { Buffer } from 'buffer';
486
+ *
487
+ * const buf = Buffer.from('buffer');
488
+ *
489
+ * console.log(buf.subarray(-6, -1).toString());
490
+ * // Prints: buffe
491
+ * // (Equivalent to buf.subarray(0, 5).)
492
+ *
493
+ * console.log(buf.subarray(-6, -2).toString());
494
+ * // Prints: buff
495
+ * // (Equivalent to buf.subarray(0, 4).)
496
+ *
497
+ * console.log(buf.subarray(-5, -2).toString());
498
+ * // Prints: uff
499
+ * // (Equivalent to buf.subarray(1, 4).)
500
+ * ```
501
+ * @param [start=0] Where the new `Buffer` will start.
502
+ * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
503
+ */
504
+ subarray(start?: number, end?: number): Buffer;
505
+ /**
506
+ * Writes `value` to `buf` at the specified `offset` as big-endian.
507
+ *
508
+ * `value` is interpreted and written as a two's complement signed integer.
509
+ *
510
+ * ```js
511
+ * import { Buffer } from 'buffer';
512
+ *
513
+ * const buf = Buffer.allocUnsafe(8);
514
+ *
515
+ * buf.writeBigInt64BE(0x0102030405060708n, 0);
516
+ *
517
+ * console.log(buf);
518
+ * // Prints: <Buffer 01 02 03 04 05 06 07 08>
519
+ * ```
520
+ * @param value Number to be written to `buf`.
521
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
522
+ * @return `offset` plus the number of bytes written.
523
+ */
524
+ writeBigInt64BE(value: bigint, offset?: number): number;
525
+ /**
526
+ * @alias Buffer.writeBigUInt64BE
527
+ */
528
+ writeBigUint64BE(value: bigint, offset?: number): number;
529
+ /**
530
+ * Writes `value` to `buf` at the specified `offset` as little-endian.
531
+ *
532
+ * `value` is interpreted and written as a two's complement signed integer.
533
+ *
534
+ * ```js
535
+ * import { Buffer } from 'buffer';
536
+ *
537
+ * const buf = Buffer.allocUnsafe(8);
538
+ *
539
+ * buf.writeBigInt64LE(0x0102030405060708n, 0);
540
+ *
541
+ * console.log(buf);
542
+ * // Prints: <Buffer 08 07 06 05 04 03 02 01>
543
+ * ```
544
+ * @param value Number to be written to `buf`.
545
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
546
+ * @return `offset` plus the number of bytes written.
547
+ */
548
+ writeBigInt64LE(value: bigint, offset?: number): number;
549
+ /**
550
+ * @alias Buffer.writeBigUInt64LE
551
+ */
552
+ writeBigUint64LE(value: bigint, offset?: number): number;
553
+ /**
554
+ * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
555
+ *
556
+ * This function is also available under the `readBigUint64BE` alias.
557
+ *
558
+ * ```js
559
+ * import { Buffer } from 'buffer';
560
+ *
561
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
562
+ *
563
+ * console.log(buf.readBigUInt64BE(0));
564
+ * // Prints: 4294967295n
565
+ * ```
566
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
567
+ */
568
+ readBigUInt64BE(offset?: number): bigint;
569
+ /**
570
+ * @alias Buffer.readBigUInt64BE
571
+ */
572
+ readBigUint64BE(offset?: number): bigint;
573
+ /**
574
+ * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
575
+ *
576
+ * This function is also available under the `readBigUint64LE` alias.
577
+ *
578
+ * ```js
579
+ * import { Buffer } from 'buffer';
580
+ *
581
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
582
+ *
583
+ * console.log(buf.readBigUInt64LE(0));
584
+ * // Prints: 18446744069414584320n
585
+ * ```
586
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
587
+ */
588
+ readBigUInt64LE(offset?: number): bigint;
589
+ /**
590
+ * @alias Buffer.readBigUInt64LE
591
+ */
592
+ readBigUint64LE(offset?: number): bigint;
593
+ /**
594
+ * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
595
+ *
596
+ * Integers read from a `Buffer` are interpreted as two's complement signed
597
+ * values.
598
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
599
+ */
600
+ readBigInt64BE(offset?: number): bigint;
601
+ /**
602
+ * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
603
+ *
604
+ * Integers read from a `Buffer` are interpreted as two's complement signed
605
+ * values.
606
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
607
+ */
608
+ readBigInt64LE(offset?: number): bigint;
609
+ /**
610
+ * Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
611
+ *
612
+ * This function is also available under the `readUint8` alias.
613
+ *
614
+ * ```js
615
+ * import { Buffer } from 'buffer';
616
+ *
617
+ * const buf = Buffer.from([1, -2]);
618
+ *
619
+ * console.log(buf.readUInt8(0));
620
+ * // Prints: 1
621
+ * console.log(buf.readUInt8(1));
622
+ * // Prints: 254
623
+ * console.log(buf.readUInt8(2));
624
+ * // Throws ERR_OUT_OF_RANGE.
625
+ * ```
626
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
627
+ */
628
+ readUInt8(offset?: number): number;
629
+ /**
630
+ * @alias Buffer.readUInt8
631
+ */
632
+ readUint8(offset?: number): number;
633
+ /**
634
+ * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.
635
+ *
636
+ * This function is also available under the `readUint16LE` alias.
637
+ *
638
+ * ```js
639
+ * import { Buffer } from 'buffer';
640
+ *
641
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
642
+ *
643
+ * console.log(buf.readUInt16LE(0).toString(16));
644
+ * // Prints: 3412
645
+ * console.log(buf.readUInt16LE(1).toString(16));
646
+ * // Prints: 5634
647
+ * console.log(buf.readUInt16LE(2).toString(16));
648
+ * // Throws ERR_OUT_OF_RANGE.
649
+ * ```
650
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
651
+ */
652
+ readUInt16LE(offset?: number): number;
653
+ /**
654
+ * @alias Buffer.readUInt16LE
655
+ */
656
+ readUint16LE(offset?: number): number;
657
+ /**
658
+ * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
659
+ *
660
+ * This function is also available under the `readUint16BE` alias.
661
+ *
662
+ * ```js
663
+ * import { Buffer } from 'buffer';
664
+ *
665
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
666
+ *
667
+ * console.log(buf.readUInt16BE(0).toString(16));
668
+ * // Prints: 1234
669
+ * console.log(buf.readUInt16BE(1).toString(16));
670
+ * // Prints: 3456
671
+ * ```
672
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
673
+ */
674
+ readUInt16BE(offset?: number): number;
675
+ /**
676
+ * @alias Buffer.readUInt16BE
677
+ */
678
+ readUint16BE(offset?: number): number;
679
+ /**
680
+ * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
681
+ *
682
+ * This function is also available under the `readUint32LE` alias.
683
+ *
684
+ * ```js
685
+ * import { Buffer } from 'buffer';
686
+ *
687
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
688
+ *
689
+ * console.log(buf.readUInt32LE(0).toString(16));
690
+ * // Prints: 78563412
691
+ * console.log(buf.readUInt32LE(1).toString(16));
692
+ * // Throws ERR_OUT_OF_RANGE.
693
+ * ```
694
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
695
+ */
696
+ readUInt32LE(offset?: number): number;
697
+ /**
698
+ * @alias Buffer.readUInt32LE
699
+ */
700
+ readUint32LE(offset?: number): number;
701
+ /**
702
+ * Reads a signed 8-bit integer from `buf` at the specified `offset`.
703
+ *
704
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
705
+ *
706
+ * ```js
707
+ * import { Buffer } from 'buffer';
708
+ *
709
+ * const buf = Buffer.from([-1, 5]);
710
+ *
711
+ * console.log(buf.readInt8(0));
712
+ * // Prints: -1
713
+ * console.log(buf.readInt8(1));
714
+ * // Prints: 5
715
+ * console.log(buf.readInt8(2));
716
+ * // Throws ERR_OUT_OF_RANGE.
717
+ * ```
718
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
719
+ */
720
+ readInt8(offset?: number): number;
721
+ /**
722
+ * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
723
+ *
724
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
725
+ *
726
+ * ```js
727
+ * import { Buffer } from 'buffer';
728
+ *
729
+ * const buf = Buffer.from([0, 5]);
730
+ *
731
+ * console.log(buf.readInt16LE(0));
732
+ * // Prints: 1280
733
+ * console.log(buf.readInt16LE(1));
734
+ * // Throws ERR_OUT_OF_RANGE.
735
+ * ```
736
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
737
+ */
738
+ readInt16LE(offset?: number): number;
739
+ /**
740
+ * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
741
+ *
742
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
743
+ *
744
+ * ```js
745
+ * import { Buffer } from 'buffer';
746
+ *
747
+ * const buf = Buffer.from([0, 5]);
748
+ *
749
+ * console.log(buf.readInt16BE(0));
750
+ * // Prints: 5
751
+ * ```
752
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
753
+ */
754
+ readInt16BE(offset?: number): number;
755
+ /**
756
+ * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
757
+ *
758
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
759
+ *
760
+ * ```js
761
+ * import { Buffer } from 'buffer';
762
+ *
763
+ * const buf = Buffer.from([0, 0, 0, 5]);
764
+ *
765
+ * console.log(buf.readInt32LE(0));
766
+ * // Prints: 83886080
767
+ * console.log(buf.readInt32LE(1));
768
+ * // Throws ERR_OUT_OF_RANGE.
769
+ * ```
770
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
771
+ */
772
+ readInt32LE(offset?: number): number;
773
+ /**
774
+ * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
775
+ *
776
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
777
+ *
778
+ * ```js
779
+ * import { Buffer } from 'buffer';
780
+ *
781
+ * const buf = Buffer.from([0, 0, 0, 5]);
782
+ *
783
+ * console.log(buf.readInt32BE(0));
784
+ * // Prints: 5
785
+ * ```
786
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
787
+ */
788
+ readInt32BE(offset?: number): number;
789
+ /**
790
+ * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
791
+ *
792
+ * ```js
793
+ * import { Buffer } from 'buffer';
794
+ *
795
+ * const buf = Buffer.from([1, 2, 3, 4]);
796
+ *
797
+ * console.log(buf.readFloatLE(0));
798
+ * // Prints: 1.539989614439558e-36
799
+ * console.log(buf.readFloatLE(1));
800
+ * // Throws ERR_OUT_OF_RANGE.
801
+ * ```
802
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
803
+ */
804
+ readFloatLE(offset?: number): number;
805
+ /**
806
+ * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
807
+ *
808
+ * ```js
809
+ * import { Buffer } from 'buffer';
810
+ *
811
+ * const buf = Buffer.from([1, 2, 3, 4]);
812
+ *
813
+ * console.log(buf.readFloatBE(0));
814
+ * // Prints: 2.387939260590663e-38
815
+ * ```
816
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
817
+ */
818
+ readFloatBE(offset?: number): number;
819
+ /**
820
+ * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
821
+ *
822
+ * ```js
823
+ * import { Buffer } from 'buffer';
824
+ *
825
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
826
+ *
827
+ * console.log(buf.readDoubleLE(0));
828
+ * // Prints: 5.447603722011605e-270
829
+ * console.log(buf.readDoubleLE(1));
830
+ * // Throws ERR_OUT_OF_RANGE.
831
+ * ```
832
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
833
+ */
834
+ readDoubleLE(offset?: number): number;
835
+ /**
836
+ * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
837
+ *
838
+ * ```js
839
+ * import { Buffer } from 'buffer';
840
+ *
841
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
842
+ *
843
+ * console.log(buf.readDoubleBE(0));
844
+ * // Prints: 8.20788039913184e-304
845
+ * ```
846
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
847
+ */
848
+ readDoubleBE(offset?: number): number;
849
+ /**
850
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a
851
+ * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
852
+ * other than an unsigned 8-bit integer.
853
+ *
854
+ * This function is also available under the `writeUint8` alias.
855
+ *
856
+ * ```js
857
+ * import { Buffer } from 'buffer';
858
+ *
859
+ * const buf = Buffer.allocUnsafe(4);
860
+ *
861
+ * buf.writeUInt8(0x3, 0);
862
+ * buf.writeUInt8(0x4, 1);
863
+ * buf.writeUInt8(0x23, 2);
864
+ * buf.writeUInt8(0x42, 3);
865
+ *
866
+ * console.log(buf);
867
+ * // Prints: <Buffer 03 04 23 42>
868
+ * ```
869
+ * @param value Number to be written to `buf`.
870
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
871
+ * @return `offset` plus the number of bytes written.
872
+ */
873
+ writeUInt8(value: number, offset?: number): number;
874
+ /**
875
+ * @alias Buffer.writeUInt8
876
+ */
877
+ writeUint8(value: number, offset?: number): number;
878
+ /**
879
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
880
+ * anything other than an unsigned 16-bit integer.
881
+ *
882
+ * This function is also available under the `writeUint16LE` alias.
883
+ *
884
+ * ```js
885
+ * import { Buffer } from 'buffer';
886
+ *
887
+ * const buf = Buffer.allocUnsafe(4);
888
+ *
889
+ * buf.writeUInt16LE(0xdead, 0);
890
+ * buf.writeUInt16LE(0xbeef, 2);
891
+ *
892
+ * console.log(buf);
893
+ * // Prints: <Buffer ad de ef be>
894
+ * ```
895
+ * @param value Number to be written to `buf`.
896
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
897
+ * @return `offset` plus the number of bytes written.
898
+ */
899
+ writeUInt16LE(value: number, offset?: number): number;
900
+ /**
901
+ * @alias Buffer.writeUInt16LE
902
+ */
903
+ writeUint16LE(value: number, offset?: number): number;
904
+ /**
905
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
906
+ * unsigned 16-bit integer.
907
+ *
908
+ * This function is also available under the `writeUint16BE` alias.
909
+ *
910
+ * ```js
911
+ * import { Buffer } from 'buffer';
912
+ *
913
+ * const buf = Buffer.allocUnsafe(4);
914
+ *
915
+ * buf.writeUInt16BE(0xdead, 0);
916
+ * buf.writeUInt16BE(0xbeef, 2);
917
+ *
918
+ * console.log(buf);
919
+ * // Prints: <Buffer de ad be ef>
920
+ * ```
921
+ * @param value Number to be written to `buf`.
922
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
923
+ * @return `offset` plus the number of bytes written.
924
+ */
925
+ writeUInt16BE(value: number, offset?: number): number;
926
+ /**
927
+ * @alias Buffer.writeUInt16BE
928
+ */
929
+ writeUint16BE(value: number, offset?: number): number;
930
+ /**
931
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
932
+ * anything other than an unsigned 32-bit integer.
933
+ *
934
+ * This function is also available under the `writeUint32LE` alias.
935
+ *
936
+ * ```js
937
+ * import { Buffer } from 'buffer';
938
+ *
939
+ * const buf = Buffer.allocUnsafe(4);
940
+ *
941
+ * buf.writeUInt32LE(0xfeedface, 0);
942
+ *
943
+ * console.log(buf);
944
+ * // Prints: <Buffer ce fa ed fe>
945
+ * ```
946
+ * @param value Number to be written to `buf`.
947
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
948
+ * @return `offset` plus the number of bytes written.
949
+ */
950
+ writeUInt32LE(value: number, offset?: number): number;
951
+ /**
952
+ * @alias Buffer.writeUInt32LE
953
+ */
954
+ writeUint32LE(value: number, offset?: number): number;
955
+ /**
956
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
957
+ * unsigned 32-bit integer.
958
+ *
959
+ * This function is also available under the `writeUint32BE` alias.
960
+ *
961
+ * ```js
962
+ * import { Buffer } from 'buffer';
963
+ *
964
+ * const buf = Buffer.allocUnsafe(4);
965
+ *
966
+ * buf.writeUInt32BE(0xfeedface, 0);
967
+ *
968
+ * console.log(buf);
969
+ * // Prints: <Buffer fe ed fa ce>
970
+ * ```
971
+ * @param value Number to be written to `buf`.
972
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
973
+ * @return `offset` plus the number of bytes written.
974
+ */
975
+ writeUInt32BE(value: number, offset?: number): number;
976
+ /**
977
+ * @alias Buffer.writeUInt32BE
978
+ */
979
+ writeUint32BE(value: number, offset?: number): number;
980
+ /**
981
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a valid
982
+ * signed 8-bit integer. Behavior is undefined when `value` is anything other than
983
+ * a signed 8-bit integer.
984
+ *
985
+ * `value` is interpreted and written as a two's complement signed integer.
986
+ *
987
+ * ```js
988
+ * import { Buffer } from 'buffer';
989
+ *
990
+ * const buf = Buffer.allocUnsafe(2);
991
+ *
992
+ * buf.writeInt8(2, 0);
993
+ * buf.writeInt8(-2, 1);
994
+ *
995
+ * console.log(buf);
996
+ * // Prints: <Buffer 02 fe>
997
+ * ```
998
+ * @param value Number to be written to `buf`.
999
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
1000
+ * @return `offset` plus the number of bytes written.
1001
+ */
1002
+ writeInt8(value: number, offset?: number): number;
1003
+ /**
1004
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
1005
+ * anything other than a signed 16-bit integer.
1006
+ *
1007
+ * The `value` is interpreted and written as a two's complement signed integer.
1008
+ *
1009
+ * ```js
1010
+ * import { Buffer } from 'buffer';
1011
+ *
1012
+ * const buf = Buffer.allocUnsafe(2);
1013
+ *
1014
+ * buf.writeInt16LE(0x0304, 0);
1015
+ *
1016
+ * console.log(buf);
1017
+ * // Prints: <Buffer 04 03>
1018
+ * ```
1019
+ * @param value Number to be written to `buf`.
1020
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1021
+ * @return `offset` plus the number of bytes written.
1022
+ */
1023
+ writeInt16LE(value: number, offset?: number): number;
1024
+ /**
1025
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
1026
+ * anything other than a signed 16-bit integer.
1027
+ *
1028
+ * The `value` is interpreted and written as a two's complement signed integer.
1029
+ *
1030
+ * ```js
1031
+ * import { Buffer } from 'buffer';
1032
+ *
1033
+ * const buf = Buffer.allocUnsafe(2);
1034
+ *
1035
+ * buf.writeInt16BE(0x0102, 0);
1036
+ *
1037
+ * console.log(buf);
1038
+ * // Prints: <Buffer 01 02>
1039
+ * ```
1040
+ * @param value Number to be written to `buf`.
1041
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1042
+ * @return `offset` plus the number of bytes written.
1043
+ */
1044
+ writeInt16BE(value: number, offset?: number): number;
1045
+ /**
1046
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
1047
+ * anything other than a signed 32-bit integer.
1048
+ *
1049
+ * The `value` is interpreted and written as a two's complement signed integer.
1050
+ *
1051
+ * ```js
1052
+ * import { Buffer } from 'buffer';
1053
+ *
1054
+ * const buf = Buffer.allocUnsafe(4);
1055
+ *
1056
+ * buf.writeInt32LE(0x05060708, 0);
1057
+ *
1058
+ * console.log(buf);
1059
+ * // Prints: <Buffer 08 07 06 05>
1060
+ * ```
1061
+ * @param value Number to be written to `buf`.
1062
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1063
+ * @return `offset` plus the number of bytes written.
1064
+ */
1065
+ writeInt32LE(value: number, offset?: number): number;
1066
+ /**
1067
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
1068
+ * anything other than a signed 32-bit integer.
1069
+ *
1070
+ * The `value` is interpreted and written as a two's complement signed integer.
1071
+ *
1072
+ * ```js
1073
+ * import { Buffer } from 'buffer';
1074
+ *
1075
+ * const buf = Buffer.allocUnsafe(4);
1076
+ *
1077
+ * buf.writeInt32BE(0x01020304, 0);
1078
+ *
1079
+ * console.log(buf);
1080
+ * // Prints: <Buffer 01 02 03 04>
1081
+ * ```
1082
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1083
+ * @return `offset` plus the number of bytes written.
1084
+ */
1085
+ writeInt32BE(value: number, offset?: number): number;
1086
+ /**
1087
+ * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
1088
+ * undefined when `value` is anything other than a JavaScript number.
1089
+ *
1090
+ * ```js
1091
+ * import { Buffer } from 'buffer';
1092
+ *
1093
+ * const buf = Buffer.allocUnsafe(4);
1094
+ *
1095
+ * buf.writeFloatLE(0xcafebabe, 0);
1096
+ *
1097
+ * console.log(buf);
1098
+ * // Prints: <Buffer bb fe 4a 4f>
1099
+ * ```
1100
+ * @param value Number to be written to `buf`.
1101
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1102
+ * @return `offset` plus the number of bytes written.
1103
+ */
1104
+ writeFloatLE(value: number, offset?: number): number;
1105
+ /**
1106
+ * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
1107
+ * undefined when `value` is anything other than a JavaScript number.
1108
+ *
1109
+ * ```js
1110
+ * import { Buffer } from 'buffer';
1111
+ *
1112
+ * const buf = Buffer.allocUnsafe(4);
1113
+ *
1114
+ * buf.writeFloatBE(0xcafebabe, 0);
1115
+ *
1116
+ * console.log(buf);
1117
+ * // Prints: <Buffer 4f 4a fe bb>
1118
+ * ```
1119
+ * @param value Number to be written to `buf`.
1120
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1121
+ * @return `offset` plus the number of bytes written.
1122
+ */
1123
+ writeFloatBE(value: number, offset?: number): number;
1124
+ /**
1125
+ * Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
1126
+ * other than a JavaScript number.
1127
+ *
1128
+ * ```js
1129
+ * import { Buffer } from 'buffer';
1130
+ *
1131
+ * const buf = Buffer.allocUnsafe(8);
1132
+ *
1133
+ * buf.writeDoubleLE(123.456, 0);
1134
+ *
1135
+ * console.log(buf);
1136
+ * // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
1137
+ * ```
1138
+ * @param value Number to be written to `buf`.
1139
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1140
+ * @return `offset` plus the number of bytes written.
1141
+ */
1142
+ writeDoubleLE(value: number, offset?: number): number;
1143
+ /**
1144
+ * Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
1145
+ * other than a JavaScript number.
1146
+ *
1147
+ * ```js
1148
+ * import { Buffer } from 'buffer';
1149
+ *
1150
+ * const buf = Buffer.allocUnsafe(8);
1151
+ *
1152
+ * buf.writeDoubleBE(123.456, 0);
1153
+ *
1154
+ * console.log(buf);
1155
+ * // Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
1156
+ * ```
1157
+ * @param value Number to be written to `buf`.
1158
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1159
+ * @return `offset` plus the number of bytes written.
1160
+ */
1161
+ writeDoubleBE(value: number, offset?: number): number;
1162
+ }
1163
+ var Buffer: BufferConstructor;
1164
+ /**
1165
+ * Decodes a string of Base64-encoded data into bytes, and encodes those bytes
1166
+ * into a string using UTF-8.
1167
+ *
1168
+ * The `data` may be any JavaScript-value that can be coerced into a string.
1169
+ *
1170
+ * @legacy Use `Buffer.from(data, 'base64')` instead.
1171
+ * @param data The Base64-encoded input string.
1172
+ */
1173
+ function atob(data: string): string;
1174
+ /**
1175
+ * Decodes a string into bytes using UTF-8, and encodes those bytes
1176
+ * into a string using Base64.
1177
+ *
1178
+ * The `data` may be any JavaScript-value that can be coerced into a string.
1179
+ *
1180
+ * @legacy Use `buf.toString('base64')` instead.
1181
+ * @param data An ASCII (Latin1) string.
1182
+ */
1183
+ function btoa(data: string): string;
1184
+
1185
+ export { Buffer, atob, btoa };
1186
+ }