@blazetrails/ruby-compat 0.0.0-stage → 0.1.0-alpha0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (625) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +6 -0
  3. package/README.md +440 -2
  4. package/dist/argument-error.d.ts +15 -0
  5. package/dist/argument-error.js +15 -0
  6. package/dist/argument-error.js.map +1 -0
  7. package/dist/array.d.ts +415 -0
  8. package/dist/array.js +1330 -0
  9. package/dist/array.js.map +1 -0
  10. package/dist/async-context-adapter.d.ts +19 -0
  11. package/dist/async-context-adapter.js +139 -0
  12. package/dist/async-context-adapter.js.map +1 -0
  13. package/dist/backtrace-location.d.ts +78 -0
  14. package/dist/backtrace-location.js +158 -0
  15. package/dist/backtrace-location.js.map +1 -0
  16. package/dist/base64.d.ts +73 -0
  17. package/dist/base64.js +164 -0
  18. package/dist/base64.js.map +1 -0
  19. package/dist/benchmark.d.ts +19 -0
  20. package/dist/benchmark.js +16 -0
  21. package/dist/benchmark.js.map +1 -0
  22. package/dist/big-decimal.d.ts +111 -0
  23. package/dist/big-decimal.js +584 -0
  24. package/dist/big-decimal.js.map +1 -0
  25. package/dist/bundler.d.ts +44 -0
  26. package/dist/bundler.js +97 -0
  27. package/dist/bundler.js.map +1 -0
  28. package/dist/cgi.d.ts +89 -0
  29. package/dist/cgi.js +168 -0
  30. package/dist/cgi.js.map +1 -0
  31. package/dist/child-process-adapter.d.ts +110 -0
  32. package/dist/child-process-adapter.js +272 -0
  33. package/dist/child-process-adapter.js.map +1 -0
  34. package/dist/class-module.d.ts +10 -0
  35. package/dist/class-module.js +10 -0
  36. package/dist/class-module.js.map +1 -0
  37. package/dist/classpath.d.ts +93 -0
  38. package/dist/classpath.js +210 -0
  39. package/dist/classpath.js.map +1 -0
  40. package/dist/closed-queue-error.d.ts +10 -0
  41. package/dist/closed-queue-error.js +10 -0
  42. package/dist/closed-queue-error.js.map +1 -0
  43. package/dist/comparable.d.ts +127 -0
  44. package/dist/comparable.js +376 -0
  45. package/dist/comparable.js.map +1 -0
  46. package/dist/complex.d.ts +49 -0
  47. package/dist/complex.js +164 -0
  48. package/dist/complex.js.map +1 -0
  49. package/dist/concurrent/atomic-boolean.d.ts +24 -0
  50. package/dist/concurrent/atomic-boolean.js +43 -0
  51. package/dist/concurrent/atomic-boolean.js.map +1 -0
  52. package/dist/concurrent/atomic-fixnum.d.ts +21 -0
  53. package/dist/concurrent/atomic-fixnum.js +35 -0
  54. package/dist/concurrent/atomic-fixnum.js.map +1 -0
  55. package/dist/concurrent/count-down-latch.d.ts +20 -0
  56. package/dist/concurrent/count-down-latch.js +50 -0
  57. package/dist/concurrent/count-down-latch.js.map +1 -0
  58. package/dist/concurrent/cyclic-barrier.d.ts +18 -0
  59. package/dist/concurrent/cyclic-barrier.js +50 -0
  60. package/dist/concurrent/cyclic-barrier.js.map +1 -0
  61. package/dist/concurrent/event.d.ts +19 -0
  62. package/dist/concurrent/event.js +31 -0
  63. package/dist/concurrent/event.js.map +1 -0
  64. package/dist/concurrent/map.d.ts +149 -0
  65. package/dist/concurrent/map.js +202 -0
  66. package/dist/concurrent/map.js.map +1 -0
  67. package/dist/concurrent/read-write-lock.d.ts +25 -0
  68. package/dist/concurrent/read-write-lock.js +70 -0
  69. package/dist/concurrent/read-write-lock.js.map +1 -0
  70. package/dist/concurrent/semaphore.d.ts +24 -0
  71. package/dist/concurrent/semaphore.js +74 -0
  72. package/dist/concurrent/semaphore.js.map +1 -0
  73. package/dist/concurrent/timer-task.d.ts +52 -0
  74. package/dist/concurrent/timer-task.js +112 -0
  75. package/dist/concurrent/timer-task.js.map +1 -0
  76. package/dist/constants.generated.d.ts +2 -0
  77. package/dist/constants.generated.js +64 -0
  78. package/dist/constants.generated.js.map +1 -0
  79. package/dist/converter-not-found-error.d.ts +14 -0
  80. package/dist/converter-not-found-error.js +14 -0
  81. package/dist/converter-not-found-error.js.map +1 -0
  82. package/dist/crypto-adapter.d.ts +64 -0
  83. package/dist/crypto-adapter.js +365 -0
  84. package/dist/crypto-adapter.js.map +1 -0
  85. package/dist/delegate.d.ts +156 -0
  86. package/dist/delegate.js +306 -0
  87. package/dist/delegate.js.map +1 -0
  88. package/dist/digest.d.ts +99 -0
  89. package/dist/digest.js +131 -0
  90. package/dist/digest.js.map +1 -0
  91. package/dist/dir.d.ts +225 -0
  92. package/dist/dir.js +608 -0
  93. package/dist/dir.js.map +1 -0
  94. package/dist/encoding-error.d.ts +14 -0
  95. package/dist/encoding-error.js +17 -0
  96. package/dist/encoding-error.js.map +1 -0
  97. package/dist/encoding.d.ts +121 -0
  98. package/dist/encoding.js +306 -0
  99. package/dist/encoding.js.map +1 -0
  100. package/dist/ensure.d.ts +15 -0
  101. package/dist/ensure.js +35 -0
  102. package/dist/ensure.js.map +1 -0
  103. package/dist/enumerable.d.ts +375 -0
  104. package/dist/enumerable.js +1102 -0
  105. package/dist/enumerable.js.map +1 -0
  106. package/dist/enumerator.d.ts +324 -0
  107. package/dist/enumerator.js +625 -0
  108. package/dist/enumerator.js.map +1 -0
  109. package/dist/eof-error.d.ts +14 -0
  110. package/dist/eof-error.js +14 -0
  111. package/dist/eof-error.js.map +1 -0
  112. package/dist/errno.d.ts +447 -0
  113. package/dist/errno.js +616 -0
  114. package/dist/errno.js.map +1 -0
  115. package/dist/exc-detailed-message.d.ts +15 -0
  116. package/dist/exc-detailed-message.js +106 -0
  117. package/dist/exc-detailed-message.js.map +1 -0
  118. package/dist/exc-to-s.d.ts +10 -0
  119. package/dist/exc-to-s.js +21 -0
  120. package/dist/exc-to-s.js.map +1 -0
  121. package/dist/exception.d.ts +44 -0
  122. package/dist/exception.js +115 -0
  123. package/dist/exception.js.map +1 -0
  124. package/dist/fiber-error.d.ts +12 -0
  125. package/dist/fiber-error.js +12 -0
  126. package/dist/fiber-error.js.map +1 -0
  127. package/dist/fiber.d.ts +51 -0
  128. package/dist/fiber.js +178 -0
  129. package/dist/fiber.js.map +1 -0
  130. package/dist/file-utils.d.ts +480 -0
  131. package/dist/file-utils.js +1824 -0
  132. package/dist/file-utils.js.map +1 -0
  133. package/dist/file.d.ts +643 -0
  134. package/dist/file.js +1334 -0
  135. package/dist/file.js.map +1 -0
  136. package/dist/float-domain-error.d.ts +17 -0
  137. package/dist/float-domain-error.js +17 -0
  138. package/dist/float-domain-error.js.map +1 -0
  139. package/dist/fork-children.d.ts +23 -0
  140. package/dist/fork-children.js +32 -0
  141. package/dist/fork-children.js.map +1 -0
  142. package/dist/frozen-error.d.ts +33 -0
  143. package/dist/frozen-error.js +41 -0
  144. package/dist/frozen-error.js.map +1 -0
  145. package/dist/fs-adapter.d.ts +158 -0
  146. package/dist/fs-adapter.js +253 -0
  147. package/dist/fs-adapter.js.map +1 -0
  148. package/dist/gem/deprecate.d.ts +10 -0
  149. package/dist/gem/deprecate.js +8 -0
  150. package/dist/gem/deprecate.js.map +1 -0
  151. package/dist/gem/requirement.d.ts +55 -0
  152. package/dist/gem/requirement.js +91 -0
  153. package/dist/gem/requirement.js.map +1 -0
  154. package/dist/gem/version.d.ts +50 -0
  155. package/dist/gem/version.js +148 -0
  156. package/dist/gem/version.js.map +1 -0
  157. package/dist/gem.d.ts +59 -0
  158. package/dist/gem.js +82 -0
  159. package/dist/gem.js.map +1 -0
  160. package/dist/hash.d.ts +967 -0
  161. package/dist/hash.js +1572 -0
  162. package/dist/hash.js.map +1 -0
  163. package/dist/http-adapter.d.ts +124 -0
  164. package/dist/http-adapter.js +220 -0
  165. package/dist/http-adapter.js.map +1 -0
  166. package/dist/immediate-executor.d.ts +20 -0
  167. package/dist/immediate-executor.js +39 -0
  168. package/dist/immediate-executor.js.map +1 -0
  169. package/dist/include.d.ts +778 -0
  170. package/dist/include.js +2208 -0
  171. package/dist/include.js.map +1 -0
  172. package/dist/index-error.d.ts +13 -0
  173. package/dist/index-error.js +13 -0
  174. package/dist/index-error.js.map +1 -0
  175. package/dist/index.d.ts +174 -0
  176. package/dist/index.js +166 -0
  177. package/dist/index.js.map +1 -0
  178. package/dist/invalid-byte-sequence-error.d.ts +62 -0
  179. package/dist/invalid-byte-sequence-error.js +75 -0
  180. package/dist/invalid-byte-sequence-error.js.map +1 -0
  181. package/dist/io-error.d.ts +14 -0
  182. package/dist/io-error.js +17 -0
  183. package/dist/io-error.js.map +1 -0
  184. package/dist/io.d.ts +867 -0
  185. package/dist/io.js +1960 -0
  186. package/dist/io.js.map +1 -0
  187. package/dist/ipaddr.d.ts +79 -0
  188. package/dist/ipaddr.js +405 -0
  189. package/dist/ipaddr.js.map +1 -0
  190. package/dist/json.d.ts +70 -0
  191. package/dist/json.js +181 -0
  192. package/dist/json.js.map +1 -0
  193. package/dist/kernel-catch.d.ts +59 -0
  194. package/dist/kernel-catch.js +184 -0
  195. package/dist/kernel-catch.js.map +1 -0
  196. package/dist/kernel-float.d.ts +19 -0
  197. package/dist/kernel-float.js +54 -0
  198. package/dist/kernel-float.js.map +1 -0
  199. package/dist/kernel-fork.d.ts +30 -0
  200. package/dist/kernel-fork.js +72 -0
  201. package/dist/kernel-fork.js.map +1 -0
  202. package/dist/kernel-format.d.ts +27 -0
  203. package/dist/kernel-format.js +901 -0
  204. package/dist/kernel-format.js.map +1 -0
  205. package/dist/kernel-hash.d.ts +7 -0
  206. package/dist/kernel-hash.js +33 -0
  207. package/dist/kernel-hash.js.map +1 -0
  208. package/dist/kernel-integer.d.ts +49 -0
  209. package/dist/kernel-integer.js +170 -0
  210. package/dist/kernel-integer.js.map +1 -0
  211. package/dist/kernel-rand.d.ts +16 -0
  212. package/dist/kernel-rand.js +237 -0
  213. package/dist/kernel-rand.js.map +1 -0
  214. package/dist/kernel-system.d.ts +39 -0
  215. package/dist/kernel-system.js +103 -0
  216. package/dist/kernel-system.js.map +1 -0
  217. package/dist/kernel-warn.d.ts +35 -0
  218. package/dist/kernel-warn.js +73 -0
  219. package/dist/kernel-warn.js.map +1 -0
  220. package/dist/key-error.d.ts +44 -0
  221. package/dist/key-error.js +59 -0
  222. package/dist/key-error.js.map +1 -0
  223. package/dist/keyword-splat.d.ts +41 -0
  224. package/dist/keyword-splat.js +65 -0
  225. package/dist/keyword-splat.js.map +1 -0
  226. package/dist/load-error.d.ts +19 -0
  227. package/dist/load-error.js +19 -0
  228. package/dist/load-error.js.map +1 -0
  229. package/dist/load.d.ts +128 -0
  230. package/dist/load.js +278 -0
  231. package/dist/load.js.map +1 -0
  232. package/dist/loaded-features.d.ts +13 -0
  233. package/dist/loaded-features.js +15 -0
  234. package/dist/loaded-features.js.map +1 -0
  235. package/dist/local-jump-error.d.ts +12 -0
  236. package/dist/local-jump-error.js +12 -0
  237. package/dist/local-jump-error.js.map +1 -0
  238. package/dist/logger/formatter.d.ts +21 -0
  239. package/dist/logger/formatter.js +43 -0
  240. package/dist/logger/formatter.js.map +1 -0
  241. package/dist/logger/log-device.d.ts +52 -0
  242. package/dist/logger/log-device.js +104 -0
  243. package/dist/logger/log-device.js.map +1 -0
  244. package/dist/logger/severity.d.ts +23 -0
  245. package/dist/logger/severity.js +42 -0
  246. package/dist/logger/severity.js.map +1 -0
  247. package/dist/logger.d.ts +127 -0
  248. package/dist/logger.js +218 -0
  249. package/dist/logger.js.map +1 -0
  250. package/dist/marshal.d.ts +83 -0
  251. package/dist/marshal.js +1487 -0
  252. package/dist/marshal.js.map +1 -0
  253. package/dist/match-data.d.ts +161 -0
  254. package/dist/match-data.js +284 -0
  255. package/dist/match-data.js.map +1 -0
  256. package/dist/method-cache.d.ts +81 -0
  257. package/dist/method-cache.js +109 -0
  258. package/dist/method-cache.js.map +1 -0
  259. package/dist/method-missing-proxy.d.ts +53 -0
  260. package/dist/method-missing-proxy.js +154 -0
  261. package/dist/method-missing-proxy.js.map +1 -0
  262. package/dist/method.d.ts +132 -0
  263. package/dist/method.js +320 -0
  264. package/dist/method.js.map +1 -0
  265. package/dist/monitor.d.ts +114 -0
  266. package/dist/monitor.js +270 -0
  267. package/dist/monitor.js.map +1 -0
  268. package/dist/mutex.d.ts +51 -0
  269. package/dist/mutex.js +150 -0
  270. package/dist/mutex.js.map +1 -0
  271. package/dist/name-error.d.ts +45 -0
  272. package/dist/name-error.js +54 -0
  273. package/dist/name-error.js.map +1 -0
  274. package/dist/net/http/exceptions.d.ts +31 -0
  275. package/dist/net/http/exceptions.js +46 -0
  276. package/dist/net/http/exceptions.js.map +1 -0
  277. package/dist/net/http/request.d.ts +137 -0
  278. package/dist/net/http/request.js +559 -0
  279. package/dist/net/http/request.js.map +1 -0
  280. package/dist/net/http/requests.d.ts +197 -0
  281. package/dist/net/http/requests.js +197 -0
  282. package/dist/net/http/requests.js.map +1 -0
  283. package/dist/net/http/response.d.ts +141 -0
  284. package/dist/net/http/response.js +416 -0
  285. package/dist/net/http/response.js.map +1 -0
  286. package/dist/net/http/responses.d.ts +345 -0
  287. package/dist/net/http/responses.js +486 -0
  288. package/dist/net/http/responses.js.map +1 -0
  289. package/dist/net/http.d.ts +278 -0
  290. package/dist/net/http.js +760 -0
  291. package/dist/net/http.js.map +1 -0
  292. package/dist/net/protocol.d.ts +227 -0
  293. package/dist/net/protocol.js +392 -0
  294. package/dist/net/protocol.js.map +1 -0
  295. package/dist/nil-class.d.ts +10 -0
  296. package/dist/nil-class.js +27 -0
  297. package/dist/nil-class.js.map +1 -0
  298. package/dist/no-method-error.d.ts +38 -0
  299. package/dist/no-method-error.js +45 -0
  300. package/dist/no-method-error.js.map +1 -0
  301. package/dist/not-implemented-error.d.ts +13 -0
  302. package/dist/not-implemented-error.js +13 -0
  303. package/dist/not-implemented-error.js.map +1 -0
  304. package/dist/numeric-class.d.ts +29 -0
  305. package/dist/numeric-class.js +41 -0
  306. package/dist/numeric-class.js.map +1 -0
  307. package/dist/numeric.d.ts +226 -0
  308. package/dist/numeric.js +848 -0
  309. package/dist/numeric.js.map +1 -0
  310. package/dist/object-space.d.ts +34 -0
  311. package/dist/object-space.js +152 -0
  312. package/dist/object-space.js.map +1 -0
  313. package/dist/object.d.ts +833 -0
  314. package/dist/object.js +2131 -0
  315. package/dist/object.js.map +1 -0
  316. package/dist/open-uri.d.ts +180 -0
  317. package/dist/open-uri.js +402 -0
  318. package/dist/open-uri.js.map +1 -0
  319. package/dist/open3.d.ts +69 -0
  320. package/dist/open3.js +134 -0
  321. package/dist/open3.js.map +1 -0
  322. package/dist/openssl.d.ts +479 -0
  323. package/dist/openssl.js +1052 -0
  324. package/dist/openssl.js.map +1 -0
  325. package/dist/optparse.d.ts +130 -0
  326. package/dist/optparse.js +457 -0
  327. package/dist/optparse.js.map +1 -0
  328. package/dist/os-adapter.d.ts +20 -0
  329. package/dist/os-adapter.js +95 -0
  330. package/dist/os-adapter.js.map +1 -0
  331. package/dist/pathname.d.ts +73 -0
  332. package/dist/pathname.js +412 -0
  333. package/dist/pathname.js.map +1 -0
  334. package/dist/pp.d.ts +60 -0
  335. package/dist/pp.js +195 -0
  336. package/dist/pp.js.map +1 -0
  337. package/dist/pretty-print.d.ts +89 -0
  338. package/dist/pretty-print.js +232 -0
  339. package/dist/pretty-print.js.map +1 -0
  340. package/dist/process-adapter.d.ts +229 -0
  341. package/dist/process-adapter.js +889 -0
  342. package/dist/process-adapter.js.map +1 -0
  343. package/dist/process.d.ts +202 -0
  344. package/dist/process.js +433 -0
  345. package/dist/process.js.map +1 -0
  346. package/dist/psych/class-loader.d.ts +92 -0
  347. package/dist/psych/class-loader.js +139 -0
  348. package/dist/psych/class-loader.js.map +1 -0
  349. package/dist/psych/coder.d.ts +144 -0
  350. package/dist/psych/coder.js +176 -0
  351. package/dist/psych/coder.js.map +1 -0
  352. package/dist/psych/core-ext.d.ts +8 -0
  353. package/dist/psych/core-ext.js +10 -0
  354. package/dist/psych/core-ext.js.map +1 -0
  355. package/dist/psych/emitter.d.ts +116 -0
  356. package/dist/psych/emitter.js +1130 -0
  357. package/dist/psych/emitter.js.map +1 -0
  358. package/dist/psych/exception.d.ts +43 -0
  359. package/dist/psych/exception.js +54 -0
  360. package/dist/psych/exception.js.map +1 -0
  361. package/dist/psych/handler.d.ts +59 -0
  362. package/dist/psych/handler.js +95 -0
  363. package/dist/psych/handler.js.map +1 -0
  364. package/dist/psych/handlers/document-stream.d.ts +17 -0
  365. package/dist/psych/handlers/document-stream.js +26 -0
  366. package/dist/psych/handlers/document-stream.js.map +1 -0
  367. package/dist/psych/nodes/alias.d.ts +15 -0
  368. package/dist/psych/nodes/alias.js +22 -0
  369. package/dist/psych/nodes/alias.js.map +1 -0
  370. package/dist/psych/nodes/document.d.ts +23 -0
  371. package/dist/psych/nodes/document.js +35 -0
  372. package/dist/psych/nodes/document.js.map +1 -0
  373. package/dist/psych/nodes/mapping.d.ts +25 -0
  374. package/dist/psych/nodes/mapping.js +35 -0
  375. package/dist/psych/nodes/mapping.js.map +1 -0
  376. package/dist/psych/nodes/node.d.ts +59 -0
  377. package/dist/psych/nodes/node.js +79 -0
  378. package/dist/psych/nodes/node.js.map +1 -0
  379. package/dist/psych/nodes/scalar.d.ts +35 -0
  380. package/dist/psych/nodes/scalar.js +47 -0
  381. package/dist/psych/nodes/scalar.js.map +1 -0
  382. package/dist/psych/nodes/sequence.d.ts +25 -0
  383. package/dist/psych/nodes/sequence.js +35 -0
  384. package/dist/psych/nodes/sequence.js.map +1 -0
  385. package/dist/psych/nodes/stream.d.ts +23 -0
  386. package/dist/psych/nodes/stream.js +31 -0
  387. package/dist/psych/nodes/stream.js.map +1 -0
  388. package/dist/psych/omap.d.ts +9 -0
  389. package/dist/psych/omap.js +9 -0
  390. package/dist/psych/omap.js.map +1 -0
  391. package/dist/psych/parser.d.ts +41 -0
  392. package/dist/psych/parser.js +139 -0
  393. package/dist/psych/parser.js.map +1 -0
  394. package/dist/psych/scalar-scanner.d.ts +31 -0
  395. package/dist/psych/scalar-scanner.js +169 -0
  396. package/dist/psych/scalar-scanner.js.map +1 -0
  397. package/dist/psych/syntax-error.d.ts +23 -0
  398. package/dist/psych/syntax-error.js +35 -0
  399. package/dist/psych/syntax-error.js.map +1 -0
  400. package/dist/psych/tree-builder.d.ts +51 -0
  401. package/dist/psych/tree-builder.js +118 -0
  402. package/dist/psych/tree-builder.js.map +1 -0
  403. package/dist/psych/visitors/depth-first.d.ts +27 -0
  404. package/dist/psych/visitors/depth-first.js +37 -0
  405. package/dist/psych/visitors/depth-first.js.map +1 -0
  406. package/dist/psych/visitors/emitter.d.ts +32 -0
  407. package/dist/psych/visitors/emitter.js +63 -0
  408. package/dist/psych/visitors/emitter.js.map +1 -0
  409. package/dist/psych/visitors/to-ruby.d.ts +110 -0
  410. package/dist/psych/visitors/to-ruby.js +396 -0
  411. package/dist/psych/visitors/to-ruby.js.map +1 -0
  412. package/dist/psych/visitors/visitor.d.ts +11 -0
  413. package/dist/psych/visitors/visitor.js +17 -0
  414. package/dist/psych/visitors/visitor.js.map +1 -0
  415. package/dist/psych/visitors/yaml-tree.d.ts +182 -0
  416. package/dist/psych/visitors/yaml-tree.js +593 -0
  417. package/dist/psych/visitors/yaml-tree.js.map +1 -0
  418. package/dist/psych-adapter.d.ts +65 -0
  419. package/dist/psych-adapter.js +121 -0
  420. package/dist/psych-adapter.js.map +1 -0
  421. package/dist/psych-yaml.d.ts +2 -0
  422. package/dist/psych-yaml.js +5 -0
  423. package/dist/psych-yaml.js.map +1 -0
  424. package/dist/psych.d.ts +257 -0
  425. package/dist/psych.js +332 -0
  426. package/dist/psych.js.map +1 -0
  427. package/dist/queue.d.ts +137 -0
  428. package/dist/queue.js +236 -0
  429. package/dist/queue.js.map +1 -0
  430. package/dist/racc/parser.d.ts +70 -0
  431. package/dist/racc/parser.js +206 -0
  432. package/dist/racc/parser.js.map +1 -0
  433. package/dist/range-error.d.ts +15 -0
  434. package/dist/range-error.js +15 -0
  435. package/dist/range-error.js.map +1 -0
  436. package/dist/range.d.ts +166 -0
  437. package/dist/range.js +421 -0
  438. package/dist/range.js.map +1 -0
  439. package/dist/rational.d.ts +168 -0
  440. package/dist/rational.js +587 -0
  441. package/dist/rational.js.map +1 -0
  442. package/dist/rb-config.d.ts +33 -0
  443. package/dist/rb-config.js +53 -0
  444. package/dist/rb-config.js.map +1 -0
  445. package/dist/rb-equal.d.ts +66 -0
  446. package/dist/rb-equal.js +262 -0
  447. package/dist/rb-equal.js.map +1 -0
  448. package/dist/rb-hash.d.ts +26 -0
  449. package/dist/rb-hash.js +108 -0
  450. package/dist/rb-hash.js.map +1 -0
  451. package/dist/regexp.d.ts +82 -0
  452. package/dist/regexp.js +191 -0
  453. package/dist/regexp.js.map +1 -0
  454. package/dist/repl-adapter.d.ts +270 -0
  455. package/dist/repl-adapter.js +562 -0
  456. package/dist/repl-adapter.js.map +1 -0
  457. package/dist/resolv.d.ts +30 -0
  458. package/dist/resolv.js +48 -0
  459. package/dist/resolv.js.map +1 -0
  460. package/dist/ruby-empty.d.ts +28 -0
  461. package/dist/ruby-empty.js +40 -0
  462. package/dist/ruby-empty.js.map +1 -0
  463. package/dist/ruby-platform.d.ts +39 -0
  464. package/dist/ruby-platform.js +49 -0
  465. package/dist/ruby-platform.js.map +1 -0
  466. package/dist/runtime-error.d.ts +15 -0
  467. package/dist/runtime-error.js +15 -0
  468. package/dist/runtime-error.js.map +1 -0
  469. package/dist/scheduled-task.d.ts +73 -0
  470. package/dist/scheduled-task.js +150 -0
  471. package/dist/scheduled-task.js.map +1 -0
  472. package/dist/secure-random.d.ts +50 -0
  473. package/dist/secure-random.js +141 -0
  474. package/dist/secure-random.js.map +1 -0
  475. package/dist/set.d.ts +158 -0
  476. package/dist/set.js +352 -0
  477. package/dist/set.js.map +1 -0
  478. package/dist/shellwords.d.ts +27 -0
  479. package/dist/shellwords.js +53 -0
  480. package/dist/shellwords.js.map +1 -0
  481. package/dist/signal-exception.d.ts +43 -0
  482. package/dist/signal-exception.js +88 -0
  483. package/dist/signal-exception.js.map +1 -0
  484. package/dist/socket.d.ts +230 -0
  485. package/dist/socket.js +484 -0
  486. package/dist/socket.js.map +1 -0
  487. package/dist/standard-error.d.ts +27 -0
  488. package/dist/standard-error.js +49 -0
  489. package/dist/standard-error.js.map +1 -0
  490. package/dist/stop-iteration.d.ts +10 -0
  491. package/dist/stop-iteration.js +10 -0
  492. package/dist/stop-iteration.js.map +1 -0
  493. package/dist/string/b.d.ts +19 -0
  494. package/dist/string/b.js +28 -0
  495. package/dist/string/b.js.map +1 -0
  496. package/dist/string/byte-methods.d.ts +57 -0
  497. package/dist/string/byte-methods.js +266 -0
  498. package/dist/string/byte-methods.js.map +1 -0
  499. package/dist/string/bytes.d.ts +35 -0
  500. package/dist/string/bytes.js +123 -0
  501. package/dist/string/bytes.js.map +1 -0
  502. package/dist/string/case-mapping.d.ts +57 -0
  503. package/dist/string/case-mapping.js +192 -0
  504. package/dist/string/case-mapping.js.map +1 -0
  505. package/dist/string/chomp.d.ts +15 -0
  506. package/dist/string/chomp.js +32 -0
  507. package/dist/string/chomp.js.map +1 -0
  508. package/dist/string/convert.d.ts +55 -0
  509. package/dist/string/convert.js +316 -0
  510. package/dist/string/convert.js.map +1 -0
  511. package/dist/string/delete.d.ts +14 -0
  512. package/dist/string/delete.js +17 -0
  513. package/dist/string/delete.js.map +1 -0
  514. package/dist/string/each.d.ts +108 -0
  515. package/dist/string/each.js +305 -0
  516. package/dist/string/each.js.map +1 -0
  517. package/dist/string/encode.d.ts +37 -0
  518. package/dist/string/encode.js +268 -0
  519. package/dist/string/encode.js.map +1 -0
  520. package/dist/string/force-encoding.d.ts +72 -0
  521. package/dist/string/force-encoding.js +147 -0
  522. package/dist/string/force-encoding.js.map +1 -0
  523. package/dist/string/inspect.d.ts +17 -0
  524. package/dist/string/inspect.js +81 -0
  525. package/dist/string/inspect.js.map +1 -0
  526. package/dist/string/method-table.d.ts +174 -0
  527. package/dist/string/method-table.js +805 -0
  528. package/dist/string/method-table.js.map +1 -0
  529. package/dist/string/scrub.d.ts +12 -0
  530. package/dist/string/scrub.js +33 -0
  531. package/dist/string/scrub.js.map +1 -0
  532. package/dist/string/slice.d.ts +26 -0
  533. package/dist/string/slice.js +73 -0
  534. package/dist/string/slice.js.map +1 -0
  535. package/dist/string/split.d.ts +11 -0
  536. package/dist/string/split.js +44 -0
  537. package/dist/string/split.js.map +1 -0
  538. package/dist/string/sub.d.ts +114 -0
  539. package/dist/string/sub.js +371 -0
  540. package/dist/string/sub.js.map +1 -0
  541. package/dist/string/succ.d.ts +14 -0
  542. package/dist/string/succ.js +118 -0
  543. package/dist/string/succ.js.map +1 -0
  544. package/dist/string/support.d.ts +142 -0
  545. package/dist/string/support.js +296 -0
  546. package/dist/string/support.js.map +1 -0
  547. package/dist/string/tr.d.ts +46 -0
  548. package/dist/string/tr.js +156 -0
  549. package/dist/string/tr.js.map +1 -0
  550. package/dist/string-io.d.ts +166 -0
  551. package/dist/string-io.js +248 -0
  552. package/dist/string-io.js.map +1 -0
  553. package/dist/string-scanner.d.ts +133 -0
  554. package/dist/string-scanner.js +248 -0
  555. package/dist/string-scanner.js.map +1 -0
  556. package/dist/struct.d.ts +54 -0
  557. package/dist/struct.js +222 -0
  558. package/dist/struct.js.map +1 -0
  559. package/dist/symbol.d.ts +48 -0
  560. package/dist/symbol.js +107 -0
  561. package/dist/symbol.js.map +1 -0
  562. package/dist/tempfile.d.ts +173 -0
  563. package/dist/tempfile.js +295 -0
  564. package/dist/tempfile.js.map +1 -0
  565. package/dist/temporal-tag.d.ts +23 -0
  566. package/dist/temporal-tag.js +29 -0
  567. package/dist/temporal-tag.js.map +1 -0
  568. package/dist/thread-error.d.ts +13 -0
  569. package/dist/thread-error.js +13 -0
  570. package/dist/thread-error.js.map +1 -0
  571. package/dist/thread-pool-executor.d.ts +121 -0
  572. package/dist/thread-pool-executor.js +254 -0
  573. package/dist/thread-pool-executor.js.map +1 -0
  574. package/dist/thread.d.ts +211 -0
  575. package/dist/thread.js +495 -0
  576. package/dist/thread.js.map +1 -0
  577. package/dist/timeout.d.ts +29 -0
  578. package/dist/timeout.js +41 -0
  579. package/dist/timeout.js.map +1 -0
  580. package/dist/tse.d.ts +40 -0
  581. package/dist/tse.js +66 -0
  582. package/dist/tse.js.map +1 -0
  583. package/dist/type-error.d.ts +14 -0
  584. package/dist/type-error.js +14 -0
  585. package/dist/type-error.js.map +1 -0
  586. package/dist/undefined-conversion-error.d.ts +10 -0
  587. package/dist/undefined-conversion-error.js +10 -0
  588. package/dist/undefined-conversion-error.js.map +1 -0
  589. package/dist/uri/common.d.ts +209 -0
  590. package/dist/uri/common.js +369 -0
  591. package/dist/uri/common.js.map +1 -0
  592. package/dist/uri/generic.d.ts +280 -0
  593. package/dist/uri/generic.js +806 -0
  594. package/dist/uri/generic.js.map +1 -0
  595. package/dist/uri/http.d.ts +23 -0
  596. package/dist/uri/http.js +30 -0
  597. package/dist/uri/http.js.map +1 -0
  598. package/dist/uri/https.d.ts +13 -0
  599. package/dist/uri/https.js +15 -0
  600. package/dist/uri/https.js.map +1 -0
  601. package/dist/uri/rfc2396-parser.d.ts +70 -0
  602. package/dist/uri/rfc2396-parser.js +264 -0
  603. package/dist/uri/rfc2396-parser.js.map +1 -0
  604. package/dist/uri/rfc3986-parser.d.ts +46 -0
  605. package/dist/uri/rfc3986-parser.js +171 -0
  606. package/dist/uri/rfc3986-parser.js.map +1 -0
  607. package/dist/uri.d.ts +13 -0
  608. package/dist/uri.js +13 -0
  609. package/dist/uri.js.map +1 -0
  610. package/dist/variable.d.ts +183 -0
  611. package/dist/variable.js +463 -0
  612. package/dist/variable.js.map +1 -0
  613. package/dist/verbose.d.ts +39 -0
  614. package/dist/verbose.js +49 -0
  615. package/dist/verbose.js.map +1 -0
  616. package/dist/yaml.d.ts +9 -0
  617. package/dist/yaml.js +9 -0
  618. package/dist/yaml.js.map +1 -0
  619. package/dist/zlib-adapter.d.ts +119 -0
  620. package/dist/zlib-adapter.js +230 -0
  621. package/dist/zlib-adapter.js.map +1 -0
  622. package/dist/zlib.d.ts +299 -0
  623. package/dist/zlib.js +679 -0
  624. package/dist/zlib.js.map +1 -0
  625. package/package.json +172 -3
package/dist/file.js ADDED
@@ -0,0 +1,1334 @@
1
+ import { constSet } from "./include.js";
2
+ import { TopLevel } from "./object.js";
3
+ import { getProcessAdapter } from "./process-adapter.js";
4
+ import { ArgumentError } from "./argument-error.js";
5
+ import { getFs, getPath } from "./fs-adapter.js";
6
+ import { IO } from "./io.js";
7
+ import { NotImplementedError } from "./not-implemented-error.js";
8
+ import { stringValue } from "./string/support.js";
9
+ /** `FMODE_SETENC_BY_BOM` (`vendor/ruby/v3.3.11/include/ruby/io.h:368`). */
10
+ const FMODE_SETENC_BY_BOM = 0x00100000;
11
+ /**
12
+ * `rb_get_path` (`vendor/ruby/v3.3.11/file.c:246`), the `FilePathValue` conversion:
13
+ * a String is the path, anything else is asked for `to_path`, and the answer (the
14
+ * object itself where it has no `to_path`) goes through `StringValue`
15
+ * (`rb_get_path_check_to_string`, `file.c:212-224`). A path holding a NUL raises
16
+ * `ArgumentError` (`rb_get_path_check_convert`, `vendor/ruby/v3.3.11/file.c:232-234`).
17
+ *
18
+ * @noRailsEquivalent PERMANENT — `vendor/ruby/v3.3.11/file.c:246`
19
+ */
20
+ export function rbGetPath(obj) {
21
+ let path;
22
+ if (typeof obj === "string") {
23
+ path = obj;
24
+ }
25
+ else {
26
+ const toPath = obj?.toPath;
27
+ const tmp = typeof toPath === "function" ? toPath.call(obj) : obj;
28
+ path = stringValue(tmp);
29
+ }
30
+ if (path.includes("\0"))
31
+ throw new ArgumentError("path name contains null byte");
32
+ return path;
33
+ }
34
+ /**
35
+ * `rb_stat` (`vendor/ruby/v3.3.11/file.c:1296`), which `fstat`s an open stream and
36
+ * `stat`s a name, answering `< 0` — `null` here — where the call fails.
37
+ */
38
+ function rbStat(file) {
39
+ try {
40
+ return typeof file === "string" ? getFs().statSync(file) : file.stat();
41
+ }
42
+ catch {
43
+ return null;
44
+ }
45
+ }
46
+ async function rbStatAsync(file) {
47
+ try {
48
+ if (typeof file !== "string")
49
+ return file.stat();
50
+ const fs = getFs();
51
+ return fs.stat ? await fs.stat(file) : fs.statSync(file);
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * `isdirsep` (`vendor/ruby/v3.3.11/file.c:3306,3311`) — `'/'` on every platform, and
59
+ * `FILE_ALT_SEPARATOR` as well where the build defines one (`file.c:3303`).
60
+ */
61
+ function isdirsep(c) {
62
+ return c === File.SEPARATOR || c === File.ALT_SEPARATOR;
63
+ }
64
+ /**
65
+ * `chompdirsep` (`vendor/ruby/v3.3.11/file.c:3484`), which answers the path without
66
+ * the run of separators that terminates it, and the whole path where none
67
+ * does.
68
+ */
69
+ function chompdirsep(path) {
70
+ let end = path.length;
71
+ while (end > 0 && isdirsep(path[end - 1]))
72
+ end--;
73
+ return path.slice(0, end);
74
+ }
75
+ const joining = new Set();
76
+ /**
77
+ * `file_inspect_join` (`vendor/ruby/v3.3.11/file.c:5006`), the `rb_exec_recursive`
78
+ * callback that joins a nested Array component.
79
+ */
80
+ function fileInspectJoin(ary, arg) {
81
+ if (joining.has(arg) || ary === arg)
82
+ throw new ArgumentError("recursive array");
83
+ joining.add(arg);
84
+ try {
85
+ return rbFileJoin(arg);
86
+ }
87
+ finally {
88
+ joining.delete(arg);
89
+ }
90
+ }
91
+ /** `rb_file_join` (`vendor/ruby/v3.3.11/file.c:5013`). */
92
+ function rbFileJoin(ary) {
93
+ if (ary.length === 0)
94
+ return "";
95
+ let result = "";
96
+ for (let i = 0; i < ary.length; i++) {
97
+ let tmp = ary[i];
98
+ if (typeof tmp !== "string") {
99
+ if (ary === tmp)
100
+ throw new ArgumentError("recursive array");
101
+ tmp = Array.isArray(tmp)
102
+ ? fileInspectJoin(ary, tmp)
103
+ : rbGetPath(tmp);
104
+ }
105
+ if (i !== 0) {
106
+ const tail = chompdirsep(result);
107
+ if (isdirsep(tmp.charAt(0)))
108
+ result = tail;
109
+ else if (tail.length === result.length)
110
+ result = `${result}${File.SEPARATOR}`;
111
+ }
112
+ result = `${result}${tmp}`;
113
+ }
114
+ return result;
115
+ }
116
+ /**
117
+ * `to_uid` (`vendor/ruby/v3.3.11/file.c:2661`), which maps a `nil` owner onto `-1` —
118
+ * the id `chown(2)` reads as "leave this one unchanged".
119
+ */
120
+ function toUid(u) {
121
+ if (u == null)
122
+ return -1;
123
+ return u;
124
+ }
125
+ /** `to_gid` (`vendor/ruby/v3.3.11/file.c:2670`), `to_uid`'s group half. */
126
+ function toGid(g) {
127
+ if (g == null)
128
+ return -1;
129
+ return g;
130
+ }
131
+ /**
132
+ * `File` (`vendor/ruby/v3.3.11/file.c:7354` `rb_cFile`), the sliver of it trails calls.
133
+ *
134
+ * Rails reaches the filesystem through this class — `File.exist?(key)` in
135
+ * `vendor/rails/v8.0.5.2/activesupport/lib/active_support/cache/file_store.rb:125`,
136
+ * `File.join(cache_path, ...)` at `file_store.rb:185`,
137
+ * `File.realpath(dir)` at `file_store.rb:196` — so trails reaches it through a
138
+ * class of the same name rather than through members named after node's `fs`.
139
+ * The backend a member lands on is the `FsAdapter` contract in
140
+ * `./fs-adapter.js`; a platform registers one, and nothing here names a
141
+ * runtime.
142
+ *
143
+ * Only the members ported bodies call are here. `File::SEPARATOR` is `"/"` on
144
+ * every platform (`vendor/ruby/v3.3.11/file.c:7427`); the backslash is
145
+ * `File::ALT_SEPARATOR`, which is `nil` off DOSISH (`file.c:7435`).
146
+ *
147
+ * @noRailsEquivalent PERMANENT — Ruby core `File` (`vendor/ruby/v3.3.11/file.c:7354`),
148
+ * which Rails calls without defining, so no Rails or gem file declares the
149
+ * class this file's single export lives in.
150
+ */
151
+ export class File extends IO {
152
+ /**
153
+ * `rb_file_initialize` (`vendor/ruby/v3.3.11/io.c:9616`) over `rb_open_file`
154
+ * (`io.c:8102`): `File.new(filename, mode = "r", opt)` opens the named file.
155
+ * Ruby's mode string carries the binary flag node's `flags` has no letter
156
+ * for, so `b` is dropped from the flags and recorded on the stream instead
157
+ * (`rb_io_binmode`, `io.c:6311`), and everything after the first `:` is
158
+ * `parse_mode_enc`'s encoding (`io.c:6667,6883-6886`).
159
+ *
160
+ * @noRailsEquivalent PERMANENT — Ruby core `File.new`
161
+ * (`vendor/ruby/v3.3.11/io.c:9616`).
162
+ *
163
+ * An Integer `fileName` is `rb_file_initialize`'s fd arm, `rb_io_initialize`
164
+ * over a descriptor already open, which has no path.
165
+ */
166
+ constructor(fileName, mode = "r", opt) {
167
+ if (typeof mode === "object") {
168
+ opt = mode;
169
+ mode = opt.mode ?? "r";
170
+ if (opt.binmode === true)
171
+ mode = mode.replace(/^[^:]*/, (m) => (m.includes("b") ? m : `${m}b`));
172
+ }
173
+ const colon = mode.indexOf(":");
174
+ const estr = colon === -1 ? null : mode.slice(colon + 1);
175
+ const vmode = colon === -1 ? mode : mode.slice(0, colon);
176
+ if (typeof fileName === "number")
177
+ super(fileName, null, mode);
178
+ else
179
+ super(getFs().openSync(fileName, vmode.replace(/b/g, ""), opt?.perm), fileName, mode);
180
+ if (vmode.includes("b"))
181
+ this.binmode();
182
+ if (estr !== null)
183
+ this.setEncoding(estr);
184
+ else if (opt?.externalEncoding != null)
185
+ this.setEncoding(opt.externalEncoding);
186
+ if (this.mode & FMODE_SETENC_BY_BOM)
187
+ this.ioSetEncodingByBom();
188
+ }
189
+ /**
190
+ * `vendor/ruby/v3.3.11/file.c:7427` — `File::SEPARATOR`, `"/"` on every platform.
191
+ *
192
+ * @noRailsEquivalent PERMANENT — Ruby core `File::SEPARATOR`.
193
+ */
194
+ static SEPARATOR = "/";
195
+ /**
196
+ * `vendor/ruby/v3.3.11/file.c:7433` — `File::ALT_SEPARATOR`, the `'\\'` of
197
+ * `FILE_ALT_SEPARATOR` (`file.c:3303`) where the build is DOSISH, and `nil`
198
+ * everywhere else (`file.c:7435`). The platform answer comes from the
199
+ * registered path backend's separator rather than from a runtime global.
200
+ *
201
+ * @noRailsEquivalent PERMANENT — Ruby core `File::ALT_SEPARATOR`.
202
+ */
203
+ static get ALT_SEPARATOR() {
204
+ return getPath().sep === "\\" ? "\\" : null;
205
+ }
206
+ /**
207
+ * `vendor/ruby/v3.3.11/file.c:7440` — `File::PATH_SEPARATOR`, the `';'` of a DOSISH
208
+ * build and `':'` everywhere else. The platform answer comes from the
209
+ * registered path backend's separator, as `ALT_SEPARATOR` above does.
210
+ *
211
+ * @noRailsEquivalent PERMANENT — Ruby core `File::PATH_SEPARATOR`.
212
+ */
213
+ static get PATH_SEPARATOR() {
214
+ return getPath().sep === "\\" ? ";" : ":";
215
+ }
216
+ /**
217
+ * `vendor/ruby/v3.3.11/file.c:7841` — `File::LOCK_EX`, the exclusive-lock operation
218
+ * `File#flock` takes (`file.c:5198`).
219
+ *
220
+ * @noRailsEquivalent PERMANENT — Ruby core `File::LOCK_EX`.
221
+ */
222
+ static LOCK_EX = 2;
223
+ /**
224
+ * `vendor/ruby/v3.3.11/file.c:7843` — `File::LOCK_UN`, the release operation
225
+ * `File#flock` takes (`file.c:5204`).
226
+ *
227
+ * @noRailsEquivalent PERMANENT — Ruby core `File::LOCK_UN`.
228
+ */
229
+ static LOCK_UN = 8;
230
+ /**
231
+ * `vendor/ruby/v3.3.11/file.c:7845` — `File::LOCK_NB`, which makes `File#flock`
232
+ * answer `false` rather than wait (`file.c:5201`).
233
+ *
234
+ * @noRailsEquivalent PERMANENT — Ruby core `File::LOCK_NB`.
235
+ */
236
+ static LOCK_NB = 4;
237
+ /**
238
+ * `vendor/ruby/v3.3.11/dir.c:3678` — a backslash is an ordinary character, not an escape.
239
+ *
240
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_NOESCAPE`.
241
+ */
242
+ static FNM_NOESCAPE = 0x01;
243
+ /**
244
+ * `vendor/ruby/v3.3.11/dir.c:3682` — `*`, `?` and a bracket stop at `/`, and `**` + `/` walks elements.
245
+ *
246
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_PATHNAME`.
247
+ */
248
+ static FNM_PATHNAME = 0x02;
249
+ /**
250
+ * `vendor/ruby/v3.3.11/dir.c:3686` — a wildcard may match a leading period.
251
+ *
252
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_DOTMATCH`.
253
+ */
254
+ static FNM_DOTMATCH = 0x04;
255
+ /**
256
+ * `vendor/ruby/v3.3.11/dir.c:3674` — case-insensitive matching.
257
+ *
258
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_CASEFOLD`.
259
+ */
260
+ static FNM_CASEFOLD = 0x08;
261
+ /**
262
+ * `vendor/ruby/v3.3.11/dir.c:222-226` — `FNM_CASEFOLD` on a case-folding filesystem
263
+ * and `0` otherwise, which is the arm `Entry_#descendant_directory?` selects
264
+ * on (`vendor/ruby/v3.3.11/lib/fileutils.rb:2453`).
265
+ *
266
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_SYSCASE`.
267
+ */
268
+ static FNM_SYSCASE = 0;
269
+ /**
270
+ * `vendor/ruby/v3.3.11/dir.c:3690` — `{a,b}` alternation, expanded by `ruby_brace_expand` (`dir.c:3471-3478`).
271
+ *
272
+ * @noRailsEquivalent PERMANENT — Ruby core `File::FNM_EXTGLOB`.
273
+ */
274
+ static FNM_EXTGLOB = 0x10;
275
+ /**
276
+ * `vendor/ruby/v3.3.11/file.c:1806` `rb_file_exist_p`, which is `rb_stat(fname)`
277
+ * against a FOLLOWED symlink — so a broken symlink is `false` even though
278
+ * `File.symlink?` is `true`.
279
+ *
280
+ * @noRailsEquivalent PERMANENT — Ruby core `File.exist?`
281
+ * (`vendor/ruby/v3.3.11/file.c:1806`).
282
+ */
283
+ static isExist(fileName) {
284
+ return getFs().existsSync(rbGetPath(fileName));
285
+ }
286
+ /**
287
+ * {@link File.isExist} over the backend's async `exists`.
288
+ *
289
+ * @noRailsEquivalent PERMANENT — Ruby core `File.exist?`
290
+ * (`vendor/ruby/v3.3.11/file.c:1806`).
291
+ */
292
+ static async isExistAsync(fileName) {
293
+ return getFs().exists(fileName);
294
+ }
295
+ /**
296
+ * `vendor/ruby/v3.3.11/file.c:2196` `rb_file_identical_p` — `false` unless both
297
+ * names stat successfully and report the same `st_dev` and `st_ino`
298
+ * (`file.c:2201-2205`). Either argument may be an open stream, which
299
+ * `rb_stat` (`file.c:1296`) `fstat`s instead. An adapter that reports no
300
+ * device identity cannot answer, so it answers `false`.
301
+ *
302
+ * @noRailsEquivalent PERMANENT — Ruby core `File.identical?`
303
+ * (`vendor/ruby/v3.3.11/file.c:2196`).
304
+ */
305
+ static isIdentical(fileName1, fileName2) {
306
+ const st1 = rbStat(fileName1);
307
+ const st2 = rbStat(fileName2);
308
+ if (!st1 || !st2)
309
+ return false;
310
+ if (st1.dev == null || st1.ino == null)
311
+ return false;
312
+ if (st1.dev !== st2.dev)
313
+ return false;
314
+ if (st1.ino !== st2.ino)
315
+ return false;
316
+ return true;
317
+ }
318
+ /**
319
+ * {@link File.isDirectory} over the backend's async `stat`: any failed stat
320
+ * answers `false`, as `rb_file_directory_p` does (`file.c:1622`).
321
+ *
322
+ * @noRailsEquivalent PERMANENT — Ruby core `File.directory?`
323
+ * (`vendor/ruby/v3.3.11/file.c:1615`).
324
+ */
325
+ static async isDirectoryAsync(fileName) {
326
+ try {
327
+ return (await getFs().stat(fileName)).isDirectory();
328
+ }
329
+ catch {
330
+ return false;
331
+ }
332
+ }
333
+ /**
334
+ * `vendor/ruby/v3.3.11/file.c:1615` `rb_file_directory_p`, which answers `false`
335
+ * rather than raising when the stat fails (`file.c:1622`).
336
+ *
337
+ * @noRailsEquivalent PERMANENT — Ruby core `File.directory?`
338
+ * (`vendor/ruby/v3.3.11/file.c:1615`).
339
+ */
340
+ static isDirectory(fileName) {
341
+ try {
342
+ return getFs().statSync(fileName).isDirectory();
343
+ }
344
+ catch {
345
+ return false;
346
+ }
347
+ }
348
+ /**
349
+ * `vendor/ruby/v3.3.11/file.c:1966` `rb_file_executable_p`, which is
350
+ * `rb_eaccess(fname, X_OK) >= 0`: the backend's `File::Stat#executable?`
351
+ * (`file.c:2244`), and `false` where the stat fails.
352
+ *
353
+ * @noRailsEquivalent PERMANENT — Ruby core `File.executable?`
354
+ * (`vendor/ruby/v3.3.11/file.c:1966`).
355
+ */
356
+ static isExecutable(fileName) {
357
+ try {
358
+ return getFs().statSync(fileName).isExecutable();
359
+ }
360
+ catch {
361
+ return false;
362
+ }
363
+ }
364
+ /**
365
+ * `vendor/ruby/v3.3.11/file.c:1723` `rb_file_symlink_p`, which `lstat`s the name and
366
+ * answers `false` rather than raising when the `lstat` fails
367
+ * (`file.c:1730`), the way its {@link File.isDirectory} neighbour does.
368
+ *
369
+ * @noRailsEquivalent PERMANENT — Ruby core `File.symlink?`
370
+ * (`vendor/ruby/v3.3.11/file.c:1723`).
371
+ */
372
+ static isSymlink(fileName) {
373
+ try {
374
+ return getFs().lstatSync(fileName).isSymbolicLink?.() === true;
375
+ }
376
+ catch {
377
+ return false;
378
+ }
379
+ }
380
+ /**
381
+ * @noRailsEquivalent PERMANENT — Ruby core `File.file?`
382
+ * (`vendor/ruby/v3.3.11/file.c:2009`), over the backend's async `stat`.
383
+ */
384
+ static async isFileAsync(fileName) {
385
+ const fs = getFs();
386
+ try {
387
+ return (await fs.stat(fileName)).isFile();
388
+ }
389
+ catch {
390
+ return false;
391
+ }
392
+ }
393
+ /**
394
+ * {@link File.isIdentical} over the backend's async `stat`, which is the
395
+ * form a caller on the async fs path awaits; a backend with no async `stat`
396
+ * is read through its sync one. A stream argument is still `fstat`ed, as
397
+ * `rb_stat` (`vendor/ruby/v3.3.11/file.c:1296`) does.
398
+ *
399
+ * @noRailsEquivalent PERMANENT — Ruby core `File.identical?`
400
+ * (`vendor/ruby/v3.3.11/file.c:2196`).
401
+ */
402
+ static async isIdenticalAsync(fileName1, fileName2) {
403
+ const st1 = await rbStatAsync(fileName1);
404
+ const st2 = await rbStatAsync(fileName2);
405
+ if (!st1 || !st2)
406
+ return false;
407
+ if (st1.dev == null || st1.ino == null)
408
+ return false;
409
+ if (st1.dev !== st2.dev)
410
+ return false;
411
+ if (st1.ino !== st2.ino)
412
+ return false;
413
+ return true;
414
+ }
415
+ /**
416
+ * {@link File.isSymlink} over the backend's async `lstat`, `false` on a
417
+ * failed `lstat`; a backend with no async `lstat` is read through its sync
418
+ * one.
419
+ *
420
+ * @noRailsEquivalent PERMANENT — Ruby core `File.symlink?`
421
+ * (`vendor/ruby/v3.3.11/file.c:1670`).
422
+ */
423
+ static async isSymlinkAsync(fileName) {
424
+ try {
425
+ const fs = getFs();
426
+ const st = fs.lstat ? await fs.lstat(fileName) : fs.lstatSync(fileName);
427
+ return st.isSymbolicLink?.() === true;
428
+ }
429
+ catch {
430
+ return false;
431
+ }
432
+ }
433
+ /**
434
+ * `vendor/ruby/v3.3.11/file.c:2009` `rb_file_file_p`, `false` on a failed stat.
435
+ *
436
+ * @noRailsEquivalent PERMANENT — Ruby core `File.file?`
437
+ * (`vendor/ruby/v3.3.11/file.c:2009`).
438
+ */
439
+ static isFile(fileName) {
440
+ try {
441
+ return getFs().statSync(fileName).isFile();
442
+ }
443
+ catch {
444
+ return false;
445
+ }
446
+ }
447
+ /**
448
+ * {@link File.isReadable} over the backend's async `access`, `rb_eaccess(fname, R_OK)`.
449
+ *
450
+ * @noRailsEquivalent PERMANENT — Ruby core `File.readable?`
451
+ * (`vendor/ruby/v3.3.11/file.c:1826`).
452
+ */
453
+ static async isReadableAsync(fileName) {
454
+ try {
455
+ await getFs().accessAsync(fileName, 4);
456
+ return true;
457
+ }
458
+ catch {
459
+ return false;
460
+ }
461
+ }
462
+ /**
463
+ * {@link File.isExecutable} over the backend's async `access`, `rb_eaccess(fname, X_OK)`.
464
+ *
465
+ * @noRailsEquivalent PERMANENT — Ruby core `File.executable?`
466
+ * (`vendor/ruby/v3.3.11/file.c:1966`).
467
+ */
468
+ static async isExecutableAsync(fileName) {
469
+ try {
470
+ await getFs().accessAsync(fileName, 1);
471
+ return true;
472
+ }
473
+ catch {
474
+ return false;
475
+ }
476
+ }
477
+ /**
478
+ * `vendor/ruby/v3.3.11/file.c:1826` `rb_file_readable_p`, which is
479
+ * `rb_eaccess(fname, R_OK) >= 0` and so is `false` both for a file that is
480
+ * not there and for one the effective user cannot read. `R_OK` is POSIX's
481
+ * `4` rather than a Ruby constant. A backend with no access check has no
482
+ * `accessSync`, and there existence is all that can be answered.
483
+ *
484
+ * @noRailsEquivalent PERMANENT — Ruby core `File.readable?`
485
+ * (`vendor/ruby/v3.3.11/file.c:1826`).
486
+ */
487
+ static isReadable(fileName) {
488
+ const fs = getFs();
489
+ if (!fs.accessSync)
490
+ return fs.existsSync(fileName);
491
+ try {
492
+ fs.accessSync(fileName, 4);
493
+ return true;
494
+ }
495
+ catch {
496
+ return false;
497
+ }
498
+ }
499
+ /**
500
+ * `vendor/ruby/v3.3.11/file.c:1329` `rb_file_s_stat`, which RAISES `Errno::ENOENT`
501
+ * rather than answering `nil` when the path is not there — the predicates
502
+ * above are the arms that swallow it.
503
+ *
504
+ * @noRailsEquivalent PERMANENT — Ruby core `File.stat`
505
+ * (`vendor/ruby/v3.3.11/file.c:1329`).
506
+ */
507
+ static stat(fileName) {
508
+ return getFs().statSync(fileName);
509
+ }
510
+ /**
511
+ * `vendor/ruby/v3.3.11/file.c:2028` `rb_file_zero_p`, which answers `false`
512
+ * rather than raising when the stat fails.
513
+ *
514
+ * @noRailsEquivalent PERMANENT — Ruby core `FileTest.empty?` (`vendor/ruby/v3.3.11/file.c:7368`).
515
+ */
516
+ static isEmpty(fileName) {
517
+ try {
518
+ return File.stat(fileName).size === 0;
519
+ }
520
+ catch {
521
+ return false;
522
+ }
523
+ }
524
+ /**
525
+ * `vendor/ruby/v3.3.11/file.c:1305` `rb_file_s_size` — the byte size of the named
526
+ * file, which is `File.stat(file_name).size`.
527
+ *
528
+ * @noRailsEquivalent PERMANENT — Ruby core `File.size`
529
+ * (`vendor/ruby/v3.3.11/file.c:1305`).
530
+ */
531
+ static size(fileName) {
532
+ return File.stat(fileName).size;
533
+ }
534
+ /**
535
+ * `vendor/ruby/v3.3.11/file.c:2047` `rb_file_size_p` — `File.size?`, `nil` both when
536
+ * the file is missing AND when it is empty, which is what makes it a
537
+ * three-state answer rather than a size.
538
+ *
539
+ * @noRailsEquivalent PERMANENT — Ruby core `File.size?`
540
+ * (`vendor/ruby/v3.3.11/file.c:2047`).
541
+ */
542
+ static isSize(fileName) {
543
+ let size;
544
+ try {
545
+ size = File.stat(fileName).size;
546
+ }
547
+ catch {
548
+ return null;
549
+ }
550
+ return size === 0 ? null : size;
551
+ }
552
+ static open(fileName, mode = "r", blockOrOpt, optBlock) {
553
+ const block = typeof blockOrOpt === "function" ? blockOrOpt : optBlock;
554
+ const opt = typeof blockOrOpt === "function" ? undefined : blockOrOpt;
555
+ const file = new File(fileName, mode, opt);
556
+ if (!block)
557
+ return file;
558
+ let result;
559
+ try {
560
+ result = block(file);
561
+ }
562
+ catch (error) {
563
+ file.close();
564
+ throw error;
565
+ }
566
+ if (result instanceof Promise) {
567
+ return result.finally(() => file.close());
568
+ }
569
+ file.close();
570
+ return result;
571
+ }
572
+ static async openAsync(fileName, mode = "r", blockOrOpt, optBlock) {
573
+ const block = typeof blockOrOpt === "function" ? blockOrOpt : optBlock;
574
+ const opt = typeof blockOrOpt === "function" ? undefined : blockOrOpt;
575
+ const perm = typeof mode === "object" ? mode.perm : opt?.perm;
576
+ const vmode = (typeof mode === "object" ? (mode.mode ?? "r") : mode).split(":")[0];
577
+ const fd = await getFs().openAsync(fileName, vmode.replace(/b/g, ""), perm);
578
+ let file;
579
+ try {
580
+ file = new this(fd, mode, opt);
581
+ }
582
+ catch (error) {
583
+ getFs().closeSync(fd);
584
+ throw error;
585
+ }
586
+ file.pathv = fileName;
587
+ if (!block)
588
+ return file;
589
+ try {
590
+ return await block(file);
591
+ }
592
+ finally {
593
+ file.close();
594
+ }
595
+ }
596
+ /** @noRailsEquivalent PERMANENT — Ruby core `File.read` (`vendor/ruby/v3.3.11/io.c:12200`). */
597
+ static read(name, opt) {
598
+ const file = File.open(name, "r", { externalEncoding: opt?.encoding });
599
+ try {
600
+ return file.read();
601
+ }
602
+ finally {
603
+ file.close();
604
+ }
605
+ }
606
+ /**
607
+ * {@link File.read} over the backend's async `readFile`, as UTF-8 text.
608
+ *
609
+ * @noRailsEquivalent PERMANENT — Ruby core `File.read` (`IO.read`,
610
+ * `vendor/ruby/v3.3.11/io.c:12200`).
611
+ */
612
+ static async readAsync(name) {
613
+ return await getFs().readFile(name, "utf8");
614
+ }
615
+ /**
616
+ * `vendor/ruby/v3.3.11/io.c:12063` `rb_io_s_foreach` in its block form: the stream
617
+ * opens through `open_key_args` (`io.c:12163`), `rb_io_each_line`
618
+ * (`io.c:4159`) yields each line with its separator retained, and
619
+ * `rb_ensure` (`io.c:12180`) closes it. The file is read in chunks, never
620
+ * whole; the decoder streams so a character straddling two chunks survives.
621
+ *
622
+ * @noRailsEquivalent PERMANENT — Ruby core `File.foreach` (`IO.foreach`,
623
+ * `vendor/ruby/v3.3.11/io.c:12063`).
624
+ */
625
+ static foreach(name, block) {
626
+ const fs = getFs();
627
+ const fd = fs.openSync(name, "r");
628
+ try {
629
+ const decoder = new TextDecoder();
630
+ const buffer = new Uint8Array(8192);
631
+ let pos = 0;
632
+ let rest = "";
633
+ for (;;) {
634
+ const read = fs.readSync(fd, buffer, 0, buffer.length, pos);
635
+ rest +=
636
+ read === 0
637
+ ? decoder.decode()
638
+ : decoder.decode(buffer.subarray(0, read), { stream: true });
639
+ let at;
640
+ while ((at = rest.indexOf("\n")) !== -1) {
641
+ block(rest.slice(0, at + 1));
642
+ rest = rest.slice(at + 1);
643
+ }
644
+ if (read === 0)
645
+ break;
646
+ pos += read;
647
+ }
648
+ if (rest !== "")
649
+ block(rest);
650
+ }
651
+ finally {
652
+ fs.closeSync(fd);
653
+ }
654
+ return null;
655
+ }
656
+ /**
657
+ * `vendor/ruby/v3.3.11/io.c:12377` `rb_io_s_write`, which answers the number of
658
+ * BYTES written rather than the string itself.
659
+ *
660
+ * @noRailsEquivalent PERMANENT — Ruby core `File.write` (`IO.write`,
661
+ * `vendor/ruby/v3.3.11/io.c:12377`).
662
+ */
663
+ static write(name, string) {
664
+ getFs().writeFileSync(name, string);
665
+ return new TextEncoder().encode(string).length;
666
+ }
667
+ /**
668
+ * `vendor/ruby/v3.3.11/file.c:3202` `rb_file_s_unlink`, which answers the number of
669
+ * files deleted and raises on the first failure.
670
+ *
671
+ * @noRailsEquivalent PERMANENT — Ruby core `File.delete`
672
+ * (`vendor/ruby/v3.3.11/file.c:3202`).
673
+ */
674
+ static delete(...files) {
675
+ for (const file of files)
676
+ getFs().unlinkSync(file);
677
+ return files.length;
678
+ }
679
+ /**
680
+ * {@link File.write} over the backend's async `writeFile`, falling back to its
681
+ * `writeFileSync`. `perm` is `IO.write`'s `perm:` option
682
+ * (`vendor/ruby/v3.3.11/io.c:6953`), the mode a created file is opened with,
683
+ * and `mode` its `mode:` open-mode string (`"wx"` is
684
+ * `CREAT | EXCL | WRONLY`, raising `Errno::EEXIST` on an existing file).
685
+ *
686
+ * @noRailsEquivalent PERMANENT — Ruby core `File.write` (`IO.write`,
687
+ * `vendor/ruby/v3.3.11/io.c:12377`).
688
+ */
689
+ static async writeAsync(name, string, { perm, mode } = {}) {
690
+ const fs = getFs();
691
+ if (fs.writeFile)
692
+ await fs.writeFile(name, string, { mode: perm, flag: mode });
693
+ else
694
+ fs.writeFileSync(name, string, { mode: perm, flag: mode });
695
+ return typeof string === "string" ? new TextEncoder().encode(string).length : string.length;
696
+ }
697
+ /**
698
+ * {@link File.delete} over the backend's async `unlink`, falling back to its
699
+ * `unlinkSync`.
700
+ *
701
+ * @noRailsEquivalent PERMANENT — Ruby core `File.delete`
702
+ * (`vendor/ruby/v3.3.11/file.c:3202`).
703
+ */
704
+ static async deleteAsync(...files) {
705
+ const fs = getFs();
706
+ for (const file of files) {
707
+ if (fs.unlink)
708
+ await fs.unlink(file);
709
+ else
710
+ fs.unlinkSync(file);
711
+ }
712
+ return files.length;
713
+ }
714
+ /**
715
+ * `vendor/ruby/v3.3.11/file.c:3279` `rb_file_s_umask`, reading only. A backend
716
+ * with no permission bits answers 0, as `chmod` below is a no-op there.
717
+ *
718
+ * @noRailsEquivalent PERMANENT
719
+ */
720
+ static umask() {
721
+ return getProcessAdapter().umask?.() ?? 0;
722
+ }
723
+ /**
724
+ * `vendor/ruby/v3.3.11/file.c:2575` `rb_file_s_chmod`, which answers the number of
725
+ * files whose mode was set. A backend with no permission bits has no
726
+ * `chmodSync`, and there the call is a no-op.
727
+ *
728
+ * @noRailsEquivalent PERMANENT — Ruby core `File.chmod`
729
+ * (`vendor/ruby/v3.3.11/file.c:2575`).
730
+ */
731
+ static chmod(mode, ...files) {
732
+ for (const file of files)
733
+ getFs().chmodSync?.(file, mode);
734
+ return files.length;
735
+ }
736
+ /**
737
+ * {@link File.chmod} over the backend's async `chmod`, falling back to its
738
+ * `chmodSync`; a backend with no permission bits has neither, and there the
739
+ * call is a no-op too.
740
+ *
741
+ * @noRailsEquivalent PERMANENT — Ruby core `File.chmod`
742
+ * (`vendor/ruby/v3.3.11/file.c:2575`).
743
+ */
744
+ static async chmodAsync(mode, ...files) {
745
+ const fs = getFs();
746
+ for (const file of files) {
747
+ if (fs.chmod)
748
+ await fs.chmod(file, mode);
749
+ else
750
+ fs.chmodSync?.(file, mode);
751
+ }
752
+ return files.length;
753
+ }
754
+ /**
755
+ * `vendor/ruby/v3.3.11/file.c:3056` `rb_file_s_link`, which answers `0`
756
+ * (`file.c:3066`) and raises `NotImplementedError` on a platform with no
757
+ * `link(2)` — spelled here as a backend with no `link`.
758
+ *
759
+ * @noRailsEquivalent PERMANENT — Ruby core `File.link`
760
+ * (`vendor/ruby/v3.3.11/file.c:3056`).
761
+ */
762
+ static async linkAsync(oldName, newName) {
763
+ const fs = getFs();
764
+ if (!fs.link)
765
+ throw new NotImplementedError("link() function is unimplemented on this machine");
766
+ await fs.link(oldName, newName);
767
+ return 0;
768
+ }
769
+ /**
770
+ * `vendor/ruby/v3.3.11/file.c:3086` `rb_file_s_symlink`, which answers `0`
771
+ * (`file.c:3096`) and raises `NotImplementedError` on a platform with no
772
+ * `symlink(2)` — spelled here as a backend with no `symlink`.
773
+ *
774
+ * @noRailsEquivalent PERMANENT — Ruby core `File.symlink`
775
+ * (`vendor/ruby/v3.3.11/file.c:3086`).
776
+ */
777
+ static async symlinkAsync(oldName, newName) {
778
+ const fs = getFs();
779
+ if (!fs.symlink)
780
+ throw new NotImplementedError("symlink() function is unimplemented on this machine");
781
+ await fs.symlink(oldName, newName);
782
+ return 0;
783
+ }
784
+ /**
785
+ * `vendor/ruby/v3.3.11/file.c:3115` `rb_file_s_readlink`: the name of the file
786
+ * the link `path` refers to. `rb_f_notimplement` stands in on a platform with
787
+ * no `readlink(2)` (`file.c:3197`), spelled here as a backend with no
788
+ * `readlinkSync`.
789
+ *
790
+ * @noRailsEquivalent PERMANENT — Ruby core `File.readlink`
791
+ * (`vendor/ruby/v3.3.11/file.c:3115`).
792
+ */
793
+ static readlink(path) {
794
+ const fs = getFs();
795
+ if (!fs.readlinkSync)
796
+ throw new NotImplementedError("readlink() function is unimplemented on this machine");
797
+ return fs.readlinkSync(path);
798
+ }
799
+ /**
800
+ * @noRailsEquivalent PERMANENT — Ruby core `File.chown`
801
+ * (`vendor/ruby/v3.3.11/file.c:2706`), over the backend's async `chown`.
802
+ */
803
+ static async chownAsync(owner, group, path) {
804
+ const fs = getFs();
805
+ if (fs.chown)
806
+ await fs.chown(path, toUid(owner), toGid(group));
807
+ else
808
+ fs.chownSync?.(path, toUid(owner), toGid(group));
809
+ }
810
+ /**
811
+ * @noRailsEquivalent PERMANENT — Ruby core `File.utime`
812
+ * (`vendor/ruby/v3.3.11/file.c:2983`), over the backend's async `utimes`.
813
+ */
814
+ static async utimeAsync(atime, mtime, path) {
815
+ const fs = getFs();
816
+ if (fs.utimes)
817
+ await fs.utimes(path, atime, mtime);
818
+ else if (fs.utimesSync)
819
+ fs.utimesSync(path, atime, mtime);
820
+ else
821
+ throw new NotImplementedError("utime() function is unimplemented on this machine");
822
+ }
823
+ /**
824
+ * `vendor/ruby/v3.3.11/file.c:2706` `rb_file_s_chown`, which answers the number of
825
+ * files whose owner was set. A `nil` owner or group is ignored
826
+ * (`file.c:2698`) — `File.chown(nil, 100, "testfile")` — which `to_uid` /
827
+ * `to_gid` (`file.c:2661,2670`) carry through as `-1`. A backend with no
828
+ * ownership has no `chownSync`, and there the call is a no-op.
829
+ *
830
+ * @noRailsEquivalent PERMANENT — Ruby core `File.chown`
831
+ * (`vendor/ruby/v3.3.11/file.c:2706`).
832
+ */
833
+ static chown(owner, group, ...files) {
834
+ const uid = toUid(owner);
835
+ const gid = toGid(group);
836
+ for (const file of files)
837
+ getFs().chownSync?.(file, uid, gid);
838
+ return files.length;
839
+ }
840
+ /**
841
+ * `vendor/ruby/v3.3.11/file.c:3231` `rb_file_s_rename`, which answers `0` and
842
+ * replaces `to` when it already exists.
843
+ *
844
+ * @noRailsEquivalent PERMANENT — Ruby core `File.rename`
845
+ * (`vendor/ruby/v3.3.11/file.c:3231`).
846
+ */
847
+ static rename(from, to) {
848
+ getFs().renameSync(from, to);
849
+ return 0;
850
+ }
851
+ /**
852
+ * `vendor/ruby/v3.3.11/file.c:2427` `rb_file_s_mtime`, the modification Time of a
853
+ * FOLLOWED symlink — it raises `ENOENT` rather than answering `nil` when the
854
+ * path does not exist.
855
+ *
856
+ * @noRailsEquivalent PERMANENT — Ruby core `File.mtime`
857
+ * (`vendor/ruby/v3.3.11/file.c:2427`).
858
+ */
859
+ static mtime(fileName) {
860
+ return getFs().statSync(fileName).mtime;
861
+ }
862
+ /**
863
+ * {@link File.mtime} over the backend's async `stat`.
864
+ *
865
+ * @noRailsEquivalent PERMANENT — Ruby core `File.mtime`
866
+ * (`vendor/ruby/v3.3.11/file.c:2427`).
867
+ */
868
+ static async mtimeAsync(fileName) {
869
+ const fs = getFs();
870
+ return (fs.stat ? await fs.stat(fileName) : fs.statSync(fileName)).mtime;
871
+ }
872
+ /**
873
+ * `vendor/ruby/v3.3.11/file.c:4559` `rb_file_s_realpath`, which resolves every
874
+ * symlink and raises `ENOENT` when the path does not exist. A backend with
875
+ * no symlink support has no `realpathSync`, and there the path resolves
876
+ * lexically.
877
+ *
878
+ * @noRailsEquivalent PERMANENT — Ruby core `File.realpath`
879
+ * (`vendor/ruby/v3.3.11/file.c:4559`).
880
+ */
881
+ static realpath(pathname) {
882
+ const fs = getFs();
883
+ if (fs.realpathSync)
884
+ return fs.realpathSync(pathname);
885
+ return File.expandPath(pathname);
886
+ }
887
+ /**
888
+ * {@link File.realpath} over the backend's async `realpath`, resolving
889
+ * lexically where the backend has none.
890
+ *
891
+ * @noRailsEquivalent PERMANENT — Ruby core `File.realpath`
892
+ * (`vendor/ruby/v3.3.11/file.c:4559`).
893
+ */
894
+ static async realpathAsync(pathname) {
895
+ const fs = getFs();
896
+ if (fs.realpath)
897
+ return await fs.realpath(pathname);
898
+ return File.expandPath(pathname);
899
+ }
900
+ /**
901
+ * `vendor/ruby/v3.3.11/file.c:4580` `rb_file_s_realdirpath`, {@link File.realpath}
902
+ * with the last component allowed to be missing, following a broken symlink
903
+ * to its target.
904
+ *
905
+ * @noRailsEquivalent PERMANENT — Ruby core `File.realdirpath`
906
+ * (`vendor/ruby/v3.3.11/file.c:4580`).
907
+ */
908
+ static async realdirpathAsync(pathname) {
909
+ const fs = getFs();
910
+ try {
911
+ return await fs.realpath(pathname);
912
+ }
913
+ catch (error) {
914
+ if (error.code !== "ENOENT")
915
+ throw error;
916
+ }
917
+ const [dir, base] = File.split(File.expandPath(pathname));
918
+ const link = await fs.readlink(pathname).catch(() => null);
919
+ if (link != null)
920
+ return File.realdirpathAsync(File.expandPath(link, dir));
921
+ return File.join(await fs.realpath(dir), base);
922
+ }
923
+ /**
924
+ * `vendor/ruby/v3.3.11/file.c:5013` `rb_file_join`, which is a STRING join and not
925
+ * a path normalization: `File.join("a", "..", "b")` is `"a/../b"`, where
926
+ * node's `path.join` answers `"b"`. A separator at the boundary is squeezed
927
+ * to one (`file.c:5061-5067`) — `File.join("a//", "/b")` is `"a/b"` — and an
928
+ * empty component keeps its separator, so `File.join("a", "")` is `"a/"`.
929
+ * Both boundary arms test with `isdirsep`, so a `File::ALT_SEPARATOR` at the
930
+ * boundary is a separator too: `File.join("a\\", "b")` is `"a\\b"` on
931
+ * Windows and `"a\\/b"` on POSIX. An Array component is joined first and
932
+ * spliced in (`file.c:5048-5054`), so an empty one contributes `""`:
933
+ * `File.join("a", [], "b")` is `"a/b"`.
934
+ *
935
+ * @noRailsEquivalent PERMANENT — Ruby core `File.join`
936
+ * (`vendor/ruby/v3.3.11/file.c:5013`).
937
+ */
938
+ static join(...args) {
939
+ return rbFileJoin(args);
940
+ }
941
+ /** @noRailsEquivalent PERMANENT — Ruby core `File.split` (`rb_file_s_split`, `vendor/ruby/v3.3.11/file.c:4999-5004`). */
942
+ static split(path) {
943
+ return [File.dirname(path), File.basename(path)];
944
+ }
945
+ /**
946
+ * `vendor/ruby/v3.3.11/file.c:4770` `rb_file_s_dirname`.
947
+ *
948
+ * @noRailsEquivalent PERMANENT — Ruby core `File.dirname`
949
+ * (`vendor/ruby/v3.3.11/file.c:4770`).
950
+ */
951
+ static dirname(fileName) {
952
+ return getPath().dirname(fileName);
953
+ }
954
+ /**
955
+ * `vendor/ruby/v3.3.11/file.c:4705` `rb_file_s_basename`. The optional `suffix` is
956
+ * stripped, and the literal `".*"` strips whatever extension is there
957
+ * (`file.c:4664-4680`). A path of separators only answers `"/"`
958
+ * (`vendor/ruby/v3.3.11/file.c:4625` `ruby_enc_find_basename`).
959
+ *
960
+ * @noRailsEquivalent PERMANENT — Ruby core `File.basename`
961
+ * (`vendor/ruby/v3.3.11/file.c:4705`).
962
+ */
963
+ static basename(fileName, suffix) {
964
+ const name = rbGetPath(fileName);
965
+ const base = /^\/+$/.test(name) ? "/" : getPath().basename(name);
966
+ if (suffix === undefined)
967
+ return base;
968
+ if (suffix === ".*") {
969
+ const extname = File.extname(base);
970
+ return extname === "" ? base : base.slice(0, base.length - extname.length);
971
+ }
972
+ return base.endsWith(suffix) && base !== suffix
973
+ ? base.slice(0, base.length - suffix.length)
974
+ : base;
975
+ }
976
+ /**
977
+ * `vendor/ruby/v3.3.11/file.c:4954` `rb_file_s_extname`: a leading dot is not an
978
+ * extension (`".bashrc"` is `""`) and a trailing dot is (`"b."` is `"."`).
979
+ *
980
+ * @noRailsEquivalent PERMANENT — Ruby core `File.extname`
981
+ * (`vendor/ruby/v3.3.11/file.c:4954`).
982
+ */
983
+ static extname(fileName) {
984
+ return getPath().extname(fileName);
985
+ }
986
+ /**
987
+ * `vendor/ruby/v3.3.11/dir.c:3457` `file_s_fnmatch` — `true` when `path` matches the
988
+ * glob `pattern`. Under `FNM_EXTGLOB` the pattern is brace-expanded first and
989
+ * the first alternative that matches wins (`dir.c:3471-3478`).
990
+ *
991
+ * @noRailsEquivalent PERMANENT — Ruby core `File.fnmatch`
992
+ * (`vendor/ruby/v3.3.11/dir.c:3457`).
993
+ */
994
+ static fnmatch(pattern, path, flags = 0) {
995
+ if (flags & File.FNM_EXTGLOB) {
996
+ return rubyBraceExpand(pattern, flags, (expanded) => fnmatch(expanded, path, flags));
997
+ }
998
+ return fnmatch(pattern, path, flags);
999
+ }
1000
+ /**
1001
+ * `vendor/ruby/v3.3.11/file.c:4126` `rb_file_s_expand_path`, which resolves
1002
+ * `fileName` against `dirString` — the working directory when it is omitted.
1003
+ *
1004
+ * @noRailsEquivalent PERMANENT — Ruby core `File.expand_path`
1005
+ * (`vendor/ruby/v3.3.11/file.c:4126`).
1006
+ */
1007
+ static expandPath(fileName, dirString) {
1008
+ return getPath().resolve(dirString == null ? getFs().cwd() : rbGetPath(dirString), rbGetPath(fileName));
1009
+ }
1010
+ /**
1011
+ * `vendor/ruby/v3.3.11/file.c:4210` `rb_file_s_absolute_path_p`.
1012
+ *
1013
+ * @noRailsEquivalent PERMANENT — Ruby core `File.absolute_path?`
1014
+ * (`vendor/ruby/v3.3.11/file.c:4210`).
1015
+ */
1016
+ static isAbsolutePath(fileName) {
1017
+ const path = rbGetPath(fileName);
1018
+ return getPath().isAbsolute?.(path) ?? path.startsWith(File.SEPARATOR);
1019
+ }
1020
+ /**
1021
+ * `vendor/ruby/v3.3.11/file.c:5301` `rb_file_flock`, which answers `0` once the lock
1022
+ * is held. A backend with no advisory locking — node's `fs` exposes no
1023
+ * `flock(2)` — has no `flockSync`, and there the stream is left unlocked,
1024
+ * which is what an unlockable file already behaves like.
1025
+ *
1026
+ * @noRailsEquivalent PERMANENT — Ruby core `File#flock`
1027
+ * (`vendor/ruby/v3.3.11/file.c:5301`).
1028
+ */
1029
+ flock(operation) {
1030
+ const locked = getFs().flockSync?.(this.fd, operation === File.LOCK_UN ? "un" : operation & File.LOCK_NB ? "exnb" : "ex");
1031
+ if (locked === false)
1032
+ return false;
1033
+ return 0;
1034
+ }
1035
+ /**
1036
+ * `vendor/ruby/v3.3.11/file.c:1330` `rb_file_size` — `fstat(2)` of the open
1037
+ * descriptor, which is why it answers the bytes already written rather than
1038
+ * what a stale `File.stat` of the path would say.
1039
+ *
1040
+ * @noRailsEquivalent PERMANENT — Ruby core `File#size`
1041
+ * (`vendor/ruby/v3.3.11/file.c:1330`).
1042
+ */
1043
+ size() {
1044
+ return this.stat().size;
1045
+ }
1046
+ /**
1047
+ * `vendor/ruby/v3.3.11/file.c:2599` `rb_file_chmod`, which answers `0`. MRI
1048
+ * calls `fchmod(2)` on the descriptor; the `FsAdapter` contract has no
1049
+ * `fchmodSync`, so the open file's path takes the mode instead.
1050
+ *
1051
+ * @noRailsEquivalent PERMANENT — Ruby core `File#chmod`
1052
+ * (`vendor/ruby/v3.3.11/file.c:2599`).
1053
+ */
1054
+ chmod(mode) {
1055
+ getFs().chmodSync?.(this.path(), mode);
1056
+ return 0;
1057
+ }
1058
+ }
1059
+ constSet(TopLevel, "File", File);
1060
+ /**
1061
+ * `Inc(p, e, enc)` (`vendor/ruby/v3.3.11/dir.c:237`) — the cursor advance MRI spells
1062
+ * through `rb_enc_mbclen`, one whole character. A JS string is UTF-16, so an
1063
+ * astral character is the two code units of a surrogate pair.
1064
+ */
1065
+ function inc(str, i) {
1066
+ const cp = str.codePointAt(i);
1067
+ return i + (cp !== undefined && cp > 0xffff ? 2 : 1);
1068
+ }
1069
+ /**
1070
+ * The one whole character at `i` — what MRI's `memcmp(t1, s, r)`
1071
+ * (`vendor/ruby/v3.3.11/dir.c:277`) and `rb_enc_codepoint` (`dir.c:281`) read, where a
1072
+ * JS index reads one code unit.
1073
+ */
1074
+ function charAt(str, i) {
1075
+ const cp = str.codePointAt(i);
1076
+ return cp === undefined ? "" : String.fromCodePoint(cp);
1077
+ }
1078
+ /**
1079
+ * `bracket` (`vendor/ruby/v3.3.11/dir.c:240`), which answers the pattern index just
1080
+ * past the closing `]` when `s` is in the class, and `null` when it is not or
1081
+ * the class never closes. Its `FNM_CASEFOLD` arm casefolds against `p`, the
1082
+ * character AFTER `t1` (`dir.c:296`) — mirrored, not corrected.
1083
+ */
1084
+ function bracket(p, pattern, s, string, flags) {
1085
+ const nocase = flags & File.FNM_CASEFOLD;
1086
+ const escape = !(flags & File.FNM_NOESCAPE);
1087
+ let ok = false;
1088
+ let not = false;
1089
+ if (p >= pattern.length)
1090
+ return null;
1091
+ if (pattern[p] === "!" || pattern[p] === "^") {
1092
+ not = true;
1093
+ p++;
1094
+ }
1095
+ while (pattern[p] !== "]") {
1096
+ let t1 = p;
1097
+ if (escape && pattern[t1] === "\\")
1098
+ t1++;
1099
+ if (t1 >= pattern.length)
1100
+ return null;
1101
+ p = inc(pattern, t1);
1102
+ if (p >= pattern.length)
1103
+ return null;
1104
+ if (pattern[p] === "-" && pattern[p + 1] !== "]") {
1105
+ let t2 = p + 1;
1106
+ if (escape && pattern[t2] === "\\")
1107
+ t2++;
1108
+ if (t2 >= pattern.length)
1109
+ return null;
1110
+ p = inc(pattern, t2);
1111
+ if (ok)
1112
+ continue;
1113
+ if (charAt(pattern, t1) === charAt(string, s) || charAt(pattern, t2) === charAt(string, s)) {
1114
+ ok = true;
1115
+ continue;
1116
+ }
1117
+ if (compareChar(charAt(string, s), charAt(pattern, t1), nocase) < 0)
1118
+ continue;
1119
+ if (compareChar(charAt(string, s), charAt(pattern, t2), nocase) > 0)
1120
+ continue;
1121
+ }
1122
+ else {
1123
+ if (ok)
1124
+ continue;
1125
+ if (charAt(pattern, t1) === charAt(string, s)) {
1126
+ ok = true;
1127
+ continue;
1128
+ }
1129
+ if (!nocase)
1130
+ continue;
1131
+ if (compareChar(charAt(string, s), charAt(pattern, p), nocase) !== 0)
1132
+ continue;
1133
+ }
1134
+ ok = true;
1135
+ }
1136
+ return ok === not ? null : p + 1;
1137
+ }
1138
+ /**
1139
+ * The `rb_enc_toupper` comparison `bracket` and `fnmatch_helper` share
1140
+ * (`vendor/ruby/v3.3.11/dir.c:281-297,383-386`).
1141
+ */
1142
+ function compareChar(a, b, nocase) {
1143
+ const x = nocase ? a.toUpperCase() : a;
1144
+ const y = nocase ? b.toUpperCase() : b;
1145
+ return x < y ? -1 : x > y ? 1 : 0;
1146
+ }
1147
+ /**
1148
+ * `fnmatch_helper` (`vendor/ruby/v3.3.11/dir.c:317`), which matches one path element
1149
+ * under `FNM_PATHNAME` and the whole string without it. The cursors it
1150
+ * advances through `*pcur` / `*scur` are the returned pair; `unescape` / `isEndP`
1151
+ * / `isEndS` / `ret` are its `UNESCAPE` / `ISEND` / `RETURN` macros
1152
+ * (`dir.c:311-314`) and `failed:` its `goto failed` (`dir.c:396`).
1153
+ */
1154
+ function fnmatchHelper(pcur, pattern, scur, string, flags) {
1155
+ const period = !(flags & File.FNM_DOTMATCH);
1156
+ const pathname = flags & File.FNM_PATHNAME;
1157
+ const escape = !(flags & File.FNM_NOESCAPE);
1158
+ const nocase = flags & File.FNM_CASEFOLD;
1159
+ let ptmp = null;
1160
+ let stmp = null;
1161
+ let p = pcur;
1162
+ let s = scur;
1163
+ const unescape = (i) => (escape && pattern[i] === "\\" ? i + 1 : i);
1164
+ const isEndP = (i) => i >= pattern.length || (!!pathname && pattern[i] === "/");
1165
+ const isEndS = (i) => i >= string.length || (!!pathname && string[i] === "/");
1166
+ const ret = (matched) => ({ matched, p, s });
1167
+ if (period && string[s] === "." && pattern[unescape(p)] !== ".")
1168
+ return ret(false);
1169
+ for (;;) {
1170
+ failed: {
1171
+ switch (pattern[p]) {
1172
+ case "*":
1173
+ do {
1174
+ p++;
1175
+ } while (pattern[p] === "*");
1176
+ if (isEndP(unescape(p))) {
1177
+ p = unescape(p);
1178
+ return ret(true);
1179
+ }
1180
+ if (isEndS(s))
1181
+ return ret(false);
1182
+ ptmp = p;
1183
+ stmp = s;
1184
+ continue;
1185
+ case "?":
1186
+ if (isEndS(s))
1187
+ return ret(false);
1188
+ p++;
1189
+ s = inc(string, s);
1190
+ continue;
1191
+ case "[": {
1192
+ if (isEndS(s))
1193
+ return ret(false);
1194
+ const t = bracket(p + 1, pattern, s, string, flags);
1195
+ if (t !== null) {
1196
+ p = t;
1197
+ s = inc(string, s);
1198
+ continue;
1199
+ }
1200
+ break failed;
1201
+ }
1202
+ }
1203
+ p = unescape(p);
1204
+ if (isEndS(s))
1205
+ return ret(isEndP(p));
1206
+ if (isEndP(p))
1207
+ break failed;
1208
+ if (charAt(pattern, p) === charAt(string, s)) {
1209
+ p = inc(pattern, p);
1210
+ s = inc(string, s);
1211
+ continue;
1212
+ }
1213
+ if (!nocase)
1214
+ break failed;
1215
+ if (compareChar(charAt(pattern, p), charAt(string, s), nocase) !== 0)
1216
+ break failed;
1217
+ p = inc(pattern, p);
1218
+ s = inc(string, s);
1219
+ continue;
1220
+ }
1221
+ if (ptmp !== null && stmp !== null) {
1222
+ p = ptmp;
1223
+ stmp = inc(string, stmp);
1224
+ s = stmp;
1225
+ continue;
1226
+ }
1227
+ return ret(false);
1228
+ }
1229
+ }
1230
+ /**
1231
+ * `fnmatch` (`vendor/ruby/v3.3.11/dir.c:411`) — the `FNM_PATHNAME` element walk with
1232
+ * its `**` + `/` backtrack, falling through to a single `fnmatch_helper` without.
1233
+ */
1234
+ function fnmatch(pattern, string, flags) {
1235
+ let p = 0;
1236
+ let s = 0;
1237
+ const period = !(flags & File.FNM_DOTMATCH);
1238
+ const pathname = flags & File.FNM_PATHNAME;
1239
+ let ptmp = null;
1240
+ let stmp = null;
1241
+ if (pathname) {
1242
+ for (;;) {
1243
+ if (pattern.startsWith("**/", p)) {
1244
+ do {
1245
+ p += 3;
1246
+ } while (pattern.startsWith("**/", p));
1247
+ ptmp = p;
1248
+ stmp = s;
1249
+ }
1250
+ const r = fnmatchHelper(p, pattern, s, string, flags);
1251
+ p = r.p;
1252
+ s = r.s;
1253
+ if (r.matched) {
1254
+ while (s < string.length && string[s] !== "/")
1255
+ s++;
1256
+ if (p < pattern.length && s < string.length) {
1257
+ p++;
1258
+ s++;
1259
+ continue;
1260
+ }
1261
+ if (p >= pattern.length && s >= string.length)
1262
+ return true;
1263
+ }
1264
+ if (ptmp !== null && stmp !== null && !(period && string[stmp] === ".")) {
1265
+ while (stmp < string.length && string[stmp] !== "/")
1266
+ stmp++;
1267
+ if (stmp < string.length) {
1268
+ p = ptmp;
1269
+ stmp++;
1270
+ s = stmp;
1271
+ continue;
1272
+ }
1273
+ }
1274
+ return false;
1275
+ }
1276
+ }
1277
+ else {
1278
+ return fnmatchHelper(p, pattern, s, string, flags).matched;
1279
+ }
1280
+ }
1281
+ /**
1282
+ * `ruby_brace_expand` (`vendor/ruby/v3.3.11/dir.c:3019`), which calls back once per
1283
+ * `{a,b}` alternative and stops at the first non-zero status — for
1284
+ * `fnmatch_brace` (`dir.c:3430`), the first alternative that matches.
1285
+ */
1286
+ function rubyBraceExpand(str, flags, func) {
1287
+ const escape = !(flags & File.FNM_NOESCAPE);
1288
+ let p = 0;
1289
+ let lbrace = -1;
1290
+ let rbrace = -1;
1291
+ let nest = 0;
1292
+ while (p < str.length) {
1293
+ if (str[p] === "{" && nest++ === 0)
1294
+ lbrace = p;
1295
+ if (str[p] === "}" && lbrace >= 0 && --nest === 0) {
1296
+ rbrace = p;
1297
+ break;
1298
+ }
1299
+ if (str[p] === "\\" && escape) {
1300
+ if (++p >= str.length)
1301
+ break;
1302
+ }
1303
+ p++;
1304
+ }
1305
+ if (lbrace >= 0 && rbrace >= 0) {
1306
+ const prefix = str.slice(0, lbrace);
1307
+ let status = false;
1308
+ p = lbrace;
1309
+ while (p < rbrace) {
1310
+ const t = ++p;
1311
+ nest = 0;
1312
+ while (p < rbrace && !(str[p] === "," && nest === 0)) {
1313
+ if (str[p] === "{")
1314
+ nest++;
1315
+ if (str[p] === "}")
1316
+ nest--;
1317
+ if (str[p] === "\\" && escape) {
1318
+ if (++p === rbrace)
1319
+ break;
1320
+ }
1321
+ p++;
1322
+ }
1323
+ status = rubyBraceExpand(prefix + str.slice(t, p) + str.slice(rbrace + 1), flags, func);
1324
+ if (status)
1325
+ break;
1326
+ }
1327
+ return status;
1328
+ }
1329
+ else if (lbrace < 0 && rbrace < 0) {
1330
+ return func(str);
1331
+ }
1332
+ return false;
1333
+ }
1334
+ //# sourceMappingURL=file.js.map