visaljs 0.0.6 → 0.0.8

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 (428) hide show
  1. package/README.md +63 -2
  2. package/THIRD_PARTY_LICENSES +1216 -0
  3. package/cli.js +4414 -325
  4. package/node/include/js_node.h +57 -1
  5. package/node/include/js_uv.h +8 -1
  6. package/node/prelude/_stream_duplex.js +4 -0
  7. package/node/prelude/_stream_passthrough.js +4 -0
  8. package/node/prelude/_stream_readable.js +4 -0
  9. package/node/prelude/_stream_transform.js +4 -0
  10. package/node/prelude/_stream_writable.js +4 -0
  11. package/node/prelude/assert.js +1334 -0
  12. package/node/prelude/assert_strict.js +12 -0
  13. package/node/prelude/async_hooks.js +1 -1
  14. package/node/prelude/buffer.js +43 -3
  15. package/node/prelude/child_process.js +1098 -0
  16. package/node/prelude/cluster.js +52 -0
  17. package/node/prelude/console.js +328 -0
  18. package/node/prelude/constants.js +10 -0
  19. package/node/prelude/crypto.js +1 -1
  20. package/node/prelude/diagnostics_channel.js +1 -1
  21. package/node/prelude/dns.js +1 -1
  22. package/node/prelude/domain.js +115 -0
  23. package/node/prelude/events.js +144 -16
  24. package/node/prelude/fs.js +1138 -151
  25. package/node/prelude/fs_promises.js +117 -11
  26. package/node/prelude/http.js +104 -27
  27. package/node/prelude/http2.js +1 -1
  28. package/node/prelude/https.js +148 -0
  29. package/node/prelude/inspector.js +27 -0
  30. package/node/prelude/inspector_promises.js +4 -0
  31. package/node/prelude/internal/async_context.js +1 -1
  32. package/node/prelude/internal/buffer_transcode.js +44 -0
  33. package/node/prelude/internal/comparisons.js +916 -0
  34. package/node/prelude/internal/compression_streams.js +153 -0
  35. package/node/prelude/internal/crypto/asym.js +27 -14
  36. package/node/prelude/internal/crypto/cipher.js +16 -5
  37. package/node/prelude/internal/crypto/diffiehellman.js +3 -2
  38. package/node/prelude/internal/crypto/hash.js +2 -1
  39. package/node/prelude/internal/crypto/kdf.js +14 -9
  40. package/node/prelude/internal/crypto/keys.js +63 -50
  41. package/node/prelude/internal/crypto/random.js +2 -1
  42. package/node/prelude/internal/crypto/util.js +4 -4
  43. package/node/prelude/internal/dotenv.js +98 -0
  44. package/node/prelude/internal/errors.js +21 -5
  45. package/node/prelude/internal/events_extras.js +116 -0
  46. package/node/prelude/internal/events_on.js +100 -0
  47. package/node/prelude/internal/features.js +55 -0
  48. package/node/prelude/internal/fetch.js +364 -0
  49. package/node/prelude/internal/form_data.js +376 -0
  50. package/node/prelude/internal/fs_bigint_stats.js +41 -0
  51. package/node/prelude/internal/fs_blob.js +19 -0
  52. package/node/prelude/internal/fs_cp.js +709 -0
  53. package/node/prelude/internal/fs_dir.js +166 -0
  54. package/node/prelude/internal/fs_filehandle.js +287 -0
  55. package/node/prelude/internal/fs_glob.js +296 -0
  56. package/node/prelude/internal/fs_statfs.js +42 -0
  57. package/node/prelude/internal/fs_stats.js +89 -0
  58. package/node/prelude/internal/fs_streams.js +541 -0
  59. package/node/prelude/internal/fs_utils.js +286 -0
  60. package/node/prelude/internal/fs_watch.js +580 -0
  61. package/node/prelude/internal/http_agent.js +26 -0
  62. package/node/prelude/internal/mime.js +249 -0
  63. package/node/prelude/internal/net.js +1 -0
  64. package/node/prelude/internal/parse_args.js +288 -0
  65. package/node/prelude/internal/perf_histogram.js +435 -0
  66. package/node/prelude/internal/perf_observe.js +119 -0
  67. package/node/prelude/internal/performance_global.js +19 -0
  68. package/node/prelude/internal/process_events.js +49 -1
  69. package/node/prelude/internal/process_memory.js +14 -0
  70. package/node/prelude/internal/process_more.js +414 -0
  71. package/node/prelude/internal/process_signals.js +2 -1
  72. package/node/prelude/internal/process_stdin.js +52 -0
  73. package/node/prelude/internal/process_stdio.js +36 -0
  74. package/node/prelude/internal/querystring.js +0 -0
  75. package/node/prelude/internal/readline.js +338 -0
  76. package/node/prelude/internal/socketaddress.js +8 -4
  77. package/node/prelude/internal/source_map.js +122 -0
  78. package/node/prelude/internal/stream_compose.js +74 -0
  79. package/node/prelude/internal/stream_from.js +6 -0
  80. package/node/prelude/internal/stream_operators.js +23 -0
  81. package/node/prelude/internal/stream_pipeline.js +7 -0
  82. package/node/prelude/internal/stream_transform.js +10 -0
  83. package/node/prelude/internal/stream_web_adapters.js +143 -0
  84. package/node/prelude/internal/streams/add_abort_signal.js +58 -0
  85. package/node/prelude/internal/streams/compose.js +244 -0
  86. package/node/prelude/internal/streams/destroy.js +358 -0
  87. package/node/prelude/internal/streams/duplex.js +199 -0
  88. package/node/prelude/internal/streams/duplexify.js +378 -0
  89. package/node/prelude/internal/streams/end_of_stream.js +387 -0
  90. package/node/prelude/internal/streams/errors.js +216 -0
  91. package/node/prelude/internal/streams/from.js +211 -0
  92. package/node/prelude/internal/streams/legacy.js +120 -0
  93. package/node/prelude/internal/streams/operators.js +375 -0
  94. package/node/prelude/internal/streams/passthrough.js +45 -0
  95. package/node/prelude/internal/streams/pipeline.js +468 -0
  96. package/node/prelude/internal/streams/readable.js +1835 -0
  97. package/node/prelude/internal/streams/state.js +48 -0
  98. package/node/prelude/internal/streams/transform.js +203 -0
  99. package/node/prelude/internal/streams/utils.js +355 -0
  100. package/node/prelude/internal/streams/validators.js +108 -0
  101. package/node/prelude/internal/streams/writable.js +1160 -0
  102. package/node/prelude/internal/structured_clone.js +238 -0
  103. package/node/prelude/internal/system_errors.js +37 -0
  104. package/node/prelude/internal/test_runner/mock.js +431 -0
  105. package/node/prelude/internal/test_runner/reporters.js +404 -0
  106. package/node/prelude/internal/test_runner/test.js +1571 -0
  107. package/node/prelude/internal/timers.js +38 -7
  108. package/node/prelude/internal/timers_global.js +1 -1
  109. package/node/prelude/internal/tls/common.js +8 -2
  110. package/node/prelude/internal/tls/wrap.js +3 -15
  111. package/node/prelude/internal/tls/x509.js +1 -1
  112. package/node/prelude/internal/tty_read_stream.js +39 -0
  113. package/node/prelude/internal/tty_streams.js +3 -0
  114. package/node/prelude/internal/util_debuglog.js +68 -0
  115. package/node/prelude/internal/util_diff.js +63 -0
  116. package/node/prelude/internal/util_more.js +111 -0
  117. package/node/prelude/internal/util_styles.js +76 -0
  118. package/node/prelude/internal/zlib_engines.js +1 -1
  119. package/node/prelude/module.js +194 -7
  120. package/node/prelude/net.js +2 -1
  121. package/node/prelude/os.js +88 -11
  122. package/node/prelude/path.js +11 -7
  123. package/node/prelude/path_posix.js +1 -1
  124. package/node/prelude/path_win32.js +1 -1
  125. package/node/prelude/perf_hooks.js +147 -0
  126. package/node/prelude/process.js +36 -1
  127. package/node/prelude/punycode.js +188 -0
  128. package/node/prelude/querystring.js +1 -1
  129. package/node/prelude/readline.js +8 -0
  130. package/node/prelude/readline_promises.js +88 -0
  131. package/node/prelude/repl.js +38 -0
  132. package/node/prelude/sea.js +23 -0
  133. package/node/prelude/stream.js +70 -1332
  134. package/node/prelude/stream_consumers.js +34 -0
  135. package/node/prelude/stream_promises.js +1 -1
  136. package/node/prelude/stream_web.js +15 -2
  137. package/node/prelude/string_decoder.js +1 -1
  138. package/node/prelude/sys.js +7 -0
  139. package/node/prelude/test.js +56 -0
  140. package/node/prelude/test_reporters.js +269 -0
  141. package/node/prelude/timers.js +7 -84
  142. package/node/prelude/timers_promises.js +1 -1
  143. package/node/prelude/tls.js +2 -1
  144. package/node/prelude/trace_events.js +52 -0
  145. package/node/prelude/tty.js +10 -4
  146. package/node/prelude/url.js +88 -27
  147. package/node/prelude/util.js +121 -5
  148. package/node/prelude/util_types.js +4 -3
  149. package/node/prelude/v8.js +814 -0
  150. package/node/prelude/vm.js +86 -0
  151. package/node/prelude/wasi.js +10 -0
  152. package/node/prelude/worker_threads.js +56 -0
  153. package/node/prelude/zlib.js +58 -25
  154. package/node/src/host_brotli.c +59 -11
  155. package/node/src/host_fs.c +342 -11
  156. package/node/src/host_fswatch.c +170 -0
  157. package/node/src/host_http.c +143 -20
  158. package/node/src/host_loop.c +25 -2
  159. package/node/src/host_net.c +55 -7
  160. package/node/src/host_os.c +55 -1
  161. package/node/src/host_proc.c +291 -0
  162. package/node/src/host_process.c +488 -0
  163. package/node/src/host_sys.c +64 -2
  164. package/node/src/host_zlib.c +27 -7
  165. package/node/src/host_zstd.c +41 -6
  166. package/node/third_party/hdrhistogram/LICENSE +42 -0
  167. package/node/third_party/hdrhistogram/README.md +5 -0
  168. package/node/third_party/libuv/LICENSE +0 -0
  169. package/node/third_party/libuv/LICENSE-extra +36 -0
  170. package/node/third_party/libuv/include/uv/aix.h +0 -0
  171. package/node/third_party/libuv/include/uv/bsd.h +0 -0
  172. package/node/third_party/libuv/include/uv/darwin.h +0 -0
  173. package/node/third_party/libuv/include/uv/errno.h +0 -0
  174. package/node/third_party/libuv/include/uv/linux.h +0 -0
  175. package/node/third_party/libuv/include/uv/os390.h +0 -0
  176. package/node/third_party/libuv/include/uv/posix.h +0 -0
  177. package/node/third_party/libuv/include/uv/sunos.h +0 -0
  178. package/node/third_party/libuv/include/uv/threadpool.h +0 -0
  179. package/node/third_party/libuv/include/uv/tree.h +0 -0
  180. package/node/third_party/libuv/include/uv/unix.h +0 -0
  181. package/node/third_party/libuv/include/uv/version.h +0 -0
  182. package/node/third_party/libuv/include/uv/win.h +0 -0
  183. package/node/third_party/libuv/include/uv.h +0 -0
  184. package/node/third_party/libuv/src/fs-poll.c +0 -0
  185. package/node/third_party/libuv/src/heap-inl.h +0 -0
  186. package/node/third_party/libuv/src/idna.c +0 -0
  187. package/node/third_party/libuv/src/idna.h +0 -0
  188. package/node/third_party/libuv/src/inet.c +0 -0
  189. package/node/third_party/libuv/src/queue.h +0 -0
  190. package/node/third_party/libuv/src/random.c +0 -0
  191. package/node/third_party/libuv/src/strscpy.c +0 -0
  192. package/node/third_party/libuv/src/strscpy.h +0 -0
  193. package/node/third_party/libuv/src/strtok.c +0 -0
  194. package/node/third_party/libuv/src/strtok.h +0 -0
  195. package/node/third_party/libuv/src/thread-common.c +0 -0
  196. package/node/third_party/libuv/src/threadpool.c +0 -0
  197. package/node/third_party/libuv/src/timer.c +0 -0
  198. package/node/third_party/libuv/src/unix/async.c +0 -0
  199. package/node/third_party/libuv/src/unix/bsd-ifaddrs.c +0 -0
  200. package/node/third_party/libuv/src/unix/core.c +0 -0
  201. package/node/third_party/libuv/src/unix/darwin-proctitle.c +0 -0
  202. package/node/third_party/libuv/src/unix/darwin-stub.h +0 -0
  203. package/node/third_party/libuv/src/unix/darwin-syscalls.h +0 -0
  204. package/node/third_party/libuv/src/unix/darwin.c +0 -0
  205. package/node/third_party/libuv/src/unix/dl.c +0 -0
  206. package/node/third_party/libuv/src/unix/fs.c +0 -0
  207. package/node/third_party/libuv/src/unix/fsevents.c +0 -0
  208. package/node/third_party/libuv/src/unix/getaddrinfo.c +0 -0
  209. package/node/third_party/libuv/src/unix/getnameinfo.c +0 -0
  210. package/node/third_party/libuv/src/unix/internal.h +0 -0
  211. package/node/third_party/libuv/src/unix/kqueue.c +0 -0
  212. package/node/third_party/libuv/src/unix/linux.c +0 -0
  213. package/node/third_party/libuv/src/unix/loop-watcher.c +0 -0
  214. package/node/third_party/libuv/src/unix/loop.c +0 -0
  215. package/node/third_party/libuv/src/unix/pipe.c +0 -0
  216. package/node/third_party/libuv/src/unix/poll.c +0 -0
  217. package/node/third_party/libuv/src/unix/process.c +0 -0
  218. package/node/third_party/libuv/src/unix/procfs-exepath.c +0 -0
  219. package/node/third_party/libuv/src/unix/proctitle.c +0 -0
  220. package/node/third_party/libuv/src/unix/random-devurandom.c +0 -0
  221. package/node/third_party/libuv/src/unix/random-getentropy.c +0 -0
  222. package/node/third_party/libuv/src/unix/random-getrandom.c +0 -0
  223. package/node/third_party/libuv/src/unix/random-sysctl-linux.c +0 -0
  224. package/node/third_party/libuv/src/unix/signal.c +0 -0
  225. package/node/third_party/libuv/src/unix/stream.c +0 -0
  226. package/node/third_party/libuv/src/unix/tcp.c +0 -0
  227. package/node/third_party/libuv/src/unix/thread.c +0 -0
  228. package/node/third_party/libuv/src/unix/tty.c +0 -0
  229. package/node/third_party/libuv/src/unix/udp.c +0 -0
  230. package/node/third_party/libuv/src/uv-common.c +0 -0
  231. package/node/third_party/libuv/src/uv-common.h +0 -0
  232. package/node/third_party/libuv/src/uv-data-getter-setters.c +0 -0
  233. package/node/third_party/libuv/src/version.c +0 -0
  234. package/node/third_party/llhttp/LICENSE +0 -0
  235. package/node/third_party/llhttp/api.c +0 -0
  236. package/node/third_party/llhttp/http.c +0 -0
  237. package/node/third_party/llhttp/llhttp.c +0 -0
  238. package/node/third_party/llhttp/llhttp.h +0 -0
  239. package/node/third_party/nodejs/LICENSE +47 -0
  240. package/node/third_party/nodejs/README.md +5 -0
  241. package/node/third_party/parseargs/LICENSE +21 -0
  242. package/node/third_party/parseargs/README.md +5 -0
  243. package/node/third_party/punycode/LICENSE +20 -0
  244. package/node/third_party/punycode/README.md +5 -0
  245. package/node/third_party/zlib/LICENSE.chromium +27 -0
  246. package/package.json +1 -5
  247. package/prebuilt/darwin-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  248. package/prebuilt/darwin-arm64/brotli-7995bbdacc52e51c.a +0 -0
  249. package/prebuilt/darwin-arm64/uv-72ab666eae197cd8.a +0 -0
  250. package/prebuilt/darwin-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  251. package/prebuilt/darwin-arm64/zstd-015315ac7c784c73.a +0 -0
  252. package/prebuilt/darwin-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  253. package/prebuilt/darwin-x64/brotli-7995bbdacc52e51c.a +0 -0
  254. package/prebuilt/darwin-x64/uv-72ab666eae197cd8.a +0 -0
  255. package/prebuilt/darwin-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  256. package/prebuilt/darwin-x64/zstd-015315ac7c784c73.a +0 -0
  257. package/prebuilt/linux-arm64/boringssl-4a47438eaf7e73ba.a +0 -0
  258. package/prebuilt/linux-arm64/brotli-65481ff838ce9def.a +0 -0
  259. package/prebuilt/linux-arm64/uv-f1353f50ff983f3c.a +0 -0
  260. package/prebuilt/linux-arm64/zlib-4ce2317a4c3f5fb5.a +0 -0
  261. package/prebuilt/linux-arm64/zstd-015315ac7c784c73.a +0 -0
  262. package/prebuilt/linux-arm64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  263. package/prebuilt/linux-arm64-musl/brotli-65481ff838ce9def.a +0 -0
  264. package/prebuilt/linux-arm64-musl/uv-f1353f50ff983f3c.a +0 -0
  265. package/prebuilt/linux-arm64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  266. package/prebuilt/linux-arm64-musl/zstd-015315ac7c784c73.a +0 -0
  267. package/prebuilt/linux-x64/boringssl-4a47438eaf7e73ba.a +0 -0
  268. package/prebuilt/linux-x64/brotli-65481ff838ce9def.a +0 -0
  269. package/prebuilt/linux-x64/uv-f1353f50ff983f3c.a +0 -0
  270. package/prebuilt/linux-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  271. package/prebuilt/linux-x64/zstd-015315ac7c784c73.a +0 -0
  272. package/prebuilt/linux-x64-musl/boringssl-4a47438eaf7e73ba.a +0 -0
  273. package/prebuilt/linux-x64-musl/brotli-65481ff838ce9def.a +0 -0
  274. package/prebuilt/linux-x64-musl/uv-f1353f50ff983f3c.a +0 -0
  275. package/prebuilt/linux-x64-musl/zlib-4ce2317a4c3f5fb5.a +0 -0
  276. package/prebuilt/linux-x64-musl/zstd-015315ac7c784c73.a +0 -0
  277. package/prebuilt/win32-x64/boringssl-ce573858472b7fc9.a +0 -0
  278. package/prebuilt/win32-x64/brotli-20d86a61f30baeb3.a +0 -0
  279. package/prebuilt/win32-x64/uv-b11bae65d7fced82.a +0 -0
  280. package/prebuilt/win32-x64/zlib-4ce2317a4c3f5fb5.a +0 -0
  281. package/prebuilt/win32-x64/zstd-015315ac7c784c73.a +0 -0
  282. package/runtime/include/js_atoms.gen.h +0 -0
  283. package/runtime/include/js_atoms.h +1 -1
  284. package/runtime/include/js_bigint.h +1 -1
  285. package/runtime/include/js_buffer.h +4 -4
  286. package/runtime/include/js_builtins.h +41 -3
  287. package/runtime/include/js_console.h +9 -4
  288. package/runtime/include/js_convert.h +1 -1
  289. package/runtime/include/js_core.def +5 -4
  290. package/runtime/include/js_crypto.h +1 -1
  291. package/runtime/include/js_error.h +1 -1
  292. package/runtime/include/js_exception.h +21 -1
  293. package/runtime/include/js_function.h +33 -9
  294. package/runtime/include/js_gc.h +172 -30
  295. package/runtime/include/js_generator.h +2 -2
  296. package/runtime/include/js_host.h +19 -1
  297. package/runtime/include/js_jobs.h +5 -5
  298. package/runtime/include/js_module.h +1 -1
  299. package/runtime/include/js_object.h +142 -15
  300. package/runtime/include/js_ops.h +107 -5
  301. package/runtime/include/js_promise.h +3 -3
  302. package/runtime/include/js_regexp.h +1 -1
  303. package/runtime/include/js_runtime.h +0 -0
  304. package/runtime/include/js_symbol.h +1 -1
  305. package/runtime/include/js_web.h +2 -1
  306. package/runtime/include/jscell.h +22 -15
  307. package/runtime/include/jscontext.h +74 -39
  308. package/runtime/include/jsnum.h +1 -1
  309. package/runtime/include/jsstring.h +19 -6
  310. package/runtime/include/jsvalue.h +7 -3
  311. package/runtime/src/arguments.c +2 -2
  312. package/runtime/src/array.c +4 -1
  313. package/runtime/src/arraybuffer.c +19 -7
  314. package/runtime/src/async_iter.c +4 -3
  315. package/runtime/src/atoms.c +1 -1
  316. package/runtime/src/base64.c +2 -2
  317. package/runtime/src/bigint.c +1 -1
  318. package/runtime/src/blob.c +22 -9
  319. package/runtime/src/boringssl_support.cc +1 -1
  320. package/runtime/src/buffer.c +299 -91
  321. package/runtime/src/builtin_table.c +1 -1
  322. package/runtime/src/builtins.c +30 -4
  323. package/runtime/src/builtins_util.h +0 -0
  324. package/runtime/src/collections.c +18 -3
  325. package/runtime/src/components.c +1 -1
  326. package/runtime/src/console.c +14 -7
  327. package/runtime/src/convert.c +0 -0
  328. package/runtime/src/core_all.c +1 -1
  329. package/runtime/src/crypto.c +1 -1
  330. package/runtime/src/crypto_asym.c +1 -1
  331. package/runtime/src/crypto_bn.c +1 -1
  332. package/runtime/src/crypto_cipher.c +10 -3
  333. package/runtime/src/crypto_hash.c +1 -1
  334. package/runtime/src/crypto_host.c +1 -1
  335. package/runtime/src/crypto_internal.h +1 -1
  336. package/runtime/src/crypto_kdf.c +1 -1
  337. package/runtime/src/crypto_key.c +14 -1
  338. package/runtime/src/crypto_pkey.c +1 -1
  339. package/runtime/src/crypto_subtle.c +142 -58
  340. package/runtime/src/crypto_tls.c +1 -1
  341. package/runtime/src/date.c +5 -2
  342. package/runtime/src/domexception.c +2 -2
  343. package/runtime/src/elements.c +56 -17
  344. package/runtime/src/elements.h +7 -2
  345. package/runtime/src/encoding.c +1 -1
  346. package/runtime/src/error.c +4 -4
  347. package/runtime/src/events.c +23 -14
  348. package/runtime/src/exception.c +1 -1
  349. package/runtime/src/fetch.c +241 -17
  350. package/runtime/src/function.c +31 -19
  351. package/runtime/src/gc.c +1716 -207
  352. package/runtime/src/gc_visit.h +87 -0
  353. package/runtime/src/generator.c +5 -3
  354. package/runtime/src/global.c +14 -6
  355. package/runtime/src/headers.c +10 -10
  356. package/runtime/src/inspect.c +76 -17
  357. package/runtime/src/internal.h +5 -2
  358. package/runtime/src/iterate.c +94 -2
  359. package/runtime/src/iterator.c +1 -1
  360. package/runtime/src/jobs.c +11 -5
  361. package/runtime/src/jsnum.c +2 -2
  362. package/runtime/src/json.c +1 -1
  363. package/runtime/src/math.c +9 -1
  364. package/runtime/src/module.c +3 -3
  365. package/runtime/src/number.c +0 -0
  366. package/runtime/src/object.c +107 -74
  367. package/runtime/src/ops.c +21 -3
  368. package/runtime/src/os.c +192 -1
  369. package/runtime/src/os.h +33 -2
  370. package/runtime/src/process.c +73 -8
  371. package/runtime/src/promise.c +4 -4
  372. package/runtime/src/proxy.c +1 -1
  373. package/runtime/src/reflect.c +1 -1
  374. package/runtime/src/regexp.c +134 -2
  375. package/runtime/src/regexp_anchor.h +1 -1
  376. package/runtime/src/regexp_message.h +1 -1
  377. package/runtime/src/shape.c +10 -19
  378. package/runtime/src/shape.h +0 -0
  379. package/runtime/src/streams.c +22 -8
  380. package/runtime/src/streams.h +0 -0
  381. package/runtime/src/string.c +64 -25
  382. package/runtime/src/string_builtins.c +7 -7
  383. package/runtime/src/symbol.c +2 -7
  384. package/runtime/src/test_host.c +3 -3
  385. package/runtime/src/tls_roots.gen.h +102 -620
  386. package/runtime/src/typedarray.c +8 -3
  387. package/runtime/src/tznames.gen.h +2 -1
  388. package/runtime/src/uri.c +1 -1
  389. package/runtime/src/url.c +42 -39
  390. package/runtime/src/weak.c +15 -12
  391. package/runtime/src/web.c +21 -3
  392. package/runtime/src/wrapper.c +0 -0
  393. package/runtime/src/writable.c +7 -6
  394. package/runtime/third_party/ada-idna/LICENSE-MIT +0 -0
  395. package/runtime/third_party/ada-idna/README.md +7 -7
  396. package/runtime/third_party/ada-idna/convert.mjs +89 -27
  397. package/runtime/third_party/ada-idna/idna.c +30 -31
  398. package/runtime/third_party/ada-idna/idna.h +0 -0
  399. package/runtime/third_party/ada-idna/idna_tables.h +2272 -1952
  400. package/runtime/third_party/boringssl/third_party/fiat/LICENSE +15 -0
  401. package/runtime/third_party/mozilla-ca/LICENSE +373 -0
  402. package/runtime/third_party/mozilla-ca/README.md +9 -0
  403. package/runtime/third_party/nodejs/LICENSE +47 -0
  404. package/runtime/third_party/nodejs/README.md +7 -0
  405. package/runtime/third_party/quickjs-dtoa/LICENSE +0 -0
  406. package/runtime/third_party/quickjs-dtoa/README.md +1 -1
  407. package/runtime/third_party/quickjs-dtoa/dtoa.c +0 -0
  408. package/runtime/third_party/quickjs-dtoa/dtoa.h +0 -0
  409. package/runtime/third_party/quickjs-dtoa/dtoa_compat.h +0 -0
  410. package/runtime/third_party/quickjs-regexp/LICENSE +0 -0
  411. package/runtime/third_party/quickjs-regexp/README.md +2 -2
  412. package/runtime/third_party/quickjs-regexp/cutils.c +0 -0
  413. package/runtime/third_party/quickjs-regexp/cutils.h +0 -0
  414. package/runtime/third_party/quickjs-regexp/libregexp-opcode.h +0 -0
  415. package/runtime/third_party/quickjs-regexp/libregexp.c +0 -0
  416. package/runtime/third_party/quickjs-regexp/libregexp.h +0 -0
  417. package/runtime/third_party/quickjs-regexp/libunicode-table.h +0 -0
  418. package/runtime/third_party/quickjs-regexp/libunicode.c +0 -0
  419. package/runtime/third_party/quickjs-regexp/libunicode.h +0 -0
  420. package/runtime/third_party/unicode/LICENSE +39 -0
  421. package/runtime/third_party/unicode/README.md +9 -0
  422. package/runtime/third_party/v8-ieee754/LICENSE +0 -0
  423. package/runtime/third_party/v8-ieee754/LICENSE.fdlibm +10 -0
  424. package/runtime/third_party/v8-ieee754/README.md +3 -2
  425. package/runtime/third_party/v8-ieee754/convert.py +0 -0
  426. package/runtime/third_party/v8-ieee754/ieee754.c +0 -0
  427. package/runtime/third_party/v8-ieee754/ieee754.h +0 -0
  428. package/runtime/tools/regexp_compile.c +2 -2
@@ -0,0 +1,1835 @@
1
+ import { feature } from "../features.js";
2
+ import * as __events from "../../events.js";
3
+ import * as __internal_streams_legacy from "./legacy.js";
4
+ import * as __buffer from "../../buffer.js";
5
+ import * as __internal_streams_add_abort_signal from "./add_abort_signal.js";
6
+ import * as __internal_streams_end_of_stream from "./end_of_stream.js";
7
+ import * as __internal_streams_destroy from "./destroy.js";
8
+ import * as __internal_streams_state from "./state.js";
9
+ import * as __internal_streams_utils from "./utils.js";
10
+ import * as __internal_errors from "./errors.js";
11
+ import * as __internal_validators from "./validators.js";
12
+ import * as __string_decoder from "../../string_decoder.js";
13
+
14
+ // Copyright Joyent, Inc. and other Node contributors.
15
+ //
16
+ // Permission is hereby granted, free of charge, to any person obtaining a
17
+ // copy of this software and associated documentation files (the
18
+ // "Software"), to deal in the Software without restriction, including
19
+ // without limitation the rights to use, copy, modify, merge, publish,
20
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
21
+ // persons to whom the Software is furnished to do so, subject to the
22
+ // following conditions:
23
+ //
24
+ // The above copyright notice and this permission notice shall be included
25
+ // in all copies or substantial portions of the Software.
26
+ //
27
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
28
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
30
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
31
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
32
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
33
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
34
+
35
+ 'use strict';
36
+
37
+ export { Readable, Readable as default };
38
+ Readable.ReadableState = ReadableState;
39
+
40
+ const EE = __events.default;
41
+ const { Stream, prependListener } = __internal_streams_legacy;
42
+ const { Buffer } = __buffer;
43
+
44
+ const {
45
+ addAbortSignal,
46
+ addAbortSignalNoValidate,
47
+ } = __internal_streams_add_abort_signal;
48
+ const { eos } = __internal_streams_end_of_stream;
49
+
50
+ /* util.debuglog('stream'): NODE_DEBUG=stream prints Node's "STREAM <pid>: …" lines */
51
+ const debug = /(^|,)\s*stream\s*(,|$)/i.test(process.env.NODE_DEBUG ?? '') ?
52
+ (...args) => console.error(`STREAM ${process.pid}:`, ...args) : () => {};
53
+ const destroyImpl = __internal_streams_destroy;
54
+ const {
55
+ getHighWaterMark,
56
+ getDefaultHighWaterMark,
57
+ } = __internal_streams_state;
58
+ const {
59
+ kState,
60
+ // bitfields
61
+ kObjectMode,
62
+ kErrorEmitted,
63
+ kAutoDestroy,
64
+ kEmitClose,
65
+ kDestroyed,
66
+ kClosed,
67
+ kCloseEmitted,
68
+ kErrored,
69
+ kConstructed,
70
+ kOnConstructed,
71
+ } = __internal_streams_utils;
72
+
73
+ const {
74
+ AbortError,
75
+ aggregateTwoErrors,
76
+ codes: {
77
+ ERR_INVALID_ARG_TYPE,
78
+ ERR_METHOD_NOT_IMPLEMENTED,
79
+ ERR_OUT_OF_RANGE,
80
+ ERR_STREAM_ITER_MISSING_FLAG,
81
+ ERR_STREAM_PUSH_AFTER_EOF,
82
+ ERR_STREAM_UNSHIFT_AFTER_END_EVENT,
83
+ ERR_UNKNOWN_ENCODING,
84
+ },
85
+ } = __internal_errors;
86
+ const {
87
+ validateAbortSignal,
88
+ validateObject,
89
+ } = __internal_validators;
90
+
91
+ const FastBuffer = Buffer[Symbol.species];
92
+
93
+ const { StringDecoder } = __string_decoder;
94
+
95
+ Object.setPrototypeOf(Readable.prototype, Stream.prototype);
96
+ Object.setPrototypeOf(Readable, Stream);
97
+ const nop = () => {};
98
+
99
+ const { errorOrDestroy } = destroyImpl;
100
+
101
+ const kErroredValue = Symbol('kErroredValue');
102
+ const kDefaultEncodingValue = Symbol('kDefaultEncodingValue');
103
+ const kDecoderValue = Symbol('kDecoderValue');
104
+ const kEncodingValue = Symbol('kEncodingValue');
105
+
106
+ const kEnded = 1 << 9;
107
+ const kEndEmitted = 1 << 10;
108
+ const kReading = 1 << 11;
109
+ const kSync = 1 << 12;
110
+ const kNeedReadable = 1 << 13;
111
+ const kEmittedReadable = 1 << 14;
112
+ const kReadableListening = 1 << 15;
113
+ const kResumeScheduled = 1 << 16;
114
+ const kMultiAwaitDrain = 1 << 17;
115
+ const kReadingMore = 1 << 18;
116
+ const kDataEmitted = 1 << 19;
117
+ const kDefaultUTF8Encoding = 1 << 20;
118
+ const kDecoder = 1 << 21;
119
+ const kEncoding = 1 << 22;
120
+ const kHasFlowing = 1 << 23;
121
+ const kFlowing = 1 << 24;
122
+ const kHasPaused = 1 << 25;
123
+ const kPaused = 1 << 26;
124
+ const kDataListening = 1 << 27;
125
+ const kEndScheduled = 1 << 28;
126
+
127
+ // TODO(benjamingr) it is likely slower to do it this way than with free functions
128
+ function makeBitMapDescriptor(bit) {
129
+ return {
130
+ enumerable: false,
131
+ get() { return (this[kState] & bit) !== 0; },
132
+ set(value) {
133
+ if (value) this[kState] |= bit;
134
+ else this[kState] &= ~bit;
135
+ },
136
+ };
137
+ }
138
+ Object.defineProperties(ReadableState.prototype, {
139
+ objectMode: makeBitMapDescriptor(kObjectMode),
140
+ ended: makeBitMapDescriptor(kEnded),
141
+ endEmitted: makeBitMapDescriptor(kEndEmitted),
142
+ reading: makeBitMapDescriptor(kReading),
143
+ // Stream is still being constructed and cannot be
144
+ // destroyed until construction finished or failed.
145
+ // Async construction is opt in, therefore we start as
146
+ // constructed.
147
+ constructed: makeBitMapDescriptor(kConstructed),
148
+ // A flag to be able to tell if the event 'readable'/'data' is emitted
149
+ // immediately, or on a later tick. We set this to true at first, because
150
+ // any actions that shouldn't happen until "later" should generally also
151
+ // not happen before the first read call.
152
+ sync: makeBitMapDescriptor(kSync),
153
+ // Whenever we return null, then we set a flag to say
154
+ // that we're awaiting a 'readable' event emission.
155
+ needReadable: makeBitMapDescriptor(kNeedReadable),
156
+ emittedReadable: makeBitMapDescriptor(kEmittedReadable),
157
+ readableListening: makeBitMapDescriptor(kReadableListening),
158
+ resumeScheduled: makeBitMapDescriptor(kResumeScheduled),
159
+ // True if the error was already emitted and should not be thrown again.
160
+ errorEmitted: makeBitMapDescriptor(kErrorEmitted),
161
+ emitClose: makeBitMapDescriptor(kEmitClose),
162
+ autoDestroy: makeBitMapDescriptor(kAutoDestroy),
163
+ // Has it been destroyed.
164
+ destroyed: makeBitMapDescriptor(kDestroyed),
165
+ // Indicates whether the stream has finished destroying.
166
+ closed: makeBitMapDescriptor(kClosed),
167
+ // True if close has been emitted or would have been emitted
168
+ // depending on emitClose.
169
+ closeEmitted: makeBitMapDescriptor(kCloseEmitted),
170
+ multiAwaitDrain: makeBitMapDescriptor(kMultiAwaitDrain),
171
+ // If true, a maybeReadMore has been scheduled.
172
+ readingMore: makeBitMapDescriptor(kReadingMore),
173
+ dataEmitted: makeBitMapDescriptor(kDataEmitted),
174
+
175
+ // Indicates whether the stream has errored. When true no further
176
+ // _read calls, 'data' or 'readable' events should occur. This is needed
177
+ // since when autoDestroy is disabled we need a way to tell whether the
178
+ // stream has failed.
179
+ errored: {
180
+ __proto__: null,
181
+ enumerable: false,
182
+ get() {
183
+ return (this[kState] & kErrored) !== 0 ? this[kErroredValue] : null;
184
+ },
185
+ set(value) {
186
+ if (value) {
187
+ this[kErroredValue] = value;
188
+ this[kState] |= kErrored;
189
+ } else {
190
+ this[kState] &= ~kErrored;
191
+ }
192
+ },
193
+ },
194
+
195
+ defaultEncoding: {
196
+ __proto__: null,
197
+ enumerable: false,
198
+ get() { return (this[kState] & kDefaultUTF8Encoding) !== 0 ? 'utf8' : this[kDefaultEncodingValue]; },
199
+ set(value) {
200
+ if (value === 'utf8' || value === 'utf-8') {
201
+ this[kState] |= kDefaultUTF8Encoding;
202
+ } else {
203
+ this[kState] &= ~kDefaultUTF8Encoding;
204
+ this[kDefaultEncodingValue] = value;
205
+ }
206
+ },
207
+ },
208
+
209
+ decoder: {
210
+ __proto__: null,
211
+ enumerable: false,
212
+ get() {
213
+ return (this[kState] & kDecoder) !== 0 ? this[kDecoderValue] : null;
214
+ },
215
+ set(value) {
216
+ if (value) {
217
+ this[kDecoderValue] = value;
218
+ this[kState] |= kDecoder;
219
+ } else {
220
+ this[kState] &= ~kDecoder;
221
+ }
222
+ },
223
+ },
224
+
225
+ encoding: {
226
+ __proto__: null,
227
+ enumerable: false,
228
+ get() {
229
+ return (this[kState] & kEncoding) !== 0 ? this[kEncodingValue] : null;
230
+ },
231
+ set(value) {
232
+ if (value) {
233
+ this[kEncodingValue] = value;
234
+ this[kState] |= kEncoding;
235
+ } else {
236
+ this[kState] &= ~kEncoding;
237
+ }
238
+ },
239
+ },
240
+
241
+ flowing: {
242
+ __proto__: null,
243
+ enumerable: false,
244
+ get() {
245
+ return (this[kState] & kHasFlowing) !== 0 ? (this[kState] & kFlowing) !== 0 : null;
246
+ },
247
+ set(value) {
248
+ if (value == null) {
249
+ this[kState] &= ~(kHasFlowing | kFlowing);
250
+ } else if (value) {
251
+ this[kState] |= (kHasFlowing | kFlowing);
252
+ } else {
253
+ this[kState] |= kHasFlowing;
254
+ this[kState] &= ~kFlowing;
255
+ }
256
+ },
257
+ },
258
+ });
259
+
260
+
261
+ function ReadableState(options, stream, isDuplex) {
262
+ // Bit map field to store ReadableState more efficiently with 1 bit per field
263
+ // instead of a V8 slot per field.
264
+ this[kState] = kEmitClose | kAutoDestroy | kConstructed | kSync;
265
+
266
+ // Object stream flag. Used to make read(n) ignore n and to
267
+ // make all the buffer merging and length checks go away.
268
+ if (options?.objectMode)
269
+ this[kState] |= kObjectMode;
270
+
271
+ if (isDuplex && options?.readableObjectMode)
272
+ this[kState] |= kObjectMode;
273
+
274
+ // The point at which it stops calling _read() to fill the buffer
275
+ // Note: 0 is a valid value, means "don't call _read preemptively ever"
276
+ this.highWaterMark = options ?
277
+ getHighWaterMark(this, options, 'readableHighWaterMark', isDuplex) :
278
+ getDefaultHighWaterMark(false);
279
+
280
+ this.buffer = [];
281
+ this.bufferIndex = 0;
282
+ this.length = 0;
283
+ this.pipes = [];
284
+
285
+ // Should close be emitted on destroy. Defaults to true.
286
+ if (options && options.emitClose === false) this[kState] &= ~kEmitClose;
287
+
288
+ // Should .destroy() be called after 'end' (and potentially 'finish').
289
+ if (options && options.autoDestroy === false) this[kState] &= ~kAutoDestroy;
290
+
291
+ // Crypto is kind of old and crusty. Historically, its default string
292
+ // encoding is 'binary' so we have to make this configurable.
293
+ // Everything else in the universe uses 'utf8', though.
294
+ const defaultEncoding = options?.defaultEncoding;
295
+ if (defaultEncoding == null || defaultEncoding === 'utf8' || defaultEncoding === 'utf-8') {
296
+ this[kState] |= kDefaultUTF8Encoding;
297
+ } else if (Buffer.isEncoding(defaultEncoding)) {
298
+ this.defaultEncoding = defaultEncoding;
299
+ } else {
300
+ throw new ERR_UNKNOWN_ENCODING(defaultEncoding);
301
+ }
302
+
303
+ // Ref the piped dest which we need a drain event on it
304
+ // type: null | Writable | Set<Writable>.
305
+ this.awaitDrainWriters = null;
306
+
307
+ if (options?.encoding) {
308
+ this.decoder = new StringDecoder(options.encoding);
309
+ this.encoding = options.encoding;
310
+ }
311
+ }
312
+
313
+ ReadableState.prototype[kOnConstructed] = function onConstructed(stream) {
314
+ if ((this[kState] & kNeedReadable) !== 0) {
315
+ maybeReadMore(stream, this);
316
+ }
317
+ };
318
+
319
+ function Readable(options) {
320
+ if (!(this instanceof Readable))
321
+ return new Readable(options);
322
+
323
+ this._events ??= {
324
+ close: undefined,
325
+ error: undefined,
326
+ data: undefined,
327
+ end: undefined,
328
+ readable: undefined,
329
+ // Skip uncommon events...
330
+ // pause: undefined,
331
+ // resume: undefined,
332
+ // pipe: undefined,
333
+ // unpipe: undefined,
334
+ // [destroyImpl.kConstruct]: undefined,
335
+ // [destroyImpl.kDestroy]: undefined,
336
+ };
337
+
338
+ this._readableState = new ReadableState(options, this, false);
339
+
340
+ if (options) {
341
+ if (typeof options.read === 'function')
342
+ this._read = options.read;
343
+
344
+ if (typeof options.destroy === 'function')
345
+ this._destroy = options.destroy;
346
+
347
+ if (typeof options.construct === 'function')
348
+ this._construct = options.construct;
349
+
350
+ if (options.signal)
351
+ addAbortSignal(options.signal, this);
352
+ }
353
+
354
+ Stream.call(this, options);
355
+
356
+ if (this._construct != null) {
357
+ destroyImpl.construct(this, () => {
358
+ this._readableState[kOnConstructed](this);
359
+ });
360
+ }
361
+ }
362
+
363
+ Readable.prototype.destroy = destroyImpl.destroy;
364
+ Readable.prototype._undestroy = destroyImpl.undestroy;
365
+ Readable.prototype._destroy = function(err, cb) {
366
+ cb(err);
367
+ };
368
+
369
+ Readable.prototype[EE.captureRejectionSymbol] = function(err) {
370
+ this.destroy(err);
371
+ };
372
+
373
+ Readable.prototype[Symbol.asyncDispose] = async function() {
374
+ let error;
375
+ if (!this.destroyed) {
376
+ error = this.readableEnded ? null : new AbortError();
377
+ this.destroy(error);
378
+ }
379
+ await new Promise((resolve, reject) => eos(this, (err) => (err && err !== error ? reject(err) : resolve(null))));
380
+ };
381
+
382
+ // Manually shove something into the read() buffer.
383
+ // This returns true if the highWaterMark has not been hit yet,
384
+ // similar to how Writable.write() returns true if you should
385
+ // write() some more.
386
+ Readable.prototype.push = function(chunk, encoding) {
387
+ debug('push', chunk);
388
+
389
+ const state = this._readableState;
390
+ return (state[kState] & kObjectMode) === 0 ?
391
+ readableAddChunkPushByteMode(this, state, chunk, encoding) :
392
+ readableAddChunkPushObjectMode(this, state, chunk, encoding);
393
+ };
394
+
395
+ // Unshift should *always* be something directly out of read().
396
+ Readable.prototype.unshift = function(chunk, encoding) {
397
+ debug('unshift', chunk);
398
+ const state = this._readableState;
399
+ return (state[kState] & kObjectMode) === 0 ?
400
+ readableAddChunkUnshiftByteMode(this, state, chunk, encoding) :
401
+ readableAddChunkUnshiftObjectMode(this, state, chunk);
402
+ };
403
+
404
+
405
+ function readableAddChunkUnshiftByteMode(stream, state, chunk, encoding) {
406
+ if (chunk === null) {
407
+ state[kState] &= ~kReading;
408
+ onEofChunk(stream, state);
409
+
410
+ return false;
411
+ }
412
+
413
+ if (typeof chunk === 'string') {
414
+ encoding ||= state.defaultEncoding;
415
+ if (state.encoding !== encoding) {
416
+ if (state.encoding) {
417
+ // When unshifting, if state.encoding is set, we have to save
418
+ // the string in the BufferList with the state encoding.
419
+ chunk = Buffer.from(chunk, encoding).toString(state.encoding);
420
+ } else {
421
+ chunk = Buffer.from(chunk, encoding);
422
+ }
423
+ }
424
+ } else if (Stream._isArrayBufferView(chunk)) {
425
+ chunk = Stream._uint8ArrayToBuffer(chunk);
426
+ } else if (chunk !== undefined && !(chunk instanceof Buffer)) {
427
+ errorOrDestroy(stream, new ERR_INVALID_ARG_TYPE(
428
+ 'chunk', ['string', 'Buffer', 'TypedArray', 'DataView'], chunk));
429
+ return false;
430
+ }
431
+
432
+
433
+ if (!(chunk && chunk.length > 0)) {
434
+ return canPushMore(state);
435
+ }
436
+
437
+ return readableAddChunkUnshiftValue(stream, state, chunk);
438
+ }
439
+
440
+ function readableAddChunkUnshiftObjectMode(stream, state, chunk) {
441
+ if (chunk === null) {
442
+ state[kState] &= ~kReading;
443
+ onEofChunk(stream, state);
444
+
445
+ return false;
446
+ }
447
+
448
+ return readableAddChunkUnshiftValue(stream, state, chunk);
449
+ }
450
+
451
+ function readableAddChunkUnshiftValue(stream, state, chunk) {
452
+ if ((state[kState] & kEndEmitted) !== 0)
453
+ errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());
454
+ else if ((state[kState] & (kDestroyed | kErrored)) !== 0)
455
+ return false;
456
+ else
457
+ addChunk(stream, state, chunk, true);
458
+
459
+ return canPushMore(state);
460
+ }
461
+
462
+ function readableAddChunkPushByteMode(stream, state, chunk, encoding) {
463
+ if (chunk === null) {
464
+ state[kState] &= ~kReading;
465
+ onEofChunk(stream, state);
466
+ return false;
467
+ }
468
+
469
+ if (typeof chunk === 'string') {
470
+ encoding ||= state.defaultEncoding;
471
+ if (state.encoding !== encoding) {
472
+ chunk = Buffer.from(chunk, encoding);
473
+ encoding = '';
474
+ }
475
+ } else if (chunk instanceof Buffer) {
476
+ encoding = '';
477
+ } else if (Stream._isArrayBufferView(chunk)) {
478
+ chunk = Stream._uint8ArrayToBuffer(chunk);
479
+ encoding = '';
480
+ } else if (chunk !== undefined) {
481
+ errorOrDestroy(stream, new ERR_INVALID_ARG_TYPE(
482
+ 'chunk', ['string', 'Buffer', 'TypedArray', 'DataView'], chunk));
483
+ return false;
484
+ }
485
+
486
+ if (!chunk || chunk.length <= 0) {
487
+ state[kState] &= ~kReading;
488
+ maybeReadMore(stream, state);
489
+
490
+ return canPushMore(state);
491
+ }
492
+
493
+ if ((state[kState] & kEnded) !== 0) {
494
+ errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
495
+ return false;
496
+ }
497
+
498
+ if ((state[kState] & (kDestroyed | kErrored)) !== 0) {
499
+ return false;
500
+ }
501
+
502
+ state[kState] &= ~kReading;
503
+ if ((state[kState] & kDecoder) !== 0 && !encoding) {
504
+ chunk = state[kDecoderValue].write(chunk);
505
+ if (chunk.length === 0) {
506
+ maybeReadMore(stream, state);
507
+ return canPushMore(state);
508
+ }
509
+ }
510
+
511
+ addChunk(stream, state, chunk, false);
512
+ return canPushMore(state);
513
+ }
514
+
515
+ function readableAddChunkPushObjectMode(stream, state, chunk, encoding) {
516
+ if (chunk === null) {
517
+ state[kState] &= ~kReading;
518
+ onEofChunk(stream, state);
519
+ return false;
520
+ }
521
+
522
+ if ((state[kState] & kEnded) !== 0) {
523
+ errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
524
+ return false;
525
+ }
526
+
527
+ if ((state[kState] & (kDestroyed | kErrored)) !== 0) {
528
+ return false;
529
+ }
530
+
531
+ state[kState] &= ~kReading;
532
+
533
+ if ((state[kState] & kDecoder) !== 0 && !encoding) {
534
+ chunk = state[kDecoderValue].write(chunk);
535
+ }
536
+
537
+ addChunk(stream, state, chunk, false);
538
+ return canPushMore(state);
539
+ }
540
+
541
+ function canPushMore(state) {
542
+ // We can push more data if we are below the highWaterMark.
543
+ // Also, if we have no data yet, we can stand some more bytes.
544
+ // This is to work around cases where hwm=0, such as the repl.
545
+ return (state[kState] & kEnded) === 0 &&
546
+ (state.length < state.highWaterMark || state.length === 0);
547
+ }
548
+
549
+ function addChunk(stream, state, chunk, addToFront) {
550
+ if ((state[kState] & (kFlowing | kSync | kDataListening)) === (kFlowing | kDataListening) && state.length === 0) {
551
+ // Use the guard to avoid creating `Set()` repeatedly
552
+ // when we have multiple pipes.
553
+ if ((state[kState] & kMultiAwaitDrain) !== 0) {
554
+ state.awaitDrainWriters.clear();
555
+ } else {
556
+ state.awaitDrainWriters = null;
557
+ }
558
+
559
+ state[kState] |= kDataEmitted;
560
+ stream.emit('data', chunk);
561
+ } else {
562
+ // Update the buffer info.
563
+ state.length += (state[kState] & kObjectMode) !== 0 ? 1 : chunk.length;
564
+ if (addToFront) {
565
+ if (state.bufferIndex > 0) {
566
+ state.buffer[--state.bufferIndex] = chunk;
567
+ } else {
568
+ state.buffer.unshift(chunk); // Slow path
569
+ }
570
+ } else {
571
+ state.buffer.push(chunk);
572
+ }
573
+
574
+ if ((state[kState] & kNeedReadable) !== 0)
575
+ emitReadable(stream);
576
+ }
577
+ maybeReadMore(stream, state);
578
+ }
579
+
580
+ Readable.prototype.isPaused = function() {
581
+ const state = this._readableState;
582
+ return (state[kState] & kPaused) !== 0 || (state[kState] & (kHasFlowing | kFlowing)) === kHasFlowing;
583
+ };
584
+
585
+ // Backwards compatibility.
586
+ Readable.prototype.setEncoding = function(enc) {
587
+ const state = this._readableState;
588
+
589
+ const decoder = new StringDecoder(enc);
590
+ state.decoder = decoder;
591
+ // If setEncoding(null), decoder.encoding equals utf8.
592
+ state.encoding = state.decoder.encoding;
593
+
594
+ // Iterate over current buffer to convert already stored Buffers:
595
+ let content = '';
596
+ for (const data of state.buffer.slice(state.bufferIndex)) {
597
+ content += decoder.write(data);
598
+ }
599
+ if ((state[kState] & kEnded) !== 0)
600
+ content += decoder.end();
601
+ state.buffer.length = 0;
602
+ state.bufferIndex = 0;
603
+
604
+ if (content !== '')
605
+ state.buffer.push(content);
606
+ state.length = content.length;
607
+ return this;
608
+ };
609
+
610
+ // Don't raise the hwm > 1GB.
611
+ const MAX_HWM = 0x40000000;
612
+ function computeNewHighWaterMark(n) {
613
+ if (n > MAX_HWM) {
614
+ throw new ERR_OUT_OF_RANGE('size', '<= 1GiB', n);
615
+ } else {
616
+ // Get the next highest power of 2 to prevent increasing hwm excessively in
617
+ // tiny amounts.
618
+ n--;
619
+ n |= n >>> 1;
620
+ n |= n >>> 2;
621
+ n |= n >>> 4;
622
+ n |= n >>> 8;
623
+ n |= n >>> 16;
624
+ n++;
625
+ }
626
+ return n;
627
+ }
628
+
629
+ // This function is designed to be inlinable, so please take care when making
630
+ // changes to the function body.
631
+ function howMuchToRead(n, state) {
632
+ if (n <= 0 || (state.length === 0 && (state[kState] & kEnded) !== 0))
633
+ return 0;
634
+ if ((state[kState] & kObjectMode) !== 0)
635
+ return 1;
636
+ if (Number.isNaN(n)) {
637
+ // Only flow one buffer at a time.
638
+ if ((state[kState] & kFlowing) !== 0 && state.length)
639
+ return state.buffer[state.bufferIndex].length;
640
+ return state.length;
641
+ }
642
+ if (n <= state.length)
643
+ return n;
644
+ return (state[kState] & kEnded) !== 0 ? state.length : 0;
645
+ }
646
+
647
+ // You can override either this method, or the async _read(n) below.
648
+ Readable.prototype.read = function(n) {
649
+ debug('read', n);
650
+ // Same as parseInt(undefined, 10), however V8 7.3 performance regressed
651
+ // in this scenario, so we are doing it manually.
652
+ if (n === undefined) {
653
+ n = NaN;
654
+ } else if (!Number.isInteger(n)) {
655
+ n = Number.parseInt(n, 10);
656
+ }
657
+ const state = this._readableState;
658
+ const nOrig = n;
659
+
660
+ // If we're asking for more than the current hwm, then raise the hwm.
661
+ if (n > state.highWaterMark)
662
+ state.highWaterMark = computeNewHighWaterMark(n);
663
+
664
+ if (n !== 0)
665
+ state[kState] &= ~kEmittedReadable;
666
+
667
+ // If we're doing read(0) to trigger a readable event, but we
668
+ // already have a bunch of data in the buffer, then just trigger
669
+ // the 'readable' event and move on. `state.length` cannot change
670
+ // within this block, so it is loaded once instead of three times.
671
+ const stateLength = state.length;
672
+ if (n === 0 &&
673
+ (state[kState] & kNeedReadable) !== 0 &&
674
+ ((state.highWaterMark !== 0 ?
675
+ stateLength >= state.highWaterMark :
676
+ stateLength > 0) ||
677
+ (state[kState] & kEnded) !== 0)) {
678
+ debug('read: emitReadable');
679
+ if (stateLength === 0 && (state[kState] & kEnded) !== 0)
680
+ endReadable(this);
681
+ else
682
+ emitReadable(this);
683
+ return null;
684
+ }
685
+
686
+ n = howMuchToRead(n, state);
687
+
688
+ // If we've ended, and we're now clear, then finish it up.
689
+ if (n === 0 && (state[kState] & kEnded) !== 0) {
690
+ if (state.length === 0)
691
+ endReadable(this);
692
+ return null;
693
+ }
694
+
695
+ // All the actual chunk generation logic needs to be
696
+ // *below* the call to _read. The reason is that in certain
697
+ // synthetic stream cases, such as passthrough streams, _read
698
+ // may be a completely synchronous operation which may change
699
+ // the state of the read buffer, providing enough data when
700
+ // before there was *not* enough.
701
+ //
702
+ // So, the steps are:
703
+ // 1. Figure out what the state of things will be after we do
704
+ // a read from the buffer.
705
+ //
706
+ // 2. If that resulting state will trigger a _read, then call _read.
707
+ // Note that this may be asynchronous, or synchronous. Yes, it is
708
+ // deeply ugly to write APIs this way, but that still doesn't mean
709
+ // that the Readable class should behave improperly, as streams are
710
+ // designed to be sync/async agnostic.
711
+ // Take note if the _read call is sync or async (ie, if the read call
712
+ // has returned yet), so that we know whether or not it's safe to emit
713
+ // 'readable' etc.
714
+ //
715
+ // 3. Actually pull the requested chunks out of the buffer and return.
716
+
717
+ // if we need a readable event, then we need to do some reading.
718
+ let doRead = (state[kState] & kNeedReadable) !== 0;
719
+ debug('need readable', doRead);
720
+
721
+ // If we currently have less than the highWaterMark, then also read some.
722
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
723
+ doRead = true;
724
+ debug('length less than watermark', doRead);
725
+ }
726
+
727
+ // However, if we've ended, then there's no point, if we're already
728
+ // reading, then it's unnecessary, if we're constructing we have to wait,
729
+ // and if we're destroyed or errored, then it's not allowed,
730
+ if ((state[kState] & (kReading | kEnded | kDestroyed | kErrored | kConstructed)) !== kConstructed) {
731
+ doRead = false;
732
+ debug('reading, ended or constructing', doRead);
733
+ } else if (doRead) {
734
+ debug('do read');
735
+ state[kState] |= kReading | kSync;
736
+ // If the length is currently zero, then we *need* a readable event.
737
+ if (state.length === 0)
738
+ state[kState] |= kNeedReadable;
739
+
740
+ // Call internal read method
741
+ try {
742
+ this._read(state.highWaterMark);
743
+ } catch (err) {
744
+ errorOrDestroy(this, err);
745
+ }
746
+ state[kState] &= ~kSync;
747
+
748
+ // If _read pushed data synchronously, then `reading` will be false,
749
+ // and we need to re-evaluate how much data we can return to the user.
750
+ if ((state[kState] & kReading) === 0)
751
+ n = howMuchToRead(nOrig, state);
752
+ }
753
+
754
+ let ret;
755
+ if (n > 0)
756
+ ret = fromList(n, state);
757
+ else
758
+ ret = null;
759
+
760
+ if (ret === null) {
761
+ state[kState] |= state.length <= state.highWaterMark ? kNeedReadable : 0;
762
+ n = 0;
763
+ } else {
764
+ state.length -= n;
765
+ if ((state[kState] & kMultiAwaitDrain) !== 0) {
766
+ state.awaitDrainWriters.clear();
767
+ } else {
768
+ state.awaitDrainWriters = null;
769
+ }
770
+ }
771
+
772
+ if (state.length === 0) {
773
+ // If we have nothing in the buffer, then we want to know
774
+ // as soon as we *do* get something into the buffer.
775
+ if ((state[kState] & kEnded) === 0)
776
+ state[kState] |= kNeedReadable;
777
+
778
+ // If we tried to read() past the EOF, then emit end on the next tick.
779
+ if (nOrig !== n && (state[kState] & kEnded) !== 0)
780
+ endReadable(this);
781
+ }
782
+
783
+ if (ret !== null && (state[kState] & (kErrorEmitted | kCloseEmitted)) === 0) {
784
+ state[kState] |= kDataEmitted;
785
+ this.emit('data', ret);
786
+ }
787
+
788
+ return ret;
789
+ };
790
+
791
+ function onEofChunk(stream, state) {
792
+ debug('onEofChunk');
793
+ if ((state[kState] & kEnded) !== 0) return;
794
+ const decoder = (state[kState] & kDecoder) !== 0 ? state[kDecoderValue] : null;
795
+ if (decoder) {
796
+ const chunk = decoder.end();
797
+ if (chunk?.length) {
798
+ state.buffer.push(chunk);
799
+ state.length += (state[kState] & kObjectMode) !== 0 ? 1 : chunk.length;
800
+ }
801
+ }
802
+ state[kState] |= kEnded;
803
+
804
+ if ((state[kState] & kSync) !== 0) {
805
+ // If we are sync, wait until next tick to emit the data.
806
+ // Otherwise we risk emitting data in the flow()
807
+ // the readable code triggers during a read() call.
808
+ emitReadable(stream);
809
+ } else {
810
+ // Emit 'readable' now to make sure it gets picked up.
811
+ state[kState] &= ~kNeedReadable;
812
+ state[kState] |= kEmittedReadable;
813
+ // We have to emit readable now that we are EOF. Modules
814
+ // in the ecosystem (e.g. dicer) rely on this event being sync.
815
+ emitReadable_(stream);
816
+ }
817
+ }
818
+
819
+ // Don't emit readable right away in sync mode, because this can trigger
820
+ // another read() call => stack overflow. This way, it might trigger
821
+ // a nextTick recursion warning, but that's not so bad.
822
+ function emitReadable(stream) {
823
+ const state = stream._readableState;
824
+ debug('emitReadable');
825
+ state[kState] &= ~kNeedReadable;
826
+ if ((state[kState] & kEmittedReadable) === 0) {
827
+ debug('emitReadable', (state[kState] & kFlowing) !== 0);
828
+ state[kState] |= kEmittedReadable;
829
+ process.nextTick(emitReadable_, stream);
830
+ }
831
+ }
832
+
833
+ function emitReadable_(stream) {
834
+ const state = stream._readableState;
835
+ debug('emitReadable_');
836
+ if ((state[kState] & (kDestroyed | kErrored)) === 0 && (state.length || (state[kState] & kEnded) !== 0)) {
837
+ stream.emit('readable');
838
+ state[kState] &= ~kEmittedReadable;
839
+ }
840
+
841
+ // The stream needs another readable event if:
842
+ // 1. It is not flowing, as the flow mechanism will take
843
+ // care of it.
844
+ // 2. It is not ended.
845
+ // 3. It is below the highWaterMark, so we can schedule
846
+ // another readable later.
847
+ state[kState] |=
848
+ (state[kState] & (kFlowing | kEnded)) === 0 &&
849
+ state.length <= state.highWaterMark ? kNeedReadable : 0;
850
+ flow(stream);
851
+ }
852
+
853
+
854
+ // At this point, the user has presumably seen the 'readable' event,
855
+ // and called read() to consume some data. that may have triggered
856
+ // in turn another _read(n) call, in which case reading = true if
857
+ // it's in progress.
858
+ // However, if we're not ended, or reading, and the length < hwm,
859
+ // then go ahead and try to read some more preemptively.
860
+ function maybeReadMore(stream, state) {
861
+ if ((state[kState] & (kReadingMore | kReading | kConstructed)) === kConstructed) {
862
+ state[kState] |= kReadingMore;
863
+ process.nextTick(maybeReadMore_, stream, state);
864
+ }
865
+ }
866
+
867
+ function maybeReadMore_(stream, state) {
868
+ // Attempt to read more data if we should.
869
+ //
870
+ // The conditions for reading more data are (one of):
871
+ // - Not enough data buffered (state.length < state.highWaterMark). The loop
872
+ // is responsible for filling the buffer with enough data if such data
873
+ // is available. If highWaterMark is 0 and we are not in the flowing mode
874
+ // we should _not_ attempt to buffer any extra data. We'll get more data
875
+ // when the stream consumer calls read() instead.
876
+ // - No data in the buffer, and the stream is in flowing mode. In this mode
877
+ // the loop below is responsible for ensuring read() is called. Failing to
878
+ // call read here would abort the flow and there's no other mechanism for
879
+ // continuing the flow if the stream consumer has just subscribed to the
880
+ // 'data' event.
881
+ //
882
+ // In addition to the above conditions to keep reading data, the following
883
+ // conditions prevent the data from being read:
884
+ // - The stream has ended (state.ended).
885
+ // - There is already a pending 'read' operation (state.reading). This is a
886
+ // case where the stream has called the implementation defined _read()
887
+ // method, but they are processing the call asynchronously and have _not_
888
+ // called push() with new data. In this case we skip performing more
889
+ // read()s. The execution ends in this method again after the _read() ends
890
+ // up calling push() with more data.
891
+ while ((state[kState] & (kReading | kEnded)) === 0 &&
892
+ (state.length < state.highWaterMark ||
893
+ ((state[kState] & kFlowing) !== 0 && state.length === 0))) {
894
+ const len = state.length;
895
+ debug('maybeReadMore read 0');
896
+ stream.read(0);
897
+ if (len === state.length)
898
+ // Didn't get any data, stop spinning.
899
+ break;
900
+ }
901
+ state[kState] &= ~kReadingMore;
902
+ }
903
+
904
+ // Abstract method. to be overridden in specific implementation classes.
905
+ // call cb(er, data) where data is <= n in length.
906
+ // for virtual (non-string, non-buffer) streams, "length" is somewhat
907
+ // arbitrary, and perhaps not very meaningful.
908
+ Readable.prototype._read = function(n) {
909
+ throw new ERR_METHOD_NOT_IMPLEMENTED('_read()');
910
+ };
911
+
912
+ Readable.prototype.pipe = function(dest, pipeOpts) {
913
+ const src = this;
914
+ const state = this._readableState;
915
+
916
+ if (state.pipes.length === 1) {
917
+ if ((state[kState] & kMultiAwaitDrain) === 0) {
918
+ state[kState] |= kMultiAwaitDrain;
919
+ state.awaitDrainWriters = new Set(
920
+ state.awaitDrainWriters ? [state.awaitDrainWriters] : [],
921
+ );
922
+ }
923
+ }
924
+
925
+ state.pipes.push(dest);
926
+ debug('pipe count=%d opts=%j', state.pipes.length, pipeOpts);
927
+
928
+ const doEnd = (!pipeOpts || pipeOpts.end !== false) &&
929
+ dest !== process.stdout &&
930
+ dest !== process.stderr;
931
+
932
+ const endFn = doEnd ? onend : unpipe;
933
+ if ((state[kState] & kEndEmitted) !== 0)
934
+ process.nextTick(endFn);
935
+ else
936
+ src.once('end', endFn);
937
+
938
+ dest.on('unpipe', onunpipe);
939
+ function onunpipe(readable, unpipeInfo) {
940
+ debug('onunpipe');
941
+ if (readable === src) {
942
+ if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
943
+ unpipeInfo.hasUnpiped = true;
944
+ cleanup();
945
+ }
946
+ }
947
+ }
948
+
949
+ function onend() {
950
+ debug('onend');
951
+ dest.end();
952
+ }
953
+
954
+ let ondrain;
955
+
956
+ let cleanedUp = false;
957
+ function cleanup() {
958
+ debug('cleanup');
959
+ // Cleanup event handlers once the pipe is broken.
960
+ dest.removeListener('close', onclose);
961
+ dest.removeListener('finish', onfinish);
962
+ if (ondrain) {
963
+ dest.removeListener('drain', ondrain);
964
+ }
965
+ dest.removeListener('error', onerror);
966
+ dest.removeListener('unpipe', onunpipe);
967
+ src.removeListener('end', onend);
968
+ src.removeListener('end', unpipe);
969
+ src.removeListener('data', ondata);
970
+
971
+ cleanedUp = true;
972
+
973
+ // If the reader is waiting for a drain event from this
974
+ // specific writer, then it would cause it to never start
975
+ // flowing again.
976
+ // So, if this is awaiting a drain, then we just call it now.
977
+ // If we don't know, then assume that we are waiting for one.
978
+ if (ondrain && state.awaitDrainWriters &&
979
+ (!dest._writableState || dest._writableState.needDrain))
980
+ ondrain();
981
+ }
982
+
983
+ function pause() {
984
+ // If the user unpiped during `dest.write()`, it is possible
985
+ // to get stuck in a permanently paused state if that write
986
+ // also returned false.
987
+ // => Check whether `dest` is still a piping destination.
988
+ if (!cleanedUp) {
989
+ if (state.pipes.length === 1 && state.pipes[0] === dest) {
990
+ debug('false write response, pause', 0);
991
+ state.awaitDrainWriters = dest;
992
+ state[kState] &= ~kMultiAwaitDrain;
993
+ } else if (state.pipes.length > 1 && state.pipes.includes(dest)) {
994
+ debug('false write response, pause', state.awaitDrainWriters.size);
995
+ state.awaitDrainWriters.add(dest);
996
+ }
997
+ src.pause();
998
+ }
999
+ if (!ondrain) {
1000
+ // When the dest drains, it reduces the awaitDrain counter
1001
+ // on the source. This would be more elegant with a .once()
1002
+ // handler in flow(), but adding and removing repeatedly is
1003
+ // too slow.
1004
+ ondrain = pipeOnDrain(src, dest);
1005
+ dest.on('drain', ondrain);
1006
+ }
1007
+ }
1008
+
1009
+ src.on('data', ondata);
1010
+ function ondata(chunk) {
1011
+ debug('ondata');
1012
+ try {
1013
+ const ret = dest.write(chunk);
1014
+ debug('dest.write', ret);
1015
+
1016
+ if (ret === false) {
1017
+ pause();
1018
+ }
1019
+ } catch (error) {
1020
+ dest.destroy(error);
1021
+ }
1022
+ }
1023
+
1024
+ // If the dest has an error, then stop piping into it.
1025
+ // However, don't suppress the throwing behavior for this.
1026
+ function onerror(er) {
1027
+ debug('onerror', er);
1028
+ unpipe();
1029
+ dest.removeListener('error', onerror);
1030
+ if (dest.listenerCount('error') === 0) {
1031
+ const s = dest._writableState || dest._readableState;
1032
+ if (s && !s.errorEmitted) {
1033
+ // User incorrectly emitted 'error' directly on the stream.
1034
+ errorOrDestroy(dest, er);
1035
+ } else {
1036
+ dest.emit('error', er);
1037
+ }
1038
+ }
1039
+ }
1040
+
1041
+ // Make sure our error handler is attached before userland ones.
1042
+ prependListener(dest, 'error', onerror);
1043
+
1044
+ // Both close and finish should trigger unpipe, but only once.
1045
+ function onclose() {
1046
+ dest.removeListener('finish', onfinish);
1047
+ unpipe();
1048
+ }
1049
+ dest.once('close', onclose);
1050
+ function onfinish() {
1051
+ debug('onfinish');
1052
+ dest.removeListener('close', onclose);
1053
+ unpipe();
1054
+ }
1055
+ dest.once('finish', onfinish);
1056
+
1057
+ function unpipe() {
1058
+ debug('unpipe');
1059
+ src.unpipe(dest);
1060
+ }
1061
+
1062
+ // Tell the dest that it's being piped to.
1063
+ dest.emit('pipe', src);
1064
+
1065
+ // Start the flow if it hasn't been started already.
1066
+
1067
+ if (dest.writableNeedDrain === true) {
1068
+ pause();
1069
+ } else if ((state[kState] & kFlowing) === 0) {
1070
+ debug('pipe resume');
1071
+ src.resume();
1072
+ }
1073
+
1074
+ return dest;
1075
+ };
1076
+
1077
+ function pipeOnDrain(src, dest) {
1078
+ return function pipeOnDrainFunctionResult() {
1079
+ const state = src._readableState;
1080
+
1081
+ // `ondrain` will call directly,
1082
+ // `this` maybe not a reference to dest,
1083
+ // so we use the real dest here.
1084
+ if (state.awaitDrainWriters === dest) {
1085
+ debug('pipeOnDrain', 1);
1086
+ state.awaitDrainWriters = null;
1087
+ } else if ((state[kState] & kMultiAwaitDrain) !== 0) {
1088
+ debug('pipeOnDrain', state.awaitDrainWriters.size);
1089
+ state.awaitDrainWriters.delete(dest);
1090
+ }
1091
+
1092
+ if ((!state.awaitDrainWriters || state.awaitDrainWriters.size === 0) &&
1093
+ (state[kState] & kDataListening) !== 0) {
1094
+ src.resume();
1095
+ }
1096
+ };
1097
+ }
1098
+
1099
+
1100
+ Readable.prototype.unpipe = function(dest) {
1101
+ const state = this._readableState;
1102
+ const unpipeInfo = { hasUnpiped: false };
1103
+
1104
+ // If we're not piping anywhere, then do nothing.
1105
+ if (state.pipes.length === 0)
1106
+ return this;
1107
+
1108
+ if (!dest) {
1109
+ // remove all.
1110
+ const dests = state.pipes;
1111
+ state.pipes = [];
1112
+ this.pause();
1113
+
1114
+ for (let i = 0; i < dests.length; i++)
1115
+ dests[i].emit('unpipe', this, { hasUnpiped: false });
1116
+ return this;
1117
+ }
1118
+
1119
+ // Try to find the right one.
1120
+ const index = state.pipes.indexOf(dest);
1121
+ if (index === -1)
1122
+ return this;
1123
+
1124
+ state.pipes.splice(index, 1);
1125
+ if (state.pipes.length === 0)
1126
+ this.pause();
1127
+
1128
+ dest.emit('unpipe', this, unpipeInfo);
1129
+
1130
+ return this;
1131
+ };
1132
+
1133
+ // Set up data events if they are asked for
1134
+ // Ensure readable listeners eventually get something.
1135
+ Readable.prototype.on = function(ev, fn) {
1136
+ const res = Stream.prototype.on.call(this, ev, fn);
1137
+ const state = this._readableState;
1138
+
1139
+ if (ev === 'data') {
1140
+ state[kState] |= kDataListening;
1141
+
1142
+ // Update readableListening so that resume() may be a no-op
1143
+ // a few lines down. This is needed to support once('readable').
1144
+ state[kState] |= this.listenerCount('readable') > 0 ? kReadableListening : 0;
1145
+
1146
+ // Try start flowing on next tick if stream isn't explicitly paused.
1147
+ if ((state[kState] & (kHasFlowing | kFlowing)) !== kHasFlowing) {
1148
+ this.resume();
1149
+ }
1150
+ } else if (ev === 'readable') {
1151
+ if ((state[kState] & (kEndEmitted | kReadableListening)) === 0) {
1152
+ state[kState] |= kReadableListening | kNeedReadable | kHasFlowing;
1153
+ state[kState] &= ~(kFlowing | kEmittedReadable);
1154
+ debug('on readable');
1155
+ if (state.length) {
1156
+ emitReadable(this);
1157
+ } else if ((state[kState] & kReading) === 0) {
1158
+ process.nextTick(nReadingNextTick, this);
1159
+ }
1160
+ }
1161
+ }
1162
+
1163
+ return res;
1164
+ };
1165
+ Readable.prototype.addListener = Readable.prototype.on;
1166
+
1167
+ Readable.prototype.removeListener = function(ev, fn) {
1168
+ const state = this._readableState;
1169
+
1170
+ const res = Stream.prototype.removeListener.call(this,
1171
+ ev, fn);
1172
+
1173
+ if (ev === 'readable') {
1174
+ // We need to check if there is someone still listening to
1175
+ // readable and reset the state. However this needs to happen
1176
+ // after readable has been emitted but before I/O (nextTick) to
1177
+ // support once('readable', fn) cycles. This means that calling
1178
+ // resume within the same tick will have no
1179
+ // effect.
1180
+ process.nextTick(updateReadableListening, this);
1181
+ } else if (ev === 'data' && this.listenerCount('data') === 0) {
1182
+ state[kState] &= ~kDataListening;
1183
+ }
1184
+
1185
+ return res;
1186
+ };
1187
+ Readable.prototype.off = Readable.prototype.removeListener;
1188
+
1189
+ Readable.prototype.removeAllListeners = function(ev) {
1190
+ const res = Stream.prototype.removeAllListeners.apply(this,
1191
+ arguments);
1192
+
1193
+ if (ev === 'readable' || ev === undefined) {
1194
+ // We need to check if there is someone still listening to
1195
+ // readable and reset the state. However this needs to happen
1196
+ // after readable has been emitted but before I/O (nextTick) to
1197
+ // support once('readable', fn) cycles. This means that calling
1198
+ // resume within the same tick will have no
1199
+ // effect.
1200
+ process.nextTick(updateReadableListening, this);
1201
+ }
1202
+
1203
+ return res;
1204
+ };
1205
+
1206
+ function updateReadableListening(self) {
1207
+ const state = self._readableState;
1208
+
1209
+ if (self.listenerCount('readable') > 0) {
1210
+ state[kState] |= kReadableListening;
1211
+ } else {
1212
+ state[kState] &= ~kReadableListening;
1213
+ }
1214
+
1215
+ if ((state[kState] & (kHasPaused | kPaused | kResumeScheduled)) === (kHasPaused | kResumeScheduled)) {
1216
+ // Flowing needs to be set to true now, otherwise
1217
+ // the upcoming resume will not flow.
1218
+ state[kState] |= kHasFlowing | kFlowing;
1219
+
1220
+ // Crude way to check if we should resume.
1221
+ } else if ((state[kState] & kDataListening) !== 0) {
1222
+ self.resume();
1223
+ } else if ((state[kState] & kReadableListening) === 0) {
1224
+ state[kState] &= ~(kHasFlowing | kFlowing);
1225
+ }
1226
+ }
1227
+
1228
+ function nReadingNextTick(self) {
1229
+ debug('readable nexttick read 0');
1230
+ self.read(0);
1231
+ }
1232
+
1233
+ // pause() and resume() are remnants of the legacy readable stream API
1234
+ // If the user uses them, then switch into old mode.
1235
+ Readable.prototype.resume = function() {
1236
+ const state = this._readableState;
1237
+ if ((state[kState] & kFlowing) === 0) {
1238
+ debug('resume');
1239
+ // We flow only if there is no one listening
1240
+ // for readable, but we still have to call
1241
+ // resume().
1242
+ state[kState] |= kHasFlowing;
1243
+ if ((state[kState] & kReadableListening) === 0) {
1244
+ state[kState] |= kFlowing;
1245
+ } else {
1246
+ state[kState] &= ~kFlowing;
1247
+ }
1248
+ resume(this, state);
1249
+ }
1250
+ state[kState] |= kHasPaused;
1251
+ state[kState] &= ~kPaused;
1252
+ return this;
1253
+ };
1254
+
1255
+ function resume(stream, state) {
1256
+ if ((state[kState] & kResumeScheduled) === 0) {
1257
+ state[kState] |= kResumeScheduled;
1258
+ process.nextTick(resume_, stream, state);
1259
+ }
1260
+ }
1261
+
1262
+ function resume_(stream, state) {
1263
+ debug('resume', (state[kState] & kReading) !== 0);
1264
+ if ((state[kState] & kReading) === 0) {
1265
+ stream.read(0);
1266
+ }
1267
+
1268
+ state[kState] &= ~kResumeScheduled;
1269
+ stream.emit('resume');
1270
+ flow(stream);
1271
+ if ((state[kState] & (kFlowing | kReading)) === kFlowing)
1272
+ stream.read(0);
1273
+ }
1274
+
1275
+ Readable.prototype.pause = function() {
1276
+ const state = this._readableState;
1277
+ debug('call pause');
1278
+ if ((state[kState] & (kHasFlowing | kFlowing)) !== kHasFlowing) {
1279
+ debug('pause');
1280
+ state[kState] |= kHasFlowing;
1281
+ state[kState] &= ~kFlowing;
1282
+ this.emit('pause');
1283
+ }
1284
+ state[kState] |= kHasPaused | kPaused;
1285
+ return this;
1286
+ };
1287
+
1288
+ function flow(stream) {
1289
+ const state = stream._readableState;
1290
+ debug('flow');
1291
+ while ((state[kState] & kFlowing) !== 0 && stream.read() !== null);
1292
+ }
1293
+
1294
+ // Wrap an old-style stream as the async data source.
1295
+ // This is *not* part of the readable stream interface.
1296
+ // It is an ugly unfortunate mess of history.
1297
+ Readable.prototype.wrap = function(stream) {
1298
+ let paused = false;
1299
+
1300
+ // TODO (ronag): Should this.destroy(err) emit
1301
+ // 'error' on the wrapped stream? Would require
1302
+ // a static factory method, e.g. Readable.wrap(stream).
1303
+
1304
+ stream.on('data', (chunk) => {
1305
+ if (!this.push(chunk) && stream.pause) {
1306
+ paused = true;
1307
+ stream.pause();
1308
+ }
1309
+ });
1310
+
1311
+ stream.on('end', () => {
1312
+ this.push(null);
1313
+ });
1314
+
1315
+ stream.on('error', (err) => {
1316
+ errorOrDestroy(this, err);
1317
+ });
1318
+
1319
+ stream.on('close', () => {
1320
+ this.destroy();
1321
+ });
1322
+
1323
+ stream.on('destroy', () => {
1324
+ this.destroy();
1325
+ });
1326
+
1327
+ this._read = () => {
1328
+ if (paused && stream.resume) {
1329
+ paused = false;
1330
+ stream.resume();
1331
+ }
1332
+ };
1333
+
1334
+ // Proxy all the other methods. Important when wrapping filters and duplexes.
1335
+ const streamKeys = Object.keys(stream);
1336
+ for (let j = 0; j < streamKeys.length; j++) {
1337
+ const i = streamKeys[j];
1338
+ if (this[i] === undefined && typeof stream[i] === 'function') {
1339
+ this[i] = stream[i].bind(stream);
1340
+ }
1341
+ }
1342
+
1343
+ return this;
1344
+ };
1345
+
1346
+ Readable.prototype[Symbol.asyncIterator] = function() {
1347
+ return streamToAsyncIterator(this);
1348
+ };
1349
+
1350
+ Readable.prototype.iterator = function(options) {
1351
+ if (options !== undefined) {
1352
+ validateObject(options, 'options');
1353
+ }
1354
+ return streamToAsyncIterator(this, options);
1355
+ };
1356
+
1357
+ function streamToAsyncIterator(stream, options) {
1358
+ if (typeof stream.read !== 'function') {
1359
+ stream = Readable.wrap(stream, { objectMode: true });
1360
+ }
1361
+
1362
+ const iter = createAsyncIterator(stream, options);
1363
+ iter.stream = stream;
1364
+ return iter;
1365
+ }
1366
+
1367
+ async function* createAsyncIterator(stream, options) {
1368
+ let callback = nop;
1369
+
1370
+ function next(resolve) {
1371
+ if (this === stream) {
1372
+ callback();
1373
+ callback = nop;
1374
+ } else {
1375
+ callback = resolve;
1376
+ }
1377
+ }
1378
+
1379
+ stream.on('readable', next);
1380
+
1381
+ let error;
1382
+ const cleanup = eos(stream, { writable: false }, (err) => {
1383
+ error = err ? aggregateTwoErrors(error, err) : null;
1384
+ callback();
1385
+ callback = nop;
1386
+ });
1387
+
1388
+ try {
1389
+ while (true) {
1390
+ const chunk = stream.destroyed ? null : stream.read();
1391
+ if (chunk !== null) {
1392
+ yield chunk;
1393
+ } else if (error) {
1394
+ throw error;
1395
+ } else if (error === null) {
1396
+ return;
1397
+ } else {
1398
+ await new Promise(next);
1399
+ }
1400
+ }
1401
+ } catch (err) {
1402
+ error = aggregateTwoErrors(error, err);
1403
+ throw error;
1404
+ } finally {
1405
+ const preserveHalfOpenDuplex =
1406
+ error === null &&
1407
+ stream.allowHalfOpen === true &&
1408
+ stream.writable === true &&
1409
+ stream.writableEnded !== true;
1410
+
1411
+ if (
1412
+ (error || options?.destroyOnReturn !== false) &&
1413
+ (error === undefined || stream._readableState.autoDestroy) &&
1414
+ !preserveHalfOpenDuplex
1415
+ ) {
1416
+ destroyImpl.destroyer(stream, null);
1417
+ } else {
1418
+ stream.off('readable', next);
1419
+ cleanup();
1420
+ }
1421
+ }
1422
+ }
1423
+
1424
+ Readable.prototype.compose = function compose(stream, options) {
1425
+ if (options != null) {
1426
+ validateObject(options, 'options');
1427
+ }
1428
+ if (options?.signal != null) {
1429
+ validateAbortSignal(options.signal, 'options.signal');
1430
+ }
1431
+
1432
+ const composedStream = feature('compose')(this, stream);
1433
+
1434
+ if (options?.signal) {
1435
+ // Not validating as we already validated before
1436
+ addAbortSignalNoValidate(
1437
+ options.signal,
1438
+ composedStream,
1439
+ );
1440
+ }
1441
+
1442
+ return composedStream;
1443
+ };
1444
+
1445
+ // Making it explicit these properties are not enumerable
1446
+ // because otherwise some prototype manipulation in
1447
+ // userland will fail.
1448
+ Object.defineProperties(Readable.prototype, {
1449
+ readable: {
1450
+ __proto__: null,
1451
+ get() {
1452
+ const r = this._readableState;
1453
+ // r.readable === false means that this is part of a Duplex stream
1454
+ // where the readable side was disabled upon construction.
1455
+ // Compat. The user might manually disable readable side through
1456
+ // deprecated setter.
1457
+ return !!r && r.readable !== false && !r.destroyed && !r.errorEmitted &&
1458
+ !r.endEmitted;
1459
+ },
1460
+ set(val) {
1461
+ // Backwards compat.
1462
+ if (this._readableState) {
1463
+ this._readableState.readable = !!val;
1464
+ }
1465
+ },
1466
+ },
1467
+
1468
+ readableDidRead: {
1469
+ __proto__: null,
1470
+ enumerable: false,
1471
+ get: function() {
1472
+ return this._readableState.dataEmitted;
1473
+ },
1474
+ },
1475
+
1476
+ readableAborted: {
1477
+ __proto__: null,
1478
+ enumerable: false,
1479
+ get: function() {
1480
+ return !!(
1481
+ this._readableState.readable !== false &&
1482
+ (this._readableState.destroyed || this._readableState.errored) &&
1483
+ !this._readableState.endEmitted
1484
+ );
1485
+ },
1486
+ },
1487
+
1488
+ readableHighWaterMark: {
1489
+ __proto__: null,
1490
+ enumerable: false,
1491
+ get: function() {
1492
+ return this._readableState.highWaterMark;
1493
+ },
1494
+ },
1495
+
1496
+ readableBuffer: {
1497
+ __proto__: null,
1498
+ enumerable: false,
1499
+ get: function() {
1500
+ return this._readableState?.buffer;
1501
+ },
1502
+ },
1503
+
1504
+ readableFlowing: {
1505
+ __proto__: null,
1506
+ enumerable: false,
1507
+ get: function() {
1508
+ return this._readableState.flowing;
1509
+ },
1510
+ set: function(state) {
1511
+ if (this._readableState) {
1512
+ this._readableState.flowing = state;
1513
+ }
1514
+ },
1515
+ },
1516
+
1517
+ readableLength: {
1518
+ __proto__: null,
1519
+ enumerable: false,
1520
+ get() {
1521
+ return this._readableState.length;
1522
+ },
1523
+ },
1524
+
1525
+ readableObjectMode: {
1526
+ __proto__: null,
1527
+ enumerable: false,
1528
+ get() {
1529
+ return this._readableState ? this._readableState.objectMode : false;
1530
+ },
1531
+ },
1532
+
1533
+ readableEncoding: {
1534
+ __proto__: null,
1535
+ enumerable: false,
1536
+ get() {
1537
+ return this._readableState ? this._readableState.encoding : null;
1538
+ },
1539
+ },
1540
+
1541
+ errored: {
1542
+ __proto__: null,
1543
+ enumerable: false,
1544
+ get() {
1545
+ return this._readableState ? this._readableState.errored : null;
1546
+ },
1547
+ },
1548
+
1549
+ closed: {
1550
+ __proto__: null,
1551
+ get() {
1552
+ return this._readableState ? this._readableState.closed : false;
1553
+ },
1554
+ },
1555
+
1556
+ destroyed: {
1557
+ __proto__: null,
1558
+ enumerable: false,
1559
+ get() {
1560
+ return this._readableState ? this._readableState.destroyed : false;
1561
+ },
1562
+ set(value) {
1563
+ // We ignore the value if the stream
1564
+ // has not been initialized yet.
1565
+ if (!this._readableState) {
1566
+ return;
1567
+ }
1568
+
1569
+ // Backward compatibility, the user is explicitly
1570
+ // managing destroyed.
1571
+ this._readableState.destroyed = value;
1572
+ },
1573
+ },
1574
+
1575
+ readableEnded: {
1576
+ __proto__: null,
1577
+ enumerable: false,
1578
+ get() {
1579
+ return this._readableState ? this._readableState.endEmitted : false;
1580
+ },
1581
+ },
1582
+
1583
+ });
1584
+
1585
+ Object.defineProperties(ReadableState.prototype, {
1586
+ // Legacy getter for `pipesCount`.
1587
+ pipesCount: {
1588
+ __proto__: null,
1589
+ get() {
1590
+ return this.pipes.length;
1591
+ },
1592
+ },
1593
+
1594
+ // Legacy property for `paused`.
1595
+ paused: {
1596
+ __proto__: null,
1597
+ get() {
1598
+ return (this[kState] & kPaused) !== 0;
1599
+ },
1600
+ set(value) {
1601
+ this[kState] |= kHasPaused;
1602
+ if (value) {
1603
+ this[kState] |= kPaused;
1604
+ } else {
1605
+ this[kState] &= ~kPaused;
1606
+ }
1607
+ },
1608
+ },
1609
+ });
1610
+
1611
+ // Exposed for testing purposes only.
1612
+ Readable._fromList = fromList;
1613
+
1614
+ // Pluck off n bytes from an array of buffers.
1615
+ // Length is the combined lengths of all the buffers in the list.
1616
+ // This function is designed to be inlinable, so please take care when making
1617
+ // changes to the function body.
1618
+ function fromList(n, state) {
1619
+ // `state.length` cannot change while this function runs (only the
1620
+ // caller updates it, after this returns) and the chunk lengths feeding
1621
+ // the copy loops cannot change across the copy calls, so every
1622
+ // repeated property load below is hoisted into a local.
1623
+ const stateLength = state.length;
1624
+
1625
+ // nothing buffered.
1626
+ if (stateLength === 0)
1627
+ return null;
1628
+
1629
+ let idx = state.bufferIndex;
1630
+ let ret;
1631
+
1632
+ const buf = state.buffer;
1633
+ const len = buf.length;
1634
+
1635
+ if ((state[kState] & kObjectMode) !== 0) {
1636
+ ret = buf[idx];
1637
+ buf[idx++] = null;
1638
+ } else if (!n || n >= stateLength) {
1639
+ // Read it all, truncate the list.
1640
+ if ((state[kState] & kDecoder) !== 0) {
1641
+ ret = '';
1642
+ while (idx < len) {
1643
+ ret += buf[idx];
1644
+ buf[idx++] = null;
1645
+ }
1646
+ } else if (len - idx === 0) {
1647
+ ret = new FastBuffer();
1648
+ } else if (len - idx === 1) {
1649
+ ret = buf[idx];
1650
+ buf[idx++] = null;
1651
+ } else {
1652
+ ret = Buffer.allocUnsafe(stateLength);
1653
+
1654
+ let i = 0;
1655
+ while (idx < len) {
1656
+ const data = buf[idx];
1657
+ ret.set(data, i);
1658
+ i += data.length;
1659
+ buf[idx++] = null;
1660
+ }
1661
+ }
1662
+ } else {
1663
+ const first = buf[idx];
1664
+ const firstLength = first.length;
1665
+ if (n < firstLength) {
1666
+ // `slice` is the same for buffers and strings.
1667
+ ret = first.slice(0, n);
1668
+ buf[idx] = first.slice(n);
1669
+ } else if (n === firstLength) {
1670
+ // First chunk is a perfect match.
1671
+ ret = first;
1672
+ buf[idx++] = null;
1673
+ } else if ((state[kState] & kDecoder) !== 0) {
1674
+ ret = '';
1675
+ while (idx < len) {
1676
+ const str = buf[idx];
1677
+ const strLength = str.length;
1678
+ if (n > strLength) {
1679
+ ret += str;
1680
+ n -= strLength;
1681
+ buf[idx++] = null;
1682
+ } else {
1683
+ if (n === strLength) {
1684
+ ret += str;
1685
+ buf[idx++] = null;
1686
+ } else {
1687
+ ret += str.slice(0, n);
1688
+ buf[idx] = str.slice(n);
1689
+ }
1690
+ break;
1691
+ }
1692
+ }
1693
+ } else {
1694
+ ret = Buffer.allocUnsafe(n);
1695
+
1696
+ const retLen = n;
1697
+ while (idx < len) {
1698
+ const data = buf[idx];
1699
+ const dataLength = data.length;
1700
+ if (n > dataLength) {
1701
+ ret.set(data, retLen - n);
1702
+ n -= dataLength;
1703
+ buf[idx++] = null;
1704
+ } else {
1705
+ if (n === dataLength) {
1706
+ ret.set(data, retLen - n);
1707
+ buf[idx++] = null;
1708
+ } else {
1709
+ ret.set(new FastBuffer(data.buffer, data.byteOffset, n), retLen - n);
1710
+ buf[idx] = new FastBuffer(data.buffer, data.byteOffset + n, dataLength - n);
1711
+ }
1712
+ break;
1713
+ }
1714
+ }
1715
+ }
1716
+ }
1717
+
1718
+ if (idx === len) {
1719
+ state.buffer.length = 0;
1720
+ state.bufferIndex = 0;
1721
+ } else if (idx > 1024) {
1722
+ state.buffer.splice(0, idx);
1723
+ state.bufferIndex = 0;
1724
+ } else {
1725
+ state.bufferIndex = idx;
1726
+ }
1727
+
1728
+ return ret;
1729
+ }
1730
+
1731
+ function endReadable(stream) {
1732
+ const state = stream._readableState;
1733
+
1734
+ debug('endReadable');
1735
+ if ((state[kState] & (kEndEmitted | kEndScheduled)) === 0) {
1736
+ state[kState] |= kEnded | kEndScheduled;
1737
+ process.nextTick(endReadableNT, state, stream);
1738
+ }
1739
+ }
1740
+
1741
+ function endReadableNT(state, stream) {
1742
+ debug('endReadableNT');
1743
+
1744
+ // The scheduled tick is running; allow endReadable() to schedule again.
1745
+ // This matters both when the 'end' emission is skipped below (e.g. after
1746
+ // an unshift()) and when the stream is later reset for reuse
1747
+ // (see undestroy()), which clears kEndEmitted but not this flag.
1748
+ state[kState] &= ~kEndScheduled;
1749
+
1750
+ // Check that we didn't get one last unshift.
1751
+ if ((state[kState] & (kErrored | kCloseEmitted | kEndEmitted)) === 0 && state.length === 0) {
1752
+ state[kState] |= kEndEmitted;
1753
+ stream.emit('end');
1754
+
1755
+ if (stream.writable && stream.allowHalfOpen === false) {
1756
+ process.nextTick(endWritableNT, stream);
1757
+ } else if (state.autoDestroy) {
1758
+ // In case of duplex streams we need a way to detect
1759
+ // if the writable side is ready for autoDestroy as well.
1760
+ const wState = stream._writableState;
1761
+ const autoDestroy = !wState || (
1762
+ wState.autoDestroy &&
1763
+ // We don't expect the writable to ever 'finish'
1764
+ // if writable is explicitly set to false.
1765
+ (wState.finished || wState.writable === false)
1766
+ );
1767
+
1768
+ if (autoDestroy) {
1769
+ stream.destroy();
1770
+ }
1771
+ }
1772
+ }
1773
+ }
1774
+
1775
+ function endWritableNT(stream) {
1776
+ const writable = stream.writable && !stream.writableEnded &&
1777
+ !stream.destroyed;
1778
+ if (writable) {
1779
+ stream.end();
1780
+ }
1781
+ }
1782
+
1783
+ Readable.from = function(iterable, opts) {
1784
+ /* internal/stream_from.js, linked into programs that name Readable.from */
1785
+ return feature('readableFrom')(Readable, iterable, opts);
1786
+ };
1787
+
1788
+ /* the conversions to and from web streams: internal/stream_web_adapters.js, linked into programs
1789
+ * that name them (internal/features.js) */
1790
+ function lazyWebStreams() {
1791
+ return feature('webStreamsAdapters');
1792
+ }
1793
+
1794
+ Readable.fromWeb = function(readableStream, options) {
1795
+ return lazyWebStreams().newStreamReadableFromReadableStream(
1796
+ readableStream,
1797
+ options);
1798
+ };
1799
+
1800
+ Readable.toWeb = function(streamReadable, options) {
1801
+ return lazyWebStreams().newReadableStreamFromStreamReadable(
1802
+ streamReadable,
1803
+ options);
1804
+ };
1805
+
1806
+ Readable.wrap = function(src, options) {
1807
+ return new Readable({
1808
+ objectMode: src.readableObjectMode ?? src.objectMode ?? true,
1809
+ ...options,
1810
+ destroy(err, callback) {
1811
+ destroyImpl.destroyer(src, err);
1812
+ callback(err);
1813
+ },
1814
+ }).wrap(src);
1815
+ };
1816
+
1817
+ // Interop with the stream/iter API via the toAsyncStreamable protocol.
1818
+ //
1819
+ // The batched iterator logic lives in classic.js (shared with the
1820
+ // fromReadable() utility for duck-typed streams). This prototype method
1821
+ // calls createBatchedAsyncIterator directly -- it must NOT call
1822
+ // fromReadable() since fromReadable() checks for toAsyncStreamable,
1823
+ // which would create infinite recursion.
1824
+ //
1825
+ // The flag cannot be checked at module load time (readable.js loads during
1826
+ // bootstrap before options are available). Instead, toAsyncStreamable is
1827
+ // always defined but lazily initializes on first call -- throwing if the
1828
+ // flag is not set.
1829
+ {
1830
+ const toAsyncStreamable = Symbol.for('Stream.toAsyncStreamable');
1831
+ /* the stream/iter API needs --experimental-stream-iter, which a compiled program never has */
1832
+ Readable.prototype[toAsyncStreamable] = function() {
1833
+ throw new ERR_STREAM_ITER_MISSING_FLAG();
1834
+ };
1835
+ }