isomorfeus-puppetmaster 0.5.2 → 0.5.6

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