@netlify/plugin-nextjs 4.40.0 → 4.40.2

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 (164) hide show
  1. package/lib/helpers/edge.js +4 -2
  2. package/lib/templates/getHandler.js +1 -2
  3. package/lib/templates/handlerUtils.js +14 -1
  4. package/lib/templates/server.js +9 -8
  5. package/lib/templates/vendor.js +20 -0
  6. package/package.json +7 -4
  7. package/src/templates/edge/next-dev.js +3 -3
  8. package/src/templates/edge/shims.js +6 -6
  9. package/src/templates/edge-shared/next-utils.ts +3 -3
  10. package/src/templates/edge-shared/utils.ts +1 -1
  11. package/src/templates/vendor/deno.land/std@0.134.0/fmt/colors.ts +536 -0
  12. package/src/templates/vendor/deno.land/std@0.134.0/testing/_diff.ts +360 -0
  13. package/src/templates/vendor/deno.land/std@0.134.0/testing/asserts.ts +866 -0
  14. package/src/templates/vendor/deno.land/std@0.175.0/_util/asserts.ts +25 -0
  15. package/src/templates/vendor/deno.land/std@0.175.0/_util/os.ts +23 -0
  16. package/src/templates/vendor/deno.land/std@0.175.0/async/abortable.ts +149 -0
  17. package/src/templates/vendor/deno.land/std@0.175.0/async/deadline.ts +30 -0
  18. package/src/templates/vendor/deno.land/std@0.175.0/async/debounce.ts +79 -0
  19. package/src/templates/vendor/deno.land/std@0.175.0/async/deferred.ts +48 -0
  20. package/src/templates/vendor/deno.land/std@0.175.0/async/delay.ts +67 -0
  21. package/src/templates/vendor/deno.land/std@0.175.0/async/mod.ts +18 -0
  22. package/src/templates/vendor/deno.land/std@0.175.0/async/mux_async_iterator.ts +97 -0
  23. package/src/templates/vendor/deno.land/std@0.175.0/async/pool.ts +95 -0
  24. package/src/templates/vendor/deno.land/std@0.175.0/async/retry.ts +81 -0
  25. package/src/templates/vendor/deno.land/std@0.175.0/async/tee.ts +100 -0
  26. package/src/templates/vendor/deno.land/std@0.175.0/bytes/index_of_needle.ts +49 -0
  27. package/src/templates/vendor/deno.land/std@0.175.0/crypto/timing_safe_equal.ts +29 -0
  28. package/src/templates/vendor/deno.land/std@0.175.0/datetime/to_imf.ts +45 -0
  29. package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64.ts +144 -0
  30. package/src/templates/vendor/deno.land/std@0.175.0/encoding/base64url.ts +70 -0
  31. package/src/templates/vendor/deno.land/std@0.175.0/flags/mod.ts +785 -0
  32. package/src/templates/vendor/deno.land/std@0.175.0/fmt/colors.ts +569 -0
  33. package/src/templates/vendor/deno.land/std@0.175.0/fmt/printf.ts +939 -0
  34. package/src/templates/vendor/deno.land/std@0.175.0/http/cookie.ts +403 -0
  35. package/src/templates/vendor/deno.land/std@0.175.0/node/_core.ts +77 -0
  36. package/src/templates/vendor/deno.land/std@0.175.0/node/_events.d.ts +848 -0
  37. package/src/templates/vendor/deno.land/std@0.175.0/node/_events.mjs +1033 -0
  38. package/src/templates/vendor/deno.land/std@0.175.0/node/_global.d.ts +66 -0
  39. package/src/templates/vendor/deno.land/std@0.175.0/node/_next_tick.ts +173 -0
  40. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/exiting.ts +4 -0
  41. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/process.ts +131 -0
  42. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/stdio.mjs +7 -0
  43. package/src/templates/vendor/deno.land/std@0.175.0/node/_process/streams.mjs +146 -0
  44. package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.d.ts +1488 -0
  45. package/src/templates/vendor/deno.land/std@0.175.0/node/_stream.mjs +746 -0
  46. package/src/templates/vendor/deno.land/std@0.175.0/node/_util/_util_callbackify.ts +129 -0
  47. package/src/templates/vendor/deno.land/std@0.175.0/node/_utils.ts +206 -0
  48. package/src/templates/vendor/deno.land/std@0.175.0/node/assert.ts +940 -0
  49. package/src/templates/vendor/deno.land/std@0.175.0/node/assertion_error.ts +579 -0
  50. package/src/templates/vendor/deno.land/std@0.175.0/node/async_hooks.ts +331 -0
  51. package/src/templates/vendor/deno.land/std@0.175.0/node/buffer.ts +13 -0
  52. package/src/templates/vendor/deno.land/std@0.175.0/node/events.ts +14 -0
  53. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.d.ts +2074 -0
  54. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/buffer.mjs +2607 -0
  55. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/_keys.ts +16 -0
  56. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/crypto/constants.ts +5 -0
  57. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/error_codes.ts +7 -0
  58. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/errors.ts +2867 -0
  59. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/fixed_queue.ts +123 -0
  60. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/hide_stack_frames.ts +16 -0
  61. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/net.ts +95 -0
  62. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/normalize_encoding.mjs +72 -0
  63. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/options.ts +45 -0
  64. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/primordials.mjs +30 -0
  65. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/process/per_thread.mjs +272 -0
  66. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/callbacks.mjs +137 -0
  67. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/readline/utils.mjs +580 -0
  68. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/destroy.mjs +320 -0
  69. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/end-of-stream.mjs +229 -0
  70. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/streams/utils.mjs +242 -0
  71. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/comparisons.ts +669 -0
  72. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/debuglog.ts +118 -0
  73. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/inspect.mjs +2237 -0
  74. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util/types.ts +113 -0
  75. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/util.mjs +143 -0
  76. package/src/templates/vendor/deno.land/std@0.175.0/node/internal/validators.mjs +317 -0
  77. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_libuv_winerror.ts +229 -0
  78. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_listen.ts +16 -0
  79. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_node.ts +18 -0
  80. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_timingSafeEqual.ts +12 -0
  81. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_utils.ts +86 -0
  82. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/_winerror.ts +16873 -0
  83. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/ares.ts +66 -0
  84. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/async_wrap.ts +152 -0
  85. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/buffer.ts +130 -0
  86. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/cares_wrap.ts +541 -0
  87. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/config.ts +3 -0
  88. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/connection_wrap.ts +80 -0
  89. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/constants.ts +900 -0
  90. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/contextify.ts +3 -0
  91. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/credentials.ts +3 -0
  92. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/crypto.ts +14 -0
  93. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/errors.ts +3 -0
  94. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs.ts +3 -0
  95. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_dir.ts +3 -0
  96. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/fs_event_wrap.ts +3 -0
  97. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/handle_wrap.ts +50 -0
  98. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/heap_utils.ts +3 -0
  99. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/http_parser.ts +3 -0
  100. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/icu.ts +3 -0
  101. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/inspector.ts +3 -0
  102. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/js_stream.ts +3 -0
  103. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/messaging.ts +3 -0
  104. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/mod.ts +108 -0
  105. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/module_wrap.ts +3 -0
  106. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/native_module.ts +3 -0
  107. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/natives.ts +3 -0
  108. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_file.ts +84 -0
  109. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/node_options.ts +39 -0
  110. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/options.ts +3 -0
  111. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/os.ts +3 -0
  112. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/performance.ts +3 -0
  113. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/pipe_wrap.ts +392 -0
  114. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/process_methods.ts +3 -0
  115. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/report.ts +3 -0
  116. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/serdes.ts +3 -0
  117. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/signal_wrap.ts +3 -0
  118. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/spawn_sync.ts +3 -0
  119. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/stream_wrap.ts +354 -0
  120. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/string_decoder.ts +15 -0
  121. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/symbols.ts +27 -0
  122. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/task_queue.ts +3 -0
  123. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tcp_wrap.ts +488 -0
  124. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/timers.ts +3 -0
  125. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tls_wrap.ts +3 -0
  126. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/trace_events.ts +3 -0
  127. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/tty_wrap.ts +3 -0
  128. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/types.ts +186 -0
  129. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/udp_wrap.ts +496 -0
  130. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/url.ts +3 -0
  131. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/util.ts +126 -0
  132. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/uv.ts +437 -0
  133. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/v8.ts +3 -0
  134. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/worker.ts +3 -0
  135. package/src/templates/vendor/deno.land/std@0.175.0/node/internal_binding/zlib.ts +3 -0
  136. package/src/templates/vendor/deno.land/std@0.175.0/node/process.ts +705 -0
  137. package/src/templates/vendor/deno.land/std@0.175.0/node/stream.ts +37 -0
  138. package/src/templates/vendor/deno.land/std@0.175.0/node/string_decoder.ts +337 -0
  139. package/src/templates/vendor/deno.land/std@0.175.0/node/util/types.ts +4 -0
  140. package/src/templates/vendor/deno.land/std@0.175.0/node/util.ts +289 -0
  141. package/src/templates/vendor/deno.land/std@0.175.0/path/_constants.ts +49 -0
  142. package/src/templates/vendor/deno.land/std@0.175.0/path/_interface.ts +30 -0
  143. package/src/templates/vendor/deno.land/std@0.175.0/path/_util.ts +194 -0
  144. package/src/templates/vendor/deno.land/std@0.175.0/path/common.ts +40 -0
  145. package/src/templates/vendor/deno.land/std@0.175.0/path/glob.ts +418 -0
  146. package/src/templates/vendor/deno.land/std@0.175.0/path/mod.ts +53 -0
  147. package/src/templates/vendor/deno.land/std@0.175.0/path/posix.ts +487 -0
  148. package/src/templates/vendor/deno.land/std@0.175.0/path/separator.ts +7 -0
  149. package/src/templates/vendor/deno.land/std@0.175.0/path/win32.ts +962 -0
  150. package/src/templates/vendor/deno.land/std@0.175.0/streams/write_all.ts +64 -0
  151. package/src/templates/vendor/deno.land/std@0.175.0/testing/_diff.ts +440 -0
  152. package/src/templates/vendor/deno.land/std@0.175.0/testing/_format.ts +23 -0
  153. package/src/templates/vendor/deno.land/std@0.175.0/testing/asserts.ts +906 -0
  154. package/src/templates/vendor/deno.land/std@0.175.0/types.d.ts +89 -0
  155. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/index.ts +133 -0
  156. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/asyncify.js +112 -0
  157. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.d.ts +88 -0
  158. package/src/templates/vendor/deno.land/x/html_rewriter@v0.1.0-pre.17/vendor/html_rewriter.js +974 -0
  159. package/src/templates/vendor/deno.land/x/path_to_regexp@v6.2.1/index.ts +621 -0
  160. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/compiled/cookie.js +13 -0
  161. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/request.js +12 -0
  162. package/src/templates/vendor/esm.sh/v91/next@12.2.5/deno/dist/server/web/spec-extension/response.js +5 -0
  163. package/src/templates/vendor/import_map.json +13 -0
  164. package/src/templates/vendor/raw.githubusercontent.com/worker-tools/resolvable-promise/master/index.ts +50 -0
@@ -0,0 +1,2074 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // Copyright DefinitelyTyped contributors. All rights reserved. MIT license.
3
+
4
+ /**
5
+ * One of many allowed encodings for the buffer content
6
+ * - ascii
7
+ * - base64
8
+ * - base64url
9
+ * - binary
10
+ * - hex
11
+ * - latin1
12
+ * - ucs-2
13
+ * - ucs2
14
+ * - utf-8
15
+ * - utf16le
16
+ * - utf8
17
+ */
18
+ type Encoding = unknown;
19
+
20
+ type WithImplicitCoercion<T> =
21
+ | T
22
+ | {
23
+ valueOf(): T;
24
+ };
25
+
26
+ /**
27
+ * `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
28
+ * Node.js APIs support `Buffer`s.
29
+ *
30
+ * 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
31
+ * extends it with methods that cover additional use cases. Node.js APIs accept
32
+ * plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.
33
+ *
34
+ * While the `Buffer` class is available within the global scope, it is still
35
+ * recommended to explicitly reference it via an import or require statement.
36
+ *
37
+ * ```js
38
+ * import { Buffer } from 'buffer';
39
+ *
40
+ * // Creates a zero-filled Buffer of length 10.
41
+ * const buf1 = Buffer.alloc(10);
42
+ *
43
+ * // Creates a Buffer of length 10,
44
+ * // filled with bytes which all have the value `1`.
45
+ * const buf2 = Buffer.alloc(10, 1);
46
+ *
47
+ * // Creates an uninitialized buffer of length 10.
48
+ * // This is faster than calling Buffer.alloc() but the returned
49
+ * // Buffer instance might contain old data that needs to be
50
+ * // overwritten using fill(), write(), or other functions that fill the Buffer's
51
+ * // contents.
52
+ * const buf3 = Buffer.allocUnsafe(10);
53
+ *
54
+ * // Creates a Buffer containing the bytes [1, 2, 3].
55
+ * const buf4 = Buffer.from([1, 2, 3]);
56
+ *
57
+ * // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
58
+ * // are all truncated using `(value &#x26; 255)` to fit into the range 0–255.
59
+ * const buf5 = Buffer.from([257, 257.5, -255, '1']);
60
+ *
61
+ * // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
62
+ * // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
63
+ * // [116, 195, 169, 115, 116] (in decimal notation)
64
+ * const buf6 = Buffer.from('tést');
65
+ *
66
+ * // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
67
+ * const buf7 = Buffer.from('tést', 'latin1');
68
+ * ```
69
+ * @see [source](https://github.com/nodejs/node/blob/v16.9.0/lib/buffer.js)
70
+ */
71
+ export class Buffer extends Uint8Array {
72
+ /**
73
+ * Allocates a new buffer containing the given {str}.
74
+ *
75
+ * @param str String to store in buffer.
76
+ * @param encoding encoding to use, optional. Default is 'utf8'
77
+ * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
78
+ */
79
+ constructor(str: string, encoding?: Encoding);
80
+ /**
81
+ * Allocates a new buffer of {size} octets.
82
+ *
83
+ * @param size count of octets to allocate.
84
+ * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
85
+ */
86
+ constructor(size: number);
87
+ /**
88
+ * Allocates a new buffer containing the given {array} of octets.
89
+ *
90
+ * @param array The octets to store.
91
+ * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
92
+ */
93
+ constructor(array: Uint8Array);
94
+ /**
95
+ * Produces a Buffer backed by the same allocated memory as
96
+ * the given {ArrayBuffer}/{SharedArrayBuffer}.
97
+ *
98
+ * @param arrayBuffer The ArrayBuffer with which to share memory.
99
+ * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
100
+ */
101
+ constructor(arrayBuffer: ArrayBuffer | SharedArrayBuffer);
102
+ /**
103
+ * Allocates a new buffer containing the given {array} of octets.
104
+ *
105
+ * @param array The octets to store.
106
+ * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
107
+ */
108
+ constructor(array: ReadonlyArray<unknown>);
109
+ /**
110
+ * Copies the passed {buffer} data onto a new {Buffer} instance.
111
+ *
112
+ * @param buffer The buffer to copy.
113
+ * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
114
+ */
115
+ constructor(buffer: Buffer);
116
+ /**
117
+ * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
118
+ * Array entries outside that range will be truncated to fit into it.
119
+ *
120
+ * ```js
121
+ * import { Buffer } from 'buffer';
122
+ *
123
+ * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
124
+ * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
125
+ * ```
126
+ *
127
+ * A `TypeError` will be thrown if `array` is not an `Array` or another type
128
+ * appropriate for `Buffer.from()` variants.
129
+ *
130
+ * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
131
+ * @since v5.10.0
132
+ */
133
+ static from(
134
+ arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
135
+ byteOffset?: number,
136
+ length?: number,
137
+ ): Buffer;
138
+ /**
139
+ * Creates a new Buffer using the passed {data}
140
+ * @param data data to create a new Buffer
141
+ */
142
+ static from(data: Uint8Array | ReadonlyArray<number>): Buffer;
143
+ static from(
144
+ data: WithImplicitCoercion<Uint8Array | ReadonlyArray<number> | string>,
145
+ ): Buffer;
146
+ /**
147
+ * Creates a new Buffer containing the given JavaScript string {str}.
148
+ * If provided, the {encoding} parameter identifies the character encoding.
149
+ * If not provided, {encoding} defaults to 'utf8'.
150
+ */
151
+ static from(
152
+ str:
153
+ | WithImplicitCoercion<string>
154
+ | {
155
+ [Symbol.toPrimitive](hint: "string"): string;
156
+ },
157
+ encoding?: Encoding,
158
+ ): Buffer;
159
+ /**
160
+ * Creates a new Buffer using the passed {data}
161
+ * @param values to create a new Buffer
162
+ */
163
+ static of(...items: number[]): Buffer;
164
+ /**
165
+ * Returns `true` if `obj` is a `Buffer`, `false` otherwise.
166
+ *
167
+ * ```js
168
+ * import { Buffer } from 'buffer';
169
+ *
170
+ * Buffer.isBuffer(Buffer.alloc(10)); // true
171
+ * Buffer.isBuffer(Buffer.from('foo')); // true
172
+ * Buffer.isBuffer('a string'); // false
173
+ * Buffer.isBuffer([]); // false
174
+ * Buffer.isBuffer(new Uint8Array(1024)); // false
175
+ * ```
176
+ * @since v0.1.101
177
+ */
178
+ static isBuffer(obj: unknown): obj is Buffer;
179
+ /**
180
+ * Returns `true` if `encoding` is the name of a supported character encoding,
181
+ * or `false` otherwise.
182
+ *
183
+ * ```js
184
+ * import { Buffer } from 'buffer';
185
+ *
186
+ * console.log(Buffer.isEncoding('utf8'));
187
+ * // Prints: true
188
+ *
189
+ * console.log(Buffer.isEncoding('hex'));
190
+ * // Prints: true
191
+ *
192
+ * console.log(Buffer.isEncoding('utf/8'));
193
+ * // Prints: false
194
+ *
195
+ * console.log(Buffer.isEncoding(''));
196
+ * // Prints: false
197
+ * ```
198
+ * @since v0.9.1
199
+ * @param encoding A character encoding name to check.
200
+ */
201
+ static isEncoding(encoding: string): boolean;
202
+ /**
203
+ * Returns the byte length of a string when encoded using `encoding`.
204
+ * 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
205
+ * for the encoding that is used to convert the string into bytes.
206
+ *
207
+ * For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.
208
+ * For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
209
+ * return value might be greater than the length of a `Buffer` created from the
210
+ * string.
211
+ *
212
+ * ```js
213
+ * import { Buffer } from 'buffer';
214
+ *
215
+ * const str = '\u00bd + \u00bc = \u00be';
216
+ *
217
+ * console.log(`${str}: ${str.length} characters, ` +
218
+ * `${Buffer.byteLength(str, 'utf8')} bytes`);
219
+ * // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
220
+ * ```
221
+ *
222
+ * When `string` is a
223
+ * `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/-
224
+ * Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
225
+ * er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
226
+ * @since v0.1.90
227
+ * @param string A value to calculate the length of.
228
+ * @param [encoding='utf8'] If `string` is a string, this is its encoding.
229
+ * @return The number of bytes contained within `string`.
230
+ */
231
+ static byteLength(
232
+ string:
233
+ | string
234
+ | ArrayBufferView
235
+ | ArrayBuffer
236
+ | SharedArrayBuffer,
237
+ encoding?: Encoding,
238
+ ): number;
239
+ /**
240
+ * Returns a new `Buffer` which is the result of concatenating all the `Buffer`instances in the `list` together.
241
+ *
242
+ * If the list has no items, or if the `totalLength` is 0, then a new zero-length`Buffer` is returned.
243
+ *
244
+ * If `totalLength` is not provided, it is calculated from the `Buffer` instances
245
+ * in `list` by adding their lengths.
246
+ *
247
+ * If `totalLength` is provided, it is coerced to an unsigned integer. If the
248
+ * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
249
+ * truncated to `totalLength`.
250
+ *
251
+ * ```js
252
+ * import { Buffer } from 'buffer';
253
+ *
254
+ * // Create a single `Buffer` from a list of three `Buffer` instances.
255
+ *
256
+ * const buf1 = Buffer.alloc(10);
257
+ * const buf2 = Buffer.alloc(14);
258
+ * const buf3 = Buffer.alloc(18);
259
+ * const totalLength = buf1.length + buf2.length + buf3.length;
260
+ *
261
+ * console.log(totalLength);
262
+ * // Prints: 42
263
+ *
264
+ * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
265
+ *
266
+ * console.log(bufA);
267
+ * // Prints: <Buffer 00 00 00 00 ...>
268
+ * console.log(bufA.length);
269
+ * // Prints: 42
270
+ * ```
271
+ *
272
+ * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
273
+ * @since v0.7.11
274
+ * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
275
+ * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
276
+ */
277
+ static concat(
278
+ list: ReadonlyArray<Uint8Array>,
279
+ totalLength?: number,
280
+ ): Buffer;
281
+ /**
282
+ * Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of`Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
283
+ *
284
+ * ```js
285
+ * import { Buffer } from 'buffer';
286
+ *
287
+ * const buf1 = Buffer.from('1234');
288
+ * const buf2 = Buffer.from('0123');
289
+ * const arr = [buf1, buf2];
290
+ *
291
+ * console.log(arr.sort(Buffer.compare));
292
+ * // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]
293
+ * // (This result is equal to: [buf2, buf1].)
294
+ * ```
295
+ * @since v0.11.13
296
+ * @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
297
+ */
298
+ static compare(buf1: Uint8Array, buf2: Uint8Array): number;
299
+ /**
300
+ * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
301
+ *
302
+ * ```js
303
+ * import { Buffer } from 'buffer';
304
+ *
305
+ * const buf = Buffer.alloc(5);
306
+ *
307
+ * console.log(buf);
308
+ * // Prints: <Buffer 00 00 00 00 00>
309
+ * ```
310
+ *
311
+ * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_INVALID_ARG_VALUE` is thrown.
312
+ *
313
+ * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
314
+ *
315
+ * ```js
316
+ * import { Buffer } from 'buffer';
317
+ *
318
+ * const buf = Buffer.alloc(5, 'a');
319
+ *
320
+ * console.log(buf);
321
+ * // Prints: <Buffer 61 61 61 61 61>
322
+ * ```
323
+ *
324
+ * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
325
+ * initialized by calling `buf.fill(fill, encoding)`.
326
+ *
327
+ * ```js
328
+ * import { Buffer } from 'buffer';
329
+ *
330
+ * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
331
+ *
332
+ * console.log(buf);
333
+ * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
334
+ * ```
335
+ *
336
+ * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
337
+ * contents will never contain sensitive data from previous allocations, including
338
+ * data that might not have been allocated for `Buffer`s.
339
+ *
340
+ * A `TypeError` will be thrown if `size` is not a number.
341
+ * @since v5.10.0
342
+ * @param size The desired length of the new `Buffer`.
343
+ * @param [fill=0] A value to pre-fill the new `Buffer` with.
344
+ * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
345
+ */
346
+ static alloc(
347
+ size: number,
348
+ fill?: string | Uint8Array | number,
349
+ encoding?: Encoding,
350
+ ): Buffer;
351
+ /**
352
+ * 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.
353
+ *
354
+ * The underlying memory for `Buffer` instances created in this way is _not_
355
+ * _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.
356
+ *
357
+ * ```js
358
+ * import { Buffer } from 'buffer';
359
+ *
360
+ * const buf = Buffer.allocUnsafe(10);
361
+ *
362
+ * console.log(buf);
363
+ * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
364
+ *
365
+ * buf.fill(0);
366
+ *
367
+ * console.log(buf);
368
+ * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
369
+ * ```
370
+ *
371
+ * A `TypeError` will be thrown if `size` is not a number.
372
+ *
373
+ * The `Buffer` module pre-allocates an internal `Buffer` instance of
374
+ * 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
375
+ * deprecated`new Buffer(size)` constructor only when `size` is less than or equal
376
+ * to `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
377
+ *
378
+ * Use of this pre-allocated internal memory pool is a key difference between
379
+ * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
380
+ * 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
381
+ * than or equal to half `Buffer.poolSize`. The
382
+ * difference is subtle but can be important when an application requires the
383
+ * additional performance that `Buffer.allocUnsafe()` provides.
384
+ * @since v5.10.0
385
+ * @param size The desired length of the new `Buffer`.
386
+ */
387
+ static allocUnsafe(size: number): Buffer;
388
+ /**
389
+ * 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
390
+ * if `size` is 0.
391
+ *
392
+ * The underlying memory for `Buffer` instances created in this way is _not_
393
+ * _initialized_. The contents of the newly created `Buffer` are unknown and_may contain sensitive data_. Use `buf.fill(0)` to initialize
394
+ * such `Buffer` instances with zeroes.
395
+ *
396
+ * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
397
+ * allocations under 4 KB are sliced from a single pre-allocated `Buffer`. This
398
+ * allows applications to avoid the garbage collection overhead of creating many
399
+ * individually allocated `Buffer` instances. This approach improves both
400
+ * performance and memory usage by eliminating the need to track and clean up as
401
+ * many individual `ArrayBuffer` objects.
402
+ *
403
+ * However, in the case where a developer may need to retain a small chunk of
404
+ * memory from a pool for an indeterminate amount of time, it may be appropriate
405
+ * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
406
+ * then copying out the relevant bits.
407
+ *
408
+ * ```js
409
+ * import { Buffer } from 'buffer';
410
+ *
411
+ * // Need to keep around a few small chunks of memory.
412
+ * const store = [];
413
+ *
414
+ * socket.on('readable', () => {
415
+ * let data;
416
+ * while (null !== (data = readable.read())) {
417
+ * // Allocate for retained data.
418
+ * const sb = Buffer.allocUnsafeSlow(10);
419
+ *
420
+ * // Copy the data into the new allocation.
421
+ * data.copy(sb, 0, 0, 10);
422
+ *
423
+ * store.push(sb);
424
+ * }
425
+ * });
426
+ * ```
427
+ *
428
+ * A `TypeError` will be thrown if `size` is not a number.
429
+ * @since v5.12.0
430
+ * @param size The desired length of the new `Buffer`.
431
+ */
432
+ static allocUnsafeSlow(size: number): Buffer;
433
+ // /**
434
+ // * This is the size (in bytes) of pre-allocated internal `Buffer` instances used
435
+ // * for pooling. This value may be modified.
436
+ // * @since v0.11.3
437
+ // */
438
+ // static poolSize: number;
439
+
440
+ /**
441
+ * 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
442
+ * not contain enough space to fit the entire string, only part of `string` will be
443
+ * written. However, partially encoded characters will not be written.
444
+ *
445
+ * ```js
446
+ * import { Buffer } from 'buffer';
447
+ *
448
+ * const buf = Buffer.alloc(256);
449
+ *
450
+ * const len = buf.write('\u00bd + \u00bc = \u00be', 0);
451
+ *
452
+ * console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
453
+ * // Prints: 12 bytes: ½ + ¼ = ¾
454
+ *
455
+ * const buffer = Buffer.alloc(10);
456
+ *
457
+ * const length = buffer.write('abcd', 8);
458
+ *
459
+ * console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
460
+ * // Prints: 2 bytes : ab
461
+ * ```
462
+ * @since v0.1.90
463
+ * @param string String to write to `buf`.
464
+ * @param [offset=0] Number of bytes to skip before starting to write `string`.
465
+ * @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
466
+ * @param [encoding='utf8'] The character encoding of `string`.
467
+ * @return Number of bytes written.
468
+ */
469
+ write(string: string, encoding?: Encoding): number;
470
+ write(string: string, offset: number, encoding?: Encoding): number;
471
+ write(
472
+ string: string,
473
+ offset: number,
474
+ length: number,
475
+ encoding?: Encoding,
476
+ ): number;
477
+ /**
478
+ * 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`.
479
+ *
480
+ * If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
481
+ * then each invalid byte is replaced with the replacement character `U+FFFD`.
482
+ *
483
+ * The maximum length of a string instance (in UTF-16 code units) is available
484
+ * as {@link constants.MAX_STRING_LENGTH}.
485
+ *
486
+ * ```js
487
+ * import { Buffer } from 'buffer';
488
+ *
489
+ * const buf1 = Buffer.allocUnsafe(26);
490
+ *
491
+ * for (let i = 0; i < 26; i++) {
492
+ * // 97 is the decimal ASCII value for 'a'.
493
+ * buf1[i] = i + 97;
494
+ * }
495
+ *
496
+ * console.log(buf1.toString('utf8'));
497
+ * // Prints: abcdefghijklmnopqrstuvwxyz
498
+ * console.log(buf1.toString('utf8', 0, 5));
499
+ * // Prints: abcde
500
+ *
501
+ * const buf2 = Buffer.from('tést');
502
+ *
503
+ * console.log(buf2.toString('hex'));
504
+ * // Prints: 74c3a97374
505
+ * console.log(buf2.toString('utf8', 0, 3));
506
+ * // Prints: té
507
+ * console.log(buf2.toString(undefined, 0, 3));
508
+ * // Prints: té
509
+ * ```
510
+ * @since v0.1.90
511
+ * @param [encoding='utf8'] The character encoding to use.
512
+ * @param [start=0] The byte offset to start decoding at.
513
+ * @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
514
+ */
515
+ toString(encoding?: Encoding, start?: number, end?: number): string;
516
+ /**
517
+ * Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls
518
+ * this function when stringifying a `Buffer` instance.
519
+ *
520
+ * `Buffer.from()` accepts objects in the format returned from this method.
521
+ * In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
522
+ *
523
+ * ```js
524
+ * import { Buffer } from 'buffer';
525
+ *
526
+ * const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
527
+ * const json = JSON.stringify(buf);
528
+ *
529
+ * console.log(json);
530
+ * // Prints: {"type":"Buffer","data":[1,2,3,4,5]}
531
+ *
532
+ * const copy = JSON.parse(json, (key, value) => {
533
+ * return value &#x26;&#x26; value.type === 'Buffer' ?
534
+ * Buffer.from(value) :
535
+ * value;
536
+ * });
537
+ *
538
+ * console.log(copy);
539
+ * // Prints: <Buffer 01 02 03 04 05>
540
+ * ```
541
+ * @since v0.9.2
542
+ */
543
+ toJSON(): {
544
+ type: "Buffer";
545
+ data: number[];
546
+ };
547
+ /**
548
+ * Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
549
+ *
550
+ * ```js
551
+ * import { Buffer } from 'buffer';
552
+ *
553
+ * const buf1 = Buffer.from('ABC');
554
+ * const buf2 = Buffer.from('414243', 'hex');
555
+ * const buf3 = Buffer.from('ABCD');
556
+ *
557
+ * console.log(buf1.equals(buf2));
558
+ * // Prints: true
559
+ * console.log(buf1.equals(buf3));
560
+ * // Prints: false
561
+ * ```
562
+ * @since v0.11.13
563
+ * @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.
564
+ */
565
+ equals(otherBuffer: Uint8Array): boolean;
566
+ /**
567
+ * Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.
568
+ * Comparison is based on the actual sequence of bytes in each `Buffer`.
569
+ *
570
+ * * `0` is returned if `target` is the same as `buf`
571
+ * * `1` is returned if `target` should come _before_`buf` when sorted.
572
+ * * `-1` is returned if `target` should come _after_`buf` when sorted.
573
+ *
574
+ * ```js
575
+ * import { Buffer } from 'buffer';
576
+ *
577
+ * const buf1 = Buffer.from('ABC');
578
+ * const buf2 = Buffer.from('BCD');
579
+ * const buf3 = Buffer.from('ABCD');
580
+ *
581
+ * console.log(buf1.compare(buf1));
582
+ * // Prints: 0
583
+ * console.log(buf1.compare(buf2));
584
+ * // Prints: -1
585
+ * console.log(buf1.compare(buf3));
586
+ * // Prints: -1
587
+ * console.log(buf2.compare(buf1));
588
+ * // Prints: 1
589
+ * console.log(buf2.compare(buf3));
590
+ * // Prints: 1
591
+ * console.log([buf1, buf2, buf3].sort(Buffer.compare));
592
+ * // Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]
593
+ * // (This result is equal to: [buf1, buf3, buf2].)
594
+ * ```
595
+ *
596
+ * The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd`arguments can be used to limit the comparison to specific ranges within `target`and `buf` respectively.
597
+ *
598
+ * ```js
599
+ * import { Buffer } from 'buffer';
600
+ *
601
+ * const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
602
+ * const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
603
+ *
604
+ * console.log(buf1.compare(buf2, 5, 9, 0, 4));
605
+ * // Prints: 0
606
+ * console.log(buf1.compare(buf2, 0, 6, 4));
607
+ * // Prints: -1
608
+ * console.log(buf1.compare(buf2, 5, 6, 5));
609
+ * // Prints: 1
610
+ * ```
611
+ *
612
+ * `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`,`targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
613
+ * @since v0.11.13
614
+ * @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
615
+ * @param [targetStart=0] The offset within `target` at which to begin comparison.
616
+ * @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).
617
+ * @param [sourceStart=0] The offset within `buf` at which to begin comparison.
618
+ * @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
619
+ */
620
+ compare(
621
+ target: Uint8Array,
622
+ targetStart?: number,
623
+ targetEnd?: number,
624
+ sourceStart?: number,
625
+ sourceEnd?: number,
626
+ ): number;
627
+ /**
628
+ * Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
629
+ *
630
+ * [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
631
+ * for all TypedArrays, including Node.js `Buffer`s, although it takes
632
+ * different function arguments.
633
+ *
634
+ * ```js
635
+ * import { Buffer } from 'buffer';
636
+ *
637
+ * // Create two `Buffer` instances.
638
+ * const buf1 = Buffer.allocUnsafe(26);
639
+ * const buf2 = Buffer.allocUnsafe(26).fill('!');
640
+ *
641
+ * for (let i = 0; i < 26; i++) {
642
+ * // 97 is the decimal ASCII value for 'a'.
643
+ * buf1[i] = i + 97;
644
+ * }
645
+ *
646
+ * // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
647
+ * buf1.copy(buf2, 8, 16, 20);
648
+ * // This is equivalent to:
649
+ * // buf2.set(buf1.subarray(16, 20), 8);
650
+ *
651
+ * console.log(buf2.toString('ascii', 0, 25));
652
+ * // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
653
+ * ```
654
+ *
655
+ * ```js
656
+ * import { Buffer } from 'buffer';
657
+ *
658
+ * // Create a `Buffer` and copy data from one region to an overlapping region
659
+ * // within the same `Buffer`.
660
+ *
661
+ * const buf = Buffer.allocUnsafe(26);
662
+ *
663
+ * for (let i = 0; i < 26; i++) {
664
+ * // 97 is the decimal ASCII value for 'a'.
665
+ * buf[i] = i + 97;
666
+ * }
667
+ *
668
+ * buf.copy(buf, 0, 4, 10);
669
+ *
670
+ * console.log(buf.toString());
671
+ * // Prints: efghijghijklmnopqrstuvwxyz
672
+ * ```
673
+ * @since v0.1.90
674
+ * @param target A `Buffer` or {@link Uint8Array} to copy into.
675
+ * @param [targetStart=0] The offset within `target` at which to begin writing.
676
+ * @param [sourceStart=0] The offset within `buf` from which to begin copying.
677
+ * @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
678
+ * @return The number of bytes copied.
679
+ */
680
+ copy(
681
+ target: Uint8Array,
682
+ targetStart?: number,
683
+ sourceStart?: number,
684
+ sourceEnd?: number,
685
+ ): number;
686
+ /**
687
+ * Returns a new `Buffer` that references the same memory as the original, but
688
+ * offset and cropped by the `start` and `end` indices.
689
+ *
690
+ * This is the same behavior as `buf.subarray()`.
691
+ *
692
+ * This method is not compatible with the `Uint8Array.prototype.slice()`,
693
+ * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
694
+ *
695
+ * ```js
696
+ * import { Buffer } from 'buffer';
697
+ *
698
+ * const buf = Buffer.from('buffer');
699
+ *
700
+ * const copiedBuf = Uint8Array.prototype.slice.call(buf);
701
+ * copiedBuf[0]++;
702
+ * console.log(copiedBuf.toString());
703
+ * // Prints: cuffer
704
+ *
705
+ * console.log(buf.toString());
706
+ * // Prints: buffer
707
+ * ```
708
+ * @since v0.3.0
709
+ * @param [start=0] Where the new `Buffer` will start.
710
+ * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
711
+ */
712
+ slice(start?: number, end?: number): Buffer;
713
+ /**
714
+ * Returns a new `Buffer` that references the same memory as the original, but
715
+ * offset and cropped by the `start` and `end` indices.
716
+ *
717
+ * Specifying `end` greater than `buf.length` will return the same result as
718
+ * that of `end` equal to `buf.length`.
719
+ *
720
+ * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
721
+ *
722
+ * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
723
+ *
724
+ * ```js
725
+ * import { Buffer } from 'buffer';
726
+ *
727
+ * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
728
+ * // from the original `Buffer`.
729
+ *
730
+ * const buf1 = Buffer.allocUnsafe(26);
731
+ *
732
+ * for (let i = 0; i < 26; i++) {
733
+ * // 97 is the decimal ASCII value for 'a'.
734
+ * buf1[i] = i + 97;
735
+ * }
736
+ *
737
+ * const buf2 = buf1.subarray(0, 3);
738
+ *
739
+ * console.log(buf2.toString('ascii', 0, buf2.length));
740
+ * // Prints: abc
741
+ *
742
+ * buf1[0] = 33;
743
+ *
744
+ * console.log(buf2.toString('ascii', 0, buf2.length));
745
+ * // Prints: !bc
746
+ * ```
747
+ *
748
+ * Specifying negative indexes causes the slice to be generated relative to the
749
+ * end of `buf` rather than the beginning.
750
+ *
751
+ * ```js
752
+ * import { Buffer } from 'buffer';
753
+ *
754
+ * const buf = Buffer.from('buffer');
755
+ *
756
+ * console.log(buf.subarray(-6, -1).toString());
757
+ * // Prints: buffe
758
+ * // (Equivalent to buf.subarray(0, 5).)
759
+ *
760
+ * console.log(buf.subarray(-6, -2).toString());
761
+ * // Prints: buff
762
+ * // (Equivalent to buf.subarray(0, 4).)
763
+ *
764
+ * console.log(buf.subarray(-5, -2).toString());
765
+ * // Prints: uff
766
+ * // (Equivalent to buf.subarray(1, 4).)
767
+ * ```
768
+ * @since v3.0.0
769
+ * @param [start=0] Where the new `Buffer` will start.
770
+ * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
771
+ */
772
+ subarray(start?: number, end?: number): Buffer;
773
+ /**
774
+ * Writes `value` to `buf` at the specified `offset` as big-endian.
775
+ *
776
+ * `value` is interpreted and written as a two's complement signed integer.
777
+ *
778
+ * ```js
779
+ * import { Buffer } from 'buffer';
780
+ *
781
+ * const buf = Buffer.allocUnsafe(8);
782
+ *
783
+ * buf.writeBigInt64BE(0x0102030405060708n, 0);
784
+ *
785
+ * console.log(buf);
786
+ * // Prints: <Buffer 01 02 03 04 05 06 07 08>
787
+ * ```
788
+ * @since v12.0.0, v10.20.0
789
+ * @param value Number to be written to `buf`.
790
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
791
+ * @return `offset` plus the number of bytes written.
792
+ */
793
+ writeBigInt64BE(value: bigint, offset?: number): number;
794
+ /**
795
+ * Writes `value` to `buf` at the specified `offset` as little-endian.
796
+ *
797
+ * `value` is interpreted and written as a two's complement signed integer.
798
+ *
799
+ * ```js
800
+ * import { Buffer } from 'buffer';
801
+ *
802
+ * const buf = Buffer.allocUnsafe(8);
803
+ *
804
+ * buf.writeBigInt64LE(0x0102030405060708n, 0);
805
+ *
806
+ * console.log(buf);
807
+ * // Prints: <Buffer 08 07 06 05 04 03 02 01>
808
+ * ```
809
+ * @since v12.0.0, v10.20.0
810
+ * @param value Number to be written to `buf`.
811
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
812
+ * @return `offset` plus the number of bytes written.
813
+ */
814
+ writeBigInt64LE(value: bigint, offset?: number): number;
815
+ /**
816
+ * Writes `value` to `buf` at the specified `offset` as big-endian.
817
+ *
818
+ * This function is also available under the `writeBigUint64BE` alias.
819
+ *
820
+ * ```js
821
+ * import { Buffer } from 'buffer';
822
+ *
823
+ * const buf = Buffer.allocUnsafe(8);
824
+ *
825
+ * buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
826
+ *
827
+ * console.log(buf);
828
+ * // Prints: <Buffer de ca fa fe ca ce fa de>
829
+ * ```
830
+ * @since v12.0.0, v10.20.0
831
+ * @param value Number to be written to `buf`.
832
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
833
+ * @return `offset` plus the number of bytes written.
834
+ */
835
+ writeBigUInt64BE(value: bigint, offset?: number): number;
836
+ /**
837
+ * Writes `value` to `buf` at the specified `offset` as little-endian
838
+ *
839
+ * ```js
840
+ * import { Buffer } from 'buffer';
841
+ *
842
+ * const buf = Buffer.allocUnsafe(8);
843
+ *
844
+ * buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
845
+ *
846
+ * console.log(buf);
847
+ * // Prints: <Buffer de fa ce ca fe fa ca de>
848
+ * ```
849
+ *
850
+ * This function is also available under the `writeBigUint64LE` alias.
851
+ * @since v12.0.0, v10.20.0
852
+ * @param value Number to be written to `buf`.
853
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
854
+ * @return `offset` plus the number of bytes written.
855
+ */
856
+ writeBigUInt64LE(value: bigint, offset?: number): number;
857
+ /**
858
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
859
+ * when `value` is anything other than an unsigned integer.
860
+ *
861
+ * This function is also available under the `writeUintLE` alias.
862
+ *
863
+ * ```js
864
+ * import { Buffer } from 'buffer';
865
+ *
866
+ * const buf = Buffer.allocUnsafe(6);
867
+ *
868
+ * buf.writeUIntLE(0x1234567890ab, 0, 6);
869
+ *
870
+ * console.log(buf);
871
+ * // Prints: <Buffer ab 90 78 56 34 12>
872
+ * ```
873
+ * @since v0.5.5
874
+ * @param value Number to be written to `buf`.
875
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
876
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
877
+ * @return `offset` plus the number of bytes written.
878
+ */
879
+ writeUIntLE(value: number, offset: number, byteLength: number): number;
880
+ /**
881
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
882
+ * when `value` is anything other than an unsigned integer.
883
+ *
884
+ * This function is also available under the `writeUintBE` alias.
885
+ *
886
+ * ```js
887
+ * import { Buffer } from 'buffer';
888
+ *
889
+ * const buf = Buffer.allocUnsafe(6);
890
+ *
891
+ * buf.writeUIntBE(0x1234567890ab, 0, 6);
892
+ *
893
+ * console.log(buf);
894
+ * // Prints: <Buffer 12 34 56 78 90 ab>
895
+ * ```
896
+ * @since v0.5.5
897
+ * @param value Number to be written to `buf`.
898
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
899
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
900
+ * @return `offset` plus the number of bytes written.
901
+ */
902
+ writeUIntBE(value: number, offset: number, byteLength: number): number;
903
+ /**
904
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
905
+ * when `value` is anything other than a signed integer.
906
+ *
907
+ * ```js
908
+ * import { Buffer } from 'buffer';
909
+ *
910
+ * const buf = Buffer.allocUnsafe(6);
911
+ *
912
+ * buf.writeIntLE(0x1234567890ab, 0, 6);
913
+ *
914
+ * console.log(buf);
915
+ * // Prints: <Buffer ab 90 78 56 34 12>
916
+ * ```
917
+ * @since v0.11.15
918
+ * @param value Number to be written to `buf`.
919
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
920
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
921
+ * @return `offset` plus the number of bytes written.
922
+ */
923
+ writeIntLE(value: number, offset: number, byteLength: number): number;
924
+ /**
925
+ * Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a
926
+ * signed integer.
927
+ *
928
+ * ```js
929
+ * import { Buffer } from 'buffer';
930
+ *
931
+ * const buf = Buffer.allocUnsafe(6);
932
+ *
933
+ * buf.writeIntBE(0x1234567890ab, 0, 6);
934
+ *
935
+ * console.log(buf);
936
+ * // Prints: <Buffer 12 34 56 78 90 ab>
937
+ * ```
938
+ * @since v0.11.15
939
+ * @param value Number to be written to `buf`.
940
+ * @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
941
+ * @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
942
+ * @return `offset` plus the number of bytes written.
943
+ */
944
+ writeIntBE(value: number, offset: number, byteLength: number): number;
945
+ /**
946
+ * Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
947
+ *
948
+ * This function is also available under the `readBigUint64BE` alias.
949
+ *
950
+ * ```js
951
+ * import { Buffer } from 'buffer';
952
+ *
953
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
954
+ *
955
+ * console.log(buf.readBigUInt64BE(0));
956
+ * // Prints: 4294967295n
957
+ * ```
958
+ * @since v12.0.0, v10.20.0
959
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
960
+ */
961
+ readBigUInt64BE(offset?: number): bigint;
962
+ /**
963
+ * Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
964
+ *
965
+ * This function is also available under the `readBigUint64LE` alias.
966
+ *
967
+ * ```js
968
+ * import { Buffer } from 'buffer';
969
+ *
970
+ * const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
971
+ *
972
+ * console.log(buf.readBigUInt64LE(0));
973
+ * // Prints: 18446744069414584320n
974
+ * ```
975
+ * @since v12.0.0, v10.20.0
976
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
977
+ */
978
+ readBigUInt64LE(offset?: number): bigint;
979
+ /**
980
+ * Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
981
+ *
982
+ * Integers read from a `Buffer` are interpreted as two's complement signed
983
+ * values.
984
+ * @since v12.0.0, v10.20.0
985
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
986
+ */
987
+ readBigInt64BE(offset?: number): bigint;
988
+ /**
989
+ * Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
990
+ *
991
+ * Integers read from a `Buffer` are interpreted as two's complement signed
992
+ * values.
993
+ * @since v12.0.0, v10.20.0
994
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
995
+ */
996
+ readBigInt64LE(offset?: number): bigint;
997
+ /**
998
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned, little-endian integer supporting
999
+ * up to 48 bits of accuracy.
1000
+ *
1001
+ * This function is also available under the `readUintLE` alias.
1002
+ *
1003
+ * ```js
1004
+ * import { Buffer } from 'buffer';
1005
+ *
1006
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1007
+ *
1008
+ * console.log(buf.readUIntLE(0, 6).toString(16));
1009
+ * // Prints: ab9078563412
1010
+ * ```
1011
+ * @since v0.11.15
1012
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
1013
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
1014
+ */
1015
+ readUIntLE(offset: number, byteLength: number): number;
1016
+ /**
1017
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as an unsigned big-endian integer supporting
1018
+ * up to 48 bits of accuracy.
1019
+ *
1020
+ * This function is also available under the `readUintBE` alias.
1021
+ *
1022
+ * ```js
1023
+ * import { Buffer } from 'buffer';
1024
+ *
1025
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1026
+ *
1027
+ * console.log(buf.readUIntBE(0, 6).toString(16));
1028
+ * // Prints: 1234567890ab
1029
+ * console.log(buf.readUIntBE(1, 6).toString(16));
1030
+ * // Throws ERR_OUT_OF_RANGE.
1031
+ * ```
1032
+ * @since v0.11.15
1033
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
1034
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
1035
+ */
1036
+ readUIntBE(offset: number, byteLength: number): number;
1037
+ /**
1038
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a little-endian, two's complement signed value
1039
+ * supporting up to 48 bits of accuracy.
1040
+ *
1041
+ * ```js
1042
+ * import { Buffer } from 'buffer';
1043
+ *
1044
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1045
+ *
1046
+ * console.log(buf.readIntLE(0, 6).toString(16));
1047
+ * // Prints: -546f87a9cbee
1048
+ * ```
1049
+ * @since v0.11.15
1050
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
1051
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
1052
+ */
1053
+ readIntLE(offset: number, byteLength: number): number;
1054
+ /**
1055
+ * Reads `byteLength` number of bytes from `buf` at the specified `offset`and interprets the result as a big-endian, two's complement signed value
1056
+ * supporting up to 48 bits of accuracy.
1057
+ *
1058
+ * ```js
1059
+ * import { Buffer } from 'buffer';
1060
+ *
1061
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
1062
+ *
1063
+ * console.log(buf.readIntBE(0, 6).toString(16));
1064
+ * // Prints: 1234567890ab
1065
+ * console.log(buf.readIntBE(1, 6).toString(16));
1066
+ * // Throws ERR_OUT_OF_RANGE.
1067
+ * console.log(buf.readIntBE(1, 0).toString(16));
1068
+ * // Throws ERR_OUT_OF_RANGE.
1069
+ * ```
1070
+ * @since v0.11.15
1071
+ * @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
1072
+ * @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
1073
+ */
1074
+ readIntBE(offset: number, byteLength: number): number;
1075
+ /**
1076
+ * Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
1077
+ *
1078
+ * This function is also available under the `readUint8` alias.
1079
+ *
1080
+ * ```js
1081
+ * import { Buffer } from 'buffer';
1082
+ *
1083
+ * const buf = Buffer.from([1, -2]);
1084
+ *
1085
+ * console.log(buf.readUInt8(0));
1086
+ * // Prints: 1
1087
+ * console.log(buf.readUInt8(1));
1088
+ * // Prints: 254
1089
+ * console.log(buf.readUInt8(2));
1090
+ * // Throws ERR_OUT_OF_RANGE.
1091
+ * ```
1092
+ * @since v0.5.0
1093
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
1094
+ */
1095
+ readUInt8(offset?: number): number;
1096
+ /**
1097
+ * Reads an unsigned, little-endian 16-bit integer from `buf` at the specified`offset`.
1098
+ *
1099
+ * This function is also available under the `readUint16LE` alias.
1100
+ *
1101
+ * ```js
1102
+ * import { Buffer } from 'buffer';
1103
+ *
1104
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
1105
+ *
1106
+ * console.log(buf.readUInt16LE(0).toString(16));
1107
+ * // Prints: 3412
1108
+ * console.log(buf.readUInt16LE(1).toString(16));
1109
+ * // Prints: 5634
1110
+ * console.log(buf.readUInt16LE(2).toString(16));
1111
+ * // Throws ERR_OUT_OF_RANGE.
1112
+ * ```
1113
+ * @since v0.5.5
1114
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1115
+ */
1116
+ readUInt16LE(offset?: number): number;
1117
+ /**
1118
+ * Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
1119
+ *
1120
+ * This function is also available under the `readUint16BE` alias.
1121
+ *
1122
+ * ```js
1123
+ * import { Buffer } from 'buffer';
1124
+ *
1125
+ * const buf = Buffer.from([0x12, 0x34, 0x56]);
1126
+ *
1127
+ * console.log(buf.readUInt16BE(0).toString(16));
1128
+ * // Prints: 1234
1129
+ * console.log(buf.readUInt16BE(1).toString(16));
1130
+ * // Prints: 3456
1131
+ * ```
1132
+ * @since v0.5.5
1133
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1134
+ */
1135
+ readUInt16BE(offset?: number): number;
1136
+ /**
1137
+ * Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
1138
+ *
1139
+ * This function is also available under the `readUint32LE` alias.
1140
+ *
1141
+ * ```js
1142
+ * import { Buffer } from 'buffer';
1143
+ *
1144
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
1145
+ *
1146
+ * console.log(buf.readUInt32LE(0).toString(16));
1147
+ * // Prints: 78563412
1148
+ * console.log(buf.readUInt32LE(1).toString(16));
1149
+ * // Throws ERR_OUT_OF_RANGE.
1150
+ * ```
1151
+ * @since v0.5.5
1152
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1153
+ */
1154
+ readUInt32LE(offset?: number): number;
1155
+ /**
1156
+ * Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.
1157
+ *
1158
+ * This function is also available under the `readUint32BE` alias.
1159
+ *
1160
+ * ```js
1161
+ * import { Buffer } from 'buffer';
1162
+ *
1163
+ * const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
1164
+ *
1165
+ * console.log(buf.readUInt32BE(0).toString(16));
1166
+ * // Prints: 12345678
1167
+ * ```
1168
+ * @since v0.5.5
1169
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1170
+ */
1171
+ readUInt32BE(offset?: number): number;
1172
+ /**
1173
+ * Reads a signed 8-bit integer from `buf` at the specified `offset`.
1174
+ *
1175
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
1176
+ *
1177
+ * ```js
1178
+ * import { Buffer } from 'buffer';
1179
+ *
1180
+ * const buf = Buffer.from([-1, 5]);
1181
+ *
1182
+ * console.log(buf.readInt8(0));
1183
+ * // Prints: -1
1184
+ * console.log(buf.readInt8(1));
1185
+ * // Prints: 5
1186
+ * console.log(buf.readInt8(2));
1187
+ * // Throws ERR_OUT_OF_RANGE.
1188
+ * ```
1189
+ * @since v0.5.0
1190
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
1191
+ */
1192
+ readInt8(offset?: number): number;
1193
+ /**
1194
+ * Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
1195
+ *
1196
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
1197
+ *
1198
+ * ```js
1199
+ * import { Buffer } from 'buffer';
1200
+ *
1201
+ * const buf = Buffer.from([0, 5]);
1202
+ *
1203
+ * console.log(buf.readInt16LE(0));
1204
+ * // Prints: 1280
1205
+ * console.log(buf.readInt16LE(1));
1206
+ * // Throws ERR_OUT_OF_RANGE.
1207
+ * ```
1208
+ * @since v0.5.5
1209
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1210
+ */
1211
+ readInt16LE(offset?: number): number;
1212
+ /**
1213
+ * Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
1214
+ *
1215
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
1216
+ *
1217
+ * ```js
1218
+ * import { Buffer } from 'buffer';
1219
+ *
1220
+ * const buf = Buffer.from([0, 5]);
1221
+ *
1222
+ * console.log(buf.readInt16BE(0));
1223
+ * // Prints: 5
1224
+ * ```
1225
+ * @since v0.5.5
1226
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
1227
+ */
1228
+ readInt16BE(offset?: number): number;
1229
+ /**
1230
+ * Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
1231
+ *
1232
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
1233
+ *
1234
+ * ```js
1235
+ * import { Buffer } from 'buffer';
1236
+ *
1237
+ * const buf = Buffer.from([0, 0, 0, 5]);
1238
+ *
1239
+ * console.log(buf.readInt32LE(0));
1240
+ * // Prints: 83886080
1241
+ * console.log(buf.readInt32LE(1));
1242
+ * // Throws ERR_OUT_OF_RANGE.
1243
+ * ```
1244
+ * @since v0.5.5
1245
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1246
+ */
1247
+ readInt32LE(offset?: number): number;
1248
+ /**
1249
+ * Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
1250
+ *
1251
+ * Integers read from a `Buffer` are interpreted as two's complement signed values.
1252
+ *
1253
+ * ```js
1254
+ * import { Buffer } from 'buffer';
1255
+ *
1256
+ * const buf = Buffer.from([0, 0, 0, 5]);
1257
+ *
1258
+ * console.log(buf.readInt32BE(0));
1259
+ * // Prints: 5
1260
+ * ```
1261
+ * @since v0.5.5
1262
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1263
+ */
1264
+ readInt32BE(offset?: number): number;
1265
+ /**
1266
+ * Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
1267
+ *
1268
+ * ```js
1269
+ * import { Buffer } from 'buffer';
1270
+ *
1271
+ * const buf = Buffer.from([1, 2, 3, 4]);
1272
+ *
1273
+ * console.log(buf.readFloatLE(0));
1274
+ * // Prints: 1.539989614439558e-36
1275
+ * console.log(buf.readFloatLE(1));
1276
+ * // Throws ERR_OUT_OF_RANGE.
1277
+ * ```
1278
+ * @since v0.11.15
1279
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1280
+ */
1281
+ readFloatLE(offset?: number): number;
1282
+ /**
1283
+ * Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
1284
+ *
1285
+ * ```js
1286
+ * import { Buffer } from 'buffer';
1287
+ *
1288
+ * const buf = Buffer.from([1, 2, 3, 4]);
1289
+ *
1290
+ * console.log(buf.readFloatBE(0));
1291
+ * // Prints: 2.387939260590663e-38
1292
+ * ```
1293
+ * @since v0.11.15
1294
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
1295
+ */
1296
+ readFloatBE(offset?: number): number;
1297
+ /**
1298
+ * Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
1299
+ *
1300
+ * ```js
1301
+ * import { Buffer } from 'buffer';
1302
+ *
1303
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1304
+ *
1305
+ * console.log(buf.readDoubleLE(0));
1306
+ * // Prints: 5.447603722011605e-270
1307
+ * console.log(buf.readDoubleLE(1));
1308
+ * // Throws ERR_OUT_OF_RANGE.
1309
+ * ```
1310
+ * @since v0.11.15
1311
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
1312
+ */
1313
+ readDoubleLE(offset?: number): number;
1314
+ /**
1315
+ * Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
1316
+ *
1317
+ * ```js
1318
+ * import { Buffer } from 'buffer';
1319
+ *
1320
+ * const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
1321
+ *
1322
+ * console.log(buf.readDoubleBE(0));
1323
+ * // Prints: 8.20788039913184e-304
1324
+ * ```
1325
+ * @since v0.11.15
1326
+ * @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
1327
+ */
1328
+ readDoubleBE(offset?: number): number;
1329
+ reverse(): this;
1330
+ /**
1331
+ * Interprets `buf` as an array of unsigned 16-bit integers and swaps the
1332
+ * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
1333
+ *
1334
+ * ```js
1335
+ * import { Buffer } from 'buffer';
1336
+ *
1337
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1338
+ *
1339
+ * console.log(buf1);
1340
+ * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1341
+ *
1342
+ * buf1.swap16();
1343
+ *
1344
+ * console.log(buf1);
1345
+ * // Prints: <Buffer 02 01 04 03 06 05 08 07>
1346
+ *
1347
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1348
+ *
1349
+ * buf2.swap16();
1350
+ * // Throws ERR_INVALID_BUFFER_SIZE.
1351
+ * ```
1352
+ *
1353
+ * One convenient use of `buf.swap16()` is to perform a fast in-place conversion
1354
+ * between UTF-16 little-endian and UTF-16 big-endian:
1355
+ *
1356
+ * ```js
1357
+ * import { Buffer } from 'buffer';
1358
+ *
1359
+ * const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
1360
+ * buf.swap16(); // Convert to big-endian UTF-16 text.
1361
+ * ```
1362
+ * @since v5.10.0
1363
+ * @return A reference to `buf`.
1364
+ */
1365
+ swap16(): Buffer;
1366
+ /**
1367
+ * Interprets `buf` as an array of unsigned 32-bit integers and swaps the
1368
+ * byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
1369
+ *
1370
+ * ```js
1371
+ * import { Buffer } from 'buffer';
1372
+ *
1373
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1374
+ *
1375
+ * console.log(buf1);
1376
+ * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1377
+ *
1378
+ * buf1.swap32();
1379
+ *
1380
+ * console.log(buf1);
1381
+ * // Prints: <Buffer 04 03 02 01 08 07 06 05>
1382
+ *
1383
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1384
+ *
1385
+ * buf2.swap32();
1386
+ * // Throws ERR_INVALID_BUFFER_SIZE.
1387
+ * ```
1388
+ * @since v5.10.0
1389
+ * @return A reference to `buf`.
1390
+ */
1391
+ swap32(): Buffer;
1392
+ /**
1393
+ * Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
1394
+ * Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
1395
+ *
1396
+ * ```js
1397
+ * import { Buffer } from 'buffer';
1398
+ *
1399
+ * const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
1400
+ *
1401
+ * console.log(buf1);
1402
+ * // Prints: <Buffer 01 02 03 04 05 06 07 08>
1403
+ *
1404
+ * buf1.swap64();
1405
+ *
1406
+ * console.log(buf1);
1407
+ * // Prints: <Buffer 08 07 06 05 04 03 02 01>
1408
+ *
1409
+ * const buf2 = Buffer.from([0x1, 0x2, 0x3]);
1410
+ *
1411
+ * buf2.swap64();
1412
+ * // Throws ERR_INVALID_BUFFER_SIZE.
1413
+ * ```
1414
+ * @since v6.3.0
1415
+ * @return A reference to `buf`.
1416
+ */
1417
+ swap64(): Buffer;
1418
+ /**
1419
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a
1420
+ * valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
1421
+ * other than an unsigned 8-bit integer.
1422
+ *
1423
+ * This function is also available under the `writeUint8` alias.
1424
+ *
1425
+ * ```js
1426
+ * import { Buffer } from 'buffer';
1427
+ *
1428
+ * const buf = Buffer.allocUnsafe(4);
1429
+ *
1430
+ * buf.writeUInt8(0x3, 0);
1431
+ * buf.writeUInt8(0x4, 1);
1432
+ * buf.writeUInt8(0x23, 2);
1433
+ * buf.writeUInt8(0x42, 3);
1434
+ *
1435
+ * console.log(buf);
1436
+ * // Prints: <Buffer 03 04 23 42>
1437
+ * ```
1438
+ * @since v0.5.0
1439
+ * @param value Number to be written to `buf`.
1440
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
1441
+ * @return `offset` plus the number of bytes written.
1442
+ */
1443
+ writeUInt8(value: number, offset?: number): number;
1444
+ /**
1445
+ * 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
1446
+ * anything other than an unsigned 16-bit integer.
1447
+ *
1448
+ * This function is also available under the `writeUint16LE` alias.
1449
+ *
1450
+ * ```js
1451
+ * import { Buffer } from 'buffer';
1452
+ *
1453
+ * const buf = Buffer.allocUnsafe(4);
1454
+ *
1455
+ * buf.writeUInt16LE(0xdead, 0);
1456
+ * buf.writeUInt16LE(0xbeef, 2);
1457
+ *
1458
+ * console.log(buf);
1459
+ * // Prints: <Buffer ad de ef be>
1460
+ * ```
1461
+ * @since v0.5.5
1462
+ * @param value Number to be written to `buf`.
1463
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1464
+ * @return `offset` plus the number of bytes written.
1465
+ */
1466
+ writeUInt16LE(value: number, offset?: number): number;
1467
+ /**
1468
+ * 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
1469
+ * unsigned 16-bit integer.
1470
+ *
1471
+ * This function is also available under the `writeUint16BE` alias.
1472
+ *
1473
+ * ```js
1474
+ * import { Buffer } from 'buffer';
1475
+ *
1476
+ * const buf = Buffer.allocUnsafe(4);
1477
+ *
1478
+ * buf.writeUInt16BE(0xdead, 0);
1479
+ * buf.writeUInt16BE(0xbeef, 2);
1480
+ *
1481
+ * console.log(buf);
1482
+ * // Prints: <Buffer de ad be ef>
1483
+ * ```
1484
+ * @since v0.5.5
1485
+ * @param value Number to be written to `buf`.
1486
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1487
+ * @return `offset` plus the number of bytes written.
1488
+ */
1489
+ writeUInt16BE(value: number, offset?: number): number;
1490
+ /**
1491
+ * 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
1492
+ * anything other than an unsigned 32-bit integer.
1493
+ *
1494
+ * This function is also available under the `writeUint32LE` alias.
1495
+ *
1496
+ * ```js
1497
+ * import { Buffer } from 'buffer';
1498
+ *
1499
+ * const buf = Buffer.allocUnsafe(4);
1500
+ *
1501
+ * buf.writeUInt32LE(0xfeedface, 0);
1502
+ *
1503
+ * console.log(buf);
1504
+ * // Prints: <Buffer ce fa ed fe>
1505
+ * ```
1506
+ * @since v0.5.5
1507
+ * @param value Number to be written to `buf`.
1508
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1509
+ * @return `offset` plus the number of bytes written.
1510
+ */
1511
+ writeUInt32LE(value: number, offset?: number): number;
1512
+ /**
1513
+ * 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
1514
+ * unsigned 32-bit integer.
1515
+ *
1516
+ * This function is also available under the `writeUint32BE` alias.
1517
+ *
1518
+ * ```js
1519
+ * import { Buffer } from 'buffer';
1520
+ *
1521
+ * const buf = Buffer.allocUnsafe(4);
1522
+ *
1523
+ * buf.writeUInt32BE(0xfeedface, 0);
1524
+ *
1525
+ * console.log(buf);
1526
+ * // Prints: <Buffer fe ed fa ce>
1527
+ * ```
1528
+ * @since v0.5.5
1529
+ * @param value Number to be written to `buf`.
1530
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1531
+ * @return `offset` plus the number of bytes written.
1532
+ */
1533
+ writeUInt32BE(value: number, offset?: number): number;
1534
+ /**
1535
+ * Writes `value` to `buf` at the specified `offset`. `value` must be a valid
1536
+ * signed 8-bit integer. Behavior is undefined when `value` is anything other than
1537
+ * a signed 8-bit integer.
1538
+ *
1539
+ * `value` is interpreted and written as a two's complement signed integer.
1540
+ *
1541
+ * ```js
1542
+ * import { Buffer } from 'buffer';
1543
+ *
1544
+ * const buf = Buffer.allocUnsafe(2);
1545
+ *
1546
+ * buf.writeInt8(2, 0);
1547
+ * buf.writeInt8(-2, 1);
1548
+ *
1549
+ * console.log(buf);
1550
+ * // Prints: <Buffer 02 fe>
1551
+ * ```
1552
+ * @since v0.5.0
1553
+ * @param value Number to be written to `buf`.
1554
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
1555
+ * @return `offset` plus the number of bytes written.
1556
+ */
1557
+ writeInt8(value: number, offset?: number): number;
1558
+ /**
1559
+ * 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
1560
+ * anything other than a signed 16-bit integer.
1561
+ *
1562
+ * The `value` is interpreted and written as a two's complement signed integer.
1563
+ *
1564
+ * ```js
1565
+ * import { Buffer } from 'buffer';
1566
+ *
1567
+ * const buf = Buffer.allocUnsafe(2);
1568
+ *
1569
+ * buf.writeInt16LE(0x0304, 0);
1570
+ *
1571
+ * console.log(buf);
1572
+ * // Prints: <Buffer 04 03>
1573
+ * ```
1574
+ * @since v0.5.5
1575
+ * @param value Number to be written to `buf`.
1576
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1577
+ * @return `offset` plus the number of bytes written.
1578
+ */
1579
+ writeInt16LE(value: number, offset?: number): number;
1580
+ /**
1581
+ * 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
1582
+ * anything other than a signed 16-bit integer.
1583
+ *
1584
+ * The `value` is interpreted and written as a two's complement signed integer.
1585
+ *
1586
+ * ```js
1587
+ * import { Buffer } from 'buffer';
1588
+ *
1589
+ * const buf = Buffer.allocUnsafe(2);
1590
+ *
1591
+ * buf.writeInt16BE(0x0102, 0);
1592
+ *
1593
+ * console.log(buf);
1594
+ * // Prints: <Buffer 01 02>
1595
+ * ```
1596
+ * @since v0.5.5
1597
+ * @param value Number to be written to `buf`.
1598
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
1599
+ * @return `offset` plus the number of bytes written.
1600
+ */
1601
+ writeInt16BE(value: number, offset?: number): number;
1602
+ /**
1603
+ * 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
1604
+ * anything other than a signed 32-bit integer.
1605
+ *
1606
+ * The `value` is interpreted and written as a two's complement signed integer.
1607
+ *
1608
+ * ```js
1609
+ * import { Buffer } from 'buffer';
1610
+ *
1611
+ * const buf = Buffer.allocUnsafe(4);
1612
+ *
1613
+ * buf.writeInt32LE(0x05060708, 0);
1614
+ *
1615
+ * console.log(buf);
1616
+ * // Prints: <Buffer 08 07 06 05>
1617
+ * ```
1618
+ * @since v0.5.5
1619
+ * @param value Number to be written to `buf`.
1620
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1621
+ * @return `offset` plus the number of bytes written.
1622
+ */
1623
+ writeInt32LE(value: number, offset?: number): number;
1624
+ /**
1625
+ * 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
1626
+ * anything other than a signed 32-bit integer.
1627
+ *
1628
+ * The `value` is interpreted and written as a two's complement signed integer.
1629
+ *
1630
+ * ```js
1631
+ * import { Buffer } from 'buffer';
1632
+ *
1633
+ * const buf = Buffer.allocUnsafe(4);
1634
+ *
1635
+ * buf.writeInt32BE(0x01020304, 0);
1636
+ *
1637
+ * console.log(buf);
1638
+ * // Prints: <Buffer 01 02 03 04>
1639
+ * ```
1640
+ * @since v0.5.5
1641
+ * @param value Number to be written to `buf`.
1642
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1643
+ * @return `offset` plus the number of bytes written.
1644
+ */
1645
+ writeInt32BE(value: number, offset?: number): number;
1646
+ /**
1647
+ * Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
1648
+ * undefined when `value` is anything other than a JavaScript number.
1649
+ *
1650
+ * ```js
1651
+ * import { Buffer } from 'buffer';
1652
+ *
1653
+ * const buf = Buffer.allocUnsafe(4);
1654
+ *
1655
+ * buf.writeFloatLE(0xcafebabe, 0);
1656
+ *
1657
+ * console.log(buf);
1658
+ * // Prints: <Buffer bb fe 4a 4f>
1659
+ * ```
1660
+ * @since v0.11.15
1661
+ * @param value Number to be written to `buf`.
1662
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1663
+ * @return `offset` plus the number of bytes written.
1664
+ */
1665
+ writeFloatLE(value: number, offset?: number): number;
1666
+ /**
1667
+ * Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
1668
+ * undefined when `value` is anything other than a JavaScript number.
1669
+ *
1670
+ * ```js
1671
+ * import { Buffer } from 'buffer';
1672
+ *
1673
+ * const buf = Buffer.allocUnsafe(4);
1674
+ *
1675
+ * buf.writeFloatBE(0xcafebabe, 0);
1676
+ *
1677
+ * console.log(buf);
1678
+ * // Prints: <Buffer 4f 4a fe bb>
1679
+ * ```
1680
+ * @since v0.11.15
1681
+ * @param value Number to be written to `buf`.
1682
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
1683
+ * @return `offset` plus the number of bytes written.
1684
+ */
1685
+ writeFloatBE(value: number, offset?: number): number;
1686
+ /**
1687
+ * 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
1688
+ * other than a JavaScript number.
1689
+ *
1690
+ * ```js
1691
+ * import { Buffer } from 'buffer';
1692
+ *
1693
+ * const buf = Buffer.allocUnsafe(8);
1694
+ *
1695
+ * buf.writeDoubleLE(123.456, 0);
1696
+ *
1697
+ * console.log(buf);
1698
+ * // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
1699
+ * ```
1700
+ * @since v0.11.15
1701
+ * @param value Number to be written to `buf`.
1702
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1703
+ * @return `offset` plus the number of bytes written.
1704
+ */
1705
+ writeDoubleLE(value: number, offset?: number): number;
1706
+ /**
1707
+ * 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
1708
+ * other than a JavaScript number.
1709
+ *
1710
+ * ```js
1711
+ * import { Buffer } from 'buffer';
1712
+ *
1713
+ * const buf = Buffer.allocUnsafe(8);
1714
+ *
1715
+ * buf.writeDoubleBE(123.456, 0);
1716
+ *
1717
+ * console.log(buf);
1718
+ * // Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
1719
+ * ```
1720
+ * @since v0.11.15
1721
+ * @param value Number to be written to `buf`.
1722
+ * @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
1723
+ * @return `offset` plus the number of bytes written.
1724
+ */
1725
+ writeDoubleBE(value: number, offset?: number): number;
1726
+ /**
1727
+ * Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
1728
+ * the entire `buf` will be filled:
1729
+ *
1730
+ * ```js
1731
+ * import { Buffer } from 'buffer';
1732
+ *
1733
+ * // Fill a `Buffer` with the ASCII character 'h'.
1734
+ *
1735
+ * const b = Buffer.allocUnsafe(50).fill('h');
1736
+ *
1737
+ * console.log(b.toString());
1738
+ * // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
1739
+ * ```
1740
+ *
1741
+ * `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
1742
+ * integer. If the resulting integer is greater than `255` (decimal), `buf` will be
1743
+ * filled with `value &#x26; 255`.
1744
+ *
1745
+ * If the final write of a `fill()` operation falls on a multi-byte character,
1746
+ * then only the bytes of that character that fit into `buf` are written:
1747
+ *
1748
+ * ```js
1749
+ * import { Buffer } from 'buffer';
1750
+ *
1751
+ * // Fill a `Buffer` with character that takes up two bytes in UTF-8.
1752
+ *
1753
+ * console.log(Buffer.allocUnsafe(5).fill('\u0222'));
1754
+ * // Prints: <Buffer c8 a2 c8 a2 c8>
1755
+ * ```
1756
+ *
1757
+ * If `value` contains invalid characters, it is truncated; if no valid
1758
+ * fill data remains, an exception is thrown:
1759
+ *
1760
+ * ```js
1761
+ * import { Buffer } from 'buffer';
1762
+ *
1763
+ * const buf = Buffer.allocUnsafe(5);
1764
+ *
1765
+ * console.log(buf.fill('a'));
1766
+ * // Prints: <Buffer 61 61 61 61 61>
1767
+ * console.log(buf.fill('aazz', 'hex'));
1768
+ * // Prints: <Buffer aa aa aa aa aa>
1769
+ * console.log(buf.fill('zz', 'hex'));
1770
+ * // Throws an exception.
1771
+ * ```
1772
+ * @since v0.5.0
1773
+ * @param value The value with which to fill `buf`.
1774
+ * @param [offset=0] Number of bytes to skip before starting to fill `buf`.
1775
+ * @param [end=buf.length] Where to stop filling `buf` (not inclusive).
1776
+ * @param [encoding='utf8'] The encoding for `value` if `value` is a string.
1777
+ * @return A reference to `buf`.
1778
+ */
1779
+ fill(
1780
+ value: string | Uint8Array | number,
1781
+ offset?: number,
1782
+ end?: number,
1783
+ encoding?: Encoding,
1784
+ ): this;
1785
+ /**
1786
+ * If `value` is:
1787
+ *
1788
+ * * a string, `value` is interpreted according to the character encoding in`encoding`.
1789
+ * * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
1790
+ * To compare a partial `Buffer`, use `buf.slice()`.
1791
+ * * a number, `value` will be interpreted as an unsigned 8-bit integer
1792
+ * value between `0` and `255`.
1793
+ *
1794
+ * ```js
1795
+ * import { Buffer } from 'buffer';
1796
+ *
1797
+ * const buf = Buffer.from('this is a buffer');
1798
+ *
1799
+ * console.log(buf.indexOf('this'));
1800
+ * // Prints: 0
1801
+ * console.log(buf.indexOf('is'));
1802
+ * // Prints: 2
1803
+ * console.log(buf.indexOf(Buffer.from('a buffer')));
1804
+ * // Prints: 8
1805
+ * console.log(buf.indexOf(97));
1806
+ * // Prints: 8 (97 is the decimal ASCII value for 'a')
1807
+ * console.log(buf.indexOf(Buffer.from('a buffer example')));
1808
+ * // Prints: -1
1809
+ * console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
1810
+ * // Prints: 8
1811
+ *
1812
+ * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
1813
+ *
1814
+ * console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
1815
+ * // Prints: 4
1816
+ * console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
1817
+ * // Prints: 6
1818
+ * ```
1819
+ *
1820
+ * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1821
+ * an integer between 0 and 255.
1822
+ *
1823
+ * If `byteOffset` is not a number, it will be coerced to a number. If the result
1824
+ * of coercion is `NaN` or `0`, then the entire buffer will be searched. This
1825
+ * behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
1826
+ *
1827
+ * ```js
1828
+ * import { Buffer } from 'buffer';
1829
+ *
1830
+ * const b = Buffer.from('abcdef');
1831
+ *
1832
+ * // Passing a value that's a number, but not a valid byte.
1833
+ * // Prints: 2, equivalent to searching for 99 or 'c'.
1834
+ * console.log(b.indexOf(99.9));
1835
+ * console.log(b.indexOf(256 + 99));
1836
+ *
1837
+ * // Passing a byteOffset that coerces to NaN or 0.
1838
+ * // Prints: 1, searching the whole buffer.
1839
+ * console.log(b.indexOf('b', undefined));
1840
+ * console.log(b.indexOf('b', {}));
1841
+ * console.log(b.indexOf('b', null));
1842
+ * console.log(b.indexOf('b', []));
1843
+ * ```
1844
+ *
1845
+ * If `value` is an empty string or empty `Buffer` and `byteOffset` is less
1846
+ * than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
1847
+ * @since v1.5.0
1848
+ * @param value What to search for.
1849
+ * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1850
+ * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1851
+ * @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1852
+ */
1853
+ indexOf(
1854
+ value: string | number | Uint8Array,
1855
+ byteOffset?: number,
1856
+ encoding?: Encoding,
1857
+ ): number;
1858
+ /**
1859
+ * Identical to `buf.indexOf()`, except the last occurrence of `value` is found
1860
+ * rather than the first occurrence.
1861
+ *
1862
+ * ```js
1863
+ * import { Buffer } from 'buffer';
1864
+ *
1865
+ * const buf = Buffer.from('this buffer is a buffer');
1866
+ *
1867
+ * console.log(buf.lastIndexOf('this'));
1868
+ * // Prints: 0
1869
+ * console.log(buf.lastIndexOf('buffer'));
1870
+ * // Prints: 17
1871
+ * console.log(buf.lastIndexOf(Buffer.from('buffer')));
1872
+ * // Prints: 17
1873
+ * console.log(buf.lastIndexOf(97));
1874
+ * // Prints: 15 (97 is the decimal ASCII value for 'a')
1875
+ * console.log(buf.lastIndexOf(Buffer.from('yolo')));
1876
+ * // Prints: -1
1877
+ * console.log(buf.lastIndexOf('buffer', 5));
1878
+ * // Prints: 5
1879
+ * console.log(buf.lastIndexOf('buffer', 4));
1880
+ * // Prints: -1
1881
+ *
1882
+ * const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
1883
+ *
1884
+ * console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
1885
+ * // Prints: 6
1886
+ * console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
1887
+ * // Prints: 4
1888
+ * ```
1889
+ *
1890
+ * If `value` is not a string, number, or `Buffer`, this method will throw a`TypeError`. If `value` is a number, it will be coerced to a valid byte value,
1891
+ * an integer between 0 and 255.
1892
+ *
1893
+ * If `byteOffset` is not a number, it will be coerced to a number. Any arguments
1894
+ * that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
1895
+ * This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
1896
+ *
1897
+ * ```js
1898
+ * import { Buffer } from 'buffer';
1899
+ *
1900
+ * const b = Buffer.from('abcdef');
1901
+ *
1902
+ * // Passing a value that's a number, but not a valid byte.
1903
+ * // Prints: 2, equivalent to searching for 99 or 'c'.
1904
+ * console.log(b.lastIndexOf(99.9));
1905
+ * console.log(b.lastIndexOf(256 + 99));
1906
+ *
1907
+ * // Passing a byteOffset that coerces to NaN.
1908
+ * // Prints: 1, searching the whole buffer.
1909
+ * console.log(b.lastIndexOf('b', undefined));
1910
+ * console.log(b.lastIndexOf('b', {}));
1911
+ *
1912
+ * // Passing a byteOffset that coerces to 0.
1913
+ * // Prints: -1, equivalent to passing 0.
1914
+ * console.log(b.lastIndexOf('b', null));
1915
+ * console.log(b.lastIndexOf('b', []));
1916
+ * ```
1917
+ *
1918
+ * If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
1919
+ * @since v6.0.0
1920
+ * @param value What to search for.
1921
+ * @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1922
+ * @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
1923
+ * @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
1924
+ */
1925
+ lastIndexOf(
1926
+ value: string | number | Uint8Array,
1927
+ byteOffset?: number,
1928
+ encoding?: Encoding,
1929
+ ): number;
1930
+ /**
1931
+ * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents
1932
+ * of `buf`.
1933
+ *
1934
+ * ```js
1935
+ * import { Buffer } from 'buffer';
1936
+ *
1937
+ * // Log the entire contents of a `Buffer`.
1938
+ *
1939
+ * const buf = Buffer.from('buffer');
1940
+ *
1941
+ * for (const pair of buf.entries()) {
1942
+ * console.log(pair);
1943
+ * }
1944
+ * // Prints:
1945
+ * // [0, 98]
1946
+ * // [1, 117]
1947
+ * // [2, 102]
1948
+ * // [3, 102]
1949
+ * // [4, 101]
1950
+ * // [5, 114]
1951
+ * ```
1952
+ * @since v1.1.0
1953
+ */
1954
+ entries(): IterableIterator<[number, number]>;
1955
+ /**
1956
+ * Equivalent to `buf.indexOf() !== -1`.
1957
+ *
1958
+ * ```js
1959
+ * import { Buffer } from 'buffer';
1960
+ *
1961
+ * const buf = Buffer.from('this is a buffer');
1962
+ *
1963
+ * console.log(buf.includes('this'));
1964
+ * // Prints: true
1965
+ * console.log(buf.includes('is'));
1966
+ * // Prints: true
1967
+ * console.log(buf.includes(Buffer.from('a buffer')));
1968
+ * // Prints: true
1969
+ * console.log(buf.includes(97));
1970
+ * // Prints: true (97 is the decimal ASCII value for 'a')
1971
+ * console.log(buf.includes(Buffer.from('a buffer example')));
1972
+ * // Prints: false
1973
+ * console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
1974
+ * // Prints: true
1975
+ * console.log(buf.includes('this', 4));
1976
+ * // Prints: false
1977
+ * ```
1978
+ * @since v5.3.0
1979
+ * @param value What to search for.
1980
+ * @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
1981
+ * @param [encoding='utf8'] If `value` is a string, this is its encoding.
1982
+ * @return `true` if `value` was found in `buf`, `false` otherwise.
1983
+ */
1984
+ includes(
1985
+ value: string | number | Buffer,
1986
+ byteOffset?: number,
1987
+ encoding?: Encoding,
1988
+ ): boolean;
1989
+ /**
1990
+ * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
1991
+ *
1992
+ * ```js
1993
+ * import { Buffer } from 'buffer';
1994
+ *
1995
+ * const buf = Buffer.from('buffer');
1996
+ *
1997
+ * for (const key of buf.keys()) {
1998
+ * console.log(key);
1999
+ * }
2000
+ * // Prints:
2001
+ * // 0
2002
+ * // 1
2003
+ * // 2
2004
+ * // 3
2005
+ * // 4
2006
+ * // 5
2007
+ * ```
2008
+ * @since v1.1.0
2009
+ */
2010
+ keys(): IterableIterator<number>;
2011
+ /**
2012
+ * Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is
2013
+ * called automatically when a `Buffer` is used in a `for..of` statement.
2014
+ *
2015
+ * ```js
2016
+ * import { Buffer } from 'buffer';
2017
+ *
2018
+ * const buf = Buffer.from('buffer');
2019
+ *
2020
+ * for (const value of buf.values()) {
2021
+ * console.log(value);
2022
+ * }
2023
+ * // Prints:
2024
+ * // 98
2025
+ * // 117
2026
+ * // 102
2027
+ * // 102
2028
+ * // 101
2029
+ * // 114
2030
+ *
2031
+ * for (const value of buf) {
2032
+ * console.log(value);
2033
+ * }
2034
+ * // Prints:
2035
+ * // 98
2036
+ * // 117
2037
+ * // 102
2038
+ * // 102
2039
+ * // 101
2040
+ * // 114
2041
+ * ```
2042
+ * @since v1.1.0
2043
+ */
2044
+ values(): IterableIterator<number>;
2045
+ }
2046
+
2047
+ export const SlowBuffer: {
2048
+ /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
2049
+ new (size: number): Buffer;
2050
+ prototype: Buffer;
2051
+ };
2052
+
2053
+ export const atob: typeof globalThis.atob;
2054
+ export const Blob: Blob;
2055
+ export const btoa: typeof globalThis.btoa;
2056
+ export const constants: {
2057
+ MAX_LENGTH: number;
2058
+ MAX_STRING_LENGTH: number;
2059
+ };
2060
+ export const kMaxLength: number;
2061
+ export const kStringMaxLength: number;
2062
+
2063
+ declare const exports: {
2064
+ atob: typeof atob;
2065
+ Blob: Blob;
2066
+ btoa: typeof btoa;
2067
+ Buffer: Buffer;
2068
+ constants: typeof constants;
2069
+ kMaxLength: typeof kMaxLength;
2070
+ kStringMaxLength: typeof kStringMaxLength;
2071
+ SlowBuffer: typeof SlowBuffer;
2072
+ };
2073
+
2074
+ export default exports;