@capsule-run/sdk 0.8.4 → 0.8.5

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 (321) hide show
  1. package/dist/polyfills/unenv-runtime/_internal/types.d.mts +5 -0
  2. package/dist/polyfills/unenv-runtime/_internal/types.mjs +1 -0
  3. package/dist/polyfills/unenv-runtime/_internal/utils.d.mts +14 -0
  4. package/dist/polyfills/unenv-runtime/_internal/utils.mjs +49 -0
  5. package/dist/polyfills/unenv-runtime/mock/empty.d.mts +2 -0
  6. package/dist/polyfills/unenv-runtime/mock/empty.mjs +1 -0
  7. package/dist/polyfills/unenv-runtime/mock/noop.d.mts +2 -0
  8. package/dist/polyfills/unenv-runtime/mock/noop.mjs +1 -0
  9. package/dist/polyfills/unenv-runtime/mock/proxy.d.mts +2 -0
  10. package/dist/polyfills/unenv-runtime/mock/proxy.mjs +43 -0
  11. package/dist/polyfills/unenv-runtime/node/assert/strict.d.mts +4 -0
  12. package/dist/polyfills/unenv-runtime/node/assert/strict.mjs +25 -0
  13. package/dist/polyfills/unenv-runtime/node/assert.d.mts +165 -0
  14. package/dist/polyfills/unenv-runtime/node/assert.mjs +737 -0
  15. package/dist/polyfills/unenv-runtime/node/async_hooks.d.mts +5 -0
  16. package/dist/polyfills/unenv-runtime/node/async_hooks.mjs +15 -0
  17. package/dist/polyfills/unenv-runtime/node/buffer.d.mts +19 -0
  18. package/dist/polyfills/unenv-runtime/node/buffer.mjs +35 -0
  19. package/dist/polyfills/unenv-runtime/node/child_process.d.mts +12 -0
  20. package/dist/polyfills/unenv-runtime/node/child_process.mjs +21 -0
  21. package/dist/polyfills/unenv-runtime/node/cluster.d.mts +33 -0
  22. package/dist/polyfills/unenv-runtime/node/cluster.mjs +71 -0
  23. package/dist/polyfills/unenv-runtime/node/console.d.mts +38 -0
  24. package/dist/polyfills/unenv-runtime/node/console.mjs +74 -0
  25. package/dist/polyfills/unenv-runtime/node/constants.d.mts +13 -0
  26. package/dist/polyfills/unenv-runtime/node/constants.mjs +254 -0
  27. package/dist/polyfills/unenv-runtime/node/crypto.d.mts +6 -0
  28. package/dist/polyfills/unenv-runtime/node/crypto.mjs +138 -0
  29. package/dist/polyfills/unenv-runtime/node/dgram.d.mts +6 -0
  30. package/dist/polyfills/unenv-runtime/node/dgram.mjs +12 -0
  31. package/dist/polyfills/unenv-runtime/node/diagnostics_channel.d.mts +11 -0
  32. package/dist/polyfills/unenv-runtime/node/diagnostics_channel.mjs +34 -0
  33. package/dist/polyfills/unenv-runtime/node/dns/promises.d.mts +27 -0
  34. package/dist/polyfills/unenv-runtime/node/dns/promises.mjs +75 -0
  35. package/dist/polyfills/unenv-runtime/node/dns.d.mts +29 -0
  36. package/dist/polyfills/unenv-runtime/node/dns.mjs +81 -0
  37. package/dist/polyfills/unenv-runtime/node/domain.d.mts +8 -0
  38. package/dist/polyfills/unenv-runtime/node/domain.mjs +16 -0
  39. package/dist/polyfills/unenv-runtime/node/events.d.mts +13 -0
  40. package/dist/polyfills/unenv-runtime/node/events.mjs +12 -0
  41. package/dist/polyfills/unenv-runtime/node/fs/promises.d.mts +7 -0
  42. package/dist/polyfills/unenv-runtime/node/fs/promises.mjs +38 -0
  43. package/dist/polyfills/unenv-runtime/node/fs.d.mts +10 -0
  44. package/dist/polyfills/unenv-runtime/node/fs.mjs +117 -0
  45. package/dist/polyfills/unenv-runtime/node/http.d.mts +23 -0
  46. package/dist/polyfills/unenv-runtime/node/http.mjs +45 -0
  47. package/dist/polyfills/unenv-runtime/node/http2.d.mts +15 -0
  48. package/dist/polyfills/unenv-runtime/node/http2.mjs +284 -0
  49. package/dist/polyfills/unenv-runtime/node/https.d.mts +10 -0
  50. package/dist/polyfills/unenv-runtime/node/https.mjs +16 -0
  51. package/dist/polyfills/unenv-runtime/node/inspector/promises.d.mts +10 -0
  52. package/dist/polyfills/unenv-runtime/node/inspector/promises.mjs +40 -0
  53. package/dist/polyfills/unenv-runtime/node/inspector.d.mts +12 -0
  54. package/dist/polyfills/unenv-runtime/node/inspector.mjs +53 -0
  55. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-hook.d.mts +7 -0
  56. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-hook.mjs +115 -0
  57. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-local-storage.d.mts +2 -0
  58. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-local-storage.mjs +36 -0
  59. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-resource.d.mts +2 -0
  60. package/dist/polyfills/unenv-runtime/node/internal/async_hooks/async-resource.mjs +37 -0
  61. package/dist/polyfills/unenv-runtime/node/internal/buffer/base64.d.mts +4 -0
  62. package/dist/polyfills/unenv-runtime/node/internal/buffer/base64.mjs +97 -0
  63. package/dist/polyfills/unenv-runtime/node/internal/buffer/buffer.d.mts +13 -0
  64. package/dist/polyfills/unenv-runtime/node/internal/buffer/buffer.mjs +1846 -0
  65. package/dist/polyfills/unenv-runtime/node/internal/buffer/file.d.mts +14 -0
  66. package/dist/polyfills/unenv-runtime/node/internal/buffer/file.mjs +26 -0
  67. package/dist/polyfills/unenv-runtime/node/internal/buffer/ieee754.d.mts +4 -0
  68. package/dist/polyfills/unenv-runtime/node/internal/buffer/ieee754.mjs +89 -0
  69. package/dist/polyfills/unenv-runtime/node/internal/crypto/constants.d.mts +58 -0
  70. package/dist/polyfills/unenv-runtime/node/internal/crypto/constants.mjs +58 -0
  71. package/dist/polyfills/unenv-runtime/node/internal/crypto/node.d.mts +78 -0
  72. package/dist/polyfills/unenv-runtime/node/internal/crypto/node.mjs +110 -0
  73. package/dist/polyfills/unenv-runtime/node/internal/crypto/web.d.mts +5 -0
  74. package/dist/polyfills/unenv-runtime/node/internal/crypto/web.mjs +9 -0
  75. package/dist/polyfills/unenv-runtime/node/internal/dgram/socket.d.mts +31 -0
  76. package/dist/polyfills/unenv-runtime/node/internal/dgram/socket.mjs +61 -0
  77. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/channel.d.mts +18 -0
  78. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/channel.mjs +40 -0
  79. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/tracing-channel.d.mts +19 -0
  80. package/dist/polyfills/unenv-runtime/node/internal/diagnostics_channel/tracing-channel.mjs +48 -0
  81. package/dist/polyfills/unenv-runtime/node/internal/dns/constants.d.mts +28 -0
  82. package/dist/polyfills/unenv-runtime/node/internal/dns/constants.mjs +28 -0
  83. package/dist/polyfills/unenv-runtime/node/internal/domain/domain.d.mts +13 -0
  84. package/dist/polyfills/unenv-runtime/node/internal/domain/domain.mjs +19 -0
  85. package/dist/polyfills/unenv-runtime/node/internal/events/events.d.mts +207 -0
  86. package/dist/polyfills/unenv-runtime/node/internal/events/events.mjs +1097 -0
  87. package/dist/polyfills/unenv-runtime/node/internal/fs/classes.d.mts +8 -0
  88. package/dist/polyfills/unenv-runtime/node/internal/fs/classes.mjs +8 -0
  89. package/dist/polyfills/unenv-runtime/node/internal/fs/constants.d.mts +59 -0
  90. package/dist/polyfills/unenv-runtime/node/internal/fs/constants.mjs +59 -0
  91. package/dist/polyfills/unenv-runtime/node/internal/fs/fs.d.mts +96 -0
  92. package/dist/polyfills/unenv-runtime/node/internal/fs/fs.mjs +106 -0
  93. package/dist/polyfills/unenv-runtime/node/internal/fs/promises.d.mts +32 -0
  94. package/dist/polyfills/unenv-runtime/node/internal/fs/promises.mjs +32 -0
  95. package/dist/polyfills/unenv-runtime/node/internal/http/agent.d.mts +14 -0
  96. package/dist/polyfills/unenv-runtime/node/internal/http/agent.mjs +16 -0
  97. package/dist/polyfills/unenv-runtime/node/internal/http/constants.d.mts +67 -0
  98. package/dist/polyfills/unenv-runtime/node/internal/http/constants.mjs +103 -0
  99. package/dist/polyfills/unenv-runtime/node/internal/http/request.d.mts +31 -0
  100. package/dist/polyfills/unenv-runtime/node/internal/http/request.mjs +53 -0
  101. package/dist/polyfills/unenv-runtime/node/internal/http/response.d.mts +42 -0
  102. package/dist/polyfills/unenv-runtime/node/internal/http/response.mjs +101 -0
  103. package/dist/polyfills/unenv-runtime/node/internal/http2/constants.d.mts +241 -0
  104. package/dist/polyfills/unenv-runtime/node/internal/http2/constants.mjs +241 -0
  105. package/dist/polyfills/unenv-runtime/node/internal/net/server.d.mts +17 -0
  106. package/dist/polyfills/unenv-runtime/node/internal/net/server.mjs +33 -0
  107. package/dist/polyfills/unenv-runtime/node/internal/net/socket.d.mts +45 -0
  108. package/dist/polyfills/unenv-runtime/node/internal/net/socket.mjs +83 -0
  109. package/dist/polyfills/unenv-runtime/node/internal/os/constants.d.mts +133 -0
  110. package/dist/polyfills/unenv-runtime/node/internal/os/constants.mjs +133 -0
  111. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/constants.d.mts +25 -0
  112. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/constants.mjs +25 -0
  113. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/histogram.d.mts +28 -0
  114. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/histogram.mjs +43 -0
  115. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/performance.d.mts +103 -0
  116. package/dist/polyfills/unenv-runtime/node/internal/perf_hooks/performance.mjs +232 -0
  117. package/dist/polyfills/unenv-runtime/node/internal/process/env.d.mts +1 -0
  118. package/dist/polyfills/unenv-runtime/node/internal/process/env.mjs +40 -0
  119. package/dist/polyfills/unenv-runtime/node/internal/process/hrtime.d.mts +2 -0
  120. package/dist/polyfills/unenv-runtime/node/internal/process/hrtime.mjs +21 -0
  121. package/dist/polyfills/unenv-runtime/node/internal/process/nexttick.d.mts +3 -0
  122. package/dist/polyfills/unenv-runtime/node/internal/process/nexttick.mjs +55 -0
  123. package/dist/polyfills/unenv-runtime/node/internal/process/node-version.d.mts +2 -0
  124. package/dist/polyfills/unenv-runtime/node/internal/process/node-version.mjs +2 -0
  125. package/dist/polyfills/unenv-runtime/node/internal/process/process.d.mts +113 -0
  126. package/dist/polyfills/unenv-runtime/node/internal/process/process.mjs +238 -0
  127. package/dist/polyfills/unenv-runtime/node/internal/punycode/punycode.d.mts +59 -0
  128. package/dist/polyfills/unenv-runtime/node/internal/punycode/punycode.mjs +410 -0
  129. package/dist/polyfills/unenv-runtime/node/internal/querystring/querystring.d.mts +11 -0
  130. package/dist/polyfills/unenv-runtime/node/internal/querystring/querystring.mjs +320 -0
  131. package/dist/polyfills/unenv-runtime/node/internal/readline/interface.d.mts +20 -0
  132. package/dist/polyfills/unenv-runtime/node/internal/readline/interface.mjs +31 -0
  133. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/interface.d.mts +7 -0
  134. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/interface.mjs +6 -0
  135. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/readline.d.mts +10 -0
  136. package/dist/polyfills/unenv-runtime/node/internal/readline/promises/readline.mjs +20 -0
  137. package/dist/polyfills/unenv-runtime/node/internal/stream/duplex.d.mts +3 -0
  138. package/dist/polyfills/unenv-runtime/node/internal/stream/duplex.mjs +19 -0
  139. package/dist/polyfills/unenv-runtime/node/internal/stream/readable.d.mts +67 -0
  140. package/dist/polyfills/unenv-runtime/node/internal/stream/readable.mjs +112 -0
  141. package/dist/polyfills/unenv-runtime/node/internal/stream/transform.d.mts +10 -0
  142. package/dist/polyfills/unenv-runtime/node/internal/stream/transform.mjs +9 -0
  143. package/dist/polyfills/unenv-runtime/node/internal/stream/writable.d.mts +2 -0
  144. package/dist/polyfills/unenv-runtime/node/internal/stream/writable.mjs +87 -0
  145. package/dist/polyfills/unenv-runtime/node/internal/timers/immediate.d.mts +9 -0
  146. package/dist/polyfills/unenv-runtime/node/internal/timers/immediate.mjs +28 -0
  147. package/dist/polyfills/unenv-runtime/node/internal/timers/scheduler.d.mts +6 -0
  148. package/dist/polyfills/unenv-runtime/node/internal/timers/scheduler.mjs +10 -0
  149. package/dist/polyfills/unenv-runtime/node/internal/timers/set-immediate.d.mts +3 -0
  150. package/dist/polyfills/unenv-runtime/node/internal/timers/set-immediate.mjs +13 -0
  151. package/dist/polyfills/unenv-runtime/node/internal/timers/set-interval.d.mts +2 -0
  152. package/dist/polyfills/unenv-runtime/node/internal/timers/set-interval.mjs +8 -0
  153. package/dist/polyfills/unenv-runtime/node/internal/timers/set-timeout.d.mts +3 -0
  154. package/dist/polyfills/unenv-runtime/node/internal/timers/set-timeout.mjs +11 -0
  155. package/dist/polyfills/unenv-runtime/node/internal/timers/timeout.d.mts +11 -0
  156. package/dist/polyfills/unenv-runtime/node/internal/timers/timeout.mjs +30 -0
  157. package/dist/polyfills/unenv-runtime/node/internal/tls/constants.d.mts +7 -0
  158. package/dist/polyfills/unenv-runtime/node/internal/tls/constants.mjs +7 -0
  159. package/dist/polyfills/unenv-runtime/node/internal/tls/secure-context.d.mts +4 -0
  160. package/dist/polyfills/unenv-runtime/node/internal/tls/secure-context.mjs +3 -0
  161. package/dist/polyfills/unenv-runtime/node/internal/tls/server.d.mts +9 -0
  162. package/dist/polyfills/unenv-runtime/node/internal/tls/server.mjs +15 -0
  163. package/dist/polyfills/unenv-runtime/node/internal/tls/tls-socket.d.mts +31 -0
  164. package/dist/polyfills/unenv-runtime/node/internal/tls/tls-socket.mjs +48 -0
  165. package/dist/polyfills/unenv-runtime/node/internal/trace_events/tracing.d.mts +7 -0
  166. package/dist/polyfills/unenv-runtime/node/internal/trace_events/tracing.mjs +10 -0
  167. package/dist/polyfills/unenv-runtime/node/internal/tty/read-stream.d.mts +8 -0
  168. package/dist/polyfills/unenv-runtime/node/internal/tty/read-stream.mjs +12 -0
  169. package/dist/polyfills/unenv-runtime/node/internal/tty/write-stream.d.mts +20 -0
  170. package/dist/polyfills/unenv-runtime/node/internal/tty/write-stream.mjs +44 -0
  171. package/dist/polyfills/unenv-runtime/node/internal/url/constants.d.mts +44 -0
  172. package/dist/polyfills/unenv-runtime/node/internal/url/constants.mjs +44 -0
  173. package/dist/polyfills/unenv-runtime/node/internal/url/errors.d.mts +26 -0
  174. package/dist/polyfills/unenv-runtime/node/internal/url/errors.mjs +54 -0
  175. package/dist/polyfills/unenv-runtime/node/internal/url/url.d.mts +22 -0
  176. package/dist/polyfills/unenv-runtime/node/internal/url/url.mjs +181 -0
  177. package/dist/polyfills/unenv-runtime/node/internal/url/util.d.mts +4 -0
  178. package/dist/polyfills/unenv-runtime/node/internal/url/util.mjs +7 -0
  179. package/dist/polyfills/unenv-runtime/node/internal/util/inherits.d.mts +1 -0
  180. package/dist/polyfills/unenv-runtime/node/internal/util/inherits.mjs +12 -0
  181. package/dist/polyfills/unenv-runtime/node/internal/util/legacy-types.d.mts +19 -0
  182. package/dist/polyfills/unenv-runtime/node/internal/util/legacy-types.mjs +25 -0
  183. package/dist/polyfills/unenv-runtime/node/internal/util/log.d.mts +8 -0
  184. package/dist/polyfills/unenv-runtime/node/internal/util/log.mjs +55 -0
  185. package/dist/polyfills/unenv-runtime/node/internal/util/mime.d.mts +19 -0
  186. package/dist/polyfills/unenv-runtime/node/internal/util/mime.mjs +35 -0
  187. package/dist/polyfills/unenv-runtime/node/internal/util/promisify.d.mts +3 -0
  188. package/dist/polyfills/unenv-runtime/node/internal/util/promisify.mjs +23 -0
  189. package/dist/polyfills/unenv-runtime/node/internal/util/types.d.mts +45 -0
  190. package/dist/polyfills/unenv-runtime/node/internal/util/types.mjs +45 -0
  191. package/dist/polyfills/unenv-runtime/node/internal/v8/deserializer.d.mts +12 -0
  192. package/dist/polyfills/unenv-runtime/node/internal/v8/deserializer.mjs +23 -0
  193. package/dist/polyfills/unenv-runtime/node/internal/v8/profiler.d.mts +10 -0
  194. package/dist/polyfills/unenv-runtime/node/internal/v8/profiler.mjs +11 -0
  195. package/dist/polyfills/unenv-runtime/node/internal/v8/serializer.d.mts +12 -0
  196. package/dist/polyfills/unenv-runtime/node/internal/v8/serializer.mjs +15 -0
  197. package/dist/polyfills/unenv-runtime/node/internal/vm/constants.d.mts +2 -0
  198. package/dist/polyfills/unenv-runtime/node/internal/vm/constants.mjs +2 -0
  199. package/dist/polyfills/unenv-runtime/node/internal/vm/script.d.mts +7 -0
  200. package/dist/polyfills/unenv-runtime/node/internal/vm/script.mjs +15 -0
  201. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/broadcast-channel.d.mts +10 -0
  202. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/broadcast-channel.mjs +13 -0
  203. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-channel.d.mts +5 -0
  204. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-channel.mjs +5 -0
  205. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-port.d.mts +12 -0
  206. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/message-port.mjs +17 -0
  207. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/worker.d.mts +21 -0
  208. package/dist/polyfills/unenv-runtime/node/internal/worker_threads/worker.mjs +25 -0
  209. package/dist/polyfills/unenv-runtime/node/internal/zlib/codes.d.mts +21 -0
  210. package/dist/polyfills/unenv-runtime/node/internal/zlib/codes.mjs +21 -0
  211. package/dist/polyfills/unenv-runtime/node/internal/zlib/constants.d.mts +108 -0
  212. package/dist/polyfills/unenv-runtime/node/internal/zlib/constants.mjs +108 -0
  213. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/_shared.d.mts +22 -0
  214. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/_shared.mjs +40 -0
  215. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/brotli.d.mts +16 -0
  216. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/brotli.mjs +16 -0
  217. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/deflate.d.mts +29 -0
  218. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/deflate.mjs +36 -0
  219. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/gzip.d.mts +16 -0
  220. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/gzip.mjs +16 -0
  221. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/zip.d.mts +9 -0
  222. package/dist/polyfills/unenv-runtime/node/internal/zlib/formats/zip.mjs +9 -0
  223. package/dist/polyfills/unenv-runtime/node/module.d.mts +54 -0
  224. package/dist/polyfills/unenv-runtime/node/module.mjs +191 -0
  225. package/dist/polyfills/unenv-runtime/node/net.d.mts +22 -0
  226. package/dist/polyfills/unenv-runtime/node/net.mjs +52 -0
  227. package/dist/polyfills/unenv-runtime/node/os.d.mts +26 -0
  228. package/dist/polyfills/unenv-runtime/node/os.mjs +118 -0
  229. package/dist/polyfills/unenv-runtime/node/path/posix.d.mts +2 -0
  230. package/dist/polyfills/unenv-runtime/node/path/posix.mjs +2 -0
  231. package/dist/polyfills/unenv-runtime/node/path/win32.d.mts +2 -0
  232. package/dist/polyfills/unenv-runtime/node/path/win32.mjs +2 -0
  233. package/dist/polyfills/unenv-runtime/node/path.d.mts +12 -0
  234. package/dist/polyfills/unenv-runtime/node/path.mjs +31 -0
  235. package/dist/polyfills/unenv-runtime/node/perf_hooks.d.mts +8 -0
  236. package/dist/polyfills/unenv-runtime/node/perf_hooks.mjs +51 -0
  237. package/dist/polyfills/unenv-runtime/node/process.d.mts +3 -0
  238. package/dist/polyfills/unenv-runtime/node/process.mjs +12 -0
  239. package/dist/polyfills/unenv-runtime/node/punycode.d.mts +3 -0
  240. package/dist/polyfills/unenv-runtime/node/punycode.mjs +3 -0
  241. package/dist/polyfills/unenv-runtime/node/querystring.d.mts +49 -0
  242. package/dist/polyfills/unenv-runtime/node/querystring.mjs +766 -0
  243. package/dist/polyfills/unenv-runtime/node/readline/promises.d.mts +6 -0
  244. package/dist/polyfills/unenv-runtime/node/readline/promises.mjs +10 -0
  245. package/dist/polyfills/unenv-runtime/node/readline.d.mts +13 -0
  246. package/dist/polyfills/unenv-runtime/node/readline.mjs +21 -0
  247. package/dist/polyfills/unenv-runtime/node/repl.d.mts +10 -0
  248. package/dist/polyfills/unenv-runtime/node/repl.mjs +20 -0
  249. package/dist/polyfills/unenv-runtime/node/sqlite.d.mts +6 -0
  250. package/dist/polyfills/unenv-runtime/node/sqlite.mjs +9 -0
  251. package/dist/polyfills/unenv-runtime/node/stream/consumers.d.mts +7 -0
  252. package/dist/polyfills/unenv-runtime/node/stream/consumers.mjs +13 -0
  253. package/dist/polyfills/unenv-runtime/node/stream/promises.d.mts +4 -0
  254. package/dist/polyfills/unenv-runtime/node/stream/promises.mjs +7 -0
  255. package/dist/polyfills/unenv-runtime/node/stream/web.d.mts +24 -0
  256. package/dist/polyfills/unenv-runtime/node/stream/web.mjs +41 -0
  257. package/dist/polyfills/unenv-runtime/node/stream.d.mts +42 -0
  258. package/dist/polyfills/unenv-runtime/node/stream.mjs +54 -0
  259. package/dist/polyfills/unenv-runtime/node/string_decoder.d.mts +5 -0
  260. package/dist/polyfills/unenv-runtime/node/string_decoder.mjs +3 -0
  261. package/dist/polyfills/unenv-runtime/node/sys.d.mts +2 -0
  262. package/dist/polyfills/unenv-runtime/node/sys.mjs +2 -0
  263. package/dist/polyfills/unenv-runtime/node/timers/promises.d.mts +6 -0
  264. package/dist/polyfills/unenv-runtime/node/timers/promises.mjs +14 -0
  265. package/dist/polyfills/unenv-runtime/node/timers.d.mts +15 -0
  266. package/dist/polyfills/unenv-runtime/node/timers.mjs +32 -0
  267. package/dist/polyfills/unenv-runtime/node/tls.d.mts +15 -0
  268. package/dist/polyfills/unenv-runtime/node/tls.mjs +41 -0
  269. package/dist/polyfills/unenv-runtime/node/trace_events.d.mts +5 -0
  270. package/dist/polyfills/unenv-runtime/node/trace_events.mjs +9 -0
  271. package/dist/polyfills/unenv-runtime/node/tty.d.mts +9 -0
  272. package/dist/polyfills/unenv-runtime/node/tty.mjs +12 -0
  273. package/dist/polyfills/unenv-runtime/node/url.d.mts +61 -0
  274. package/dist/polyfills/unenv-runtime/node/url.mjs +1044 -0
  275. package/dist/polyfills/unenv-runtime/node/util/types.d.mts +3 -0
  276. package/dist/polyfills/unenv-runtime/node/util/types.mjs +3 -0
  277. package/dist/polyfills/unenv-runtime/node/util.d.mts +32 -0
  278. package/dist/polyfills/unenv-runtime/node/util.mjs +84 -0
  279. package/dist/polyfills/unenv-runtime/node/v8.d.mts +29 -0
  280. package/dist/polyfills/unenv-runtime/node/v8.mjs +108 -0
  281. package/dist/polyfills/unenv-runtime/node/vm.d.mts +15 -0
  282. package/dist/polyfills/unenv-runtime/node/vm.mjs +41 -0
  283. package/dist/polyfills/unenv-runtime/node/wasi.d.mts +4 -0
  284. package/dist/polyfills/unenv-runtime/node/wasi.mjs +3 -0
  285. package/dist/polyfills/unenv-runtime/node/worker_threads.d.mts +23 -0
  286. package/dist/polyfills/unenv-runtime/node/worker_threads.mjs +55 -0
  287. package/dist/polyfills/unenv-runtime/node/zlib.d.mts +16 -0
  288. package/dist/polyfills/unenv-runtime/node/zlib.mjs +212 -0
  289. package/dist/polyfills/unenv-runtime/npm/cross-fetch.d.mts +6 -0
  290. package/dist/polyfills/unenv-runtime/npm/cross-fetch.mjs +6 -0
  291. package/dist/polyfills/unenv-runtime/npm/debug.d.mts +15 -0
  292. package/dist/polyfills/unenv-runtime/npm/debug.mjs +43 -0
  293. package/dist/polyfills/unenv-runtime/npm/fsevents.d.mts +16 -0
  294. package/dist/polyfills/unenv-runtime/npm/fsevents.mjs +20 -0
  295. package/dist/polyfills/unenv-runtime/npm/inherits.d.mts +2 -0
  296. package/dist/polyfills/unenv-runtime/npm/inherits.mjs +2 -0
  297. package/dist/polyfills/unenv-runtime/npm/node-fetch.d.mts +12 -0
  298. package/dist/polyfills/unenv-runtime/npm/node-fetch.mjs +23 -0
  299. package/dist/polyfills/unenv-runtime/npm/whatwg-url/index.d.mts +13 -0
  300. package/dist/polyfills/unenv-runtime/npm/whatwg-url/index.mjs +15 -0
  301. package/dist/polyfills/unenv-runtime/npm/whatwg-url/webidl2js-wrapper.d.mts +2 -0
  302. package/dist/polyfills/unenv-runtime/npm/whatwg-url/webidl2js-wrapper.mjs +2 -0
  303. package/dist/polyfills/unenv-runtime/polyfill/buffer.d.mts +1 -0
  304. package/dist/polyfills/unenv-runtime/polyfill/buffer.mjs +4 -0
  305. package/dist/polyfills/unenv-runtime/polyfill/globalthis-global.d.mts +1 -0
  306. package/dist/polyfills/unenv-runtime/polyfill/globalthis-global.mjs +5 -0
  307. package/dist/polyfills/unenv-runtime/polyfill/globalthis.d.mts +2 -0
  308. package/dist/polyfills/unenv-runtime/polyfill/globalthis.mjs +2 -0
  309. package/dist/polyfills/unenv-runtime/polyfill/package.json +3 -0
  310. package/dist/polyfills/unenv-runtime/polyfill/performance.d.mts +2 -0
  311. package/dist/polyfills/unenv-runtime/polyfill/performance.mjs +10 -0
  312. package/dist/polyfills/unenv-runtime/polyfill/process.d.mts +2 -0
  313. package/dist/polyfills/unenv-runtime/polyfill/process.mjs +10 -0
  314. package/dist/polyfills/unenv-runtime/polyfill/source-maps.mjs +15 -0
  315. package/dist/polyfills/unenv-runtime/polyfill/timers.d.mts +1 -0
  316. package/dist/polyfills/unenv-runtime/polyfill/timers.mjs +7 -0
  317. package/dist/polyfills/unenv-runtime/web/performance/_polyfills.d.mts +100 -0
  318. package/dist/polyfills/unenv-runtime/web/performance/_polyfills.mjs +184 -0
  319. package/dist/polyfills/unenv-runtime/web/performance/index.d.mts +12 -0
  320. package/dist/polyfills/unenv-runtime/web/performance/index.mjs +14 -0
  321. package/package.json +2 -2
@@ -0,0 +1,1846 @@
1
+ // @ts-nocheck
2
+ // Source: https://github.com/feross/buffer/blob/795bbb5bda1b39f1370ebd784bea6107b087e3a7/index.js
3
+ /*!
4
+ * The buffer module from node.js, for the browser.
5
+ *
6
+ * @author Feross Aboukhadijeh <https://feross.org>
7
+ * @license MIT
8
+ */
9
+ import * as base64 from "./base64.mjs";
10
+ import * as ieee754 from "./ieee754.mjs";
11
+ const customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
12
+ export const INSPECT_MAX_BYTES = 50;
13
+ const K_MAX_LENGTH = 2147483647;
14
+ export const kMaxLength = K_MAX_LENGTH;
15
+ /**
16
+ * If `Buffer.TYPED_ARRAY_SUPPORT`:
17
+ * === true Use Uint8Array implementation (fastest)
18
+ * === false Print warning and recommend using `buffer` v4.x which has an Object
19
+ * implementation (most compatible, even IE6)
20
+ *
21
+ * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
22
+ * Opera 11.6+, iOS 4.2+.
23
+ *
24
+ * We report that the browser does not support typed arrays if the are not subclassable
25
+ * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`
26
+ * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support
27
+ * for __proto__ and has a buggy typed array implementation.
28
+ */
29
+ Buffer.TYPED_ARRAY_SUPPORT = typedArraySupport();
30
+ if (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
31
+ console.error("This environment lacks typed array (Uint8Array) support which is required by " + "`buffer` v5.x. Use `buffer` v4.x if you require old browser support.");
32
+ }
33
+ function typedArraySupport() {
34
+ // Can typed array instances can be augmented?
35
+ try {
36
+ const arr = new Uint8Array(1);
37
+ const proto = { foo: function() {
38
+ return 42;
39
+ } };
40
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
41
+ Object.setPrototypeOf(arr, proto);
42
+ return arr.foo() === 42;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ Object.defineProperty(Buffer.prototype, "parent", {
48
+ enumerable: true,
49
+ get: function() {
50
+ if (!Buffer.isBuffer(this)) {
51
+ return;
52
+ }
53
+ return this.buffer;
54
+ }
55
+ });
56
+ Object.defineProperty(Buffer.prototype, "offset", {
57
+ enumerable: true,
58
+ get: function() {
59
+ if (!Buffer.isBuffer(this)) {
60
+ return;
61
+ }
62
+ return this.byteOffset;
63
+ }
64
+ });
65
+ function createBuffer(length) {
66
+ if (length > K_MAX_LENGTH) {
67
+ throw new RangeError("The value \"" + length + "\" is invalid for option \"size\"");
68
+ }
69
+ // Return an augmented `Uint8Array` instance
70
+ const buf = new Uint8Array(length);
71
+ Object.setPrototypeOf(buf, Buffer.prototype);
72
+ return buf;
73
+ }
74
+ /**
75
+ * The Buffer constructor returns instances of `Uint8Array` that have their
76
+ * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
77
+ * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
78
+ * and the `Uint8Array` methods. Square bracket notation works as expected -- it
79
+ * returns a single octet.
80
+ *
81
+ * The `Uint8Array` prototype remains unmodified.
82
+ */
83
+ export function Buffer(arg, encodingOrOffset, length) {
84
+ // Common case.
85
+ if (typeof arg === "number") {
86
+ if (typeof encodingOrOffset === "string") {
87
+ throw new TypeError("The \"string\" argument must be of type string. Received type number");
88
+ }
89
+ return allocUnsafe(arg);
90
+ }
91
+ return from(arg, encodingOrOffset, length);
92
+ }
93
+ Buffer.poolSize = 8192;
94
+ function from(value, encodingOrOffset, length) {
95
+ if (typeof value === "string") {
96
+ return fromString(value, encodingOrOffset);
97
+ }
98
+ if (ArrayBuffer.isView(value)) {
99
+ return fromArrayView(value);
100
+ }
101
+ if (value == null) {
102
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value);
103
+ }
104
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
105
+ return fromArrayBuffer(value, encodingOrOffset, length);
106
+ }
107
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
108
+ return fromArrayBuffer(value, encodingOrOffset, length);
109
+ }
110
+ if (typeof value === "number") {
111
+ throw new TypeError("The \"value\" argument must not be of type number. Received type number");
112
+ }
113
+ const valueOf = value.valueOf && value.valueOf();
114
+ if (valueOf != null && valueOf !== value) {
115
+ return Buffer.from(valueOf, encodingOrOffset, length);
116
+ }
117
+ const b = fromObject(value);
118
+ if (b) {
119
+ return b;
120
+ }
121
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
122
+ return Buffer.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
123
+ }
124
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, " + "or Array-like Object. Received type " + typeof value);
125
+ }
126
+ /**
127
+ * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
128
+ * if value is a number.
129
+ * Buffer.from(str[, encoding])
130
+ * Buffer.from(array)
131
+ * Buffer.from(buffer)
132
+ * Buffer.from(arrayBuffer[, byteOffset[, length]])
133
+ **/
134
+ Buffer.from = function(value, encodingOrOffset, length) {
135
+ return from(value, encodingOrOffset, length);
136
+ };
137
+ // Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
138
+ // https://github.com/feross/buffer/pull/148
139
+ Object.setPrototypeOf(Buffer.prototype, Uint8Array.prototype);
140
+ Object.setPrototypeOf(Buffer, Uint8Array);
141
+ function assertSize(size) {
142
+ if (typeof size !== "number") {
143
+ throw new TypeError("\"size\" argument must be of type number");
144
+ } else if (size < 0) {
145
+ throw new RangeError("The value \"" + size + "\" is invalid for option \"size\"");
146
+ }
147
+ }
148
+ function alloc(size, fill, encoding) {
149
+ assertSize(size);
150
+ if (size <= 0) {
151
+ return createBuffer(size);
152
+ }
153
+ if (fill !== undefined) {
154
+ // Only pay attention to encoding if it's a string. This
155
+ // prevents accidentally sending in a number that would
156
+ // be interpreted as a start offset.
157
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
158
+ }
159
+ return createBuffer(size);
160
+ }
161
+ /**
162
+ * Creates a new filled Buffer instance.
163
+ * alloc(size[, fill[, encoding]])
164
+ **/
165
+ Buffer.alloc = function(size, fill, encoding) {
166
+ return alloc(size, fill, encoding);
167
+ };
168
+ function allocUnsafe(size) {
169
+ assertSize(size);
170
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
171
+ }
172
+ /**
173
+ * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
174
+ * */
175
+ Buffer.allocUnsafe = function(size) {
176
+ return allocUnsafe(size);
177
+ };
178
+ /**
179
+ * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
180
+ */
181
+ Buffer.allocUnsafeSlow = function(size) {
182
+ return allocUnsafe(size);
183
+ };
184
+ function fromString(string, encoding) {
185
+ if (typeof encoding !== "string" || encoding === "") {
186
+ encoding = "utf8";
187
+ }
188
+ if (!Buffer.isEncoding(encoding)) {
189
+ throw new TypeError("Unknown encoding: " + encoding);
190
+ }
191
+ const length = byteLength(string, encoding) | 0;
192
+ let buf = createBuffer(length);
193
+ const actual = buf.write(string, encoding);
194
+ if (actual !== length) {
195
+ // Writing a hex string, for example, that contains invalid characters will
196
+ // cause everything after the first invalid character to be ignored. (e.g.
197
+ // 'abxxcd' will be treated as 'ab')
198
+ buf = buf.slice(0, actual);
199
+ }
200
+ return buf;
201
+ }
202
+ function fromArrayLike(array) {
203
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
204
+ const buf = createBuffer(length);
205
+ for (let i = 0; i < length; i += 1) {
206
+ buf[i] = array[i] & 255;
207
+ }
208
+ return buf;
209
+ }
210
+ function fromArrayView(arrayView) {
211
+ if (isInstance(arrayView, Uint8Array)) {
212
+ const copy = new Uint8Array(arrayView);
213
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
214
+ }
215
+ return fromArrayLike(arrayView);
216
+ }
217
+ function fromArrayBuffer(array, byteOffset, length) {
218
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
219
+ throw new RangeError("\"offset\" is outside of buffer bounds");
220
+ }
221
+ if (array.byteLength < byteOffset + (length || 0)) {
222
+ throw new RangeError("\"length\" is outside of buffer bounds");
223
+ }
224
+ let buf;
225
+ if (byteOffset === undefined && length === undefined) {
226
+ buf = new Uint8Array(array);
227
+ } else if (length === undefined) {
228
+ buf = new Uint8Array(array, byteOffset);
229
+ } else {
230
+ buf = new Uint8Array(array, byteOffset, length);
231
+ }
232
+ // Return an augmented `Uint8Array` instance
233
+ Object.setPrototypeOf(buf, Buffer.prototype);
234
+ return buf;
235
+ }
236
+ function fromObject(obj) {
237
+ if (Buffer.isBuffer(obj)) {
238
+ const len = checked(obj.length) | 0;
239
+ const buf = createBuffer(len);
240
+ if (buf.length === 0) {
241
+ return buf;
242
+ }
243
+ obj.copy(buf, 0, 0, len);
244
+ return buf;
245
+ }
246
+ if (obj.length !== undefined) {
247
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
248
+ return createBuffer(0);
249
+ }
250
+ return fromArrayLike(obj);
251
+ }
252
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
253
+ return fromArrayLike(obj.data);
254
+ }
255
+ }
256
+ function checked(length) {
257
+ // Note: cannot use `length < K_MAX_LENGTH` here because that fails when
258
+ // length is NaN (which is otherwise coerced to zero.)
259
+ if (length >= K_MAX_LENGTH) {
260
+ throw new RangeError("Attempt to allocate Buffer larger than maximum " + "size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
261
+ }
262
+ return length | 0;
263
+ }
264
+ export function SlowBuffer(length) {
265
+ if (+length != length) {
266
+ length = 0;
267
+ }
268
+ return Buffer.alloc(+length);
269
+ }
270
+ Buffer.isBuffer = function isBuffer(b) {
271
+ return b != null && b._isBuffer === true && b !== Buffer.prototype;
272
+ };
273
+ Buffer.compare = function compare(a, b) {
274
+ if (isInstance(a, Uint8Array)) {
275
+ a = Buffer.from(a, a.offset, a.byteLength);
276
+ }
277
+ if (isInstance(b, Uint8Array)) {
278
+ b = Buffer.from(b, b.offset, b.byteLength);
279
+ }
280
+ if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
281
+ throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");
282
+ }
283
+ if (a === b) {
284
+ return 0;
285
+ }
286
+ let x = a.length;
287
+ let y = b.length;
288
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
289
+ if (a[i] !== b[i]) {
290
+ x = a[i];
291
+ y = b[i];
292
+ break;
293
+ }
294
+ }
295
+ if (x < y) {
296
+ return -1;
297
+ }
298
+ if (y < x) {
299
+ return 1;
300
+ }
301
+ return 0;
302
+ };
303
+ Buffer.isEncoding = function isEncoding(encoding) {
304
+ switch (String(encoding).toLowerCase()) {
305
+ case "hex":
306
+ case "utf8":
307
+ case "utf-8":
308
+ case "ascii":
309
+ case "latin1":
310
+ case "binary":
311
+ case "base64":
312
+ case "ucs2":
313
+ case "ucs-2":
314
+ case "utf16le":
315
+ case "utf-16le": return true;
316
+ default: return false;
317
+ }
318
+ };
319
+ Buffer.concat = function concat(list, length) {
320
+ if (!Array.isArray(list)) {
321
+ throw new TypeError("\"list\" argument must be an Array of Buffers");
322
+ }
323
+ if (list.length === 0) {
324
+ return Buffer.alloc(0);
325
+ }
326
+ let i;
327
+ if (length === undefined) {
328
+ length = 0;
329
+ for (i = 0; i < list.length; ++i) {
330
+ length += list[i].length;
331
+ }
332
+ }
333
+ const buffer = Buffer.allocUnsafe(length);
334
+ let pos = 0;
335
+ for (i = 0; i < list.length; ++i) {
336
+ let buf = list[i];
337
+ if (isInstance(buf, Uint8Array)) {
338
+ if (pos + buf.length > buffer.length) {
339
+ if (!Buffer.isBuffer(buf)) {
340
+ buf = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
341
+ }
342
+ buf.copy(buffer, pos);
343
+ } else {
344
+ Uint8Array.prototype.set.call(buffer, buf, pos);
345
+ }
346
+ } else if (Buffer.isBuffer(buf)) {
347
+ buf.copy(buffer, pos);
348
+ } else {
349
+ throw new TypeError("\"list\" argument must be an Array of Buffers");
350
+ }
351
+ pos += buf.length;
352
+ }
353
+ return buffer;
354
+ };
355
+ function byteLength(string, encoding) {
356
+ if (Buffer.isBuffer(string)) {
357
+ return string.length;
358
+ }
359
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
360
+ return string.byteLength;
361
+ }
362
+ if (typeof string !== "string") {
363
+ throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. " + "Received type " + typeof string);
364
+ }
365
+ const len = string.length;
366
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
367
+ if (!mustMatch && len === 0) {
368
+ return 0;
369
+ }
370
+ // Use a for loop to avoid recursion
371
+ let loweredCase = false;
372
+ for (;;) {
373
+ switch (encoding) {
374
+ case "ascii":
375
+ case "latin1":
376
+ case "binary": return len;
377
+ case "utf8":
378
+ case "utf-8": return utf8ToBytes(string).length;
379
+ case "ucs2":
380
+ case "ucs-2":
381
+ case "utf16le":
382
+ case "utf-16le": return len * 2;
383
+ case "hex": return len >>> 1;
384
+ case "base64": return base64ToBytes(string).length;
385
+ default:
386
+ if (loweredCase) {
387
+ return mustMatch ? -1 : utf8ToBytes(string).length;
388
+ }
389
+ encoding = ("" + encoding).toLowerCase();
390
+ loweredCase = true;
391
+ }
392
+ }
393
+ }
394
+ Buffer.byteLength = byteLength;
395
+ function slowToString(encoding, start, end) {
396
+ let loweredCase = false;
397
+ // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
398
+ // property of a typed array.
399
+ // This behaves neither like String nor Uint8Array in that we set start/end
400
+ // to their upper/lower bounds if the value passed is out of range.
401
+ // undefined is handled specially as per ECMA-262 6th Edition,
402
+ // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
403
+ if (start === undefined || start < 0) {
404
+ start = 0;
405
+ }
406
+ // Return early if start > this.length. Done here to prevent potential uint32
407
+ // coercion fail below.
408
+ if (start > this.length) {
409
+ return "";
410
+ }
411
+ if (end === undefined || end > this.length) {
412
+ end = this.length;
413
+ }
414
+ if (end <= 0) {
415
+ return "";
416
+ }
417
+ // Force coercion to uint32. This will also coerce falsey/NaN values to 0.
418
+ end >>>= 0;
419
+ start >>>= 0;
420
+ if (end <= start) {
421
+ return "";
422
+ }
423
+ if (!encoding) {
424
+ encoding = "utf8";
425
+ }
426
+ while (true) {
427
+ switch (encoding) {
428
+ case "hex": return hexSlice(this, start, end);
429
+ case "utf8":
430
+ case "utf-8": return utf8Slice(this, start, end);
431
+ case "ascii": return asciiSlice(this, start, end);
432
+ case "latin1":
433
+ case "binary": return latin1Slice(this, start, end);
434
+ case "base64": return base64Slice(this, start, end);
435
+ case "ucs2":
436
+ case "ucs-2":
437
+ case "utf16le":
438
+ case "utf-16le": return utf16leSlice(this, start, end);
439
+ default:
440
+ if (loweredCase) {
441
+ throw new TypeError("Unknown encoding: " + encoding);
442
+ }
443
+ encoding = (encoding + "").toLowerCase();
444
+ loweredCase = true;
445
+ }
446
+ }
447
+ }
448
+ // This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
449
+ // to detect a Buffer instance. It's not possible to use `instanceof Buffer`
450
+ // reliably in a browserify context because there could be multiple different
451
+ // copies of the 'buffer' package in use. This method works even for Buffer
452
+ // instances that were created from another copy of the `buffer` package.
453
+ // See: https://github.com/feross/buffer/issues/154
454
+ Buffer.prototype._isBuffer = true;
455
+ function swap(b, n, m) {
456
+ const i = b[n];
457
+ b[n] = b[m];
458
+ b[m] = i;
459
+ }
460
+ Buffer.prototype.swap16 = function swap16() {
461
+ const len = this.length;
462
+ if (len % 2 !== 0) {
463
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
464
+ }
465
+ for (let i = 0; i < len; i += 2) {
466
+ swap(this, i, i + 1);
467
+ }
468
+ return this;
469
+ };
470
+ Buffer.prototype.swap32 = function swap32() {
471
+ const len = this.length;
472
+ if (len % 4 !== 0) {
473
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
474
+ }
475
+ for (let i = 0; i < len; i += 4) {
476
+ swap(this, i, i + 3);
477
+ swap(this, i + 1, i + 2);
478
+ }
479
+ return this;
480
+ };
481
+ Buffer.prototype.swap64 = function swap64() {
482
+ const len = this.length;
483
+ if (len % 8 !== 0) {
484
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
485
+ }
486
+ for (let i = 0; i < len; i += 8) {
487
+ swap(this, i, i + 7);
488
+ swap(this, i + 1, i + 6);
489
+ swap(this, i + 2, i + 5);
490
+ swap(this, i + 3, i + 4);
491
+ }
492
+ return this;
493
+ };
494
+ Buffer.prototype.toString = function toString() {
495
+ const length = this.length;
496
+ if (length === 0) {
497
+ return "";
498
+ }
499
+ if (arguments.length === 0) {
500
+ return utf8Slice(this, 0, length);
501
+ }
502
+ return Reflect.apply(slowToString, this, arguments);
503
+ };
504
+ Buffer.prototype.toLocaleString = Buffer.prototype.toString;
505
+ Buffer.prototype.equals = function equals(b) {
506
+ if (!Buffer.isBuffer(b)) {
507
+ throw new TypeError("Argument must be a Buffer");
508
+ }
509
+ if (this === b) {
510
+ return true;
511
+ }
512
+ return Buffer.compare(this, b) === 0;
513
+ };
514
+ Buffer.prototype.inspect = function inspect() {
515
+ let str = "";
516
+ const max = INSPECT_MAX_BYTES;
517
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
518
+ if (this.length > max) {
519
+ str += " ... ";
520
+ }
521
+ return "<Buffer " + str + ">";
522
+ };
523
+ if (customInspectSymbol) {
524
+ Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect;
525
+ }
526
+ Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
527
+ if (isInstance(target, Uint8Array)) {
528
+ target = Buffer.from(target, target.offset, target.byteLength);
529
+ }
530
+ if (!Buffer.isBuffer(target)) {
531
+ throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. " + "Received type " + typeof target);
532
+ }
533
+ if (start === undefined) {
534
+ start = 0;
535
+ }
536
+ if (end === undefined) {
537
+ end = target ? target.length : 0;
538
+ }
539
+ if (thisStart === undefined) {
540
+ thisStart = 0;
541
+ }
542
+ if (thisEnd === undefined) {
543
+ thisEnd = this.length;
544
+ }
545
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
546
+ throw new RangeError("out of range index");
547
+ }
548
+ if (thisStart >= thisEnd && start >= end) {
549
+ return 0;
550
+ }
551
+ if (thisStart >= thisEnd) {
552
+ return -1;
553
+ }
554
+ if (start >= end) {
555
+ return 1;
556
+ }
557
+ start >>>= 0;
558
+ end >>>= 0;
559
+ thisStart >>>= 0;
560
+ thisEnd >>>= 0;
561
+ if (this === target) {
562
+ return 0;
563
+ }
564
+ let x = thisEnd - thisStart;
565
+ let y = end - start;
566
+ const len = Math.min(x, y);
567
+ const thisCopy = this.slice(thisStart, thisEnd);
568
+ const targetCopy = target.slice(start, end);
569
+ for (let i = 0; i < len; ++i) {
570
+ if (thisCopy[i] !== targetCopy[i]) {
571
+ x = thisCopy[i];
572
+ y = targetCopy[i];
573
+ break;
574
+ }
575
+ }
576
+ if (x < y) {
577
+ return -1;
578
+ }
579
+ if (y < x) {
580
+ return 1;
581
+ }
582
+ return 0;
583
+ };
584
+ // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
585
+ // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
586
+ //
587
+ // Arguments:
588
+ // - buffer - a Buffer to search
589
+ // - val - a string, Buffer, or number
590
+ // - byteOffset - an index into `buffer`; will be clamped to an int32
591
+ // - encoding - an optional encoding, relevant is val is a string
592
+ // - dir - true for indexOf, false for lastIndexOf
593
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
594
+ // Empty buffer means no match
595
+ if (buffer.length === 0) {
596
+ return -1;
597
+ }
598
+ // Normalize byteOffset
599
+ if (typeof byteOffset === "string") {
600
+ encoding = byteOffset;
601
+ byteOffset = 0;
602
+ } else if (byteOffset > 2147483647) {
603
+ byteOffset = 2147483647;
604
+ } else if (byteOffset < -2147483648) {
605
+ byteOffset = -2147483648;
606
+ }
607
+ byteOffset = +byteOffset;
608
+ if (numberIsNaN(byteOffset)) {
609
+ // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
610
+ byteOffset = dir ? 0 : buffer.length - 1;
611
+ }
612
+ // Normalize byteOffset: negative offsets start from the end of the buffer
613
+ if (byteOffset < 0) {
614
+ byteOffset = buffer.length + byteOffset;
615
+ }
616
+ if (byteOffset >= buffer.length) {
617
+ if (dir) {
618
+ return -1;
619
+ } else {
620
+ byteOffset = buffer.length - 1;
621
+ }
622
+ } else if (byteOffset < 0) {
623
+ if (dir) {
624
+ byteOffset = 0;
625
+ } else {
626
+ return -1;
627
+ }
628
+ }
629
+ // Normalize val
630
+ if (typeof val === "string") {
631
+ val = Buffer.from(val, encoding);
632
+ }
633
+ // Finally, search either indexOf (if dir is true) or lastIndexOf
634
+ if (Buffer.isBuffer(val)) {
635
+ // Special case: looking for empty string/buffer always fails
636
+ if (val.length === 0) {
637
+ return -1;
638
+ }
639
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
640
+ } else if (typeof val === "number") {
641
+ val = val & 255;
642
+ if (typeof Uint8Array.prototype.indexOf === "function") {
643
+ return dir ? Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) : Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
644
+ }
645
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
646
+ }
647
+ throw new TypeError("val must be string, number or Buffer");
648
+ }
649
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
650
+ let indexSize = 1;
651
+ let arrLength = arr.length;
652
+ let valLength = val.length;
653
+ if (encoding !== undefined) {
654
+ encoding = String(encoding).toLowerCase();
655
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
656
+ if (arr.length < 2 || val.length < 2) {
657
+ return -1;
658
+ }
659
+ indexSize = 2;
660
+ arrLength /= 2;
661
+ valLength /= 2;
662
+ byteOffset /= 2;
663
+ }
664
+ }
665
+ function read(buf, i) {
666
+ return indexSize === 1 ? buf[i] : buf.readUInt16BE(i * indexSize);
667
+ }
668
+ let i;
669
+ if (dir) {
670
+ let foundIndex = -1;
671
+ for (i = byteOffset; i < arrLength; i++) {
672
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
673
+ if (foundIndex === -1) {
674
+ foundIndex = i;
675
+ }
676
+ if (i - foundIndex + 1 === valLength) {
677
+ return foundIndex * indexSize;
678
+ }
679
+ } else {
680
+ if (foundIndex !== -1) {
681
+ i -= i - foundIndex;
682
+ }
683
+ foundIndex = -1;
684
+ }
685
+ }
686
+ } else {
687
+ if (byteOffset + valLength > arrLength) {
688
+ byteOffset = arrLength - valLength;
689
+ }
690
+ for (i = byteOffset; i >= 0; i--) {
691
+ let found = true;
692
+ for (let j = 0; j < valLength; j++) {
693
+ if (read(arr, i + j) !== read(val, j)) {
694
+ found = false;
695
+ break;
696
+ }
697
+ }
698
+ if (found) {
699
+ return i;
700
+ }
701
+ }
702
+ }
703
+ return -1;
704
+ }
705
+ Buffer.prototype.includes = function includes(val, byteOffset, encoding) {
706
+ return this.indexOf(val, byteOffset, encoding) !== -1;
707
+ };
708
+ Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
709
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
710
+ };
711
+ Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
712
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
713
+ };
714
+ function hexWrite(buf, string, offset, length) {
715
+ offset = Number(offset) || 0;
716
+ const remaining = buf.length - offset;
717
+ if (length) {
718
+ length = Number(length);
719
+ if (length > remaining) {
720
+ length = remaining;
721
+ }
722
+ } else {
723
+ length = remaining;
724
+ }
725
+ const strLen = string.length;
726
+ if (length > strLen / 2) {
727
+ length = strLen / 2;
728
+ }
729
+ let i;
730
+ for (i = 0; i < length; ++i) {
731
+ const parsed = Number.parseInt(string.slice(i * 2, i * 2 + 2), 16);
732
+ if (numberIsNaN(parsed)) {
733
+ return i;
734
+ }
735
+ buf[offset + i] = parsed;
736
+ }
737
+ return i;
738
+ }
739
+ function utf8Write(buf, string, offset, length) {
740
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
741
+ }
742
+ function asciiWrite(buf, string, offset, length) {
743
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
744
+ }
745
+ function base64Write(buf, string, offset, length) {
746
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
747
+ }
748
+ function ucs2Write(buf, string, offset, length) {
749
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
750
+ }
751
+ Buffer.prototype.write = function write(string, offset, length, encoding) {
752
+ // Buffer#write(string)
753
+ if (offset === undefined) {
754
+ encoding = "utf8";
755
+ length = this.length;
756
+ offset = 0;
757
+ } else if (length === undefined && typeof offset === "string") {
758
+ encoding = offset;
759
+ length = this.length;
760
+ offset = 0;
761
+ } else if (Number.isFinite(offset)) {
762
+ offset = offset >>> 0;
763
+ if (Number.isFinite(length)) {
764
+ length = length >>> 0;
765
+ if (encoding === undefined) {
766
+ encoding = "utf8";
767
+ }
768
+ } else {
769
+ encoding = length;
770
+ length = undefined;
771
+ }
772
+ } else {
773
+ throw new TypeError("Buffer.write(string, encoding, offset[, length]) is no longer supported");
774
+ }
775
+ const remaining = this.length - offset;
776
+ if (length === undefined || length > remaining) {
777
+ length = remaining;
778
+ }
779
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
780
+ throw new RangeError("Attempt to write outside buffer bounds");
781
+ }
782
+ if (!encoding) {
783
+ encoding = "utf8";
784
+ }
785
+ let loweredCase = false;
786
+ for (;;) {
787
+ switch (encoding) {
788
+ case "hex": return hexWrite(this, string, offset, length);
789
+ case "utf8":
790
+ case "utf-8": return utf8Write(this, string, offset, length);
791
+ case "ascii":
792
+ case "latin1":
793
+ case "binary": return asciiWrite(this, string, offset, length);
794
+ case "base64":
795
+ // Warning: maxLength not taken into account in base64Write
796
+ return base64Write(this, string, offset, length);
797
+ case "ucs2":
798
+ case "ucs-2":
799
+ case "utf16le":
800
+ case "utf-16le": return ucs2Write(this, string, offset, length);
801
+ default:
802
+ if (loweredCase) {
803
+ throw new TypeError("Unknown encoding: " + encoding);
804
+ }
805
+ encoding = ("" + encoding).toLowerCase();
806
+ loweredCase = true;
807
+ }
808
+ }
809
+ };
810
+ Buffer.prototype.toJSON = function toJSON() {
811
+ return {
812
+ type: "Buffer",
813
+ data: Array.prototype.slice.call(this._arr || this, 0)
814
+ };
815
+ };
816
+ function base64Slice(buf, start, end) {
817
+ return start === 0 && end === buf.length ? base64.fromByteArray(buf) : base64.fromByteArray(buf.slice(start, end));
818
+ }
819
+ function utf8Slice(buf, start, end) {
820
+ end = Math.min(buf.length, end);
821
+ const res = [];
822
+ let i = start;
823
+ while (i < end) {
824
+ const firstByte = buf[i];
825
+ let codePoint = null;
826
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
827
+ if (i + bytesPerSequence <= end) {
828
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
829
+ switch (bytesPerSequence) {
830
+ case 1:
831
+ if (firstByte < 128) {
832
+ codePoint = firstByte;
833
+ }
834
+ break;
835
+ case 2:
836
+ secondByte = buf[i + 1];
837
+ if ((secondByte & 192) === 128) {
838
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
839
+ if (tempCodePoint > 127) {
840
+ codePoint = tempCodePoint;
841
+ }
842
+ }
843
+ break;
844
+ case 3:
845
+ secondByte = buf[i + 1];
846
+ thirdByte = buf[i + 2];
847
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
848
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
849
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
850
+ codePoint = tempCodePoint;
851
+ }
852
+ }
853
+ break;
854
+ case 4:
855
+ secondByte = buf[i + 1];
856
+ thirdByte = buf[i + 2];
857
+ fourthByte = buf[i + 3];
858
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
859
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
860
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
861
+ codePoint = tempCodePoint;
862
+ }
863
+ }
864
+ }
865
+ }
866
+ if (codePoint === null) {
867
+ // we did not generate a valid codePoint so insert a
868
+ // replacement char (U+FFFD) and advance only 1 byte
869
+ codePoint = 65533;
870
+ bytesPerSequence = 1;
871
+ } else if (codePoint > 65535) {
872
+ // encode to utf16 (surrogate pair dance)
873
+ codePoint -= 65536;
874
+ res.push(codePoint >>> 10 & 1023 | 55296);
875
+ codePoint = 56320 | codePoint & 1023;
876
+ }
877
+ res.push(codePoint);
878
+ i += bytesPerSequence;
879
+ }
880
+ return decodeCodePointsArray(res);
881
+ }
882
+ // Based on http://stackoverflow.com/a/22747272/680742, the browser with
883
+ // the lowest limit is Chrome, with 0x10000 args.
884
+ // We go 1 magnitude less, for safety
885
+ const MAX_ARGUMENTS_LENGTH = 4096;
886
+ function decodeCodePointsArray(codePoints) {
887
+ const len = codePoints.length;
888
+ if (len <= MAX_ARGUMENTS_LENGTH) {
889
+ return String.fromCharCode.apply(String, codePoints);
890
+ }
891
+ // Decode in chunks to avoid "call stack size exceeded".
892
+ let res = "";
893
+ let i = 0;
894
+ while (i < len) {
895
+ res += String.fromCharCode.apply(String, codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH));
896
+ }
897
+ return res;
898
+ }
899
+ function asciiSlice(buf, start, end) {
900
+ let ret = "";
901
+ end = Math.min(buf.length, end);
902
+ for (let i = start; i < end; ++i) {
903
+ ret += String.fromCharCode(buf[i] & 127);
904
+ }
905
+ return ret;
906
+ }
907
+ function latin1Slice(buf, start, end) {
908
+ let ret = "";
909
+ end = Math.min(buf.length, end);
910
+ for (let i = start; i < end; ++i) {
911
+ ret += String.fromCharCode(buf[i]);
912
+ }
913
+ return ret;
914
+ }
915
+ function hexSlice(buf, start, end) {
916
+ const len = buf.length;
917
+ if (!start || start < 0) {
918
+ start = 0;
919
+ }
920
+ if (!end || end < 0 || end > len) {
921
+ end = len;
922
+ }
923
+ let out = "";
924
+ for (let i = start; i < end; ++i) {
925
+ out += hexSliceLookupTable[buf[i]];
926
+ }
927
+ return out;
928
+ }
929
+ function utf16leSlice(buf, start, end) {
930
+ const bytes = buf.slice(start, end);
931
+ let res = "";
932
+ // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)
933
+ for (let i = 0; i < bytes.length - 1; i += 2) {
934
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
935
+ }
936
+ return res;
937
+ }
938
+ Buffer.prototype.slice = function slice(start, end) {
939
+ const len = this.length;
940
+ start = Math.trunc(start);
941
+ end = end === undefined ? len : Math.trunc(end);
942
+ if (start < 0) {
943
+ start += len;
944
+ if (start < 0) {
945
+ start = 0;
946
+ }
947
+ } else if (start > len) {
948
+ start = len;
949
+ }
950
+ if (end < 0) {
951
+ end += len;
952
+ if (end < 0) {
953
+ end = 0;
954
+ }
955
+ } else if (end > len) {
956
+ end = len;
957
+ }
958
+ if (end < start) {
959
+ end = start;
960
+ }
961
+ const newBuf = this.subarray(start, end);
962
+ // Return an augmented `Uint8Array` instance
963
+ Object.setPrototypeOf(newBuf, Buffer.prototype);
964
+ return newBuf;
965
+ };
966
+ /*
967
+ * Need to make sure that buffer isn't trying to write out of bounds.
968
+ */
969
+ function checkOffset(offset, ext, length) {
970
+ if (offset % 1 !== 0 || offset < 0) {
971
+ throw new RangeError("offset is not uint");
972
+ }
973
+ if (offset + ext > length) {
974
+ throw new RangeError("Trying to access beyond buffer length");
975
+ }
976
+ }
977
+ Buffer.prototype.readUintLE = Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {
978
+ offset = offset >>> 0;
979
+ byteLength = byteLength >>> 0;
980
+ if (!noAssert) {
981
+ checkOffset(offset, byteLength, this.length);
982
+ }
983
+ let val = this[offset];
984
+ let mul = 1;
985
+ let i = 0;
986
+ while (++i < byteLength && (mul *= 256)) {
987
+ val += this[offset + i] * mul;
988
+ }
989
+ return val;
990
+ };
991
+ Buffer.prototype.readUintBE = Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {
992
+ offset = offset >>> 0;
993
+ byteLength = byteLength >>> 0;
994
+ if (!noAssert) {
995
+ checkOffset(offset, byteLength, this.length);
996
+ }
997
+ let val = this[offset + --byteLength];
998
+ let mul = 1;
999
+ while (byteLength > 0 && (mul *= 256)) {
1000
+ val += this[offset + --byteLength] * mul;
1001
+ }
1002
+ return val;
1003
+ };
1004
+ Buffer.prototype.readUint8 = Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1005
+ offset = offset >>> 0;
1006
+ if (!noAssert) {
1007
+ checkOffset(offset, 1, this.length);
1008
+ }
1009
+ return this[offset];
1010
+ };
1011
+ Buffer.prototype.readUint16LE = Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1012
+ offset = offset >>> 0;
1013
+ if (!noAssert) {
1014
+ checkOffset(offset, 2, this.length);
1015
+ }
1016
+ return this[offset] | this[offset + 1] << 8;
1017
+ };
1018
+ Buffer.prototype.readUint16BE = Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1019
+ offset = offset >>> 0;
1020
+ if (!noAssert) {
1021
+ checkOffset(offset, 2, this.length);
1022
+ }
1023
+ return this[offset] << 8 | this[offset + 1];
1024
+ };
1025
+ Buffer.prototype.readUint32LE = Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1026
+ offset = offset >>> 0;
1027
+ if (!noAssert) {
1028
+ checkOffset(offset, 4, this.length);
1029
+ }
1030
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1031
+ };
1032
+ Buffer.prototype.readUint32BE = Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1033
+ offset = offset >>> 0;
1034
+ if (!noAssert) {
1035
+ checkOffset(offset, 4, this.length);
1036
+ }
1037
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1038
+ };
1039
+ Buffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1040
+ offset = offset >>> 0;
1041
+ validateNumber(offset, "offset");
1042
+ const first = this[offset];
1043
+ const last = this[offset + 7];
1044
+ if (first === undefined || last === undefined) {
1045
+ boundsError(offset, this.length - 8);
1046
+ }
1047
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1048
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1049
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1050
+ });
1051
+ Buffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1052
+ offset = offset >>> 0;
1053
+ validateNumber(offset, "offset");
1054
+ const first = this[offset];
1055
+ const last = this[offset + 7];
1056
+ if (first === undefined || last === undefined) {
1057
+ boundsError(offset, this.length - 8);
1058
+ }
1059
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1060
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1061
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1062
+ });
1063
+ Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {
1064
+ offset = offset >>> 0;
1065
+ byteLength = byteLength >>> 0;
1066
+ if (!noAssert) {
1067
+ checkOffset(offset, byteLength, this.length);
1068
+ }
1069
+ let val = this[offset];
1070
+ let mul = 1;
1071
+ let i = 0;
1072
+ while (++i < byteLength && (mul *= 256)) {
1073
+ val += this[offset + i] * mul;
1074
+ }
1075
+ mul *= 128;
1076
+ if (val >= mul) {
1077
+ val -= Math.pow(2, 8 * byteLength);
1078
+ }
1079
+ return val;
1080
+ };
1081
+ Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {
1082
+ offset = offset >>> 0;
1083
+ byteLength = byteLength >>> 0;
1084
+ if (!noAssert) {
1085
+ checkOffset(offset, byteLength, this.length);
1086
+ }
1087
+ let i = byteLength;
1088
+ let mul = 1;
1089
+ let val = this[offset + --i];
1090
+ while (i > 0 && (mul *= 256)) {
1091
+ val += this[offset + --i] * mul;
1092
+ }
1093
+ mul *= 128;
1094
+ if (val >= mul) {
1095
+ val -= Math.pow(2, 8 * byteLength);
1096
+ }
1097
+ return val;
1098
+ };
1099
+ Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {
1100
+ offset = offset >>> 0;
1101
+ if (!noAssert) {
1102
+ checkOffset(offset, 1, this.length);
1103
+ }
1104
+ if (!(this[offset] & 128)) {
1105
+ return this[offset];
1106
+ }
1107
+ return (255 - this[offset] + 1) * -1;
1108
+ };
1109
+ Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1110
+ offset = offset >>> 0;
1111
+ if (!noAssert) {
1112
+ checkOffset(offset, 2, this.length);
1113
+ }
1114
+ const val = this[offset] | this[offset + 1] << 8;
1115
+ return val & 32768 ? val | 4294901760 : val;
1116
+ };
1117
+ Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1118
+ offset = offset >>> 0;
1119
+ if (!noAssert) {
1120
+ checkOffset(offset, 2, this.length);
1121
+ }
1122
+ const val = this[offset + 1] | this[offset] << 8;
1123
+ return val & 32768 ? val | 4294901760 : val;
1124
+ };
1125
+ Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1126
+ offset = offset >>> 0;
1127
+ if (!noAssert) {
1128
+ checkOffset(offset, 4, this.length);
1129
+ }
1130
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1131
+ };
1132
+ Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1133
+ offset = offset >>> 0;
1134
+ if (!noAssert) {
1135
+ checkOffset(offset, 4, this.length);
1136
+ }
1137
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1138
+ };
1139
+ Buffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1140
+ offset = offset >>> 0;
1141
+ validateNumber(offset, "offset");
1142
+ const first = this[offset];
1143
+ const last = this[offset + 7];
1144
+ if (first === undefined || last === undefined) {
1145
+ boundsError(offset, this.length - 8);
1146
+ }
1147
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1148
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1149
+ });
1150
+ Buffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1151
+ offset = offset >>> 0;
1152
+ validateNumber(offset, "offset");
1153
+ const first = this[offset];
1154
+ const last = this[offset + 7];
1155
+ if (first === undefined || last === undefined) {
1156
+ boundsError(offset, this.length - 8);
1157
+ }
1158
+ const val = (first << 24) + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1159
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1160
+ });
1161
+ Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1162
+ offset = offset >>> 0;
1163
+ if (!noAssert) {
1164
+ checkOffset(offset, 4, this.length);
1165
+ }
1166
+ return ieee754.read(this, offset, true, 23, 4);
1167
+ };
1168
+ Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1169
+ offset = offset >>> 0;
1170
+ if (!noAssert) {
1171
+ checkOffset(offset, 4, this.length);
1172
+ }
1173
+ return ieee754.read(this, offset, false, 23, 4);
1174
+ };
1175
+ Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1176
+ offset = offset >>> 0;
1177
+ if (!noAssert) {
1178
+ checkOffset(offset, 8, this.length);
1179
+ }
1180
+ return ieee754.read(this, offset, true, 52, 8);
1181
+ };
1182
+ Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1183
+ offset = offset >>> 0;
1184
+ if (!noAssert) {
1185
+ checkOffset(offset, 8, this.length);
1186
+ }
1187
+ return ieee754.read(this, offset, false, 52, 8);
1188
+ };
1189
+ function checkInt(buf, value, offset, ext, max, min) {
1190
+ if (!Buffer.isBuffer(buf)) {
1191
+ throw new TypeError("\"buffer\" argument must be a Buffer instance");
1192
+ }
1193
+ if (value > max || value < min) {
1194
+ throw new RangeError("\"value\" argument is out of bounds");
1195
+ }
1196
+ if (offset + ext > buf.length) {
1197
+ throw new RangeError("Index out of range");
1198
+ }
1199
+ }
1200
+ Buffer.prototype.writeUintLE = Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {
1201
+ value = +value;
1202
+ offset = offset >>> 0;
1203
+ byteLength = byteLength >>> 0;
1204
+ if (!noAssert) {
1205
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1206
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1207
+ }
1208
+ let mul = 1;
1209
+ let i = 0;
1210
+ this[offset] = value & 255;
1211
+ while (++i < byteLength && (mul *= 256)) {
1212
+ this[offset + i] = value / mul & 255;
1213
+ }
1214
+ return offset + byteLength;
1215
+ };
1216
+ Buffer.prototype.writeUintBE = Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {
1217
+ value = +value;
1218
+ offset = offset >>> 0;
1219
+ byteLength = byteLength >>> 0;
1220
+ if (!noAssert) {
1221
+ const maxBytes = Math.pow(2, 8 * byteLength) - 1;
1222
+ checkInt(this, value, offset, byteLength, maxBytes, 0);
1223
+ }
1224
+ let i = byteLength - 1;
1225
+ let mul = 1;
1226
+ this[offset + i] = value & 255;
1227
+ while (--i >= 0 && (mul *= 256)) {
1228
+ this[offset + i] = value / mul & 255;
1229
+ }
1230
+ return offset + byteLength;
1231
+ };
1232
+ Buffer.prototype.writeUint8 = Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1233
+ value = +value;
1234
+ offset = offset >>> 0;
1235
+ if (!noAssert) {
1236
+ checkInt(this, value, offset, 1, 255, 0);
1237
+ }
1238
+ this[offset] = value & 255;
1239
+ return offset + 1;
1240
+ };
1241
+ Buffer.prototype.writeUint16LE = Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1242
+ value = +value;
1243
+ offset = offset >>> 0;
1244
+ if (!noAssert) {
1245
+ checkInt(this, value, offset, 2, 65535, 0);
1246
+ }
1247
+ this[offset] = value & 255;
1248
+ this[offset + 1] = value >>> 8;
1249
+ return offset + 2;
1250
+ };
1251
+ Buffer.prototype.writeUint16BE = Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1252
+ value = +value;
1253
+ offset = offset >>> 0;
1254
+ if (!noAssert) {
1255
+ checkInt(this, value, offset, 2, 65535, 0);
1256
+ }
1257
+ this[offset] = value >>> 8;
1258
+ this[offset + 1] = value & 255;
1259
+ return offset + 2;
1260
+ };
1261
+ Buffer.prototype.writeUint32LE = Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1262
+ value = +value;
1263
+ offset = offset >>> 0;
1264
+ if (!noAssert) {
1265
+ checkInt(this, value, offset, 4, 4294967295, 0);
1266
+ }
1267
+ this[offset + 3] = value >>> 24;
1268
+ this[offset + 2] = value >>> 16;
1269
+ this[offset + 1] = value >>> 8;
1270
+ this[offset] = value & 255;
1271
+ return offset + 4;
1272
+ };
1273
+ Buffer.prototype.writeUint32BE = Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1274
+ value = +value;
1275
+ offset = offset >>> 0;
1276
+ if (!noAssert) {
1277
+ checkInt(this, value, offset, 4, 4294967295, 0);
1278
+ }
1279
+ this[offset] = value >>> 24;
1280
+ this[offset + 1] = value >>> 16;
1281
+ this[offset + 2] = value >>> 8;
1282
+ this[offset + 3] = value & 255;
1283
+ return offset + 4;
1284
+ };
1285
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1286
+ checkIntBI(value, min, max, buf, offset, 7);
1287
+ let lo = Number(value & BigInt(4294967295));
1288
+ buf[offset++] = lo;
1289
+ lo = lo >> 8;
1290
+ buf[offset++] = lo;
1291
+ lo = lo >> 8;
1292
+ buf[offset++] = lo;
1293
+ lo = lo >> 8;
1294
+ buf[offset++] = lo;
1295
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1296
+ buf[offset++] = hi;
1297
+ hi = hi >> 8;
1298
+ buf[offset++] = hi;
1299
+ hi = hi >> 8;
1300
+ buf[offset++] = hi;
1301
+ hi = hi >> 8;
1302
+ buf[offset++] = hi;
1303
+ return offset;
1304
+ }
1305
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1306
+ checkIntBI(value, min, max, buf, offset, 7);
1307
+ let lo = Number(value & BigInt(4294967295));
1308
+ buf[offset + 7] = lo;
1309
+ lo = lo >> 8;
1310
+ buf[offset + 6] = lo;
1311
+ lo = lo >> 8;
1312
+ buf[offset + 5] = lo;
1313
+ lo = lo >> 8;
1314
+ buf[offset + 4] = lo;
1315
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1316
+ buf[offset + 3] = hi;
1317
+ hi = hi >> 8;
1318
+ buf[offset + 2] = hi;
1319
+ hi = hi >> 8;
1320
+ buf[offset + 1] = hi;
1321
+ hi = hi >> 8;
1322
+ buf[offset] = hi;
1323
+ return offset + 8;
1324
+ }
1325
+ Buffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1326
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1327
+ });
1328
+ Buffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1329
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1330
+ });
1331
+ Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {
1332
+ value = +value;
1333
+ offset = offset >>> 0;
1334
+ if (!noAssert) {
1335
+ const limit = Math.pow(2, 8 * byteLength - 1);
1336
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
1337
+ }
1338
+ let i = 0;
1339
+ let mul = 1;
1340
+ let sub = 0;
1341
+ this[offset] = value & 255;
1342
+ while (++i < byteLength && (mul *= 256)) {
1343
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1344
+ sub = 1;
1345
+ }
1346
+ this[offset + i] = Math.trunc(value / mul) - sub & 255;
1347
+ }
1348
+ return offset + byteLength;
1349
+ };
1350
+ Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {
1351
+ value = +value;
1352
+ offset = offset >>> 0;
1353
+ if (!noAssert) {
1354
+ const limit = Math.pow(2, 8 * byteLength - 1);
1355
+ checkInt(this, value, offset, byteLength, limit - 1, -limit);
1356
+ }
1357
+ let i = byteLength - 1;
1358
+ let mul = 1;
1359
+ let sub = 0;
1360
+ this[offset + i] = value & 255;
1361
+ while (--i >= 0 && (mul *= 256)) {
1362
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1363
+ sub = 1;
1364
+ }
1365
+ this[offset + i] = Math.trunc(value / mul) - sub & 255;
1366
+ }
1367
+ return offset + byteLength;
1368
+ };
1369
+ Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1370
+ value = +value;
1371
+ offset = offset >>> 0;
1372
+ if (!noAssert) {
1373
+ checkInt(this, value, offset, 1, 127, -128);
1374
+ }
1375
+ if (value < 0) {
1376
+ value = 255 + value + 1;
1377
+ }
1378
+ this[offset] = value & 255;
1379
+ return offset + 1;
1380
+ };
1381
+ Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1382
+ value = +value;
1383
+ offset = offset >>> 0;
1384
+ if (!noAssert) {
1385
+ checkInt(this, value, offset, 2, 32767, -32768);
1386
+ }
1387
+ this[offset] = value & 255;
1388
+ this[offset + 1] = value >>> 8;
1389
+ return offset + 2;
1390
+ };
1391
+ Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1392
+ value = +value;
1393
+ offset = offset >>> 0;
1394
+ if (!noAssert) {
1395
+ checkInt(this, value, offset, 2, 32767, -32768);
1396
+ }
1397
+ this[offset] = value >>> 8;
1398
+ this[offset + 1] = value & 255;
1399
+ return offset + 2;
1400
+ };
1401
+ Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1402
+ value = +value;
1403
+ offset = offset >>> 0;
1404
+ if (!noAssert) {
1405
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1406
+ }
1407
+ this[offset] = value & 255;
1408
+ this[offset + 1] = value >>> 8;
1409
+ this[offset + 2] = value >>> 16;
1410
+ this[offset + 3] = value >>> 24;
1411
+ return offset + 4;
1412
+ };
1413
+ Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1414
+ value = +value;
1415
+ offset = offset >>> 0;
1416
+ if (!noAssert) {
1417
+ checkInt(this, value, offset, 4, 2147483647, -2147483648);
1418
+ }
1419
+ if (value < 0) {
1420
+ value = 4294967295 + value + 1;
1421
+ }
1422
+ this[offset] = value >>> 24;
1423
+ this[offset + 1] = value >>> 16;
1424
+ this[offset + 2] = value >>> 8;
1425
+ this[offset + 3] = value & 255;
1426
+ return offset + 4;
1427
+ };
1428
+ Buffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1429
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1430
+ });
1431
+ Buffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1432
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1433
+ });
1434
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1435
+ if (offset + ext > buf.length) {
1436
+ throw new RangeError("Index out of range");
1437
+ }
1438
+ if (offset < 0) {
1439
+ throw new RangeError("Index out of range");
1440
+ }
1441
+ }
1442
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1443
+ value = +value;
1444
+ offset = offset >>> 0;
1445
+ if (!noAssert) {
1446
+ checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
1447
+ }
1448
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1449
+ return offset + 4;
1450
+ }
1451
+ Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1452
+ return writeFloat(this, value, offset, true, noAssert);
1453
+ };
1454
+ Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1455
+ return writeFloat(this, value, offset, false, noAssert);
1456
+ };
1457
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1458
+ value = +value;
1459
+ offset = offset >>> 0;
1460
+ if (!noAssert) {
1461
+ checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
1462
+ }
1463
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1464
+ return offset + 8;
1465
+ }
1466
+ Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1467
+ return writeDouble(this, value, offset, true, noAssert);
1468
+ };
1469
+ Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1470
+ return writeDouble(this, value, offset, false, noAssert);
1471
+ };
1472
+ // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
1473
+ Buffer.prototype.copy = function copy(target, targetStart, start, end) {
1474
+ if (!Buffer.isBuffer(target)) {
1475
+ throw new TypeError("argument should be a Buffer");
1476
+ }
1477
+ if (!start) {
1478
+ start = 0;
1479
+ }
1480
+ if (!end && end !== 0) {
1481
+ end = this.length;
1482
+ }
1483
+ if (targetStart >= target.length) {
1484
+ targetStart = target.length;
1485
+ }
1486
+ if (!targetStart) {
1487
+ targetStart = 0;
1488
+ }
1489
+ if (end > 0 && end < start) {
1490
+ end = start;
1491
+ }
1492
+ // Copy 0 bytes; we're done
1493
+ if (end === start) {
1494
+ return 0;
1495
+ }
1496
+ if (target.length === 0 || this.length === 0) {
1497
+ return 0;
1498
+ }
1499
+ // Fatal error conditions
1500
+ if (targetStart < 0) {
1501
+ throw new RangeError("targetStart out of bounds");
1502
+ }
1503
+ if (start < 0 || start >= this.length) {
1504
+ throw new RangeError("Index out of range");
1505
+ }
1506
+ if (end < 0) {
1507
+ throw new RangeError("sourceEnd out of bounds");
1508
+ }
1509
+ // Are we oob?
1510
+ if (end > this.length) {
1511
+ end = this.length;
1512
+ }
1513
+ if (target.length - targetStart < end - start) {
1514
+ end = target.length - targetStart + start;
1515
+ }
1516
+ const len = end - start;
1517
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1518
+ // Use built-in when available, missing from IE11
1519
+ this.copyWithin(targetStart, start, end);
1520
+ } else {
1521
+ Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);
1522
+ }
1523
+ return len;
1524
+ };
1525
+ // Usage:
1526
+ // buffer.fill(number[, offset[, end]])
1527
+ // buffer.fill(buffer[, offset[, end]])
1528
+ // buffer.fill(string[, offset[, end]][, encoding])
1529
+ Buffer.prototype.fill = function fill(val, start, end, encoding) {
1530
+ // Handle string cases:
1531
+ if (typeof val === "string") {
1532
+ if (typeof start === "string") {
1533
+ encoding = start;
1534
+ start = 0;
1535
+ end = this.length;
1536
+ } else if (typeof end === "string") {
1537
+ encoding = end;
1538
+ end = this.length;
1539
+ }
1540
+ if (encoding !== undefined && typeof encoding !== "string") {
1541
+ throw new TypeError("encoding must be a string");
1542
+ }
1543
+ if (typeof encoding === "string" && !Buffer.isEncoding(encoding)) {
1544
+ throw new TypeError("Unknown encoding: " + encoding);
1545
+ }
1546
+ if (val.length === 1) {
1547
+ const code = val.charCodeAt(0);
1548
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1549
+ // Fast path: If `val` fits into a single byte, use that numeric value.
1550
+ val = code;
1551
+ }
1552
+ }
1553
+ } else if (typeof val === "number") {
1554
+ val = val & 255;
1555
+ } else if (typeof val === "boolean") {
1556
+ val = Number(val);
1557
+ }
1558
+ // Invalid ranges are not set to a default, so can range check early.
1559
+ if (start < 0 || this.length < start || this.length < end) {
1560
+ throw new RangeError("Out of range index");
1561
+ }
1562
+ if (end <= start) {
1563
+ return this;
1564
+ }
1565
+ start = start >>> 0;
1566
+ end = end === undefined ? this.length : end >>> 0;
1567
+ if (!val) {
1568
+ val = 0;
1569
+ }
1570
+ let i;
1571
+ if (typeof val === "number") {
1572
+ for (i = start; i < end; ++i) {
1573
+ this[i] = val;
1574
+ }
1575
+ } else {
1576
+ const bytes = Buffer.isBuffer(val) ? val : Buffer.from(val, encoding);
1577
+ const len = bytes.length;
1578
+ if (len === 0) {
1579
+ throw new TypeError("The value \"" + val + "\" is invalid for argument \"value\"");
1580
+ }
1581
+ for (i = 0; i < end - start; ++i) {
1582
+ this[i + start] = bytes[i % len];
1583
+ }
1584
+ }
1585
+ return this;
1586
+ };
1587
+ // CUSTOM ERRORS
1588
+ // =============
1589
+ // Simplified versions from Node, changed for Buffer-only usage
1590
+ const errors = {};
1591
+ function E(sym, getMessage, Base) {
1592
+ errors[sym] = class NodeError extends Base {
1593
+ constructor() {
1594
+ super();
1595
+ Object.defineProperty(this, "message", {
1596
+ value: Reflect.apply(getMessage, this, arguments),
1597
+ writable: true,
1598
+ configurable: true
1599
+ });
1600
+ // Add the error code to the name to include it in the stack trace.
1601
+ this.name = `${this.name} [${sym}]`;
1602
+ // Access the stack to generate the error message including the error code
1603
+ // from the name.
1604
+ this.stack;
1605
+ // Reset the name to the actual name.
1606
+ delete this.name;
1607
+ }
1608
+ get code() {
1609
+ return sym;
1610
+ }
1611
+ set code(value) {
1612
+ Object.defineProperty(this, "code", {
1613
+ configurable: true,
1614
+ enumerable: true,
1615
+ value,
1616
+ writable: true
1617
+ });
1618
+ }
1619
+ toString() {
1620
+ return `${this.name} [${sym}]: ${this.message}`;
1621
+ }
1622
+ };
1623
+ }
1624
+ E("ERR_BUFFER_OUT_OF_BOUNDS", function(name) {
1625
+ if (name) {
1626
+ return `${name} is outside of buffer bounds`;
1627
+ }
1628
+ return "Attempt to access memory outside buffer bounds";
1629
+ }, RangeError);
1630
+ E("ERR_INVALID_ARG_TYPE", function(name, actual) {
1631
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1632
+ }, TypeError);
1633
+ E("ERR_OUT_OF_RANGE", function(str, range, input) {
1634
+ let msg = `The value of "${str}" is out of range.`;
1635
+ let received = input;
1636
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1637
+ received = addNumericalSeparator(String(input));
1638
+ } else if (typeof input === "bigint") {
1639
+ received = String(input);
1640
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1641
+ received = addNumericalSeparator(received);
1642
+ }
1643
+ received += "n";
1644
+ }
1645
+ msg += ` It must be ${range}. Received ${received}`;
1646
+ return msg;
1647
+ }, RangeError);
1648
+ function addNumericalSeparator(val) {
1649
+ let res = "";
1650
+ let i = val.length;
1651
+ const start = val[0] === "-" ? 1 : 0;
1652
+ for (; i >= start + 4; i -= 3) {
1653
+ res = `_${val.slice(i - 3, i)}${res}`;
1654
+ }
1655
+ return `${val.slice(0, i)}${res}`;
1656
+ }
1657
+ // CHECK FUNCTIONS
1658
+ // ===============
1659
+ function checkBounds(buf, offset, byteLength) {
1660
+ validateNumber(offset, "offset");
1661
+ if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {
1662
+ boundsError(offset, buf.length - (byteLength + 1));
1663
+ }
1664
+ }
1665
+ function checkIntBI(value, min, max, buf, offset, byteLength) {
1666
+ if (value > max || value < min) {
1667
+ const n = typeof min === "bigint" ? "n" : "";
1668
+ let range;
1669
+ if (byteLength > 3) {
1670
+ range = min === 0 || min === BigInt(0) ? `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}` : `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` + `${(byteLength + 1) * 8 - 1}${n}`;
1671
+ } else {
1672
+ range = `>= ${min}${n} and <= ${max}${n}`;
1673
+ }
1674
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1675
+ }
1676
+ checkBounds(buf, offset, byteLength);
1677
+ }
1678
+ function validateNumber(value, name) {
1679
+ if (typeof value !== "number") {
1680
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1681
+ }
1682
+ }
1683
+ function boundsError(value, length, type) {
1684
+ if (Math.floor(value) !== value) {
1685
+ validateNumber(value, type);
1686
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1687
+ }
1688
+ if (length < 0) {
1689
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1690
+ }
1691
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", `>= ${type ? 1 : 0} and <= ${length}`, value);
1692
+ }
1693
+ // HELPER FUNCTIONS
1694
+ // ================
1695
+ const INVALID_BASE64_RE = /[^\w+/-]/g;
1696
+ function base64clean(str) {
1697
+ // Node takes equal signs as end of the Base64 encoding
1698
+ str = str.split("=")[0];
1699
+ // Node strips out invalid characters like \n and \t from the string, base64-js does not
1700
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1701
+ // Node converts strings with length < 2 to ''
1702
+ if (str.length < 2) {
1703
+ return "";
1704
+ }
1705
+ // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
1706
+ while (str.length % 4 !== 0) {
1707
+ str = str + "=";
1708
+ }
1709
+ return str;
1710
+ }
1711
+ function utf8ToBytes(string, units) {
1712
+ units = units || Number.POSITIVE_INFINITY;
1713
+ let codePoint;
1714
+ const length = string.length;
1715
+ let leadSurrogate = null;
1716
+ const bytes = [];
1717
+ for (let i = 0; i < length; ++i) {
1718
+ codePoint = string.charCodeAt(i);
1719
+ // is surrogate component
1720
+ if (codePoint > 55295 && codePoint < 57344) {
1721
+ // last char was a lead
1722
+ if (!leadSurrogate) {
1723
+ // no lead yet
1724
+ if (codePoint > 56319) {
1725
+ // unexpected trail
1726
+ if ((units -= 3) > -1) {
1727
+ bytes.push(239, 191, 189);
1728
+ }
1729
+ continue;
1730
+ } else if (i + 1 === length) {
1731
+ // unpaired lead
1732
+ if ((units -= 3) > -1) {
1733
+ bytes.push(239, 191, 189);
1734
+ }
1735
+ continue;
1736
+ }
1737
+ // valid lead
1738
+ leadSurrogate = codePoint;
1739
+ continue;
1740
+ }
1741
+ // 2 leads in a row
1742
+ if (codePoint < 56320) {
1743
+ if ((units -= 3) > -1) {
1744
+ bytes.push(239, 191, 189);
1745
+ }
1746
+ leadSurrogate = codePoint;
1747
+ continue;
1748
+ }
1749
+ // valid surrogate pair
1750
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1751
+ } else if (leadSurrogate && (units -= 3) > -1) {
1752
+ bytes.push(239, 191, 189);
1753
+ }
1754
+ leadSurrogate = null;
1755
+ // encode utf8
1756
+ if (codePoint < 128) {
1757
+ if ((units -= 1) < 0) {
1758
+ break;
1759
+ }
1760
+ bytes.push(codePoint);
1761
+ } else if (codePoint < 2048) {
1762
+ if ((units -= 2) < 0) {
1763
+ break;
1764
+ }
1765
+ bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
1766
+ } else if (codePoint < 65536) {
1767
+ if ((units -= 3) < 0) {
1768
+ break;
1769
+ }
1770
+ bytes.push(codePoint >> 12 | 224, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
1771
+ } else if (codePoint < 1114112) {
1772
+ if ((units -= 4) < 0) {
1773
+ break;
1774
+ }
1775
+ bytes.push(codePoint >> 18 | 240, codePoint >> 12 & 63 | 128, codePoint >> 6 & 63 | 128, codePoint & 63 | 128);
1776
+ } else {
1777
+ throw new Error("Invalid code point");
1778
+ }
1779
+ }
1780
+ return bytes;
1781
+ }
1782
+ function asciiToBytes(str) {
1783
+ const byteArray = [];
1784
+ for (let i = 0; i < str.length; ++i) {
1785
+ // Node's code seems to be doing this and not & 0x7F..
1786
+ byteArray.push(str.charCodeAt(i) & 255);
1787
+ }
1788
+ return byteArray;
1789
+ }
1790
+ function utf16leToBytes(str, units) {
1791
+ let c, hi, lo;
1792
+ const byteArray = [];
1793
+ for (let i = 0; i < str.length; ++i) {
1794
+ if ((units -= 2) < 0) {
1795
+ break;
1796
+ }
1797
+ c = str.charCodeAt(i);
1798
+ hi = c >> 8;
1799
+ lo = c % 256;
1800
+ byteArray.push(lo, hi);
1801
+ }
1802
+ return byteArray;
1803
+ }
1804
+ function base64ToBytes(str) {
1805
+ return base64.toByteArray(base64clean(str));
1806
+ }
1807
+ function blitBuffer(src, dst, offset, length) {
1808
+ let i;
1809
+ for (i = 0; i < length; ++i) {
1810
+ if (i + offset >= dst.length || i >= src.length) {
1811
+ break;
1812
+ }
1813
+ dst[i + offset] = src[i];
1814
+ }
1815
+ return i;
1816
+ }
1817
+ // ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
1818
+ // the `instanceof` check but they should be treated as of that type.
1819
+ // See: https://github.com/feross/buffer/issues/166
1820
+ function isInstance(obj, type) {
1821
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1822
+ }
1823
+ function numberIsNaN(obj) {
1824
+ // For IE11 support
1825
+ return obj !== obj;
1826
+ }
1827
+ // Create lookup table for `toString('hex')`
1828
+ // See: https://github.com/feross/buffer/issues/219
1829
+ const hexSliceLookupTable = (function() {
1830
+ const alphabet = "0123456789abcdef";
1831
+ const table = Array.from({ length: 256 });
1832
+ for (let i = 0; i < 16; ++i) {
1833
+ const i16 = i * 16;
1834
+ for (let j = 0; j < 16; ++j) {
1835
+ table[i16 + j] = alphabet[i] + alphabet[j];
1836
+ }
1837
+ }
1838
+ return table;
1839
+ })();
1840
+ // Return not function with Error if BigInt not supported
1841
+ function defineBigIntMethod(fn) {
1842
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1843
+ }
1844
+ function BufferBigIntNotDefined() {
1845
+ throw new Error("BigInt not supported");
1846
+ }