cf-workers-native 0.0.0-stage → 0.1.2-beta.local.sha2f5e4e6956f4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (629) hide show
  1. package/LICENSE +21 -0
  2. package/Package.swift +25 -0
  3. package/README.md +92 -2
  4. package/dist/android.d.ts +2 -0
  5. package/dist/android.js +1 -0
  6. package/dist/browser/abort/index.d.ts +13 -0
  7. package/dist/browser/abort/index.js +66 -0
  8. package/dist/browser/body/index.d.ts +24 -0
  9. package/dist/browser/body/index.js +116 -0
  10. package/dist/browser/body/stream-body.d.ts +13 -0
  11. package/dist/browser/body/stream-body.js +84 -0
  12. package/dist/browser/documents/body.d.ts +3 -0
  13. package/dist/browser/documents/body.js +48 -0
  14. package/dist/browser/documents/form-body.d.ts +1 -0
  15. package/dist/browser/documents/form-body.js +54 -0
  16. package/dist/browser/documents/host.d.ts +11 -0
  17. package/dist/browser/documents/host.js +256 -0
  18. package/dist/browser/documents/links-source.d.ts +1 -0
  19. package/dist/browser/documents/links-source.js +1 -0
  20. package/dist/browser/documents/links.d.ts +1 -0
  21. package/dist/browser/documents/links.js +33 -0
  22. package/dist/browser/documents/page-config.d.ts +5 -0
  23. package/dist/browser/documents/page-config.js +5 -0
  24. package/dist/browser/documents/page-source.d.ts +1 -0
  25. package/dist/browser/documents/page-source.js +1 -0
  26. package/dist/browser/documents/page.d.ts +2 -0
  27. package/dist/browser/documents/page.js +153 -0
  28. package/dist/browser/documents/registration.d.ts +5 -0
  29. package/dist/browser/documents/registration.js +75 -0
  30. package/dist/browser/documents/runtime.d.ts +7 -0
  31. package/dist/browser/documents/runtime.js +161 -0
  32. package/dist/browser/documents/service-worker.js +285 -0
  33. package/dist/browser/encoding/index.d.ts +7 -0
  34. package/dist/browser/encoding/index.js +3 -0
  35. package/dist/browser/fetch/LICENSE-3RD-PARTY.md +9 -0
  36. package/dist/browser/fetch/LICENSE-APACHE +177 -0
  37. package/dist/browser/fetch/host-call.d.ts +3 -0
  38. package/dist/browser/fetch/host-call.js +67 -0
  39. package/dist/browser/fetch/index.d.ts +5 -0
  40. package/dist/browser/fetch/index.js +96 -0
  41. package/dist/browser/fetch/interop.d.ts +6 -0
  42. package/dist/browser/fetch/interop.js +48 -0
  43. package/dist/browser/fetch/native-network.d.ts +20 -0
  44. package/dist/browser/fetch/native-network.js +233 -0
  45. package/dist/browser/fetch/outbound.d.ts +2 -0
  46. package/dist/browser/fetch/outbound.js +11 -0
  47. package/dist/browser/fetch/relay.d.ts +7 -0
  48. package/dist/browser/fetch/relay.js +100 -0
  49. package/dist/browser/fetch/scope.d.ts +8 -0
  50. package/dist/browser/fetch/scope.js +108 -0
  51. package/dist/browser/fetch/transport.d.ts +39 -0
  52. package/dist/browser/fetch/transport.js +136 -0
  53. package/dist/browser/headers/LICENSE-3RD-PARTY.md +9 -0
  54. package/dist/browser/headers/LICENSE-APACHE +177 -0
  55. package/dist/browser/headers/index.d.ts +20 -0
  56. package/dist/browser/headers/index.js +194 -0
  57. package/dist/browser/isolated/bridge.d.ts +8 -0
  58. package/dist/browser/isolated/bridge.js +267 -0
  59. package/dist/browser/isolated/protocol.d.ts +40 -0
  60. package/dist/browser/isolated/protocol.js +1 -0
  61. package/dist/browser/isolated/transport.d.ts +2 -0
  62. package/dist/browser/isolated/transport.js +157 -0
  63. package/dist/browser/request/LICENSE-3RD-PARTY.md +10 -0
  64. package/dist/browser/request/LICENSE-APACHE +177 -0
  65. package/dist/browser/request/index.d.ts +48 -0
  66. package/dist/browser/request/index.js +182 -0
  67. package/dist/browser/response/LICENSE-3RD-PARTY.md +10 -0
  68. package/dist/browser/response/LICENSE-APACHE +177 -0
  69. package/dist/browser/response/index.d.ts +43 -0
  70. package/dist/browser/response/index.js +192 -0
  71. package/dist/browser/response/status.d.ts +1 -0
  72. package/dist/browser/response/status.js +75 -0
  73. package/dist/browser/structured-clone/index.d.ts +1 -0
  74. package/dist/browser/structured-clone/index.js +479 -0
  75. package/dist/cloudflare/apis/cloudflare-node/index.d.ts +18 -0
  76. package/dist/cloudflare/apis/cloudflare-node/index.js +150 -0
  77. package/dist/cloudflare/apis/cloudflare-workers/index.d.ts +8 -0
  78. package/dist/cloudflare/apis/cloudflare-workers/index.js +37 -0
  79. package/dist/cloudflare/apis/types.d.ts +7 -0
  80. package/dist/cloudflare/apis/types.js +1 -0
  81. package/dist/cloudflare/bindings/config.d.ts +42 -0
  82. package/dist/cloudflare/bindings/config.js +280 -0
  83. package/dist/cloudflare/bindings/kv/contract.d.ts +6 -0
  84. package/dist/cloudflare/bindings/kv/contract.js +181 -0
  85. package/dist/cloudflare/bindings/kv/index.d.ts +18 -0
  86. package/dist/cloudflare/bindings/kv/index.js +61 -0
  87. package/dist/cloudflare/bindings/kv/storage.d.ts +25 -0
  88. package/dist/cloudflare/bindings/kv/storage.js +320 -0
  89. package/dist/cloudflare/bindings/kv/types.d.ts +50 -0
  90. package/dist/cloudflare/bindings/kv/types.js +1 -0
  91. package/dist/cloudflare/bindings/remote.d.ts +8 -0
  92. package/dist/cloudflare/bindings/remote.js +261 -0
  93. package/dist/cloudflare/workers/contract.d.ts +8 -0
  94. package/dist/cloudflare/workers/contract.js +65 -0
  95. package/dist/cloudflare/workers/feature.d.ts +10 -0
  96. package/dist/cloudflare/workers/feature.js +28 -0
  97. package/dist/cloudflare/workers/runtime.d.ts +23 -0
  98. package/dist/cloudflare/workers/runtime.js +121 -0
  99. package/dist/cloudflare/workers/types.d.ts +49 -0
  100. package/dist/cloudflare/workers/types.js +1 -0
  101. package/dist/cloudflare/workers/worker-runtime.d.ts +44 -0
  102. package/dist/cloudflare/workers/worker-runtime.js +267 -0
  103. package/dist/compat/assert/LICENSE-3RD-PARTY.md +5 -0
  104. package/dist/compat/assert/LICENSE-APACHE +177 -0
  105. package/dist/compat/assert/assertion-error.d.ts +26 -0
  106. package/dist/compat/assert/assertion-error.js +468 -0
  107. package/dist/compat/assert/diff.d.ts +26 -0
  108. package/dist/compat/assert/diff.js +329 -0
  109. package/dist/compat/assert/errors.d.ts +11 -0
  110. package/dist/compat/assert/errors.js +55 -0
  111. package/dist/compat/assert/index.cjs +24 -0
  112. package/dist/compat/assert/index.d.cts +43 -0
  113. package/dist/compat/assert/index.d.ts +50 -0
  114. package/dist/compat/assert/index.js +858 -0
  115. package/dist/compat/async-hooks/LICENSE-APACHE +177 -0
  116. package/dist/compat/async-hooks/NOTICE.md +8 -0
  117. package/dist/compat/async-hooks/callbacks.d.ts +7 -0
  118. package/dist/compat/async-hooks/callbacks.js +18 -0
  119. package/dist/compat/async-hooks/hooks.d.ts +10 -0
  120. package/dist/compat/async-hooks/hooks.js +111 -0
  121. package/dist/compat/async-hooks/index.d.ts +41 -0
  122. package/dist/compat/async-hooks/index.js +298 -0
  123. package/dist/compat/buffer/LICENSE-3RD-PARTY.md +15 -0
  124. package/dist/compat/buffer/LICENSE-APACHE +177 -0
  125. package/dist/compat/buffer/blob.d.ts +22 -0
  126. package/dist/compat/buffer/blob.js +210 -0
  127. package/dist/compat/buffer/bytes.d.ts +34 -0
  128. package/dist/compat/buffer/bytes.js +228 -0
  129. package/dist/compat/buffer/errors.d.ts +41 -0
  130. package/dist/compat/buffer/errors.js +265 -0
  131. package/dist/compat/buffer/index.d.ts +25 -0
  132. package/dist/compat/buffer/index.js +24 -0
  133. package/dist/compat/buffer/internal-buffer.d.ts +148 -0
  134. package/dist/compat/buffer/internal-buffer.js +1809 -0
  135. package/dist/compat/buffer/support.d.ts +13 -0
  136. package/dist/compat/buffer/support.js +65 -0
  137. package/dist/compat/child-process/LICENSE-3RD-PARTY.md +8 -0
  138. package/dist/compat/child-process/LICENSE-APACHE +177 -0
  139. package/dist/compat/child-process/errors.d.ts +4 -0
  140. package/dist/compat/child-process/errors.js +6 -0
  141. package/dist/compat/child-process/index.d.ts +49 -0
  142. package/dist/compat/child-process/index.js +96 -0
  143. package/dist/compat/cluster/LICENSE-3RD-PARTY.md +40 -0
  144. package/dist/compat/cluster/LICENSE-APACHE +177 -0
  145. package/dist/compat/cluster/errors.d.ts +4 -0
  146. package/dist/compat/cluster/errors.js +6 -0
  147. package/dist/compat/cluster/index.d.ts +47 -0
  148. package/dist/compat/cluster/index.js +88 -0
  149. package/dist/compat/constants/LICENSE-3RD-PARTY.md +6 -0
  150. package/dist/compat/constants/LICENSE-APACHE +177 -0
  151. package/dist/compat/constants/index.d.ts +481 -0
  152. package/dist/compat/constants/index.js +488 -0
  153. package/dist/compat/dgram/LICENSE-3RD-PARTY.md +8 -0
  154. package/dist/compat/dgram/LICENSE-APACHE +177 -0
  155. package/dist/compat/dgram/index.d.ts +10 -0
  156. package/dist/compat/dgram/index.js +132 -0
  157. package/dist/compat/diagnostics-channel/LICENSE-3RD-PARTY.md +13 -0
  158. package/dist/compat/diagnostics-channel/LICENSE-APACHE +177 -0
  159. package/dist/compat/diagnostics-channel/index.d.ts +73 -0
  160. package/dist/compat/diagnostics-channel/index.js +261 -0
  161. package/dist/compat/diagnostics-channel/native.d.ts +26 -0
  162. package/dist/compat/diagnostics-channel/native.js +154 -0
  163. package/dist/compat/dns/LICENSE-3RD-PARTY.md +5 -0
  164. package/dist/compat/dns/LICENSE-APACHE +177 -0
  165. package/dist/compat/dns/client.d.ts +72 -0
  166. package/dist/compat/dns/client.js +161 -0
  167. package/dist/compat/dns/constants.d.ts +27 -0
  168. package/dist/compat/dns/constants.js +31 -0
  169. package/dist/compat/dns/errors.d.ts +8 -0
  170. package/dist/compat/dns/errors.js +12 -0
  171. package/dist/compat/dns/index.d.ts +97 -0
  172. package/dist/compat/dns/index.js +127 -0
  173. package/dist/compat/dns/parser.d.ts +18 -0
  174. package/dist/compat/dns/parser.js +144 -0
  175. package/dist/compat/dns/promise-resolver.d.ts +82 -0
  176. package/dist/compat/dns/promise-resolver.js +113 -0
  177. package/dist/compat/dns/promises.d.ts +50 -0
  178. package/dist/compat/dns/promises.js +53 -0
  179. package/dist/compat/dns/resolver.d.ts +34 -0
  180. package/dist/compat/dns/resolver.js +415 -0
  181. package/dist/compat/domain/LICENSE-3RD-PARTY.md +5 -0
  182. package/dist/compat/domain/LICENSE-APACHE +177 -0
  183. package/dist/compat/domain/index.d.ts +22 -0
  184. package/dist/compat/domain/index.js +79 -0
  185. package/dist/compat/fs/index.d.ts +85 -0
  186. package/dist/compat/fs/index.js +255 -0
  187. package/dist/compat/fs/promises/index.d.ts +3 -0
  188. package/dist/compat/fs/promises/index.js +3 -0
  189. package/dist/compat/http/index.d.ts +322 -0
  190. package/dist/compat/http/index.js +1356 -0
  191. package/dist/compat/http/registry.d.ts +19 -0
  192. package/dist/compat/http/registry.js +13 -0
  193. package/dist/compat/http-agent/LICENSE-3RD-PARTY.md +5 -0
  194. package/dist/compat/http-agent/LICENSE-APACHE +177 -0
  195. package/dist/compat/http-agent/index.d.ts +7 -0
  196. package/dist/compat/http-agent/index.js +10 -0
  197. package/dist/compat/http-client/LICENSE-3RD-PARTY.md +5 -0
  198. package/dist/compat/http-client/LICENSE-APACHE +177 -0
  199. package/dist/compat/http-client/index.d.ts +6 -0
  200. package/dist/compat/http-client/index.js +7 -0
  201. package/dist/compat/http-incoming/LICENSE-3RD-PARTY.md +5 -0
  202. package/dist/compat/http-incoming/LICENSE-APACHE +177 -0
  203. package/dist/compat/http-incoming/index.d.ts +6 -0
  204. package/dist/compat/http-incoming/index.js +9 -0
  205. package/dist/compat/http2/LICENSE-3RD-PARTY.md +29 -0
  206. package/dist/compat/http2/LICENSE-APACHE +177 -0
  207. package/dist/compat/http2/constants.d.ts +255 -0
  208. package/dist/compat/http2/constants.js +515 -0
  209. package/dist/compat/http2/errors.d.ts +4 -0
  210. package/dist/compat/http2/errors.js +6 -0
  211. package/dist/compat/http2/index.d.ts +283 -0
  212. package/dist/compat/http2/index.js +68 -0
  213. package/dist/compat/https/LICENSE-3RD-PARTY.md +5 -0
  214. package/dist/compat/https/LICENSE-APACHE +177 -0
  215. package/dist/compat/https/agent.d.ts +10 -0
  216. package/dist/compat/https/agent.js +99 -0
  217. package/dist/compat/https/errors.d.ts +4 -0
  218. package/dist/compat/https/errors.js +6 -0
  219. package/dist/compat/https/index.d.ts +20 -0
  220. package/dist/compat/https/index.js +50 -0
  221. package/dist/compat/https/server.d.ts +8 -0
  222. package/dist/compat/https/server.js +27 -0
  223. package/dist/compat/immediate/index.d.ts +11 -0
  224. package/dist/compat/immediate/index.js +58 -0
  225. package/dist/compat/inspector/LICENSE-3RD-PARTY.md +34 -0
  226. package/dist/compat/inspector/LICENSE-APACHE +177 -0
  227. package/dist/compat/inspector/errors.d.ts +4 -0
  228. package/dist/compat/inspector/errors.js +6 -0
  229. package/dist/compat/inspector/index.d.ts +18 -0
  230. package/dist/compat/inspector/index.js +117 -0
  231. package/dist/compat/inspector/promises.d.ts +18 -0
  232. package/dist/compat/inspector/promises.js +114 -0
  233. package/dist/compat/module/index.cjs +2 -0
  234. package/dist/compat/module/index.d.cts +2 -0
  235. package/dist/compat/module/index.d.ts +11 -0
  236. package/dist/compat/module/index.js +44 -0
  237. package/dist/compat/module/resolve-unavailable.d.ts +1 -0
  238. package/dist/compat/module/resolve-unavailable.js +3 -0
  239. package/dist/compat/net/LICENSE-3RD-PARTY.md +15 -0
  240. package/dist/compat/net/LICENSE-APACHE +177 -0
  241. package/dist/compat/net/error-base.d.ts +14 -0
  242. package/dist/compat/net/error-base.js +62 -0
  243. package/dist/compat/net/errors.d.ts +76 -0
  244. package/dist/compat/net/errors.js +333 -0
  245. package/dist/compat/net/index.d.ts +23 -0
  246. package/dist/compat/net/index.js +46 -0
  247. package/dist/compat/net/internal-net.d.ts +236 -0
  248. package/dist/compat/net/internal-net.js +2292 -0
  249. package/dist/compat/net/ports.d.ts +32 -0
  250. package/dist/compat/net/ports.js +149 -0
  251. package/dist/compat/net/reader.d.ts +8 -0
  252. package/dist/compat/net/reader.js +36 -0
  253. package/dist/compat/net/sockets.d.ts +20 -0
  254. package/dist/compat/net/sockets.js +195 -0
  255. package/dist/compat/net/validators.d.ts +18 -0
  256. package/dist/compat/net/validators.js +154 -0
  257. package/dist/compat/os/LICENSE-3RD-PARTY.md +8 -0
  258. package/dist/compat/os/LICENSE-APACHE +177 -0
  259. package/dist/compat/os/index.d.ts +329 -0
  260. package/dist/compat/os/index.js +278 -0
  261. package/dist/compat/path/LICENSE-3RD-PARTY.md +35 -0
  262. package/dist/compat/path/LICENSE-APACHE +177 -0
  263. package/dist/compat/path/index.d.ts +4 -0
  264. package/dist/compat/path/index.js +11 -0
  265. package/dist/compat/path/internal-path.d.ts +95 -0
  266. package/dist/compat/path/internal-path.js +1542 -0
  267. package/dist/compat/path/posix/index.d.ts +4 -0
  268. package/dist/compat/path/posix/index.js +5 -0
  269. package/dist/compat/path/win32/index.d.ts +4 -0
  270. package/dist/compat/path/win32/index.js +5 -0
  271. package/dist/compat/perf-hooks/LICENSE-3RD-PARTY.md +5 -0
  272. package/dist/compat/perf-hooks/LICENSE-APACHE +177 -0
  273. package/dist/compat/perf-hooks/index.d.ts +85 -0
  274. package/dist/compat/perf-hooks/index.js +79 -0
  275. package/dist/compat/perf-hooks/performance.d.ts +96 -0
  276. package/dist/compat/perf-hooks/performance.js +445 -0
  277. package/dist/compat/punycode/LICENSE-3RD-PARTY.md +7 -0
  278. package/dist/compat/punycode/LICENSE-APACHE +177 -0
  279. package/dist/compat/punycode/index.d.ts +93 -0
  280. package/dist/compat/punycode/index.js +410 -0
  281. package/dist/compat/querystring/LICENSE-3RD-PARTY.md +35 -0
  282. package/dist/compat/querystring/LICENSE-APACHE +177 -0
  283. package/dist/compat/querystring/index.d.ts +14 -0
  284. package/dist/compat/querystring/index.js +18 -0
  285. package/dist/compat/querystring/internal-querystring.d.ts +22 -0
  286. package/dist/compat/querystring/internal-querystring.js +498 -0
  287. package/dist/compat/readline/LICENSE-3RD-PARTY.md +37 -0
  288. package/dist/compat/readline/LICENSE-APACHE +177 -0
  289. package/dist/compat/readline/index.d.ts +21 -0
  290. package/dist/compat/readline/index.js +56 -0
  291. package/dist/compat/readline/interface.d.ts +22 -0
  292. package/dist/compat/readline/interface.js +85 -0
  293. package/dist/compat/readline/internal-promises.d.ts +32 -0
  294. package/dist/compat/readline/internal-promises.js +104 -0
  295. package/dist/compat/readline/promises.d.ts +8 -0
  296. package/dist/compat/readline/promises.js +32 -0
  297. package/dist/compat/repl/LICENSE-3RD-PARTY.md +5 -0
  298. package/dist/compat/repl/LICENSE-APACHE +177 -0
  299. package/dist/compat/repl/builtin-modules.d.ts +1 -0
  300. package/dist/compat/repl/builtin-modules.js +101 -0
  301. package/dist/compat/repl/errors.d.ts +4 -0
  302. package/dist/compat/repl/errors.js +6 -0
  303. package/dist/compat/repl/index.d.ts +53 -0
  304. package/dist/compat/repl/index.js +106 -0
  305. package/dist/compat/sqlite/LICENSE-3RD-PARTY.md +6 -0
  306. package/dist/compat/sqlite/LICENSE-APACHE +177 -0
  307. package/dist/compat/sqlite/index.d.ts +12 -0
  308. package/dist/compat/sqlite/index.js +101 -0
  309. package/dist/compat/sqlite/native.d.ts +16 -0
  310. package/dist/compat/sqlite/native.js +33 -0
  311. package/dist/compat/stream/LICENSE-3RD-PARTY.md +13 -0
  312. package/dist/compat/stream/LICENSE-APACHE +177 -0
  313. package/dist/compat/stream/add-abort-signal.d.ts +4 -0
  314. package/dist/compat/stream/add-abort-signal.js +73 -0
  315. package/dist/compat/stream/compose.d.ts +1 -0
  316. package/dist/compat/stream/compose.js +313 -0
  317. package/dist/compat/stream/destroy.d.ts +5 -0
  318. package/dist/compat/stream/destroy.js +315 -0
  319. package/dist/compat/stream/duplex.d.ts +48 -0
  320. package/dist/compat/stream/duplex.js +789 -0
  321. package/dist/compat/stream/end-of-stream.d.ts +16 -0
  322. package/dist/compat/stream/end-of-stream.js +269 -0
  323. package/dist/compat/stream/errors.d.ts +40 -0
  324. package/dist/compat/stream/errors.js +86 -0
  325. package/dist/compat/stream/events.d.ts +6 -0
  326. package/dist/compat/stream/events.js +28 -0
  327. package/dist/compat/stream/index.cjs +27 -0
  328. package/dist/compat/stream/index.d.cts +25 -0
  329. package/dist/compat/stream/index.d.ts +20 -0
  330. package/dist/compat/stream/index.js +55 -0
  331. package/dist/compat/stream/legacy.d.ts +8 -0
  332. package/dist/compat/stream/legacy.js +105 -0
  333. package/dist/compat/stream/once.d.ts +7 -0
  334. package/dist/compat/stream/once.js +13 -0
  335. package/dist/compat/stream/pipeline.d.ts +5 -0
  336. package/dist/compat/stream/pipeline.js +567 -0
  337. package/dist/compat/stream/process.d.ts +1 -0
  338. package/dist/compat/stream/process.js +4 -0
  339. package/dist/compat/stream/promises.d.ts +7 -0
  340. package/dist/compat/stream/promises.js +60 -0
  341. package/dist/compat/stream/readable.d.ts +29 -0
  342. package/dist/compat/stream/readable.js +2267 -0
  343. package/dist/compat/stream/state.d.ts +8 -0
  344. package/dist/compat/stream/state.js +63 -0
  345. package/dist/compat/stream/transform.d.ts +2 -0
  346. package/dist/compat/stream/transform.js +202 -0
  347. package/dist/compat/stream/util.d.ts +55 -0
  348. package/dist/compat/stream/util.js +345 -0
  349. package/dist/compat/stream/validators.d.ts +2 -0
  350. package/dist/compat/stream/validators.js +14 -0
  351. package/dist/compat/stream/writable.d.ts +21 -0
  352. package/dist/compat/stream/writable.js +1325 -0
  353. package/dist/compat/stream-consumers/LICENSE-3RD-PARTY.md +5 -0
  354. package/dist/compat/stream-consumers/LICENSE-APACHE +177 -0
  355. package/dist/compat/stream-consumers/index.d.ts +14 -0
  356. package/dist/compat/stream-consumers/index.js +62 -0
  357. package/dist/compat/stream-consumers/iterable.d.ts +1 -0
  358. package/dist/compat/stream-consumers/iterable.js +34 -0
  359. package/dist/compat/stream-duplex/LICENSE-3RD-PARTY.md +13 -0
  360. package/dist/compat/stream-duplex/LICENSE-APACHE +177 -0
  361. package/dist/compat/stream-duplex/index.cjs +3 -0
  362. package/dist/compat/stream-duplex/index.d.cts +2 -0
  363. package/dist/compat/stream-duplex/index.d.ts +3 -0
  364. package/dist/compat/stream-duplex/index.js +8 -0
  365. package/dist/compat/stream-passthrough/LICENSE-3RD-PARTY.md +13 -0
  366. package/dist/compat/stream-passthrough/LICENSE-APACHE +177 -0
  367. package/dist/compat/stream-passthrough/index.cjs +3 -0
  368. package/dist/compat/stream-passthrough/index.d.cts +2 -0
  369. package/dist/compat/stream-passthrough/index.d.ts +3 -0
  370. package/dist/compat/stream-passthrough/index.js +8 -0
  371. package/dist/compat/stream-promises/LICENSE-3RD-PARTY.md +13 -0
  372. package/dist/compat/stream-promises/LICENSE-APACHE +177 -0
  373. package/dist/compat/stream-promises/index.d.ts +1 -0
  374. package/dist/compat/stream-promises/index.js +1 -0
  375. package/dist/compat/stream-readable/LICENSE-3RD-PARTY.md +13 -0
  376. package/dist/compat/stream-readable/LICENSE-APACHE +177 -0
  377. package/dist/compat/stream-readable/index.cjs +3 -0
  378. package/dist/compat/stream-readable/index.d.cts +2 -0
  379. package/dist/compat/stream-readable/index.d.ts +3 -0
  380. package/dist/compat/stream-readable/index.js +8 -0
  381. package/dist/compat/stream-transform/LICENSE-3RD-PARTY.md +13 -0
  382. package/dist/compat/stream-transform/LICENSE-APACHE +177 -0
  383. package/dist/compat/stream-transform/index.cjs +3 -0
  384. package/dist/compat/stream-transform/index.d.cts +2 -0
  385. package/dist/compat/stream-transform/index.d.ts +3 -0
  386. package/dist/compat/stream-transform/index.js +8 -0
  387. package/dist/compat/stream-web/LICENSE-MIT +22 -0
  388. package/dist/compat/stream-web/NOTICE.md +3 -0
  389. package/dist/compat/stream-web/context.d.ts +2 -0
  390. package/dist/compat/stream-web/context.js +35 -0
  391. package/dist/compat/stream-web/index.d.ts +80 -0
  392. package/dist/compat/stream-web/index.js +129 -0
  393. package/dist/compat/stream-web/interop.d.ts +6 -0
  394. package/dist/compat/stream-web/interop.js +72 -0
  395. package/dist/compat/stream-web/ponyfill.d.ts +1 -0
  396. package/dist/compat/stream-web/ponyfill.js +2093 -0
  397. package/dist/compat/stream-web/runtime.d.ts +16 -0
  398. package/dist/compat/stream-web/runtime.js +51 -0
  399. package/dist/compat/stream-writable/LICENSE-3RD-PARTY.md +13 -0
  400. package/dist/compat/stream-writable/LICENSE-APACHE +177 -0
  401. package/dist/compat/stream-writable/index.cjs +3 -0
  402. package/dist/compat/stream-writable/index.d.cts +2 -0
  403. package/dist/compat/stream-writable/index.d.ts +3 -0
  404. package/dist/compat/stream-writable/index.js +8 -0
  405. package/dist/compat/string-decoder/LICENSE-3RD-PARTY.md +38 -0
  406. package/dist/compat/string-decoder/LICENSE-APACHE +177 -0
  407. package/dist/compat/string-decoder/index.d.ts +33 -0
  408. package/dist/compat/string-decoder/index.js +518 -0
  409. package/dist/compat/test/LICENSE-3RD-PARTY.md +37 -0
  410. package/dist/compat/test/LICENSE-APACHE +177 -0
  411. package/dist/compat/test/index.d.ts +9 -0
  412. package/dist/compat/test/index.js +11 -0
  413. package/dist/compat/test/mock.d.ts +103 -0
  414. package/dist/compat/test/mock.js +397 -0
  415. package/dist/compat/test/validators.d.ts +2 -0
  416. package/dist/compat/test/validators.js +14 -0
  417. package/dist/compat/timers/LICENSE-3RD-PARTY.md +7 -0
  418. package/dist/compat/timers/LICENSE-APACHE +177 -0
  419. package/dist/compat/timers/errors.d.ts +28 -0
  420. package/dist/compat/timers/errors.js +206 -0
  421. package/dist/compat/timers/host.d.ts +11 -0
  422. package/dist/compat/timers/host.js +60 -0
  423. package/dist/compat/timers/index.cjs +3 -0
  424. package/dist/compat/timers/index.d.cts +23 -0
  425. package/dist/compat/timers/index.d.ts +36 -0
  426. package/dist/compat/timers/index.js +20 -0
  427. package/dist/compat/timers/installation.d.ts +4 -0
  428. package/dist/compat/timers/installation.js +61 -0
  429. package/dist/compat/timers/internal-promises.d.ts +19 -0
  430. package/dist/compat/timers/internal-promises.js +173 -0
  431. package/dist/compat/timers/promises.cjs +2 -0
  432. package/dist/compat/timers/promises.d.cts +12 -0
  433. package/dist/compat/timers/promises.d.ts +14 -0
  434. package/dist/compat/timers/promises.js +3 -0
  435. package/dist/compat/timers/timers.d.ts +32 -0
  436. package/dist/compat/timers/timers.js +147 -0
  437. package/dist/compat/timers/validation.d.ts +5 -0
  438. package/dist/compat/timers/validation.js +22 -0
  439. package/dist/compat/timers/wait.d.ts +4 -0
  440. package/dist/compat/timers/wait.js +91 -0
  441. package/dist/compat/tls-common/LICENSE-3RD-PARTY.md +11 -0
  442. package/dist/compat/tls-common/LICENSE-APACHE +177 -0
  443. package/dist/compat/tls-common/index.d.ts +14 -0
  444. package/dist/compat/tls-common/index.js +88 -0
  445. package/dist/compat/trace-events/LICENSE-3RD-PARTY.md +5 -0
  446. package/dist/compat/trace-events/LICENSE-APACHE +177 -0
  447. package/dist/compat/trace-events/index.d.ts +18 -0
  448. package/dist/compat/trace-events/index.js +88 -0
  449. package/dist/compat/tty/LICENSE-3RD-PARTY.md +8 -0
  450. package/dist/compat/tty/LICENSE-APACHE +177 -0
  451. package/dist/compat/tty/index.d.ts +17 -0
  452. package/dist/compat/tty/index.js +101 -0
  453. package/dist/compat/url/LICENSE-3RD-PARTY.md +63 -0
  454. package/dist/compat/url/LICENSE-ADA +18 -0
  455. package/dist/compat/url/LICENSE-APACHE +177 -0
  456. package/dist/compat/url/LICENSE-UNICODE +39 -0
  457. package/dist/compat/url/LICENSE-WHATWG-URL +21 -0
  458. package/dist/compat/url/brand.d.ts +4 -0
  459. package/dist/compat/url/brand.js +10 -0
  460. package/dist/compat/url/constants.d.ts +27 -0
  461. package/dist/compat/url/constants.js +28 -0
  462. package/dist/compat/url/errors.d.ts +44 -0
  463. package/dist/compat/url/errors.js +248 -0
  464. package/dist/compat/url/idna-data.d.ts +3958 -0
  465. package/dist/compat/url/idna-data.js +22 -0
  466. package/dist/compat/url/idna.d.ts +9 -0
  467. package/dist/compat/url/idna.js +47 -0
  468. package/dist/compat/url/index.d.ts +48 -0
  469. package/dist/compat/url/index.js +39 -0
  470. package/dist/compat/url/installation.d.ts +4 -0
  471. package/dist/compat/url/installation.js +61 -0
  472. package/dist/compat/url/internal-url.d.ts +34 -0
  473. package/dist/compat/url/internal-url.js +264 -0
  474. package/dist/compat/url/legacy-url.d.ts +28 -0
  475. package/dist/compat/url/legacy-url.js +870 -0
  476. package/dist/compat/url/parser-platform.d.ts +3 -0
  477. package/dist/compat/url/parser-platform.js +26 -0
  478. package/dist/compat/url/standard-url.d.ts +2 -0
  479. package/dist/compat/url/standard-url.js +3189 -0
  480. package/dist/compat/url/unicode.d.ts +2 -0
  481. package/dist/compat/url/unicode.js +119 -0
  482. package/dist/compat/url/validation.d.ts +2 -0
  483. package/dist/compat/url/validation.js +9 -0
  484. package/dist/compat/url/web-url.d.ts +27 -0
  485. package/dist/compat/url/web-url.js +119 -0
  486. package/dist/compat/util/LICENSE-3RD-PARTY.md +5 -0
  487. package/dist/compat/util/LICENSE-APACHE +177 -0
  488. package/dist/compat/util/additional.d.ts +11 -0
  489. package/dist/compat/util/additional.js +121 -0
  490. package/dist/compat/util/comparison-types.d.ts +16 -0
  491. package/dist/compat/util/comparison-types.js +50 -0
  492. package/dist/compat/util/comparisons.d.ts +1 -0
  493. package/dist/compat/util/comparisons.js +527 -0
  494. package/dist/compat/util/core.d.ts +18 -0
  495. package/dist/compat/util/core.js +265 -0
  496. package/dist/compat/util/debuglog.d.ts +1 -0
  497. package/dist/compat/util/debuglog.js +78 -0
  498. package/dist/compat/util/index.d.ts +35 -0
  499. package/dist/compat/util/index.js +77 -0
  500. package/dist/compat/util/inspect-binding.d.ts +13 -0
  501. package/dist/compat/util/inspect-binding.js +39 -0
  502. package/dist/compat/util/inspect-types.d.ts +13 -0
  503. package/dist/compat/util/inspect-types.js +30 -0
  504. package/dist/compat/util/inspect.d.ts +152 -0
  505. package/dist/compat/util/inspect.js +2503 -0
  506. package/dist/compat/util/mime.d.ts +24 -0
  507. package/dist/compat/util/mime.js +284 -0
  508. package/dist/compat/util/properties.d.ts +9 -0
  509. package/dist/compat/util/properties.js +76 -0
  510. package/dist/compat/v8/LICENSE-3RD-PARTY.md +6 -0
  511. package/dist/compat/v8/LICENSE-APACHE +177 -0
  512. package/dist/compat/v8/errors.d.ts +5 -0
  513. package/dist/compat/v8/errors.js +7 -0
  514. package/dist/compat/v8/index.d.ts +106 -0
  515. package/dist/compat/v8/index.js +280 -0
  516. package/dist/compat/vm/LICENSE-3RD-PARTY.md +39 -0
  517. package/dist/compat/vm/LICENSE-APACHE +177 -0
  518. package/dist/compat/vm/errors.d.ts +5 -0
  519. package/dist/compat/vm/errors.js +7 -0
  520. package/dist/compat/vm/index.d.ts +47 -0
  521. package/dist/compat/vm/index.js +231 -0
  522. package/dist/compat/vm/validation.d.ts +3 -0
  523. package/dist/compat/vm/validation.js +14 -0
  524. package/dist/compat/wasi/LICENSE-3RD-PARTY.md +8 -0
  525. package/dist/compat/wasi/LICENSE-APACHE +177 -0
  526. package/dist/compat/wasi/errors.d.ts +4 -0
  527. package/dist/compat/wasi/errors.js +6 -0
  528. package/dist/compat/wasi/index.d.ts +15 -0
  529. package/dist/compat/wasi/index.js +44 -0
  530. package/dist/compat/worker-threads/LICENSE-3RD-PARTY.md +5 -0
  531. package/dist/compat/worker-threads/LICENSE-APACHE +177 -0
  532. package/dist/compat/worker-threads/errors.d.ts +4 -0
  533. package/dist/compat/worker-threads/errors.js +6 -0
  534. package/dist/compat/worker-threads/index.d.ts +71 -0
  535. package/dist/compat/worker-threads/index.js +138 -0
  536. package/dist/compat/worker-threads/message-channel.d.ts +18 -0
  537. package/dist/compat/worker-threads/message-channel.js +157 -0
  538. package/dist/configured.d.ts +3 -0
  539. package/dist/configured.js +4 -0
  540. package/dist/environment.d.ts +4 -0
  541. package/dist/environment.js +18 -0
  542. package/dist/index.d.ts +11 -0
  543. package/dist/index.js +107 -0
  544. package/dist/ios.d.ts +2 -0
  545. package/dist/ios.js +1 -0
  546. package/dist/native-entry.d.ts +8 -0
  547. package/dist/native-entry.js +67 -0
  548. package/dist/shared/brotli/LICENSE-APACHE +201 -0
  549. package/dist/shared/brotli/LICENSE-MIT +9 -0
  550. package/dist/shared/brotli/NOTICE +3 -0
  551. package/dist/shared/brotli/index.d.ts +2 -0
  552. package/dist/shared/brotli/index.js +288 -0
  553. package/dist/shared/contracts/index.d.ts +42 -0
  554. package/dist/shared/contracts/index.js +88 -0
  555. package/dist/shared/contracts/testing.d.ts +22 -0
  556. package/dist/shared/contracts/testing.js +57 -0
  557. package/dist/shared/globals/index.d.ts +3 -0
  558. package/dist/shared/globals/index.js +87 -0
  559. package/dist/shared/globals/inject.d.ts +2 -0
  560. package/dist/shared/globals/inject.js +3 -0
  561. package/dist/shared/globals/install.d.ts +1 -0
  562. package/dist/shared/globals/install.js +15 -0
  563. package/dist/shared/globals/node-install.d.ts +1 -0
  564. package/dist/shared/globals/node-install.js +4 -0
  565. package/dist/shared/globals/platform.d.ts +104 -0
  566. package/dist/shared/globals/platform.js +37 -0
  567. package/dist/shared/globals/runtime.d.ts +6 -0
  568. package/dist/shared/globals/runtime.js +8 -0
  569. package/dist/shared/globals/symbols.d.ts +4 -0
  570. package/dist/shared/globals/symbols.js +35 -0
  571. package/dist/shared/globals/web.d.ts +4 -0
  572. package/dist/shared/globals/web.js +108 -0
  573. package/dist/shared/http-wire/LICENSE.llhttp +22 -0
  574. package/dist/shared/http-wire/LICENSE.undici +21 -0
  575. package/dist/shared/http-wire/NOTICE.md +14 -0
  576. package/dist/shared/http-wire/index.d.ts +27 -0
  577. package/dist/shared/http-wire/index.js +132 -0
  578. package/dist/shared/http-wire/wasm.d.ts +2 -0
  579. package/dist/shared/http-wire/wasm.js +2 -0
  580. package/dist/tooling/async.d.ts +7 -0
  581. package/dist/tooling/async.js +99 -0
  582. package/dist/tooling/build-isolation.d.ts +4 -0
  583. package/dist/tooling/build-isolation.js +34 -0
  584. package/dist/tooling/documents.d.ts +7 -0
  585. package/dist/tooling/documents.js +26 -0
  586. package/dist/tooling/esbuild.d.ts +15 -0
  587. package/dist/tooling/esbuild.js +193 -0
  588. package/dist/tooling/files.d.ts +2 -0
  589. package/dist/tooling/files.js +18 -0
  590. package/dist/tooling/opennext/build.d.ts +1 -0
  591. package/dist/tooling/opennext/build.js +121 -0
  592. package/dist/tooling/opennext/index.d.ts +3 -0
  593. package/dist/tooling/opennext/index.js +213 -0
  594. package/dist/tooling/opennext/plan.d.ts +9 -0
  595. package/dist/tooling/opennext/plan.js +36 -0
  596. package/dist/tooling/opennext/safety.d.ts +4 -0
  597. package/dist/tooling/opennext/safety.js +36 -0
  598. package/dist/tooling/route-permissions.d.ts +3 -0
  599. package/dist/tooling/route-permissions.js +15 -0
  600. package/dist/tooling/server-modules.d.ts +30 -0
  601. package/dist/tooling/server-modules.js +98 -0
  602. package/dist/tooling/server-only-html.d.ts +1 -0
  603. package/dist/tooling/server-only-html.js +66 -0
  604. package/dist/tooling/server-only.d.ts +6 -0
  605. package/dist/tooling/server-only.js +53 -0
  606. package/dist/tooling/server.d.ts +25 -0
  607. package/dist/tooling/server.js +981 -0
  608. package/dist/tooling/shared.d.ts +13 -0
  609. package/dist/tooling/shared.js +130 -0
  610. package/dist/tooling/vite.d.ts +18 -0
  611. package/dist/tooling/vite.js +448 -0
  612. package/dist/tooling/void/index.d.ts +3 -0
  613. package/dist/tooling/void/index.js +205 -0
  614. package/dist/tooling/void/plan.d.ts +17 -0
  615. package/dist/tooling/void/plan.js +288 -0
  616. package/native/android/build.gradle +68 -0
  617. package/native/android/consumer-rules.pro +2 -0
  618. package/native/android/src/main/AndroidManifest.xml +6 -0
  619. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkerSockets.java +202 -0
  620. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersCapacitorPlugin.java +256 -0
  621. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNative.java +22 -0
  622. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeActivity.java +178 -0
  623. package/native/android/src/main/java/jp/rdlabo/workerscapacitor/WorkersNativeBridge.java +45 -0
  624. package/native/ios/DocumentBridge.swift +330 -0
  625. package/native/ios/NetworkBridge.swift +51 -0
  626. package/native/ios/SocketBridge.swift +180 -0
  627. package/native/ios/WorkersCapacitorPlugin.swift +152 -0
  628. package/native/ios-host/WorkersView.swift +194 -0
  629. package/package.json +154 -4
@@ -0,0 +1,1809 @@
1
+ // Copyright (c) 2017-2022 Cloudflare, Inc.
2
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
3
+ // https://opensource.org/licenses/Apache-2.0
4
+ //
5
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
6
+ // Copyright Joyent and Node contributors. All rights reserved. MIT license.
7
+ // Copyright Feross Aboukhadijeh, and other contributors. All rights reserved. MIT license.
8
+ // Adapted from workerd v1.20261012.1; native byte helpers use Web APIs.
9
+ /* eslint-disable */
10
+ import { ERR_BUFFER_OUT_OF_BOUNDS, ERR_OUT_OF_RANGE, ERR_INVALID_ARG_TYPE, ERR_INVALID_ARG_VALUE, ERR_INVALID_BUFFER_SIZE, ERR_UNKNOWN_ENCODING, } from "./errors.js";
11
+ import { default as bufferUtil } from "./bytes.js";
12
+ import { isAnyArrayBuffer, isArrayBufferView, isUint8Array, } from "./support.js";
13
+ import { normalizeEncoding, getEncodingOps } from "./support.js";
14
+ import { validateString } from "./support.js";
15
+ import internalUtil from "./support.js";
16
+ import { inspect as utilInspect } from "node:util";
17
+ const { ASCII, BASE64, BASE64URL, HEX, LATIN1, UTF16LE, UTF8 } = bufferUtil;
18
+ // Temporary buffers to convert numbers.
19
+ const float32Array = new Float32Array(1);
20
+ const uInt8Float32Array = new Uint8Array(float32Array.buffer);
21
+ const float64Array = new Float64Array(1);
22
+ const uInt8Float64Array = new Uint8Array(float64Array.buffer);
23
+ // Check endianness.
24
+ float32Array[0] = -1; // 0xBF800000
25
+ // Either it is [0, 0, 128, 191] or [191, 128, 0, 0]. It is not possible to
26
+ // check this with `os.endianness()` because that is determined at compile time.
27
+ export const bigEndian = uInt8Float32Array[3] === 0;
28
+ // Node.js caps its max length at uint32_t max, we are very intentionally more
29
+ // conservative here, capping at int32_t max.
30
+ export const kMaxLength = 2147483647;
31
+ export const kStringMaxLength = 536870888;
32
+ const MAX_UINT32 = 2 ** 32;
33
+ const kIsBuffer = Symbol("kIsBuffer");
34
+ const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function"
35
+ ? Symbol["for"]("nodejs.util.inspect.custom")
36
+ : null;
37
+ // One difference between Node.js and workerd is that, workerd
38
+ // doesn't expose a setter for this, whereas Node.js does.
39
+ export const INSPECT_MAX_BYTES = 50;
40
+ export const constants = {
41
+ MAX_LENGTH: kMaxLength,
42
+ MAX_STRING_LENGTH: kStringMaxLength,
43
+ };
44
+ function createBuffer(length) {
45
+ if (length > kMaxLength) {
46
+ throw new ERR_OUT_OF_RANGE("The given length is invalid", `0 to ${kMaxLength}`, length);
47
+ }
48
+ const buf = new Uint8Array(length);
49
+ Object.setPrototypeOf(buf, Buffer.prototype);
50
+ return buf;
51
+ }
52
+ export function Buffer(value, encodingOrOffset, length) {
53
+ if (typeof value === "number") {
54
+ if (typeof encodingOrOffset === "string") {
55
+ throw new ERR_INVALID_ARG_TYPE("string", "string", value);
56
+ }
57
+ return allocUnsafe(value);
58
+ }
59
+ return _from(value, encodingOrOffset, length);
60
+ }
61
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
62
+ Object.setPrototypeOf(Buffer, Uint8Array);
63
+ Object.defineProperties(Buffer, {
64
+ // By default, Node.js allocates Buffers from a shared slab allocation
65
+ // as a performance optimization. While this is fast, it's not ideal
66
+ // in our environment as it could potentially be used to leak buffer
67
+ // data across multiple requests. We always want our Buffer instances
68
+ // to be distinct allocations. To signal this, we keep our poolSize
69
+ // always set to 0.
70
+ poolSize: {
71
+ enumerable: true,
72
+ value: 0,
73
+ writable: false,
74
+ },
75
+ });
76
+ Object.defineProperties(Buffer.prototype, {
77
+ parent: {
78
+ enumerable: true,
79
+ get() {
80
+ if (!Buffer.isBuffer(this)) {
81
+ return void 0;
82
+ }
83
+ return this.buffer;
84
+ },
85
+ },
86
+ offset: {
87
+ enumerable: true,
88
+ get() {
89
+ if (!Buffer.isBuffer(this)) {
90
+ return void 0;
91
+ }
92
+ return this.byteOffset;
93
+ },
94
+ },
95
+ [kIsBuffer]: {
96
+ enumerable: false,
97
+ configurable: false,
98
+ value: true,
99
+ },
100
+ });
101
+ function _from(value, encodingOrOffset, length) {
102
+ if (typeof value === "string") {
103
+ return fromString(value, encodingOrOffset);
104
+ }
105
+ if (typeof value === "object" && value != null) {
106
+ if (isAnyArrayBuffer(value)) {
107
+ return fromArrayBuffer(value, encodingOrOffset, length);
108
+ }
109
+ const valueOf = value?.valueOf();
110
+ if (valueOf != null &&
111
+ valueOf !== value &&
112
+ (typeof valueOf === "string" || typeof valueOf === "object")) {
113
+ return _from(valueOf, encodingOrOffset, length);
114
+ }
115
+ if (value.length !== undefined ||
116
+ isAnyArrayBuffer(value.buffer)) {
117
+ if (typeof value.length !== "number") {
118
+ return createBuffer(0);
119
+ }
120
+ return fromArrayLike(value);
121
+ }
122
+ if (value.type === "Buffer" &&
123
+ Array.isArray(value.data)) {
124
+ return fromArrayLike(value.data);
125
+ }
126
+ const toPrimitive = value[Symbol.toPrimitive];
127
+ if (typeof toPrimitive === "function") {
128
+ const primitive = toPrimitive("string");
129
+ if (typeof primitive === "string") {
130
+ return fromString(primitive, encodingOrOffset);
131
+ }
132
+ }
133
+ }
134
+ throw new ERR_INVALID_ARG_TYPE("first argument", [
135
+ "string",
136
+ "Buffer",
137
+ "TypedArray",
138
+ "ArrayBuffer",
139
+ "SharedArrayBuffer",
140
+ "Array",
141
+ "Array-like Object",
142
+ ], value);
143
+ }
144
+ function from(value, encodingOrOffset, length) {
145
+ return _from(value, encodingOrOffset, length);
146
+ }
147
+ function fromString(string, encoding) {
148
+ if (typeof encoding !== "string" || encoding === "") {
149
+ encoding = "utf8";
150
+ }
151
+ const normalizedEncoding = normalizeEncoding(encoding);
152
+ if (normalizedEncoding === undefined) {
153
+ throw new ERR_UNKNOWN_ENCODING(`${encoding}`);
154
+ }
155
+ const ab = bufferUtil.decodeString(`${string}`, normalizedEncoding);
156
+ if (ab === undefined) {
157
+ throw new ERR_INVALID_ARG_VALUE("string", string, `Unable to decode string using encoding ${encoding}`);
158
+ }
159
+ return fromArrayBuffer(ab.buffer, 0, ab.byteLength);
160
+ }
161
+ function fromArrayLike(array) {
162
+ const u8 = Uint8Array.from(array);
163
+ return fromArrayBuffer(u8.buffer, u8.byteOffset, u8.byteLength);
164
+ }
165
+ function fromArrayBuffer(obj, byteOffset, length) {
166
+ // Convert byteOffset to integer
167
+ if (byteOffset === undefined) {
168
+ byteOffset = 0;
169
+ }
170
+ else {
171
+ byteOffset = +byteOffset;
172
+ if (Number.isNaN(byteOffset)) {
173
+ byteOffset = 0;
174
+ }
175
+ }
176
+ const maxLength = obj.byteLength - byteOffset;
177
+ if (maxLength < 0) {
178
+ throw new ERR_BUFFER_OUT_OF_BOUNDS("offset");
179
+ }
180
+ if (length === undefined) {
181
+ length = maxLength;
182
+ }
183
+ else {
184
+ // Convert length to non-negative integer.
185
+ length = +length;
186
+ if (length > 0) {
187
+ if (length > maxLength) {
188
+ throw new ERR_BUFFER_OUT_OF_BOUNDS("length");
189
+ }
190
+ }
191
+ else {
192
+ length = 0;
193
+ }
194
+ }
195
+ const buffer = new Uint8Array(obj, byteOffset, length);
196
+ Object.setPrototypeOf(buffer, Buffer.prototype);
197
+ return buffer;
198
+ }
199
+ Buffer.from = from;
200
+ function of(...args) {
201
+ const buf = Buffer.alloc(args.length);
202
+ for (let k = 0; k < args.length; k++)
203
+ buf[k] = args[k];
204
+ return buf;
205
+ }
206
+ Buffer.of = of;
207
+ function alloc(size, fill, encoding) {
208
+ validateNumber(size, "size");
209
+ if (Number.isNaN(size)) {
210
+ throw new ERR_INVALID_ARG_VALUE.RangeError("size", size);
211
+ }
212
+ if (size >= kMaxLength) {
213
+ throw new ERR_OUT_OF_RANGE("size", `0 to ${kMaxLength}`, size);
214
+ }
215
+ const buffer = createBuffer(size);
216
+ if (fill !== undefined) {
217
+ if (encoding !== undefined) {
218
+ validateString(encoding, "encoding");
219
+ }
220
+ return buffer.fill(fill, encoding);
221
+ }
222
+ return buffer;
223
+ }
224
+ Buffer.alloc = alloc;
225
+ function allocUnsafe(size) {
226
+ return alloc(size);
227
+ }
228
+ Buffer.allocUnsafe = allocUnsafe;
229
+ Buffer.allocUnsafeSlow = allocUnsafe;
230
+ export function SlowBuffer(length) {
231
+ return alloc(+length);
232
+ }
233
+ Object.setPrototypeOf(SlowBuffer.prototype, Uint8Array.prototype);
234
+ Object.setPrototypeOf(SlowBuffer, Uint8Array);
235
+ Buffer.isBuffer = function isBuffer(b) {
236
+ return b instanceof Buffer;
237
+ };
238
+ export function compare(a, b) {
239
+ if (isInstance(a, Uint8Array)) {
240
+ const buf = a;
241
+ a = fromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength);
242
+ }
243
+ if (isInstance(b, Uint8Array)) {
244
+ const buf = b;
245
+ b = fromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength);
246
+ }
247
+ if (!Buffer.isBuffer(a)) {
248
+ throw new ERR_INVALID_ARG_TYPE("a", ["Buffer", "Uint8Array"], typeof a);
249
+ }
250
+ if (!Buffer.isBuffer(b)) {
251
+ throw new ERR_INVALID_ARG_TYPE("b", ["Buffer", "Uint8Array"], typeof b);
252
+ }
253
+ if (a === b)
254
+ return 0;
255
+ return bufferUtil.compare(a, b);
256
+ }
257
+ Buffer.compare = compare;
258
+ export function isEncoding(encoding) {
259
+ return (typeof encoding === "string" &&
260
+ encoding.length !== 0 &&
261
+ normalizeEncoding(encoding) !== undefined);
262
+ }
263
+ Buffer.isEncoding = isEncoding;
264
+ Buffer.concat = function concat(list, length) {
265
+ if (!Array.isArray(list)) {
266
+ throw new ERR_INVALID_ARG_TYPE("list", "(Buffer|Uint8Array)[]", list);
267
+ }
268
+ if (list.length === 0)
269
+ return alloc(0);
270
+ if (length === undefined) {
271
+ length = 0;
272
+ for (let i = 0; i < list.length; i++) {
273
+ if (list[i].length !== undefined) {
274
+ length += list[i].length;
275
+ }
276
+ else {
277
+ throw new ERR_INVALID_ARG_TYPE("list", "(Buffer|Uint8Array)[]", list[i]);
278
+ }
279
+ }
280
+ }
281
+ validateOffset(length, "length");
282
+ const ab = bufferUtil.concat(list, length);
283
+ return fromArrayBuffer(ab.buffer, 0, length);
284
+ };
285
+ function base64ByteLength(str) {
286
+ let len = str.length;
287
+ if (str.charCodeAt(len - 1) === 0x3d) {
288
+ len--;
289
+ }
290
+ if (len > 1 && str.charCodeAt(len - 1) === 0x3d)
291
+ len--;
292
+ // Base64 ratio: 3/4
293
+ return (len * 3) >>> 2;
294
+ }
295
+ function byteLength(string, encoding) {
296
+ if (typeof string !== "string") {
297
+ if (isArrayBufferView(string) || isAnyArrayBuffer(string)) {
298
+ return string.byteLength;
299
+ }
300
+ throw new ERR_INVALID_ARG_TYPE("string", ["string", "Buffer", "ArrayBuffer"], string);
301
+ }
302
+ string = `${string}`;
303
+ const normalizedEncoding = normalizeEncoding(encoding) ?? UTF8;
304
+ switch (normalizedEncoding) {
305
+ case ASCII:
306
+ // Fall through
307
+ case LATIN1:
308
+ return string.length;
309
+ case UTF16LE:
310
+ return string.length * 2;
311
+ case BASE64:
312
+ // Fall through
313
+ case BASE64URL:
314
+ return base64ByteLength(string);
315
+ case HEX:
316
+ return string.length >>> 1;
317
+ case UTF8:
318
+ // Fall-through
319
+ default:
320
+ return bufferUtil.byteLength(string);
321
+ }
322
+ }
323
+ Buffer.byteLength = byteLength;
324
+ Buffer.prototype.swap16 = function swap16() {
325
+ const len = this.length;
326
+ if (len % 2 !== 0) {
327
+ throw new ERR_INVALID_BUFFER_SIZE(16);
328
+ }
329
+ bufferUtil.swap(this, 16);
330
+ return this;
331
+ };
332
+ Buffer.prototype.swap32 = function swap32() {
333
+ const len = this.length;
334
+ if (len % 4 !== 0) {
335
+ throw new ERR_INVALID_BUFFER_SIZE(32);
336
+ }
337
+ bufferUtil.swap(this, 32);
338
+ return this;
339
+ };
340
+ Buffer.prototype.swap64 = function swap64() {
341
+ const len = this.length;
342
+ if (len % 8 !== 0) {
343
+ throw new ERR_INVALID_BUFFER_SIZE(64);
344
+ }
345
+ bufferUtil.swap(this, 64);
346
+ return this;
347
+ };
348
+ Buffer.prototype.toString = function toString(encoding, start, end) {
349
+ if (arguments.length === 0) {
350
+ return bufferUtil.toString(this, 0, this.length, UTF8);
351
+ }
352
+ const len = this.length;
353
+ if (start === undefined || start <= 0) {
354
+ start = 0;
355
+ }
356
+ else if (start >= len) {
357
+ return "";
358
+ }
359
+ else {
360
+ start |= 0;
361
+ }
362
+ if (end === undefined || end > len) {
363
+ end = len;
364
+ }
365
+ else {
366
+ end |= 0;
367
+ }
368
+ if (end <= start) {
369
+ return "";
370
+ }
371
+ const normalizedEncoding = getEncodingOps(encoding);
372
+ if (normalizedEncoding === undefined) {
373
+ throw new ERR_UNKNOWN_ENCODING(`${encoding}`);
374
+ }
375
+ return bufferUtil.toString(this, start, end, normalizedEncoding);
376
+ };
377
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
378
+ Buffer.prototype.equals = function equals(b) {
379
+ return compare(this, b) === 0;
380
+ };
381
+ Buffer.prototype.inspect = function inspect(_recurseTimes, ctx) {
382
+ let str = "";
383
+ const max = Math.min(this.byteLength, INSPECT_MAX_BYTES);
384
+ str = this.toString("hex", 0, max)
385
+ .replace(/(.{2})/g, "$1 ")
386
+ .trim();
387
+ const remaining = this.byteLength - max;
388
+ if (remaining > 0) {
389
+ str += ` ... ${remaining} more byte${remaining > 1 ? "s" : ""}`;
390
+ }
391
+ // Inspect special properties as well, if possible.
392
+ if (ctx) {
393
+ let extras = false;
394
+ const filter = ctx.showHidden
395
+ ? internalUtil.ALL_PROPERTIES
396
+ : internalUtil.ONLY_ENUMERABLE;
397
+ const obj = { __proto__: null };
398
+ internalUtil.getOwnNonIndexProperties(this, filter).forEach((key) => {
399
+ extras = true;
400
+ obj[key] = this[key];
401
+ });
402
+ if (extras) {
403
+ if (this.length !== 0)
404
+ str += ", ";
405
+ // The browser util polyfill omits null-prototype prefixes and symbols.
406
+ // Buffer owns this property list; render its keys explicitly instead of
407
+ // slicing a host-specific object inspection prefix.
408
+ const options = { ...ctx, breakLength: Infinity, compact: true };
409
+ str += Reflect.ownKeys(obj)
410
+ .map((key) => {
411
+ const name = typeof key === "symbol"
412
+ ? String(key)
413
+ : /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)
414
+ ? key
415
+ : utilInspect(key, options);
416
+ return `${name}: ${utilInspect(obj[key], options)}`;
417
+ })
418
+ .join(", ");
419
+ }
420
+ }
421
+ return "<Buffer " + str + ">";
422
+ };
423
+ if (customInspectSymbol) {
424
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
425
+ }
426
+ Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
427
+ if (isInstance(target, Uint8Array)) {
428
+ target = fromArrayBuffer(target.buffer, target.byteOffset, target.byteLength);
429
+ }
430
+ if (!Buffer.isBuffer(target)) {
431
+ throw new ERR_INVALID_ARG_TYPE("target", ["Buffer", "Uint8Array"], target);
432
+ }
433
+ if (start === undefined) {
434
+ start = 0;
435
+ }
436
+ else {
437
+ validateOffset(start, "targetStart", 0, kMaxLength);
438
+ }
439
+ if (end === undefined) {
440
+ end = target.length;
441
+ }
442
+ else {
443
+ validateOffset(end, "targetEnd", 0, target.length);
444
+ }
445
+ if (thisStart === undefined) {
446
+ thisStart = 0;
447
+ }
448
+ else {
449
+ validateOffset(thisStart, "sourceStart", 0, kMaxLength);
450
+ }
451
+ if (thisEnd === undefined) {
452
+ thisEnd = this.length;
453
+ }
454
+ else {
455
+ validateOffset(thisEnd, "sourceEnd", 0, this.length);
456
+ }
457
+ return bufferUtil.compare(this, target, {
458
+ aStart: thisStart,
459
+ aEnd: thisEnd,
460
+ bStart: start,
461
+ bEnd: end,
462
+ });
463
+ };
464
+ function includes(val, byteOffset, encoding) {
465
+ return this.indexOf(val, byteOffset, encoding) !== -1;
466
+ }
467
+ Buffer.prototype.includes = includes;
468
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
469
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
470
+ //
471
+ // Arguments:
472
+ // - buffer - a Buffer to search
473
+ // - val - a string, Buffer, or number
474
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
475
+ // - encoding - an optional encoding, relevant if val is a string
476
+ // - dir - true for indexOf, false for lastIndexOf
477
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
478
+ if (Buffer.isBuffer(val) && !isUint8Array(val)) {
479
+ throw new ERR_INVALID_ARG_TYPE("val", ["string", "number", "Buffer", "Uint8Array"], val);
480
+ }
481
+ if (typeof byteOffset === "string") {
482
+ encoding = byteOffset;
483
+ byteOffset = undefined;
484
+ }
485
+ else if (byteOffset > 0x7fffffff) {
486
+ byteOffset = 0x7fffffff;
487
+ }
488
+ else if (byteOffset < -0x80000000) {
489
+ byteOffset = -0x80000000;
490
+ }
491
+ // Coerce to Number. Values like null and [] become 0.
492
+ byteOffset = +byteOffset;
493
+ // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer.
494
+ if (Number.isNaN(byteOffset)) {
495
+ byteOffset = dir ? 0 : buffer.length || buffer.byteLength;
496
+ }
497
+ dir = !!dir; // Cast to bool.
498
+ if (typeof val === "number") {
499
+ val = (val >>> 0) & 0xff;
500
+ if (dir) {
501
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
502
+ }
503
+ else {
504
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
505
+ }
506
+ }
507
+ if (typeof val !== "string" && !isUint8Array(val) && !Buffer.isBuffer(val)) {
508
+ throw new ERR_INVALID_ARG_TYPE("value", ["number", "string", "Buffer", "Uint8Array"], val);
509
+ }
510
+ const normalizedEncoding = normalizeEncoding(encoding);
511
+ if (normalizedEncoding === undefined) {
512
+ throw new ERR_UNKNOWN_ENCODING(`${encoding}`);
513
+ }
514
+ const result = bufferUtil.indexOf(buffer, val, byteOffset, normalizedEncoding, dir);
515
+ return result == null ? -1 : result;
516
+ }
517
+ Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
518
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
519
+ };
520
+ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
521
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
522
+ };
523
+ Buffer.prototype.asciiSlice = function asciiSlice(start, end) {
524
+ validateOffset(start, "start", 0, this.length);
525
+ validateOffset(end, "end", 0, this.length);
526
+ return bufferUtil.toString(this, start, end, ASCII);
527
+ };
528
+ Buffer.prototype.base64Slice = function base64Slice(start, end) {
529
+ validateOffset(start, "start", 0, this.length);
530
+ validateOffset(end, "end", 0, this.length);
531
+ return bufferUtil.toString(this, start, end, BASE64);
532
+ };
533
+ Buffer.prototype.base64urlSlice = function base64urlSlice(start, end) {
534
+ validateOffset(start, "start", 0, this.length);
535
+ validateOffset(end, "end", 0, this.length);
536
+ return bufferUtil.toString(this, start, end, BASE64URL);
537
+ };
538
+ Buffer.prototype.hexSlice = function hexSlice(start, end) {
539
+ validateOffset(start, "start", 0, this.length);
540
+ validateOffset(end, "end", 0, this.length);
541
+ return bufferUtil.toString(this, start, end, HEX);
542
+ };
543
+ Buffer.prototype.latin1Slice = function latin1Slice(start, end) {
544
+ validateOffset(start, "start", 0, this.length);
545
+ validateOffset(end, "end", 0, this.length);
546
+ return bufferUtil.toString(this, start, end, LATIN1);
547
+ };
548
+ Buffer.prototype.ucs2Slice = function ucs2Slice(start, end) {
549
+ validateOffset(start, "start", 0, this.length);
550
+ validateOffset(end, "end", 0, this.length);
551
+ return bufferUtil.toString(this, start, end, UTF16LE);
552
+ };
553
+ Buffer.prototype.utf8Slice = function utf8Slice(start, end) {
554
+ validateOffset(start, "start", 0, this.length);
555
+ validateOffset(end, "end", 0, this.length);
556
+ return bufferUtil.toString(this, start, end, UTF8);
557
+ };
558
+ Buffer.prototype.asciiWrite = function asciiWrite(string, offset, length) {
559
+ offset ??= 0;
560
+ length ??= this.length;
561
+ validateOffset(offset, "offset", 0, this.length);
562
+ validateOffset(length, "length", 0, this.length - offset);
563
+ return bufferUtil.write(this, `${string}`, offset, length, ASCII);
564
+ };
565
+ Buffer.prototype.base64Write = function base64Write(string, offset, length) {
566
+ offset ??= 0;
567
+ length ??= this.length;
568
+ validateOffset(offset, "offset", 0, this.length);
569
+ validateOffset(length, "length", 0, this.length - offset);
570
+ return bufferUtil.write(this, `${string}`, offset, length, BASE64);
571
+ };
572
+ Buffer.prototype.base64urlWrite = function base64urlWrite(string, offset, length) {
573
+ offset ??= 0;
574
+ length ??= this.length;
575
+ validateOffset(offset, "offset", 0, this.length);
576
+ validateOffset(length, "length", 0, this.length - offset);
577
+ return bufferUtil.write(this, `${string}`, offset, length, BASE64URL);
578
+ };
579
+ Buffer.prototype.hexWrite = function hexWrite(string, offset, length) {
580
+ offset ??= 0;
581
+ length ??= this.length;
582
+ validateOffset(offset, "offset", 0, this.length);
583
+ validateOffset(length, "length", 0, this.length - offset);
584
+ return bufferUtil.write(this, `${string}`, offset, length, HEX);
585
+ };
586
+ Buffer.prototype.latin1Write = function latin1Write(string, offset, length) {
587
+ offset ??= 0;
588
+ length ??= this.length;
589
+ validateOffset(offset, "offset", 0, this.length);
590
+ validateOffset(length, "length", 0, this.length - offset);
591
+ return bufferUtil.write(this, `${string}`, offset, length, LATIN1);
592
+ };
593
+ Buffer.prototype.ucs2Write = function ucs2Write(string, offset, length) {
594
+ offset ??= 0;
595
+ length ??= this.length;
596
+ validateOffset(offset, "offset", 0, this.length);
597
+ validateOffset(length, "length", 0, this.length - offset);
598
+ return bufferUtil.write(this, `${string}`, offset, length, UTF16LE);
599
+ };
600
+ Buffer.prototype.utf8Write = function utf8Write(string, offset, length) {
601
+ offset ??= 0;
602
+ length ??= this.length;
603
+ validateOffset(offset, "offset", 0, this.length);
604
+ validateOffset(length, "length", 0, this.length - offset);
605
+ return bufferUtil.write(this, `${string}`, offset, length, UTF8);
606
+ };
607
+ Buffer.prototype.write = function write(string, offset, length, encoding) {
608
+ string = `${string}`;
609
+ if (offset === undefined) {
610
+ // Buffer#write(string)
611
+ return bufferUtil.write(this, string, 0, this.length, UTF8);
612
+ }
613
+ if (length === undefined && typeof offset === "string") {
614
+ // Buffer#write(string, encoding)
615
+ encoding = offset;
616
+ length = this.length;
617
+ offset = 0;
618
+ }
619
+ else {
620
+ // Buffer#write(string, offset[, length][, encoding])
621
+ validateOffset(offset, "offset", 0, this.length);
622
+ const remaining = this.length - offset;
623
+ if (length === undefined) {
624
+ length = remaining;
625
+ }
626
+ else if (typeof length === "string") {
627
+ encoding = length;
628
+ length = remaining;
629
+ }
630
+ else {
631
+ validateOffset(length, "length", 0, this.length);
632
+ if (length > remaining) {
633
+ length = remaining;
634
+ }
635
+ }
636
+ }
637
+ if (!encoding) {
638
+ return bufferUtil.write(this, string, offset, length, UTF8);
639
+ }
640
+ const normalizedEncoding = normalizeEncoding(encoding);
641
+ if (normalizedEncoding === undefined) {
642
+ throw new ERR_UNKNOWN_ENCODING(`${encoding}`);
643
+ }
644
+ return bufferUtil.write(this, string, offset, length, normalizedEncoding);
645
+ };
646
+ Buffer.prototype.toJSON = function toJSON() {
647
+ return {
648
+ type: "Buffer",
649
+ data: Array.prototype.slice.call(this._arr || this, 0),
650
+ };
651
+ };
652
+ Buffer.prototype.slice = function slice(start, end) {
653
+ const len = this.length;
654
+ start = ~~start;
655
+ end = end === void 0 ? len : ~~end;
656
+ if (start < 0) {
657
+ start += len;
658
+ if (start < 0) {
659
+ start = 0;
660
+ }
661
+ }
662
+ else if (start > len) {
663
+ start = len;
664
+ }
665
+ if (end === undefined) {
666
+ end = this.byteLength;
667
+ }
668
+ else if (end < 0) {
669
+ end += len;
670
+ if (end < 0) {
671
+ end = 0;
672
+ }
673
+ }
674
+ else if (end > len) {
675
+ end = len;
676
+ }
677
+ if (end < start) {
678
+ end = start;
679
+ }
680
+ const newBuf = this.subarray(start, end);
681
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
682
+ return newBuf;
683
+ };
684
+ Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength) {
685
+ if (offset === undefined) {
686
+ throw new ERR_INVALID_ARG_TYPE("offset", "number", offset);
687
+ }
688
+ switch (byteLength) {
689
+ case 1:
690
+ return this.readUInt8(offset);
691
+ case 2:
692
+ return this.readUInt16LE(offset);
693
+ case 3:
694
+ return readUInt24LE(this, offset);
695
+ case 4:
696
+ return this.readUInt32LE(offset);
697
+ case 5:
698
+ return readUInt40LE(this, offset);
699
+ case 6:
700
+ return readUInt48LE(this, offset);
701
+ default:
702
+ boundsError(byteLength, 6, "byteLength");
703
+ }
704
+ };
705
+ Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength) {
706
+ if (offset === undefined) {
707
+ throw new ERR_INVALID_ARG_TYPE("offset", "number", offset);
708
+ }
709
+ switch (byteLength) {
710
+ case 1:
711
+ return this.readUInt8(offset);
712
+ case 2:
713
+ return this.readUInt16BE(offset);
714
+ case 3:
715
+ return readUInt24BE(this, offset);
716
+ case 4:
717
+ return this.readUInt32BE(offset);
718
+ case 5:
719
+ return readUInt40BE(this, offset);
720
+ case 6:
721
+ return readUInt48BE(this, offset);
722
+ default:
723
+ boundsError(byteLength, 6, "byteLength");
724
+ }
725
+ };
726
+ Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset = 0) {
727
+ validateOffset(offset, "offset", 0, this.length);
728
+ const val = this[offset];
729
+ if (val === undefined) {
730
+ boundsError(offset, this.length - 1);
731
+ }
732
+ return val;
733
+ };
734
+ Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = readUInt16BE;
735
+ Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE =
736
+ function readUInt16LE(offset = 0) {
737
+ validateOffset(offset, "offset", 0, this.length);
738
+ const first = this[offset];
739
+ const last = this[offset + 1];
740
+ if (first === undefined || last === undefined) {
741
+ boundsError(offset, this.length - 2);
742
+ }
743
+ return first + last * 2 ** 8;
744
+ };
745
+ Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE =
746
+ function readUInt32LE(offset = 0) {
747
+ validateOffset(offset, "offset", 0, this.length);
748
+ const first = this[offset];
749
+ const last = this[offset + 3];
750
+ if (first === undefined || last === undefined) {
751
+ boundsError(offset, this.length - 4);
752
+ }
753
+ return (first +
754
+ this[++offset] * 2 ** 8 +
755
+ this[++offset] * 2 ** 16 +
756
+ last * 2 ** 24);
757
+ };
758
+ Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = readUInt32BE;
759
+ Buffer.prototype.readBigUint64LE = Buffer.prototype.readBigUInt64LE =
760
+ function readBigUInt64LE(offset = 0) {
761
+ offset = offset >>> 0;
762
+ validateOffset(offset, "offset", 0, this.length);
763
+ const first = this[offset];
764
+ const last = this[offset + 7];
765
+ if (first === undefined || last === undefined) {
766
+ boundsError(offset, this.length - 8);
767
+ }
768
+ const lo = first +
769
+ this[++offset] * 2 ** 8 +
770
+ this[++offset] * 2 ** 16 +
771
+ this[++offset] * 2 ** 24;
772
+ const hi = this[++offset] +
773
+ this[++offset] * 2 ** 8 +
774
+ this[++offset] * 2 ** 16 +
775
+ last * 2 ** 24;
776
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
777
+ };
778
+ Buffer.prototype.readBigUint64BE = Buffer.prototype.readBigUInt64BE =
779
+ function readBigUInt64BE(offset = 0) {
780
+ offset = offset >>> 0;
781
+ validateOffset(offset, "offset", 0, this.length);
782
+ const first = this[offset];
783
+ const last = this[offset + 7];
784
+ if (first === undefined || last === undefined) {
785
+ boundsError(offset, this.length - 8);
786
+ }
787
+ const hi = first * 2 ** 24 +
788
+ this[++offset] * 2 ** 16 +
789
+ this[++offset] * 2 ** 8 +
790
+ this[++offset];
791
+ const lo = this[++offset] * 2 ** 24 +
792
+ this[++offset] * 2 ** 16 +
793
+ this[++offset] * 2 ** 8 +
794
+ last;
795
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
796
+ };
797
+ Buffer.prototype.readIntLE = function readIntLE(offset, byteLength) {
798
+ if (offset === undefined) {
799
+ throw new ERR_INVALID_ARG_TYPE("offset", "number", offset);
800
+ }
801
+ switch (byteLength) {
802
+ case 1:
803
+ return this.readInt8(offset);
804
+ case 2:
805
+ return this.readInt16LE(offset);
806
+ case 3:
807
+ return readInt24LE(this, offset);
808
+ case 4:
809
+ return this.readInt32LE(offset);
810
+ case 5:
811
+ return readInt40LE(this, offset);
812
+ case 6:
813
+ return readInt48LE(this, offset);
814
+ default:
815
+ boundsError(byteLength, 6, "byteLength");
816
+ }
817
+ };
818
+ Buffer.prototype.readIntBE = function readIntBE(offset, byteLength) {
819
+ if (offset === undefined) {
820
+ throw new ERR_INVALID_ARG_TYPE("offset", "number", offset);
821
+ }
822
+ switch (byteLength) {
823
+ case 1:
824
+ return this.readInt8(offset);
825
+ case 2:
826
+ return this.readInt16BE(offset);
827
+ case 3:
828
+ return readInt24BE(this, offset);
829
+ case 4:
830
+ return this.readInt32BE(offset);
831
+ case 5:
832
+ return readInt40BE(this, offset);
833
+ case 6:
834
+ return readInt48BE(this, offset);
835
+ default:
836
+ boundsError(byteLength, 6, "byteLength");
837
+ }
838
+ };
839
+ Buffer.prototype.readInt8 = function readInt8(offset = 0) {
840
+ validateOffset(offset, "offset", 0, this.length);
841
+ const val = this[offset];
842
+ if (val === undefined) {
843
+ boundsError(offset, this.length - 1);
844
+ }
845
+ return val | ((val & (2 ** 7)) * 0x1fffffe);
846
+ };
847
+ Buffer.prototype.readInt16LE = function readInt16LE(offset = 0) {
848
+ validateOffset(offset, "offset", 0, this.length);
849
+ const first = this[offset];
850
+ const last = this[offset + 1];
851
+ if (first === undefined || last === undefined) {
852
+ boundsError(offset, this.length - 2);
853
+ }
854
+ const val = first + last * 2 ** 8;
855
+ return val | ((val & (2 ** 15)) * 0x1fffe);
856
+ };
857
+ Buffer.prototype.readInt16BE = function readInt16BE(offset = 0) {
858
+ validateOffset(offset, "offset", 0, this.length);
859
+ const first = this[offset];
860
+ const last = this[offset + 1];
861
+ if (first === undefined || last === undefined) {
862
+ boundsError(offset, this.length - 2);
863
+ }
864
+ const val = first * 2 ** 8 + last;
865
+ return val | ((val & (2 ** 15)) * 0x1fffe);
866
+ };
867
+ Buffer.prototype.readInt32LE = function readInt32LE(offset = 0) {
868
+ validateOffset(offset, "offset", 0, this.length);
869
+ const first = this[offset];
870
+ const last = this[offset + 3];
871
+ if (first === undefined || last === undefined) {
872
+ boundsError(offset, this.length - 4);
873
+ }
874
+ return (first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + (last << 24)); // Overflow
875
+ };
876
+ Buffer.prototype.readInt32BE = function readInt32BE(offset = 0) {
877
+ validateOffset(offset, "offset", 0, this.length);
878
+ const first = this[offset];
879
+ const last = this[offset + 3];
880
+ if (first === undefined || last === undefined) {
881
+ boundsError(offset, this.length - 4);
882
+ }
883
+ return ((first << 24) + // Overflow
884
+ this[++offset] * 2 ** 16 +
885
+ this[++offset] * 2 ** 8 +
886
+ last);
887
+ };
888
+ Buffer.prototype.readBigInt64LE = function readBigInt64LE(offset = 0) {
889
+ offset = offset >>> 0;
890
+ validateOffset(offset, "offset", 0, this.length);
891
+ const first = this[offset];
892
+ const last = this[offset + 7];
893
+ if (first === undefined || last === undefined) {
894
+ boundsError(offset, this.length - 8);
895
+ }
896
+ const val = this[offset + 4] +
897
+ this[offset + 5] * 2 ** 8 +
898
+ this[offset + 6] * 2 ** 16 +
899
+ (last << 24);
900
+ return ((BigInt(val) << BigInt(32)) +
901
+ BigInt(first +
902
+ this[++offset] * 2 ** 8 +
903
+ this[++offset] * 2 ** 16 +
904
+ this[++offset] * 2 ** 24));
905
+ };
906
+ Buffer.prototype.readBigInt64BE = function readBigInt64BE(offset = 0) {
907
+ offset = offset >>> 0;
908
+ validateOffset(offset, "offset", 0, this.length);
909
+ const first = this[offset];
910
+ const last = this[offset + 7];
911
+ if (first === undefined || last === undefined) {
912
+ boundsError(offset, this.length - 8);
913
+ }
914
+ const val = (first << 24) +
915
+ this[++offset] * 2 ** 16 +
916
+ this[++offset] * 2 ** 8 +
917
+ this[++offset];
918
+ return ((BigInt(val) << BigInt(32)) +
919
+ BigInt(this[++offset] * 2 ** 24 +
920
+ this[++offset] * 2 ** 16 +
921
+ this[++offset] * 2 ** 8 +
922
+ last));
923
+ };
924
+ Buffer.prototype.readFloatLE = function readFloatLE(offset = 0) {
925
+ return bigEndian
926
+ ? readFloatBackwards(this, offset)
927
+ : readFloatForwards(this, offset);
928
+ };
929
+ Buffer.prototype.readFloatBE = function readFloatBE(offset = 0) {
930
+ return bigEndian
931
+ ? readFloatForwards(this, offset)
932
+ : readFloatBackwards(this, offset);
933
+ };
934
+ Buffer.prototype.readDoubleLE = function readDoubleLE(offset = 0) {
935
+ return bigEndian
936
+ ? readDoubleBackwards(this, offset)
937
+ : readDoubleForwards(this, offset);
938
+ };
939
+ Buffer.prototype.readDoubleBE = function readDoubleBE(offset = 0) {
940
+ return bigEndian
941
+ ? readDoubleForwards(this, offset)
942
+ : readDoubleBackwards(this, offset);
943
+ };
944
+ Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE =
945
+ function writeUIntLE(value, offset, byteLength) {
946
+ switch (byteLength) {
947
+ case 1:
948
+ return writeU_Int8(this, value, offset, 0, 0xff);
949
+ case 2:
950
+ return writeU_Int16LE(this, value, offset, 0, 0xffff);
951
+ case 3:
952
+ return writeU_Int24LE(this, value, offset, 0, 0xffffff);
953
+ case 4:
954
+ return writeU_Int32LE(this, value, offset, 0, 0xffffffff);
955
+ case 5:
956
+ return writeU_Int40LE(this, value, offset, 0, 0xffffffffff);
957
+ case 6:
958
+ return writeU_Int48LE(this, value, offset, 0, 0xffffffffffff);
959
+ default:
960
+ boundsError(byteLength, 6, "byteLength");
961
+ }
962
+ };
963
+ Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE =
964
+ function writeUIntBE(value, offset, byteLength) {
965
+ switch (byteLength) {
966
+ case 1:
967
+ return writeU_Int8(this, value, offset, 0, 0xff);
968
+ case 2:
969
+ return writeU_Int16BE(this, value, offset, 0, 0xffff);
970
+ case 3:
971
+ return writeU_Int24BE(this, value, offset, 0, 0xffffff);
972
+ case 4:
973
+ return writeU_Int32BE(this, value, offset, 0, 0xffffffff);
974
+ case 5:
975
+ return writeU_Int40BE(this, value, offset, 0, 0xffffffffff);
976
+ case 6:
977
+ return writeU_Int48BE(this, value, offset, 0, 0xffffffffffff);
978
+ default:
979
+ boundsError(byteLength, 6, "byteLength");
980
+ }
981
+ };
982
+ Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset = 0) {
983
+ return writeU_Int8(this, value, offset, 0, 0xff);
984
+ };
985
+ Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE =
986
+ function writeUInt16LE(value, offset = 0) {
987
+ return writeU_Int16LE(this, value, offset, 0, 0xffff);
988
+ };
989
+ Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE =
990
+ function writeUInt16BE(value, offset = 0) {
991
+ return writeU_Int16BE(this, value, offset, 0, 0xffff);
992
+ };
993
+ Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE =
994
+ function writeUInt32LE(value, offset = 0) {
995
+ return _writeUInt32LE(this, value, offset, 0, 0xffffffff);
996
+ };
997
+ Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE =
998
+ function writeUInt32BE(value, offset = 0) {
999
+ return _writeUInt32BE(this, value, offset, 0, 0xffffffff);
1000
+ };
1001
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1002
+ checkIntBI(value, min, max, buf, offset, 7);
1003
+ let lo = Number(value & BigInt(4294967295));
1004
+ buf[offset++] = lo;
1005
+ lo = lo >> 8;
1006
+ buf[offset++] = lo;
1007
+ lo = lo >> 8;
1008
+ buf[offset++] = lo;
1009
+ lo = lo >> 8;
1010
+ buf[offset++] = lo;
1011
+ let hi = Number((value >> BigInt(32)) & BigInt(4294967295));
1012
+ buf[offset++] = hi;
1013
+ hi = hi >> 8;
1014
+ buf[offset++] = hi;
1015
+ hi = hi >> 8;
1016
+ buf[offset++] = hi;
1017
+ hi = hi >> 8;
1018
+ buf[offset++] = hi;
1019
+ return offset;
1020
+ }
1021
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1022
+ checkIntBI(value, min, max, buf, offset, 7);
1023
+ let lo = Number(value & BigInt(4294967295));
1024
+ buf[offset + 7] = lo;
1025
+ lo = lo >> 8;
1026
+ buf[offset + 6] = lo;
1027
+ lo = lo >> 8;
1028
+ buf[offset + 5] = lo;
1029
+ lo = lo >> 8;
1030
+ buf[offset + 4] = lo;
1031
+ let hi = Number((value >> BigInt(32)) & BigInt(4294967295));
1032
+ buf[offset + 3] = hi;
1033
+ hi = hi >> 8;
1034
+ buf[offset + 2] = hi;
1035
+ hi = hi >> 8;
1036
+ buf[offset + 1] = hi;
1037
+ hi = hi >> 8;
1038
+ buf[offset] = hi;
1039
+ return offset + 8;
1040
+ }
1041
+ Buffer.prototype.writeBigUint64LE = Buffer.prototype.writeBigUInt64LE =
1042
+ function writeBigUInt64LE(value, offset = 0) {
1043
+ return wrtBigUInt64LE(this, value, offset, 0n, 0xffffffffffffffffn);
1044
+ };
1045
+ Buffer.prototype.writeBigUint64BE = Buffer.prototype.writeBigUInt64BE =
1046
+ function writeBigUInt64BE(value, offset = 0) {
1047
+ return wrtBigUInt64BE(this, value, offset, 0n, 0xffffffffffffffffn);
1048
+ };
1049
+ Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength) {
1050
+ switch (byteLength) {
1051
+ case 1:
1052
+ return writeU_Int8(this, value, offset, -0x80, 0x7f);
1053
+ case 2:
1054
+ return writeU_Int16LE(this, value, offset, -0x8000, 0x7fff);
1055
+ case 3:
1056
+ return writeU_Int24LE(this, value, offset, -0x800000, 0x7fffff);
1057
+ case 4:
1058
+ return writeU_Int32LE(this, value, offset, -0x80000000, 0x7fffffff);
1059
+ case 5:
1060
+ return writeU_Int40LE(this, value, offset, -0x8000000000, 0x7fffffffff);
1061
+ case 6:
1062
+ return writeU_Int48LE(this, value, offset, -0x800000000000, 0x7fffffffffff);
1063
+ default:
1064
+ boundsError(byteLength, 6, "byteLength");
1065
+ }
1066
+ };
1067
+ Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength) {
1068
+ switch (byteLength) {
1069
+ case 1:
1070
+ return writeU_Int8(this, value, offset, -0x80, 0x7f);
1071
+ case 2:
1072
+ return writeU_Int16BE(this, value, offset, -0x8000, 0x7fff);
1073
+ case 3:
1074
+ return writeU_Int24BE(this, value, offset, -0x800000, 0x7fffff);
1075
+ case 4:
1076
+ return writeU_Int32BE(this, value, offset, -0x80000000, 0x7fffffff);
1077
+ case 5:
1078
+ return writeU_Int40BE(this, value, offset, -0x8000000000, 0x7fffffffff);
1079
+ case 6:
1080
+ return writeU_Int48BE(this, value, offset, -0x800000000000, 0x7fffffffffff);
1081
+ default:
1082
+ boundsError(byteLength, 6, "byteLength");
1083
+ }
1084
+ };
1085
+ Buffer.prototype.writeInt8 = function writeInt8(value, offset = 0) {
1086
+ return writeU_Int8(this, value, offset, -0x80, 0x7f);
1087
+ };
1088
+ Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset = 0) {
1089
+ return writeU_Int16LE(this, value, offset, -0x8000, 0x7fff);
1090
+ };
1091
+ Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset = 0) {
1092
+ return writeU_Int16BE(this, value, offset, -0x8000, 0x7fff);
1093
+ };
1094
+ Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset = 0) {
1095
+ return writeU_Int32LE(this, value, offset, -0x80000000, 0x7fffffff);
1096
+ };
1097
+ Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset = 0) {
1098
+ return writeU_Int32BE(this, value, offset, -0x80000000, 0x7fffffff);
1099
+ };
1100
+ Buffer.prototype.writeBigInt64LE = function writeBigInt64LE(value, offset = 0) {
1101
+ return wrtBigUInt64LE(this, value, offset, -0x8000000000000000n, 0x7fffffffffffffffn);
1102
+ };
1103
+ Buffer.prototype.writeBigInt64BE = function writeBigInt64BE(value, offset = 0) {
1104
+ return wrtBigUInt64BE(this, value, offset, -0x8000000000000000n, 0x7fffffffffffffffn);
1105
+ };
1106
+ Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset) {
1107
+ return bigEndian
1108
+ ? writeFloatBackwards(this, value, offset)
1109
+ : writeFloatForwards(this, value, offset);
1110
+ };
1111
+ Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset) {
1112
+ return bigEndian
1113
+ ? writeFloatForwards(this, value, offset)
1114
+ : writeFloatBackwards(this, value, offset);
1115
+ };
1116
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset) {
1117
+ return bigEndian
1118
+ ? writeDoubleBackwards(this, value, offset)
1119
+ : writeDoubleForwards(this, value, offset);
1120
+ };
1121
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset) {
1122
+ return bigEndian
1123
+ ? writeDoubleForwards(this, value, offset)
1124
+ : writeDoubleBackwards(this, value, offset);
1125
+ };
1126
+ Buffer.prototype.copy = function copy(target, targetStart, sourceStart, sourceEnd) {
1127
+ if (!isUint8Array(target)) {
1128
+ throw new ERR_INVALID_ARG_TYPE("target", ["Buffer", "Uint8Array"], target);
1129
+ }
1130
+ targetStart = toInteger(targetStart, 0);
1131
+ if (targetStart < 0) {
1132
+ throw new ERR_OUT_OF_RANGE("targetStart", ">= 0", targetStart);
1133
+ }
1134
+ sourceStart = toInteger(sourceStart, 0);
1135
+ if (sourceStart < 0) {
1136
+ throw new ERR_OUT_OF_RANGE("sourceStart", ">= 0", sourceStart);
1137
+ }
1138
+ if (sourceStart >= MAX_UINT32) {
1139
+ throw new ERR_OUT_OF_RANGE("sourceStart", `< ${MAX_UINT32}`, sourceStart);
1140
+ }
1141
+ sourceEnd ??= this.length;
1142
+ sourceEnd = toInteger(sourceEnd, 0);
1143
+ if (sourceEnd < 0) {
1144
+ throw new ERR_OUT_OF_RANGE("sourceEnd", ">= 0", sourceEnd);
1145
+ }
1146
+ if (sourceEnd >= MAX_UINT32) {
1147
+ throw new ERR_OUT_OF_RANGE("sourceEnd", `< ${MAX_UINT32}`, sourceEnd);
1148
+ }
1149
+ if (targetStart >= target.length) {
1150
+ return 0;
1151
+ }
1152
+ if (sourceEnd > 0 &&
1153
+ sourceEnd < sourceStart) {
1154
+ sourceEnd = sourceStart;
1155
+ }
1156
+ if (sourceEnd === sourceStart) {
1157
+ return 0;
1158
+ }
1159
+ if (target.length === 0 || this.length === 0) {
1160
+ return 0;
1161
+ }
1162
+ if (sourceEnd > this.length) {
1163
+ sourceEnd = this.length;
1164
+ }
1165
+ if (target.length - targetStart <
1166
+ sourceEnd - sourceStart) {
1167
+ sourceEnd =
1168
+ target.length - targetStart + sourceStart;
1169
+ }
1170
+ const len = sourceEnd - sourceStart;
1171
+ if (this === target) {
1172
+ this.copyWithin(targetStart, sourceStart, sourceEnd);
1173
+ }
1174
+ else {
1175
+ const sub = this.subarray(sourceStart, sourceEnd);
1176
+ target.set(sub, targetStart);
1177
+ }
1178
+ return len;
1179
+ };
1180
+ Buffer.prototype.fill = function fill(val, start, end, encoding) {
1181
+ let normalizedEncoding;
1182
+ if (typeof val === "string") {
1183
+ if (typeof start === "string") {
1184
+ encoding = start;
1185
+ start = 0;
1186
+ end = this.length;
1187
+ }
1188
+ else if (typeof end === "string") {
1189
+ encoding = end;
1190
+ end = this.length;
1191
+ }
1192
+ normalizedEncoding = normalizeEncoding(encoding);
1193
+ if (normalizedEncoding === undefined) {
1194
+ throw new ERR_UNKNOWN_ENCODING(`${encoding}`);
1195
+ }
1196
+ if (val.length === 1) {
1197
+ const code = val.charCodeAt(0);
1198
+ if ((encoding === "utf8" && code < 128) || encoding === "latin1") {
1199
+ val = code;
1200
+ }
1201
+ }
1202
+ }
1203
+ if (start !== undefined) {
1204
+ validateNumber(start, "start");
1205
+ }
1206
+ if (end !== undefined) {
1207
+ validateNumber(end, "end");
1208
+ }
1209
+ if (end < 0 || end > this.length) {
1210
+ throw new ERR_OUT_OF_RANGE("end", `0 to ${this.length}`, end);
1211
+ }
1212
+ if (start < 0 ||
1213
+ this.length < start ||
1214
+ this.length < end) {
1215
+ throw new ERR_OUT_OF_RANGE("start", "0 to end", start);
1216
+ }
1217
+ if (end <= start) {
1218
+ return this;
1219
+ }
1220
+ start = start >>> 0;
1221
+ end = end === void 0 ? this.length : end >>> 0;
1222
+ if (typeof val === "string") {
1223
+ bufferUtil.fillImpl(this, val, start, end, normalizedEncoding);
1224
+ return this;
1225
+ }
1226
+ if (isArrayBufferView(val)) {
1227
+ if (val.byteLength === 0) {
1228
+ throw new ERR_INVALID_ARG_VALUE("value", "zero-length");
1229
+ }
1230
+ bufferUtil.fillImpl(this, val, start, end);
1231
+ return this;
1232
+ }
1233
+ if (typeof val === "number") {
1234
+ val = val & 255;
1235
+ }
1236
+ else if (typeof val === "boolean") {
1237
+ val = Number(val);
1238
+ }
1239
+ val ??= 0;
1240
+ Uint8Array.prototype.fill.call(this, val, start, end);
1241
+ return this;
1242
+ };
1243
+ function checkBounds(buf, offset, byteLength2) {
1244
+ validateOffset(offset, "offset", 0, buf.length);
1245
+ if (buf[offset] === undefined || buf[offset + byteLength2] === undefined) {
1246
+ boundsError(offset, buf.length - (byteLength2 + 1));
1247
+ }
1248
+ }
1249
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1250
+ if (value > max || value < min) {
1251
+ const n = typeof min === "bigint" ? "n" : "";
1252
+ let range;
1253
+ if (byteLength2 > 3) {
1254
+ if (min === 0 || min === BigInt(0)) {
1255
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1256
+ }
1257
+ else {
1258
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1259
+ }
1260
+ }
1261
+ else {
1262
+ range = `>= ${min}${n} and <= ${max}${n}`;
1263
+ }
1264
+ throw new ERR_OUT_OF_RANGE("value", range, value);
1265
+ }
1266
+ checkBounds(buf, offset, byteLength2);
1267
+ }
1268
+ function isInstance(obj, type) {
1269
+ return (obj instanceof type ||
1270
+ (obj != null &&
1271
+ obj.constructor != null &&
1272
+ obj.constructor.name != null &&
1273
+ obj.constructor.name === type.name));
1274
+ }
1275
+ function readUInt48LE(buf, offset = 0) {
1276
+ validateOffset(offset, "offset", 0, buf.length);
1277
+ const first = buf[offset];
1278
+ const last = buf[offset + 5];
1279
+ if (first === undefined || last === undefined) {
1280
+ boundsError(offset, buf.length - 6);
1281
+ }
1282
+ return (first +
1283
+ buf[++offset] * 2 ** 8 +
1284
+ buf[++offset] * 2 ** 16 +
1285
+ buf[++offset] * 2 ** 24 +
1286
+ (buf[++offset] + last * 2 ** 8) * 2 ** 32);
1287
+ }
1288
+ function readUInt40LE(buf, offset = 0) {
1289
+ validateOffset(offset, "offset", 0, buf.length);
1290
+ const first = buf[offset];
1291
+ const last = buf[offset + 4];
1292
+ if (first === undefined || last === undefined) {
1293
+ boundsError(offset, buf.length - 5);
1294
+ }
1295
+ return (first +
1296
+ buf[++offset] * 2 ** 8 +
1297
+ buf[++offset] * 2 ** 16 +
1298
+ buf[++offset] * 2 ** 24 +
1299
+ last * 2 ** 32);
1300
+ }
1301
+ function readUInt24LE(buf, offset = 0) {
1302
+ validateOffset(offset, "offset", 0, buf.length);
1303
+ const first = buf[offset];
1304
+ const last = buf[offset + 2];
1305
+ if (first === undefined || last === undefined) {
1306
+ boundsError(offset, buf.length - 3);
1307
+ }
1308
+ return first + buf[++offset] * 2 ** 8 + last * 2 ** 16;
1309
+ }
1310
+ function readUInt48BE(buf, offset = 0) {
1311
+ validateOffset(offset, "offset", 0, buf.length);
1312
+ const first = buf[offset];
1313
+ const last = buf[offset + 5];
1314
+ if (first === undefined || last === undefined) {
1315
+ boundsError(offset, buf.length - 6);
1316
+ }
1317
+ return ((first * 2 ** 8 + buf[++offset]) * 2 ** 32 +
1318
+ buf[++offset] * 2 ** 24 +
1319
+ buf[++offset] * 2 ** 16 +
1320
+ buf[++offset] * 2 ** 8 +
1321
+ last);
1322
+ }
1323
+ function readUInt40BE(buf, offset = 0) {
1324
+ validateOffset(offset, "offset", 0, buf.length);
1325
+ const first = buf[offset];
1326
+ const last = buf[offset + 4];
1327
+ if (first === undefined || last === undefined) {
1328
+ boundsError(offset, buf.length - 5);
1329
+ }
1330
+ return (first * 2 ** 32 +
1331
+ buf[++offset] * 2 ** 24 +
1332
+ buf[++offset] * 2 ** 16 +
1333
+ buf[++offset] * 2 ** 8 +
1334
+ last);
1335
+ }
1336
+ function readUInt24BE(buf, offset = 0) {
1337
+ validateOffset(offset, "offset", 0, buf.length);
1338
+ const first = buf[offset];
1339
+ const last = buf[offset + 2];
1340
+ if (first === undefined || last === undefined) {
1341
+ boundsError(offset, buf.length - 3);
1342
+ }
1343
+ return first * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
1344
+ }
1345
+ function readUInt16BE(offset = 0) {
1346
+ validateOffset(offset, "offset", 0, this.length);
1347
+ const first = this[offset];
1348
+ const last = this[offset + 1];
1349
+ if (first === undefined || last === undefined) {
1350
+ boundsError(offset, this.length - 2);
1351
+ }
1352
+ return first * 2 ** 8 + last;
1353
+ }
1354
+ function readUInt32BE(offset = 0) {
1355
+ validateOffset(offset, "offset", 0, this.length);
1356
+ const first = this[offset];
1357
+ const last = this[offset + 3];
1358
+ if (first === undefined || last === undefined) {
1359
+ boundsError(offset, this.length - 4);
1360
+ }
1361
+ return (first * 2 ** 24 +
1362
+ this[++offset] * 2 ** 16 +
1363
+ this[++offset] * 2 ** 8 +
1364
+ last);
1365
+ }
1366
+ function readDoubleBackwards(buffer, offset = 0) {
1367
+ validateOffset(offset, "offset", 0, buffer.length);
1368
+ const first = buffer[offset];
1369
+ const last = buffer[offset + 7];
1370
+ if (first === undefined || last === undefined) {
1371
+ boundsError(offset, buffer.length - 8);
1372
+ }
1373
+ uInt8Float64Array[7] = first;
1374
+ uInt8Float64Array[6] = buffer[++offset];
1375
+ uInt8Float64Array[5] = buffer[++offset];
1376
+ uInt8Float64Array[4] = buffer[++offset];
1377
+ uInt8Float64Array[3] = buffer[++offset];
1378
+ uInt8Float64Array[2] = buffer[++offset];
1379
+ uInt8Float64Array[1] = buffer[++offset];
1380
+ uInt8Float64Array[0] = last;
1381
+ return float64Array[0];
1382
+ }
1383
+ function readDoubleForwards(buffer, offset = 0) {
1384
+ validateOffset(offset, "offset", 0, buffer.length);
1385
+ const first = buffer[offset];
1386
+ const last = buffer[offset + 7];
1387
+ if (first === undefined || last === undefined) {
1388
+ boundsError(offset, buffer.length - 8);
1389
+ }
1390
+ uInt8Float64Array[0] = first;
1391
+ uInt8Float64Array[1] = buffer[++offset];
1392
+ uInt8Float64Array[2] = buffer[++offset];
1393
+ uInt8Float64Array[3] = buffer[++offset];
1394
+ uInt8Float64Array[4] = buffer[++offset];
1395
+ uInt8Float64Array[5] = buffer[++offset];
1396
+ uInt8Float64Array[6] = buffer[++offset];
1397
+ uInt8Float64Array[7] = last;
1398
+ return float64Array[0];
1399
+ }
1400
+ function writeDoubleForwards(buffer, val, offset = 0) {
1401
+ val = +val;
1402
+ checkBounds(buffer, offset, 7);
1403
+ float64Array[0] = val;
1404
+ buffer[offset++] = uInt8Float64Array[0];
1405
+ buffer[offset++] = uInt8Float64Array[1];
1406
+ buffer[offset++] = uInt8Float64Array[2];
1407
+ buffer[offset++] = uInt8Float64Array[3];
1408
+ buffer[offset++] = uInt8Float64Array[4];
1409
+ buffer[offset++] = uInt8Float64Array[5];
1410
+ buffer[offset++] = uInt8Float64Array[6];
1411
+ buffer[offset++] = uInt8Float64Array[7];
1412
+ return offset;
1413
+ }
1414
+ function writeDoubleBackwards(buffer, val, offset = 0) {
1415
+ val = +val;
1416
+ checkBounds(buffer, offset, 7);
1417
+ float64Array[0] = val;
1418
+ buffer[offset++] = uInt8Float64Array[7];
1419
+ buffer[offset++] = uInt8Float64Array[6];
1420
+ buffer[offset++] = uInt8Float64Array[5];
1421
+ buffer[offset++] = uInt8Float64Array[4];
1422
+ buffer[offset++] = uInt8Float64Array[3];
1423
+ buffer[offset++] = uInt8Float64Array[2];
1424
+ buffer[offset++] = uInt8Float64Array[1];
1425
+ buffer[offset++] = uInt8Float64Array[0];
1426
+ return offset;
1427
+ }
1428
+ function readFloatBackwards(buffer, offset = 0) {
1429
+ validateOffset(offset, "offset", 0, buffer.length);
1430
+ const first = buffer[offset];
1431
+ const last = buffer[offset + 3];
1432
+ if (first === undefined || last === undefined) {
1433
+ boundsError(offset, buffer.length - 4);
1434
+ }
1435
+ uInt8Float32Array[3] = first;
1436
+ uInt8Float32Array[2] = buffer[++offset];
1437
+ uInt8Float32Array[1] = buffer[++offset];
1438
+ uInt8Float32Array[0] = last;
1439
+ return float32Array[0];
1440
+ }
1441
+ function readFloatForwards(buffer, offset = 0) {
1442
+ validateOffset(offset, "offset", 0, buffer.length);
1443
+ const first = buffer[offset];
1444
+ const last = buffer[offset + 3];
1445
+ if (first === undefined || last === undefined) {
1446
+ boundsError(offset, buffer.length - 4);
1447
+ }
1448
+ uInt8Float32Array[0] = first;
1449
+ uInt8Float32Array[1] = buffer[++offset];
1450
+ uInt8Float32Array[2] = buffer[++offset];
1451
+ uInt8Float32Array[3] = last;
1452
+ return float32Array[0];
1453
+ }
1454
+ function writeFloatForwards(buffer, val, offset = 0) {
1455
+ val = +val;
1456
+ checkBounds(buffer, offset, 3);
1457
+ float32Array[0] = val;
1458
+ buffer[offset++] = uInt8Float32Array[0];
1459
+ buffer[offset++] = uInt8Float32Array[1];
1460
+ buffer[offset++] = uInt8Float32Array[2];
1461
+ buffer[offset++] = uInt8Float32Array[3];
1462
+ return offset;
1463
+ }
1464
+ function writeFloatBackwards(buffer, val, offset = 0) {
1465
+ val = +val;
1466
+ checkBounds(buffer, offset, 3);
1467
+ float32Array[0] = val;
1468
+ buffer[offset++] = uInt8Float32Array[3];
1469
+ buffer[offset++] = uInt8Float32Array[2];
1470
+ buffer[offset++] = uInt8Float32Array[1];
1471
+ buffer[offset++] = uInt8Float32Array[0];
1472
+ return offset;
1473
+ }
1474
+ function readInt24LE(buf, offset = 0) {
1475
+ validateOffset(offset, "offset", 0, buf.length);
1476
+ const first = buf[offset];
1477
+ const last = buf[offset + 2];
1478
+ if (first === undefined || last === undefined) {
1479
+ boundsError(offset, buf.length - 3);
1480
+ }
1481
+ const val = first + buf[++offset] * 2 ** 8 + last * 2 ** 16;
1482
+ return val | ((val & (2 ** 23)) * 0x1fe);
1483
+ }
1484
+ function readInt40LE(buf, offset = 0) {
1485
+ validateOffset(offset, "offset", 0, buf.length);
1486
+ const first = buf[offset];
1487
+ const last = buf[offset + 4];
1488
+ if (first === undefined || last === undefined) {
1489
+ boundsError(offset, buf.length - 5);
1490
+ }
1491
+ return ((last | ((last & (2 ** 7)) * 0x1fffffe)) * 2 ** 32 +
1492
+ first +
1493
+ buf[++offset] * 2 ** 8 +
1494
+ buf[++offset] * 2 ** 16 +
1495
+ buf[++offset] * 2 ** 24);
1496
+ }
1497
+ function readInt48LE(buf, offset = 0) {
1498
+ validateOffset(offset, "offset", 0, buf.length);
1499
+ const first = buf[offset];
1500
+ const last = buf[offset + 5];
1501
+ if (first === undefined || last === undefined) {
1502
+ boundsError(offset, buf.length - 6);
1503
+ }
1504
+ const val = buf[offset + 4] + last * 2 ** 8;
1505
+ return ((val | ((val & (2 ** 15)) * 0x1fffe)) * 2 ** 32 +
1506
+ first +
1507
+ buf[++offset] * 2 ** 8 +
1508
+ buf[++offset] * 2 ** 16 +
1509
+ buf[++offset] * 2 ** 24);
1510
+ }
1511
+ function readInt24BE(buf, offset = 0) {
1512
+ validateOffset(offset, "offset", 0, buf.length);
1513
+ const first = buf[offset];
1514
+ const last = buf[offset + 2];
1515
+ if (first === undefined || last === undefined) {
1516
+ boundsError(offset, buf.length - 3);
1517
+ }
1518
+ const val = first * 2 ** 16 + buf[++offset] * 2 ** 8 + last;
1519
+ return val | ((val & (2 ** 23)) * 0x1fe);
1520
+ }
1521
+ function readInt48BE(buf, offset = 0) {
1522
+ validateOffset(offset, "offset", 0, buf.length);
1523
+ const first = buf[offset];
1524
+ const last = buf[offset + 5];
1525
+ if (first === undefined || last === undefined) {
1526
+ boundsError(offset, buf.length - 6);
1527
+ }
1528
+ const val = buf[++offset] + first * 2 ** 8;
1529
+ return ((val | ((val & (2 ** 15)) * 0x1fffe)) * 2 ** 32 +
1530
+ buf[++offset] * 2 ** 24 +
1531
+ buf[++offset] * 2 ** 16 +
1532
+ buf[++offset] * 2 ** 8 +
1533
+ last);
1534
+ }
1535
+ function readInt40BE(buf, offset = 0) {
1536
+ validateOffset(offset, "offset", 0, buf.length);
1537
+ const first = buf[offset];
1538
+ const last = buf[offset + 4];
1539
+ if (first === undefined || last === undefined) {
1540
+ boundsError(offset, buf.length - 5);
1541
+ }
1542
+ return ((first | ((first & (2 ** 7)) * 0x1fffffe)) * 2 ** 32 +
1543
+ buf[++offset] * 2 ** 24 +
1544
+ buf[++offset] * 2 ** 16 +
1545
+ buf[++offset] * 2 ** 8 +
1546
+ last);
1547
+ }
1548
+ function boundsError(value, length, type) {
1549
+ if (Math.floor(value) !== value) {
1550
+ throw new ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1551
+ }
1552
+ if (length < 0) {
1553
+ throw new ERR_BUFFER_OUT_OF_BOUNDS();
1554
+ }
1555
+ throw new ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
1556
+ }
1557
+ function validateNumber(value, name) {
1558
+ if (typeof value !== "number") {
1559
+ throw new ERR_INVALID_ARG_TYPE(name, "number", value);
1560
+ }
1561
+ }
1562
+ function checkInt(value, min, max, buf, offset, byteLength) {
1563
+ if (value > max || value < min) {
1564
+ const n = typeof min === "bigint" ? "n" : "";
1565
+ let range;
1566
+ if (byteLength > 3) {
1567
+ if (min === 0 || min === 0n) {
1568
+ range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;
1569
+ }
1570
+ else {
1571
+ range =
1572
+ `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and ` +
1573
+ `< 2${n} ** ${(byteLength + 1) * 8 - 1}${n}`;
1574
+ }
1575
+ }
1576
+ else {
1577
+ range = `>= ${min}${n} and <= ${max}${n}`;
1578
+ }
1579
+ throw new ERR_OUT_OF_RANGE("value", range, value);
1580
+ }
1581
+ checkBounds(buf, offset, byteLength);
1582
+ }
1583
+ function toInteger(n, defaultVal) {
1584
+ if (n === undefined)
1585
+ n = 0;
1586
+ n = +n;
1587
+ if (!Number.isNaN(n) &&
1588
+ n >= Number.MIN_SAFE_INTEGER &&
1589
+ n <= Number.MAX_SAFE_INTEGER) {
1590
+ return n % 1 === 0 ? n : Math.floor(n);
1591
+ }
1592
+ return defaultVal;
1593
+ }
1594
+ function writeU_Int8(buf, value, offset, min, max) {
1595
+ value = +value;
1596
+ validateOffset(offset, "offset", 0, buf.length);
1597
+ if (value > max || value < min) {
1598
+ throw new ERR_OUT_OF_RANGE("value", `>= ${min} and <= ${max}`, value);
1599
+ }
1600
+ if (buf[offset] === undefined) {
1601
+ boundsError(offset, buf.length - 1);
1602
+ }
1603
+ buf[offset] = value;
1604
+ return offset + 1;
1605
+ }
1606
+ function writeU_Int16BE(buf, value, offset, min, max) {
1607
+ value = +value;
1608
+ validateOffset(offset, "offset", 0, buf.length);
1609
+ checkInt(value, min, max, buf, offset, 1);
1610
+ buf[offset++] = value >>> 8;
1611
+ buf[offset++] = value;
1612
+ return offset;
1613
+ }
1614
+ function _writeUInt32LE(buf, value, offset, min, max) {
1615
+ value = +value;
1616
+ validateOffset(offset, "offset", 0, buf.length);
1617
+ checkInt(value, min, max, buf, offset, 3);
1618
+ buf[offset++] = value;
1619
+ value = value >>> 8;
1620
+ buf[offset++] = value;
1621
+ value = value >>> 8;
1622
+ buf[offset++] = value;
1623
+ value = value >>> 8;
1624
+ buf[offset++] = value;
1625
+ return offset;
1626
+ }
1627
+ function writeU_Int16LE(buf, value, offset, min, max) {
1628
+ value = +value;
1629
+ validateOffset(offset, "offset", 0, buf.length);
1630
+ checkInt(value, min, max, buf, offset, 1);
1631
+ buf[offset++] = value;
1632
+ buf[offset++] = value >>> 8;
1633
+ return offset;
1634
+ }
1635
+ function _writeUInt32BE(buf, value, offset, min, max) {
1636
+ value = +value;
1637
+ validateOffset(offset, "offset", 0, buf.length);
1638
+ checkInt(value, min, max, buf, offset, 3);
1639
+ buf[offset + 3] = value;
1640
+ value = value >>> 8;
1641
+ buf[offset + 2] = value;
1642
+ value = value >>> 8;
1643
+ buf[offset + 1] = value;
1644
+ value = value >>> 8;
1645
+ buf[offset] = value;
1646
+ return offset + 4;
1647
+ }
1648
+ function writeU_Int48BE(buf, value, offset, min, max) {
1649
+ value = +value;
1650
+ validateOffset(offset, "offset", 0, buf.length);
1651
+ checkInt(value, min, max, buf, offset, 5);
1652
+ const newVal = Math.floor(value * 2 ** -32);
1653
+ buf[offset++] = newVal >>> 8;
1654
+ buf[offset++] = newVal;
1655
+ buf[offset + 3] = value;
1656
+ value = value >>> 8;
1657
+ buf[offset + 2] = value;
1658
+ value = value >>> 8;
1659
+ buf[offset + 1] = value;
1660
+ value = value >>> 8;
1661
+ buf[offset] = value;
1662
+ return offset + 4;
1663
+ }
1664
+ function writeU_Int40BE(buf, value, offset, min, max) {
1665
+ value = +value;
1666
+ validateOffset(offset, "offset", 0, buf.length);
1667
+ checkInt(value, min, max, buf, offset, 4);
1668
+ buf[offset++] = Math.floor(value * 2 ** -32);
1669
+ buf[offset + 3] = value;
1670
+ value = value >>> 8;
1671
+ buf[offset + 2] = value;
1672
+ value = value >>> 8;
1673
+ buf[offset + 1] = value;
1674
+ value = value >>> 8;
1675
+ buf[offset] = value;
1676
+ return offset + 4;
1677
+ }
1678
+ function writeU_Int32BE(buf, value, offset, min, max) {
1679
+ value = +value;
1680
+ validateOffset(offset, "offset", 0, buf.length);
1681
+ checkInt(value, min, max, buf, offset, 3);
1682
+ buf[offset + 3] = value;
1683
+ value = value >>> 8;
1684
+ buf[offset + 2] = value;
1685
+ value = value >>> 8;
1686
+ buf[offset + 1] = value;
1687
+ value = value >>> 8;
1688
+ buf[offset] = value;
1689
+ return offset + 4;
1690
+ }
1691
+ function writeU_Int24BE(buf, value, offset, min, max) {
1692
+ value = +value;
1693
+ validateOffset(offset, "offset", 0, buf.length);
1694
+ checkInt(value, min, max, buf, offset, 2);
1695
+ buf[offset + 2] = value;
1696
+ value = value >>> 8;
1697
+ buf[offset + 1] = value;
1698
+ value = value >>> 8;
1699
+ buf[offset] = value;
1700
+ return offset + 3;
1701
+ }
1702
+ function validateOffset(value, name, min = 0, max = Number.MAX_SAFE_INTEGER) {
1703
+ if (typeof value !== "number") {
1704
+ throw new ERR_INVALID_ARG_TYPE(name, "number", value);
1705
+ }
1706
+ if (!Number.isInteger(value)) {
1707
+ throw new ERR_OUT_OF_RANGE(name, "an integer", value);
1708
+ }
1709
+ if (value < min || value > max) {
1710
+ throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
1711
+ }
1712
+ }
1713
+ function writeU_Int48LE(buf, value, offset, min, max) {
1714
+ value = +value;
1715
+ validateOffset(offset, "offset", 0, buf.length);
1716
+ checkInt(value, min, max, buf, offset, 5);
1717
+ const newVal = Math.floor(value * 2 ** -32);
1718
+ buf[offset++] = value;
1719
+ value = value >>> 8;
1720
+ buf[offset++] = value;
1721
+ value = value >>> 8;
1722
+ buf[offset++] = value;
1723
+ value = value >>> 8;
1724
+ buf[offset++] = value;
1725
+ buf[offset++] = newVal;
1726
+ buf[offset++] = newVal >>> 8;
1727
+ return offset;
1728
+ }
1729
+ function writeU_Int40LE(buf, value, offset, min, max) {
1730
+ value = +value;
1731
+ validateOffset(offset, "offset", 0, buf.length);
1732
+ checkInt(value, min, max, buf, offset, 4);
1733
+ const newVal = value;
1734
+ buf[offset++] = value;
1735
+ value = value >>> 8;
1736
+ buf[offset++] = value;
1737
+ value = value >>> 8;
1738
+ buf[offset++] = value;
1739
+ value = value >>> 8;
1740
+ buf[offset++] = value;
1741
+ buf[offset++] = Math.floor(newVal * 2 ** -32);
1742
+ return offset;
1743
+ }
1744
+ function writeU_Int32LE(buf, value, offset, min, max) {
1745
+ value = +value;
1746
+ validateOffset(offset, "offset", 0, buf.length);
1747
+ checkInt(value, min, max, buf, offset, 3);
1748
+ buf[offset++] = value;
1749
+ value = value >>> 8;
1750
+ buf[offset++] = value;
1751
+ value = value >>> 8;
1752
+ buf[offset++] = value;
1753
+ value = value >>> 8;
1754
+ buf[offset++] = value;
1755
+ return offset;
1756
+ }
1757
+ function writeU_Int24LE(buf, value, offset, min, max) {
1758
+ value = +value;
1759
+ validateOffset(offset, "offset", 0, buf.length);
1760
+ checkInt(value, min, max, buf, offset, 2);
1761
+ buf[offset++] = value;
1762
+ value = value >>> 8;
1763
+ buf[offset++] = value;
1764
+ value = value >>> 8;
1765
+ buf[offset++] = value;
1766
+ return offset;
1767
+ }
1768
+ export function isAscii(value) {
1769
+ if (value?.detached || value?.buffer?.detached) {
1770
+ throw new Error("Unable to determine if buffer is ASCII when it is detached");
1771
+ }
1772
+ return bufferUtil.isAscii(value);
1773
+ }
1774
+ export function isUtf8(value) {
1775
+ if (value?.detached || value?.buffer?.detached) {
1776
+ throw new Error("Unable to determine if buffer is UTF8 when it is detached");
1777
+ }
1778
+ return bufferUtil.isUtf8(value);
1779
+ }
1780
+ export function transcode(source, fromEncoding, toEncoding) {
1781
+ if (!isArrayBufferView(source)) {
1782
+ throw new ERR_INVALID_ARG_TYPE("source", "ArrayBufferView", typeof source);
1783
+ }
1784
+ const normalizedFromEncoding = normalizeEncoding(fromEncoding);
1785
+ if (normalizedFromEncoding === undefined) {
1786
+ throw new ERR_UNKNOWN_ENCODING(fromEncoding);
1787
+ }
1788
+ const normalizedToEncoding = normalizeEncoding(toEncoding);
1789
+ if (normalizedToEncoding === undefined) {
1790
+ throw new ERR_UNKNOWN_ENCODING(toEncoding);
1791
+ }
1792
+ const u8 = bufferUtil.transcode(source, normalizedFromEncoding, normalizedToEncoding);
1793
+ return Buffer.from(u8.buffer, u8.byteOffset, u8.byteLength);
1794
+ }
1795
+ export function resolveObjectURL(_id) {
1796
+ throw new Error("resolveObjectURL is not implemented");
1797
+ }
1798
+ export default {
1799
+ Buffer,
1800
+ constants,
1801
+ kMaxLength,
1802
+ kStringMaxLength,
1803
+ SlowBuffer,
1804
+ isAscii,
1805
+ isUtf8,
1806
+ INSPECT_MAX_BYTES,
1807
+ transcode,
1808
+ resolveObjectURL,
1809
+ };