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

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 (622) 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 +77 -0
  14. package/dist/backtrace-location.js +155 -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 +110 -0
  23. package/dist/big-decimal.js +582 -0
  24. package/dist/big-decimal.js.map +1 -0
  25. package/dist/bundler.d.ts +44 -0
  26. package/dist/bundler.js +101 -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 +90 -0
  38. package/dist/classpath.js +207 -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 +48 -0
  47. package/dist/complex.js +162 -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 +218 -0
  92. package/dist/dir.js +599 -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 +1100 -0
  105. package/dist/enumerable.js.map +1 -0
  106. package/dist/enumerator.d.ts +321 -0
  107. package/dist/enumerator.js +642 -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 +327 -0
  113. package/dist/errno.js +452 -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 +34 -0
  122. package/dist/exception.js +99 -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 +1823 -0
  132. package/dist/file-utils.js.map +1 -0
  133. package/dist/file.d.ts +635 -0
  134. package/dist/file.js +1312 -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 +42 -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 +64 -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 +123 -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 +2195 -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 +67 -0
  191. package/dist/json.js +185 -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 +40 -0
  215. package/dist/kernel-system.js +97 -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 +121 -0
  230. package/dist/load.js +263 -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 +215 -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 +17 -0
  257. package/dist/method-cache.js +19 -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 +14 -0
  303. package/dist/not-implemented-error.js.map +1 -0
  304. package/dist/numeric.d.ts +211 -0
  305. package/dist/numeric.js +802 -0
  306. package/dist/numeric.js.map +1 -0
  307. package/dist/object-space.d.ts +34 -0
  308. package/dist/object-space.js +152 -0
  309. package/dist/object-space.js.map +1 -0
  310. package/dist/object.d.ts +908 -0
  311. package/dist/object.js +2238 -0
  312. package/dist/object.js.map +1 -0
  313. package/dist/open-uri.d.ts +180 -0
  314. package/dist/open-uri.js +402 -0
  315. package/dist/open-uri.js.map +1 -0
  316. package/dist/open3.d.ts +69 -0
  317. package/dist/open3.js +134 -0
  318. package/dist/open3.js.map +1 -0
  319. package/dist/openssl.d.ts +479 -0
  320. package/dist/openssl.js +1052 -0
  321. package/dist/openssl.js.map +1 -0
  322. package/dist/optparse.d.ts +130 -0
  323. package/dist/optparse.js +457 -0
  324. package/dist/optparse.js.map +1 -0
  325. package/dist/os-adapter.d.ts +20 -0
  326. package/dist/os-adapter.js +95 -0
  327. package/dist/os-adapter.js.map +1 -0
  328. package/dist/pathname.d.ts +71 -0
  329. package/dist/pathname.js +394 -0
  330. package/dist/pathname.js.map +1 -0
  331. package/dist/pp.d.ts +60 -0
  332. package/dist/pp.js +195 -0
  333. package/dist/pp.js.map +1 -0
  334. package/dist/pretty-print.d.ts +89 -0
  335. package/dist/pretty-print.js +232 -0
  336. package/dist/pretty-print.js.map +1 -0
  337. package/dist/process-adapter.d.ts +224 -0
  338. package/dist/process-adapter.js +878 -0
  339. package/dist/process-adapter.js.map +1 -0
  340. package/dist/process.d.ts +192 -0
  341. package/dist/process.js +403 -0
  342. package/dist/process.js.map +1 -0
  343. package/dist/psych/class-loader.d.ts +92 -0
  344. package/dist/psych/class-loader.js +139 -0
  345. package/dist/psych/class-loader.js.map +1 -0
  346. package/dist/psych/coder.d.ts +144 -0
  347. package/dist/psych/coder.js +176 -0
  348. package/dist/psych/coder.js.map +1 -0
  349. package/dist/psych/core-ext.d.ts +8 -0
  350. package/dist/psych/core-ext.js +10 -0
  351. package/dist/psych/core-ext.js.map +1 -0
  352. package/dist/psych/emitter.d.ts +116 -0
  353. package/dist/psych/emitter.js +1130 -0
  354. package/dist/psych/emitter.js.map +1 -0
  355. package/dist/psych/exception.d.ts +43 -0
  356. package/dist/psych/exception.js +54 -0
  357. package/dist/psych/exception.js.map +1 -0
  358. package/dist/psych/handler.d.ts +59 -0
  359. package/dist/psych/handler.js +95 -0
  360. package/dist/psych/handler.js.map +1 -0
  361. package/dist/psych/handlers/document-stream.d.ts +17 -0
  362. package/dist/psych/handlers/document-stream.js +26 -0
  363. package/dist/psych/handlers/document-stream.js.map +1 -0
  364. package/dist/psych/nodes/alias.d.ts +15 -0
  365. package/dist/psych/nodes/alias.js +22 -0
  366. package/dist/psych/nodes/alias.js.map +1 -0
  367. package/dist/psych/nodes/document.d.ts +23 -0
  368. package/dist/psych/nodes/document.js +35 -0
  369. package/dist/psych/nodes/document.js.map +1 -0
  370. package/dist/psych/nodes/mapping.d.ts +25 -0
  371. package/dist/psych/nodes/mapping.js +35 -0
  372. package/dist/psych/nodes/mapping.js.map +1 -0
  373. package/dist/psych/nodes/node.d.ts +59 -0
  374. package/dist/psych/nodes/node.js +79 -0
  375. package/dist/psych/nodes/node.js.map +1 -0
  376. package/dist/psych/nodes/scalar.d.ts +35 -0
  377. package/dist/psych/nodes/scalar.js +47 -0
  378. package/dist/psych/nodes/scalar.js.map +1 -0
  379. package/dist/psych/nodes/sequence.d.ts +25 -0
  380. package/dist/psych/nodes/sequence.js +35 -0
  381. package/dist/psych/nodes/sequence.js.map +1 -0
  382. package/dist/psych/nodes/stream.d.ts +23 -0
  383. package/dist/psych/nodes/stream.js +31 -0
  384. package/dist/psych/nodes/stream.js.map +1 -0
  385. package/dist/psych/omap.d.ts +9 -0
  386. package/dist/psych/omap.js +9 -0
  387. package/dist/psych/omap.js.map +1 -0
  388. package/dist/psych/parser.d.ts +41 -0
  389. package/dist/psych/parser.js +139 -0
  390. package/dist/psych/parser.js.map +1 -0
  391. package/dist/psych/scalar-scanner.d.ts +35 -0
  392. package/dist/psych/scalar-scanner.js +173 -0
  393. package/dist/psych/scalar-scanner.js.map +1 -0
  394. package/dist/psych/syntax-error.d.ts +23 -0
  395. package/dist/psych/syntax-error.js +35 -0
  396. package/dist/psych/syntax-error.js.map +1 -0
  397. package/dist/psych/tree-builder.d.ts +51 -0
  398. package/dist/psych/tree-builder.js +118 -0
  399. package/dist/psych/tree-builder.js.map +1 -0
  400. package/dist/psych/visitors/depth-first.d.ts +27 -0
  401. package/dist/psych/visitors/depth-first.js +37 -0
  402. package/dist/psych/visitors/depth-first.js.map +1 -0
  403. package/dist/psych/visitors/emitter.d.ts +32 -0
  404. package/dist/psych/visitors/emitter.js +63 -0
  405. package/dist/psych/visitors/emitter.js.map +1 -0
  406. package/dist/psych/visitors/to-ruby.d.ts +110 -0
  407. package/dist/psych/visitors/to-ruby.js +396 -0
  408. package/dist/psych/visitors/to-ruby.js.map +1 -0
  409. package/dist/psych/visitors/visitor.d.ts +11 -0
  410. package/dist/psych/visitors/visitor.js +17 -0
  411. package/dist/psych/visitors/visitor.js.map +1 -0
  412. package/dist/psych/visitors/yaml-tree.d.ts +182 -0
  413. package/dist/psych/visitors/yaml-tree.js +593 -0
  414. package/dist/psych/visitors/yaml-tree.js.map +1 -0
  415. package/dist/psych-adapter.d.ts +65 -0
  416. package/dist/psych-adapter.js +121 -0
  417. package/dist/psych-adapter.js.map +1 -0
  418. package/dist/psych-yaml.d.ts +2 -0
  419. package/dist/psych-yaml.js +5 -0
  420. package/dist/psych-yaml.js.map +1 -0
  421. package/dist/psych.d.ts +257 -0
  422. package/dist/psych.js +332 -0
  423. package/dist/psych.js.map +1 -0
  424. package/dist/queue.d.ts +129 -0
  425. package/dist/queue.js +215 -0
  426. package/dist/queue.js.map +1 -0
  427. package/dist/racc/parser.d.ts +70 -0
  428. package/dist/racc/parser.js +206 -0
  429. package/dist/racc/parser.js.map +1 -0
  430. package/dist/range-error.d.ts +15 -0
  431. package/dist/range-error.js +15 -0
  432. package/dist/range-error.js.map +1 -0
  433. package/dist/range.d.ts +166 -0
  434. package/dist/range.js +421 -0
  435. package/dist/range.js.map +1 -0
  436. package/dist/rational.d.ts +167 -0
  437. package/dist/rational.js +379 -0
  438. package/dist/rational.js.map +1 -0
  439. package/dist/rb-config.d.ts +33 -0
  440. package/dist/rb-config.js +53 -0
  441. package/dist/rb-config.js.map +1 -0
  442. package/dist/rb-equal.d.ts +66 -0
  443. package/dist/rb-equal.js +261 -0
  444. package/dist/rb-equal.js.map +1 -0
  445. package/dist/rb-hash.d.ts +26 -0
  446. package/dist/rb-hash.js +108 -0
  447. package/dist/rb-hash.js.map +1 -0
  448. package/dist/regexp.d.ts +82 -0
  449. package/dist/regexp.js +191 -0
  450. package/dist/regexp.js.map +1 -0
  451. package/dist/repl-adapter.d.ts +188 -0
  452. package/dist/repl-adapter.js +388 -0
  453. package/dist/repl-adapter.js.map +1 -0
  454. package/dist/resolv.d.ts +30 -0
  455. package/dist/resolv.js +48 -0
  456. package/dist/resolv.js.map +1 -0
  457. package/dist/ruby-empty.d.ts +28 -0
  458. package/dist/ruby-empty.js +40 -0
  459. package/dist/ruby-empty.js.map +1 -0
  460. package/dist/ruby-platform.d.ts +39 -0
  461. package/dist/ruby-platform.js +49 -0
  462. package/dist/ruby-platform.js.map +1 -0
  463. package/dist/runtime-error.d.ts +15 -0
  464. package/dist/runtime-error.js +16 -0
  465. package/dist/runtime-error.js.map +1 -0
  466. package/dist/scheduled-task.d.ts +73 -0
  467. package/dist/scheduled-task.js +150 -0
  468. package/dist/scheduled-task.js.map +1 -0
  469. package/dist/secure-random.d.ts +33 -0
  470. package/dist/secure-random.js +78 -0
  471. package/dist/secure-random.js.map +1 -0
  472. package/dist/set.d.ts +158 -0
  473. package/dist/set.js +352 -0
  474. package/dist/set.js.map +1 -0
  475. package/dist/shellwords.d.ts +27 -0
  476. package/dist/shellwords.js +53 -0
  477. package/dist/shellwords.js.map +1 -0
  478. package/dist/signal-exception.d.ts +21 -0
  479. package/dist/signal-exception.js +21 -0
  480. package/dist/signal-exception.js.map +1 -0
  481. package/dist/socket.d.ts +230 -0
  482. package/dist/socket.js +484 -0
  483. package/dist/socket.js.map +1 -0
  484. package/dist/standard-error.d.ts +18 -0
  485. package/dist/standard-error.js +23 -0
  486. package/dist/standard-error.js.map +1 -0
  487. package/dist/stop-iteration.d.ts +10 -0
  488. package/dist/stop-iteration.js +10 -0
  489. package/dist/stop-iteration.js.map +1 -0
  490. package/dist/string/b.d.ts +19 -0
  491. package/dist/string/b.js +28 -0
  492. package/dist/string/b.js.map +1 -0
  493. package/dist/string/byte-methods.d.ts +57 -0
  494. package/dist/string/byte-methods.js +266 -0
  495. package/dist/string/byte-methods.js.map +1 -0
  496. package/dist/string/bytes.d.ts +35 -0
  497. package/dist/string/bytes.js +123 -0
  498. package/dist/string/bytes.js.map +1 -0
  499. package/dist/string/case-mapping.d.ts +57 -0
  500. package/dist/string/case-mapping.js +192 -0
  501. package/dist/string/case-mapping.js.map +1 -0
  502. package/dist/string/chomp.d.ts +15 -0
  503. package/dist/string/chomp.js +32 -0
  504. package/dist/string/chomp.js.map +1 -0
  505. package/dist/string/convert.d.ts +55 -0
  506. package/dist/string/convert.js +316 -0
  507. package/dist/string/convert.js.map +1 -0
  508. package/dist/string/delete.d.ts +14 -0
  509. package/dist/string/delete.js +17 -0
  510. package/dist/string/delete.js.map +1 -0
  511. package/dist/string/each.d.ts +108 -0
  512. package/dist/string/each.js +305 -0
  513. package/dist/string/each.js.map +1 -0
  514. package/dist/string/encode.d.ts +37 -0
  515. package/dist/string/encode.js +268 -0
  516. package/dist/string/encode.js.map +1 -0
  517. package/dist/string/force-encoding.d.ts +72 -0
  518. package/dist/string/force-encoding.js +147 -0
  519. package/dist/string/force-encoding.js.map +1 -0
  520. package/dist/string/inspect.d.ts +17 -0
  521. package/dist/string/inspect.js +81 -0
  522. package/dist/string/inspect.js.map +1 -0
  523. package/dist/string/method-table.d.ts +174 -0
  524. package/dist/string/method-table.js +805 -0
  525. package/dist/string/method-table.js.map +1 -0
  526. package/dist/string/scrub.d.ts +12 -0
  527. package/dist/string/scrub.js +33 -0
  528. package/dist/string/scrub.js.map +1 -0
  529. package/dist/string/slice.d.ts +26 -0
  530. package/dist/string/slice.js +73 -0
  531. package/dist/string/slice.js.map +1 -0
  532. package/dist/string/split.d.ts +11 -0
  533. package/dist/string/split.js +44 -0
  534. package/dist/string/split.js.map +1 -0
  535. package/dist/string/sub.d.ts +114 -0
  536. package/dist/string/sub.js +371 -0
  537. package/dist/string/sub.js.map +1 -0
  538. package/dist/string/succ.d.ts +14 -0
  539. package/dist/string/succ.js +118 -0
  540. package/dist/string/succ.js.map +1 -0
  541. package/dist/string/support.d.ts +135 -0
  542. package/dist/string/support.js +283 -0
  543. package/dist/string/support.js.map +1 -0
  544. package/dist/string/tr.d.ts +46 -0
  545. package/dist/string/tr.js +156 -0
  546. package/dist/string/tr.js.map +1 -0
  547. package/dist/string-io.d.ts +166 -0
  548. package/dist/string-io.js +248 -0
  549. package/dist/string-io.js.map +1 -0
  550. package/dist/string-scanner.d.ts +133 -0
  551. package/dist/string-scanner.js +248 -0
  552. package/dist/string-scanner.js.map +1 -0
  553. package/dist/struct.d.ts +54 -0
  554. package/dist/struct.js +222 -0
  555. package/dist/struct.js.map +1 -0
  556. package/dist/symbol.d.ts +48 -0
  557. package/dist/symbol.js +107 -0
  558. package/dist/symbol.js.map +1 -0
  559. package/dist/tempfile.d.ts +173 -0
  560. package/dist/tempfile.js +290 -0
  561. package/dist/tempfile.js.map +1 -0
  562. package/dist/temporal-tag.d.ts +23 -0
  563. package/dist/temporal-tag.js +29 -0
  564. package/dist/temporal-tag.js.map +1 -0
  565. package/dist/thread-error.d.ts +13 -0
  566. package/dist/thread-error.js +13 -0
  567. package/dist/thread-error.js.map +1 -0
  568. package/dist/thread-pool-executor.d.ts +119 -0
  569. package/dist/thread-pool-executor.js +250 -0
  570. package/dist/thread-pool-executor.js.map +1 -0
  571. package/dist/thread.d.ts +211 -0
  572. package/dist/thread.js +495 -0
  573. package/dist/thread.js.map +1 -0
  574. package/dist/timeout.d.ts +29 -0
  575. package/dist/timeout.js +41 -0
  576. package/dist/timeout.js.map +1 -0
  577. package/dist/tse.d.ts +40 -0
  578. package/dist/tse.js +62 -0
  579. package/dist/tse.js.map +1 -0
  580. package/dist/type-error.d.ts +14 -0
  581. package/dist/type-error.js +15 -0
  582. package/dist/type-error.js.map +1 -0
  583. package/dist/undefined-conversion-error.d.ts +10 -0
  584. package/dist/undefined-conversion-error.js +10 -0
  585. package/dist/undefined-conversion-error.js.map +1 -0
  586. package/dist/uri/common.d.ts +209 -0
  587. package/dist/uri/common.js +369 -0
  588. package/dist/uri/common.js.map +1 -0
  589. package/dist/uri/generic.d.ts +283 -0
  590. package/dist/uri/generic.js +810 -0
  591. package/dist/uri/generic.js.map +1 -0
  592. package/dist/uri/http.d.ts +23 -0
  593. package/dist/uri/http.js +30 -0
  594. package/dist/uri/http.js.map +1 -0
  595. package/dist/uri/https.d.ts +13 -0
  596. package/dist/uri/https.js +15 -0
  597. package/dist/uri/https.js.map +1 -0
  598. package/dist/uri/rfc2396-parser.d.ts +70 -0
  599. package/dist/uri/rfc2396-parser.js +264 -0
  600. package/dist/uri/rfc2396-parser.js.map +1 -0
  601. package/dist/uri/rfc3986-parser.d.ts +46 -0
  602. package/dist/uri/rfc3986-parser.js +171 -0
  603. package/dist/uri/rfc3986-parser.js.map +1 -0
  604. package/dist/uri.d.ts +13 -0
  605. package/dist/uri.js +13 -0
  606. package/dist/uri.js.map +1 -0
  607. package/dist/variable.d.ts +183 -0
  608. package/dist/variable.js +463 -0
  609. package/dist/variable.js.map +1 -0
  610. package/dist/verbose.d.ts +21 -0
  611. package/dist/verbose.js +26 -0
  612. package/dist/verbose.js.map +1 -0
  613. package/dist/yaml.d.ts +9 -0
  614. package/dist/yaml.js +9 -0
  615. package/dist/yaml.js.map +1 -0
  616. package/dist/zlib-adapter.d.ts +117 -0
  617. package/dist/zlib-adapter.js +250 -0
  618. package/dist/zlib-adapter.js.map +1 -0
  619. package/dist/zlib.d.ts +248 -0
  620. package/dist/zlib.js +362 -0
  621. package/dist/zlib.js.map +1 -0
  622. package/package.json +82 -3
@@ -0,0 +1,802 @@
1
+ import { ArgumentError } from "./argument-error.js";
2
+ import { Complex } from "./complex.js";
3
+ import { FloatDomainError } from "./float-domain-error.js";
4
+ import { NameError } from "./name-error.js";
5
+ import { NilClass } from "./nil-class.js";
6
+ import { NoMethodError } from "./no-method-error.js";
7
+ import { rbBuiltinClassName, rbInspect, rbObjClassname, toS } from "./object.js";
8
+ import { Rational, ZeroDivisionError } from "./rational.js";
9
+ import { TypeError } from "./type-error.js";
10
+ import { rbStrToF, rbStrToI } from "./string/convert.js";
11
+ import { isSymbol } from "./symbol.js";
12
+ /** @noRailsEquivalent PERMANENT — Ruby core `Float#round` (`vendor/ruby/v3.3.11/numeric.c:2505`). */
13
+ export function round(x, ndigits = 0) {
14
+ if (typeof x !== "number" && !(x instanceof Number))
15
+ return x.round(ndigits);
16
+ const number = x.valueOf();
17
+ if (number === 0)
18
+ return ndigits > 0 ? x : 0;
19
+ if (ndigits < 0)
20
+ return intRound(Number(toI(number)), ndigits);
21
+ if (ndigits === 0)
22
+ return roundHalfUp(number, 1);
23
+ if (!rbFloatTypeP(x))
24
+ return number;
25
+ if (Number.isFinite(number)) {
26
+ const binexp = frexp(number);
27
+ if (floatRoundOverflow(ndigits, binexp))
28
+ return x;
29
+ if (floatRoundUnderflow(ndigits, binexp))
30
+ return rbDbl2num(0);
31
+ if (ndigits > 14)
32
+ return rbDbl2num(floRoundByRational(number, ndigits));
33
+ const f = 10 ** ndigits;
34
+ return rbDbl2num(roundHalfUp(number, f) / f);
35
+ }
36
+ return x;
37
+ }
38
+ function roundHalfUp(x, s) {
39
+ const xs = x * s;
40
+ let f = Math.sign(xs) * Math.round(Math.abs(xs));
41
+ if (s === 1)
42
+ return f;
43
+ if (x > 0) {
44
+ if ((f + 0.5) / s <= x)
45
+ f += 1;
46
+ }
47
+ else if ((f - 0.5) / s >= x) {
48
+ f -= 1;
49
+ }
50
+ return f;
51
+ }
52
+ function intRound(num, ndigits) {
53
+ const f = 10 ** -ndigits;
54
+ if (!Number.isFinite(f))
55
+ return 0;
56
+ const x = Math.abs(num);
57
+ return Math.sign(num) * Math.floor((x + f / 2) / f) * f + 0;
58
+ }
59
+ function frexp(number) {
60
+ let binexp = Math.floor(Math.log2(Math.abs(number))) + 1;
61
+ while (Math.abs(number) >= 2 ** binexp)
62
+ binexp += 1;
63
+ while (Math.abs(number) < 2 ** (binexp - 1))
64
+ binexp -= 1;
65
+ return binexp;
66
+ }
67
+ function floatRoundOverflow(ndigits, binexp) {
68
+ const floatDig = FLOAT_DIG + 2;
69
+ return ndigits >= floatDig - (binexp > 0 ? Math.trunc(binexp / 4) : Math.trunc(binexp / 3) - 1);
70
+ }
71
+ function floatRoundUnderflow(ndigits, binexp) {
72
+ return ndigits < -(binexp > 0 ? Math.trunc(binexp / 3) + 1 : Math.trunc(binexp / 4));
73
+ }
74
+ function floRoundByRational(number, ndigits) {
75
+ const r = new Rational(number, 1);
76
+ const num = r.numerator * 10n ** BigInt(ndigits);
77
+ const abs = num < 0n ? -num : num;
78
+ const q = (2n * abs + r.denominator) / (2n * r.denominator);
79
+ return Number(`${num < 0n ? "-" : ""}${q}e-${ndigits}`);
80
+ }
81
+ /**
82
+ * Ruby `Integer#/` over two Fixnums (`vendor/ruby/v3.3.11/numeric.c:4164`
83
+ * `fix_divide`, the `FIXNUM_P(y)` arm): `rb_num_zerodiv` for a zero divisor,
84
+ * else `rb_fix_div_fix` (`vendor/ruby/v3.3.11/internal/fixnum.h:149`), which
85
+ * floors where JS `/` answers a fraction.
86
+ * @noRailsEquivalent PERMANENT — Ruby core `Integer#/` (`vendor/ruby/v3.3.11/numeric.c:4164`).
87
+ */
88
+ export function fixDiv(x, y) {
89
+ if (y === 0)
90
+ throw new ZeroDivisionError("divided by 0");
91
+ return Math.floor(x / y) + 0;
92
+ }
93
+ /**
94
+ * Ruby `Integer#%` over two Fixnums (`vendor/ruby/v3.3.11/numeric.c:4268`
95
+ * `fix_mod`, the `FIXNUM_P(y)` arm): `rb_num_zerodiv` for a zero divisor,
96
+ * else `rb_fix_mod_fix` (`vendor/ruby/v3.3.11/internal/fixnum.h:160`), whose
97
+ * result takes the divisor's sign where JS `%` takes the dividend's.
98
+ * @noRailsEquivalent PERMANENT — Ruby core `Integer#%` (`vendor/ruby/v3.3.11/numeric.c:4268`).
99
+ */
100
+ export function fixMod(x, y) {
101
+ if (y === 0)
102
+ throw new ZeroDivisionError("divided by 0");
103
+ const mod = x % y;
104
+ if (mod === 0)
105
+ return 0;
106
+ return mod < 0 !== y < 0 ? mod + y : mod;
107
+ }
108
+ /**
109
+ * Ruby `Integer#anybits?` (`vendor/ruby/v3.3.11/numeric.c:3647` `int_anybits_p`):
110
+ * whether any of `mask`'s set bits are set in `self`.
111
+ *
112
+ * Taken over BigInt rather than JS `&`, which truncates both operands to signed
113
+ * 32 bits: `rb_int_and` is arbitrary-precision, so `(2**40).anybits?(2**40)` is
114
+ * true in Ruby and false under `&`. BigInt's bitwise operators read a value as
115
+ * two's complement of unbounded width, which is the notation
116
+ * `vendor/ruby/v3.3.11/spec/ruby/core/integer/anybits_spec.rb:15-20` pins for negative
117
+ * receivers and the bignum cases at `:9-12`.
118
+ *
119
+ * @noRailsEquivalent PERMANENT — Ruby core `Integer#anybits?` (`vendor/ruby/v3.3.11/numeric.c:3647`).
120
+ */
121
+ export function anybits(x, mask) {
122
+ return (BigInt(x) & BigInt(mask)) !== 0n;
123
+ }
124
+ /**
125
+ * Ruby's `obj.to_i` send, dispatched on the receiver's class: `NilClass#to_i`
126
+ * (`vendor/ruby/v3.3.11/object.c:4414`), `Integer#to_i` (`vendor/ruby/v3.3.11/numeric.c`
127
+ * `int_to_i`), `Float#to_i` (`flo_to_i`, `FloatDomainError` off the finite
128
+ * range; `dbl2ival`'s Bignum arm, `vendor/ruby/v3.3.11/numeric.c:1436-1442`,
129
+ * past the safe-integer range), `String#to_i` (`rb_str_to_i`, {@link rbStrToI}), else the
130
+ * receiver's own `toI`. A Symbol has no `to_i` (`vendor/ruby/v3.3.11/string.c`
131
+ * defines none on `rb_cSymbol`), so a colon-prefixed string raises.
132
+ *
133
+ * @noRailsEquivalent PERMANENT — a Ruby method send, which JS has no receiver
134
+ * for on a primitive.
135
+ */
136
+ export function toI(obj) {
137
+ if (obj == null)
138
+ return NilClass.toI();
139
+ if (typeof obj === "bigint")
140
+ return obj;
141
+ if (typeof obj === "number" || obj instanceof Number) {
142
+ if (!Number.isFinite(obj.valueOf()))
143
+ throw new FloatDomainError(String(obj));
144
+ const f = Math.trunc(obj.valueOf()) + 0;
145
+ return Number.isSafeInteger(f) ? f : BigInt(f);
146
+ }
147
+ if (isSymbol(obj))
148
+ throw new NoMethodError("undefined method 'to_i' for an instance of Symbol");
149
+ if (typeof obj === "string")
150
+ return rbStrToI(obj);
151
+ if (typeof obj.toI === "function") {
152
+ return obj.toI();
153
+ }
154
+ throw new NoMethodError(`undefined method 'to_i' for an instance of ${rbObjClassname(obj)}`);
155
+ }
156
+ /**
157
+ * Ruby's `obj.to_f` send, dispatched on the receiver's class: `NilClass#to_f`
158
+ * (`vendor/ruby/v3.3.11/nilclass.rb:22`), `Float#to_f`
159
+ * (`vendor/ruby/v3.3.11/numeric.rb:312`), `Integer#to_f`
160
+ * (`vendor/ruby/v3.3.11/numeric.c:5356` `int_to_f`), `String#to_f`
161
+ * (`vendor/ruby/v3.3.11/string.c:6633` `rb_str_to_f`, {@link rbStrToF}), else the
162
+ * receiver's own `toF`. The answer is a Float, so it is seated by
163
+ * {@link rbDbl2num}.
164
+ *
165
+ * @noRailsEquivalent PERMANENT
166
+ */
167
+ export function toF(obj) {
168
+ if (obj == null)
169
+ return rbDbl2num(NilClass.toF());
170
+ if (obj instanceof Number)
171
+ return obj;
172
+ if (typeof obj === "number" || typeof obj === "bigint")
173
+ return rbDbl2num(Number(obj));
174
+ if (isSymbol(obj))
175
+ throw new NoMethodError("undefined method 'to_f' for an instance of Symbol");
176
+ if (typeof obj === "string")
177
+ return rbDbl2num(rbStrToF(obj));
178
+ if (typeof obj.toF === "function") {
179
+ return rbDbl2num(obj.toF());
180
+ }
181
+ throw new NoMethodError(`undefined method 'to_f' for an instance of ${rbObjClassname(obj)}`);
182
+ }
183
+ /**
184
+ * Ruby's `obj.nan?` send: `Float#nan?` (`vendor/ruby/v3.3.11/numeric.c:1961`
185
+ * `flo_is_nan_p`) over the `number` seat, else the receiver's own `isNan`
186
+ * (`BigDecimal#nan?`, `vendor/ruby/v3.3.11/ext/bigdecimal/bigdecimal.c:1208`).
187
+ *
188
+ * @noRailsEquivalent PERMANENT
189
+ */
190
+ export function isNan(obj) {
191
+ if (typeof obj === "number" || obj instanceof Number)
192
+ return Number.isNaN(obj.valueOf());
193
+ if (typeof obj?.isNan === "function") {
194
+ return obj.isNan();
195
+ }
196
+ throw new NoMethodError(`undefined method 'nan?' for an instance of ${rbObjClassname(obj)}`);
197
+ }
198
+ /**
199
+ * Ruby's `obj.finite?` send: `Float#finite?` (`vendor/ruby/v3.3.11/numeric.c:2022`
200
+ * `rb_flo_is_finite_p`) over the `number` seat, `Numeric#finite?`
201
+ * (`vendor/ruby/v3.3.11/numeric.rb:38`) for an Integer, else the receiver's own `isFinite`
202
+ * (`BigDecimal#finite?`, `vendor/ruby/v3.3.11/ext/bigdecimal/bigdecimal.c:1229`).
203
+ *
204
+ * @noRailsEquivalent PERMANENT
205
+ */
206
+ export function isFinite(obj) {
207
+ if (typeof obj === "number" || obj instanceof Number)
208
+ return Number.isFinite(obj.valueOf());
209
+ if (typeof obj === "bigint")
210
+ return true;
211
+ if (typeof obj?.isFinite === "function") {
212
+ return obj.isFinite();
213
+ }
214
+ throw new NoMethodError(`undefined method 'finite?' for an instance of ${rbObjClassname(obj)}`);
215
+ }
216
+ /**
217
+ * `RB_FLOAT_TYPE_P` (`vendor/ruby/v3.3.11/include/ruby/internal/value_type.h:263`)
218
+ * over the Float seats `rbObjClassname` reads: a fractional `number`, or a boxed one.
219
+ * @noRailsEquivalent PERMANENT
220
+ */
221
+ export function rbFloatTypeP(x) {
222
+ return x instanceof Number || (typeof x === "number" && !Number.isInteger(x));
223
+ }
224
+ /**
225
+ * `DBL2NUM` (`vendor/ruby/v3.3.11/include/ruby/internal/arithmetic/double.h:29`), boxed when whole-valued.
226
+ * @noRailsEquivalent PERMANENT
227
+ */
228
+ export function rbDbl2num(d) {
229
+ return (Number.isInteger(d) ? new Number(d) : d);
230
+ }
231
+ /**
232
+ * `RB_INTEGER_TYPE_P` (`vendor/ruby/v3.3.11/include/ruby/internal/value_type.h:94`).
233
+ * @noRailsEquivalent PERMANENT
234
+ */
235
+ export function rbIntegerTypeP(x) {
236
+ return typeof x === "bigint" || (typeof x === "number" && Number.isInteger(x));
237
+ }
238
+ /**
239
+ * `rb_big_norm` (`vendor/ruby/v3.3.11/bignum.c:3188`).
240
+ * @noRailsEquivalent PERMANENT
241
+ */
242
+ export function rbBigNorm(x) {
243
+ return Number.isSafeInteger(Number(x)) ? Number(x) : x;
244
+ }
245
+ /**
246
+ * `fix_mul` (`vendor/ruby/v3.3.11/numeric.c:4045`), `rb_float_mul` (`numeric.c:1237`),
247
+ * `rb_rational_mul` (`vendor/ruby/v3.3.11/rational.c:861`).
248
+ * @noRailsEquivalent PERMANENT
249
+ */
250
+ export function numericMul(x, y) {
251
+ if (rbFloatTypeP(x)) {
252
+ if (rbIntegerTypeP(y) || rbFloatTypeP(y))
253
+ return rbDbl2num(x.valueOf() * Number(y.valueOf()));
254
+ if (y instanceof Rational)
255
+ return rbDbl2num(x.valueOf() * y.toF());
256
+ }
257
+ else if (x instanceof Rational) {
258
+ if (rbIntegerTypeP(y))
259
+ return x.mul(y);
260
+ if (rbFloatTypeP(y))
261
+ return rbDbl2num(x.toF() * y.valueOf());
262
+ }
263
+ else if (rbIntegerTypeP(x)) {
264
+ if (rbIntegerTypeP(y)) {
265
+ if (typeof x === "number" && typeof y === "number" && Number.isSafeInteger(x * y)) {
266
+ return x * y;
267
+ }
268
+ return rbBigNorm(BigInt(x) * BigInt(y));
269
+ }
270
+ if (rbFloatTypeP(y))
271
+ return rbDbl2num(Number(x) * y.valueOf());
272
+ if (y instanceof Rational)
273
+ return y.mul(x);
274
+ }
275
+ throw new TypeError(`${rbBuiltinClassName(y)} can't be coerced into ${rbObjClassname(x)}`);
276
+ }
277
+ /**
278
+ * `fix_minus` (`vendor/ruby/v3.3.11/numeric.c:3995`), `rb_float_minus` (`numeric.c:1207`),
279
+ * `rb_rational_minus` (`vendor/ruby/v3.3.11/rational.c:765`).
280
+ * @noRailsEquivalent PERMANENT
281
+ */
282
+ export function numericMinus(x, y) {
283
+ if (rbFloatTypeP(x)) {
284
+ if (rbIntegerTypeP(y) || rbFloatTypeP(y))
285
+ return rbDbl2num(x.valueOf() - Number(y.valueOf()));
286
+ if (y instanceof Rational)
287
+ return rbDbl2num(x.valueOf() - y.toF());
288
+ }
289
+ else if (x instanceof Rational) {
290
+ if (rbIntegerTypeP(y))
291
+ return x.add(-BigInt(y));
292
+ if (rbFloatTypeP(y))
293
+ return rbDbl2num(x.toF() - y.valueOf());
294
+ if (y instanceof Rational)
295
+ return x.add(new Rational(-y.numerator, y.denominator));
296
+ }
297
+ else if (rbIntegerTypeP(x)) {
298
+ if (rbIntegerTypeP(y)) {
299
+ if (typeof x === "number" && typeof y === "number" && Number.isSafeInteger(x - y)) {
300
+ return x - y;
301
+ }
302
+ return rbBigNorm(BigInt(x) - BigInt(y));
303
+ }
304
+ if (rbFloatTypeP(y))
305
+ return rbDbl2num(Number(x) - y.valueOf());
306
+ if (y instanceof Rational)
307
+ return new Rational(x, 1).add(new Rational(-y.numerator, y.denominator));
308
+ }
309
+ else {
310
+ throw new NoMethodError(`undefined method '-' for an instance of ${rbObjClassname(x)}`);
311
+ }
312
+ throw new TypeError(`${rbBuiltinClassName(y)} can't be coerced into ${rbObjClassname(x)}`);
313
+ }
314
+ /**
315
+ * `Integer#/` (`vendor/ruby/v3.3.11/numeric.c:4220` `rb_int_div`, `fix_divide`
316
+ * at `:4164`) and `Float#/` (`numeric.c:1292` `rb_float_div`): two Integers
317
+ * floor (`rb_fix_div_fix`, a Bignum through `rb_big_div`), and a Float on either
318
+ * side divides as doubles (`rb_flo_div_flo`), answering a Float.
319
+ * @noRailsEquivalent PERMANENT
320
+ */
321
+ export function numericDiv(x, y) {
322
+ if (rbIntegerTypeP(x) && rbIntegerTypeP(y)) {
323
+ if (typeof x === "number" && typeof y === "number")
324
+ return fixDiv(x, y);
325
+ const a = BigInt(x);
326
+ const b = BigInt(y);
327
+ if (b === 0n)
328
+ throw new ZeroDivisionError("divided by 0");
329
+ const q = a / b;
330
+ return rbBigNorm(a % b !== 0n && a < 0n !== b < 0n ? q - 1n : q);
331
+ }
332
+ if ((rbIntegerTypeP(x) || rbFloatTypeP(x)) && (rbIntegerTypeP(y) || rbFloatTypeP(y)))
333
+ return rbDbl2num(Number(x.valueOf()) / Number(y.valueOf()));
334
+ throw new NoMethodError(`undefined method '/' for an instance of ${rbObjClassname(x)}`);
335
+ }
336
+ /**
337
+ * `Integer#-@` (`vendor/ruby/v3.3.11/numeric.c:3833` `rb_int_uminus`) and
338
+ * `Float#-@` (`numeric.c:1156` `rb_float_uminus`): a Float stays a Float.
339
+ * @noRailsEquivalent PERMANENT
340
+ */
341
+ export function numericUminus(x) {
342
+ if (rbFloatTypeP(x))
343
+ return rbDbl2num(-x.valueOf());
344
+ if (typeof x === "bigint")
345
+ return rbBigNorm(-x);
346
+ if (rbIntegerTypeP(x))
347
+ return x === 0 ? 0 : -x;
348
+ throw new NoMethodError(`undefined method '-@' for an instance of ${rbObjClassname(x)}`);
349
+ }
350
+ /**
351
+ * `Integer#abs` (`vendor/ruby/v3.3.11/numeric.c:5384` `rb_int_abs`) and
352
+ * `Float#abs` (`numeric.c:1942` `rb_float_abs`): a Float stays a Float.
353
+ * @noRailsEquivalent PERMANENT
354
+ */
355
+ export function numericAbs(x) {
356
+ if (rbFloatTypeP(x))
357
+ return rbDbl2num(Math.abs(x.valueOf()));
358
+ if (typeof x === "bigint")
359
+ return x < 0n ? -x : x;
360
+ if (rbIntegerTypeP(x))
361
+ return Math.abs(x);
362
+ throw new NoMethodError(`undefined method 'abs' for an instance of ${rbObjClassname(x)}`);
363
+ }
364
+ /**
365
+ * `fix_mod` (`vendor/ruby/v3.3.11/numeric.c:4268`), `flo_mod` (`numeric.c:1416`),
366
+ * `num_modulo` (`numeric.c:700`) for a Rational: the result takes the divisor's sign.
367
+ * @noRailsEquivalent PERMANENT
368
+ */
369
+ export function numericModulo(x, y) {
370
+ if (x instanceof Rational || y instanceof Rational) {
371
+ if (rbFloatTypeP(x) || rbFloatTypeP(y)) {
372
+ return numericModulo(rbDbl2num(toF(x)), rbDbl2num(toF(y)));
373
+ }
374
+ if (rbIntegerTypeP(x) && y instanceof Rational)
375
+ return new Rational(x, 1).mod(y);
376
+ if (x instanceof Rational && (rbIntegerTypeP(y) || y instanceof Rational))
377
+ return x.mod(y);
378
+ }
379
+ else if (rbIntegerTypeP(x) && rbIntegerTypeP(y)) {
380
+ if (typeof x === "number" && typeof y === "number")
381
+ return fixMod(x, y);
382
+ const b = BigInt(y);
383
+ if (b === 0n)
384
+ throw new ZeroDivisionError("divided by 0");
385
+ const mod = BigInt(x) % b;
386
+ return rbBigNorm(mod !== 0n && mod < 0n !== b < 0n ? mod + b : mod);
387
+ }
388
+ else if ((rbIntegerTypeP(x) || rbFloatTypeP(x)) && (rbIntegerTypeP(y) || rbFloatTypeP(y))) {
389
+ const fx = Number(x.valueOf());
390
+ const fy = Number(y.valueOf());
391
+ if (fy === 0)
392
+ throw new ZeroDivisionError("divided by 0");
393
+ const mod = fx % fy;
394
+ return rbDbl2num(fy * mod < 0 ? mod + fy : mod);
395
+ }
396
+ throw new TypeError(`${rbBuiltinClassName(y)} can't be coerced into ${rbObjClassname(x)}`);
397
+ }
398
+ /** `rb_dbl_complex_new_polar_pi` (`vendor/ruby/v3.3.11/complex.c:702`). */
399
+ function rbDblComplexNewPolarPi(abs, ang) {
400
+ let fi = Math.trunc(ang);
401
+ const fr = ang - fi;
402
+ const pos = fr === 0.5;
403
+ if (pos || fr === -0.5) {
404
+ const half = fi / 2.0;
405
+ if ((half - Math.trunc(half) !== fr) !== pos)
406
+ abs = -abs;
407
+ return new Complex(rbDbl2num(0.0), rbDbl2num(abs));
408
+ }
409
+ else if (fr === 0.0) {
410
+ fi = fi / 2.0;
411
+ if (fi - Math.trunc(fi) !== 0.0)
412
+ abs = -abs;
413
+ return rbDbl2num(abs);
414
+ }
415
+ else {
416
+ const real = abs * Math.cos(Math.PI * ang);
417
+ const imag = abs * Math.sin(Math.PI * ang);
418
+ return new Complex(rbDbl2num(real), rbDbl2num(imag));
419
+ }
420
+ }
421
+ /** `rb_rational_pow` (`vendor/ruby/v3.3.11/rational.c:980`). */
422
+ function rbRationalPow(self, other) {
423
+ if ((rbIntegerTypeP(other) && BigInt(other) === 0n) ||
424
+ (other instanceof Rational && other.numerator === 0n)) {
425
+ return new Rational(1, 1);
426
+ }
427
+ if (other instanceof Rational) {
428
+ if (other.denominator === 1n)
429
+ other = rbBigNorm(other.numerator);
430
+ }
431
+ if (rbIntegerTypeP(other)) {
432
+ if (self.denominator === 1n) {
433
+ if (self.numerator === 1n) {
434
+ return new Rational(1, 1);
435
+ }
436
+ else if (self.numerator === -1n) {
437
+ return new Rational(BigInt(other) % 2n ? -1 : 1, 1);
438
+ }
439
+ else if (self.numerator === 0n) {
440
+ if (BigInt(other) < 0n) {
441
+ throw new ZeroDivisionError("divided by 0");
442
+ }
443
+ else {
444
+ return new Rational(0, 1);
445
+ }
446
+ }
447
+ }
448
+ const n = BigInt(other);
449
+ if (n > 0n) {
450
+ return new Rational(self.numerator ** n, self.denominator ** n);
451
+ }
452
+ else if (n < 0n) {
453
+ return new Rational(self.denominator ** -n, self.numerator ** -n);
454
+ }
455
+ else {
456
+ return new Rational(1, 1);
457
+ }
458
+ }
459
+ else if (rbFloatTypeP(other) || other instanceof Rational) {
460
+ return numericPow(rbDbl2num(self.toF()), other);
461
+ }
462
+ throw new TypeError(`${rbBuiltinClassName(other)} can't be coerced into Rational`);
463
+ }
464
+ /**
465
+ * `fix_pow` (`vendor/ruby/v3.3.11/numeric.c:4521`), whose negative Integer exponent
466
+ * is `fix_pow_inverted`'s Rational (`numeric.c:4501`), and `rb_float_pow`
467
+ * (`numeric.c:1510`). C's `pow` answers 1.0 for a base of 1.0 or an exponent of
468
+ * 0.0 whatever the other operand, where `Math.pow` answers NaN for a NaN one.
469
+ * @noRailsEquivalent PERMANENT
470
+ */
471
+ export function numericPow(x, y) {
472
+ if (rbIntegerTypeP(x) && rbIntegerTypeP(y)) {
473
+ const a = BigInt(x);
474
+ const b = BigInt(y);
475
+ if (a === 1n)
476
+ return 1;
477
+ if (a === -1n)
478
+ return b % 2n ? -1 : 1;
479
+ if (b < 0n) {
480
+ if (a === 0n)
481
+ throw new ZeroDivisionError("divided by 0");
482
+ return new Rational(1n, a ** -b);
483
+ }
484
+ return rbBigNorm(a ** b);
485
+ }
486
+ if (rbIntegerTypeP(x) && rbFloatTypeP(y)) {
487
+ const a = Number(x);
488
+ const dy = y.valueOf();
489
+ if (dy === 0.0)
490
+ return rbDbl2num(1.0);
491
+ if (a === 0)
492
+ return rbDbl2num(dy < 0 ? Infinity : 0.0);
493
+ if (a === 1)
494
+ return rbDbl2num(1.0);
495
+ if (a < 0 && dy !== Math.round(dy))
496
+ return rbDblComplexNewPolarPi(Math.pow(-a, dy), dy);
497
+ return rbDbl2num(Math.pow(a, dy));
498
+ }
499
+ if (x instanceof Rational)
500
+ return rbRationalPow(x, y);
501
+ if (rbIntegerTypeP(x) && y instanceof Rational)
502
+ return rbRationalPow(new Rational(x, 1), y);
503
+ if (rbFloatTypeP(x) && (rbIntegerTypeP(y) || rbFloatTypeP(y) || y instanceof Rational)) {
504
+ const dx = x.valueOf();
505
+ if (y === 2)
506
+ return rbDbl2num(dx * dx);
507
+ const dy = y instanceof Rational ? y.toF() : Number(y.valueOf());
508
+ if (!rbIntegerTypeP(y) && dx < 0 && dy !== Math.round(dy)) {
509
+ return rbDblComplexNewPolarPi(Math.pow(-dx, dy), dy);
510
+ }
511
+ if (dx === 1 || dy === 0)
512
+ return rbDbl2num(1.0);
513
+ return rbDbl2num(Math.pow(dx, dy));
514
+ }
515
+ throw new TypeError(`${rbBuiltinClassName(y)} can't be coerced into ${rbObjClassname(x)}`);
516
+ }
517
+ /**
518
+ * `fix_plus` (`vendor/ruby/v3.3.11/numeric.c:3942`), `rb_float_plus` (`numeric.c:1176`),
519
+ * `rb_rational_plus` (`vendor/ruby/v3.3.11/rational.c:724`), else `rb_num_coerce_bin`.
520
+ * @noRailsEquivalent PERMANENT
521
+ */
522
+ export function numericPlus(x, y) {
523
+ if (rbFloatTypeP(x)) {
524
+ if (rbIntegerTypeP(y) || rbFloatTypeP(y))
525
+ return rbDbl2num(x.valueOf() + Number(y.valueOf()));
526
+ }
527
+ else if (x instanceof Rational) {
528
+ if (rbIntegerTypeP(y))
529
+ return x.add(y);
530
+ if (rbFloatTypeP(y))
531
+ return rbDbl2num(x.toF() + y.valueOf());
532
+ if (y instanceof Rational)
533
+ return x.add(y);
534
+ }
535
+ else if (rbIntegerTypeP(x)) {
536
+ if (rbIntegerTypeP(y)) {
537
+ if (typeof x === "number" && typeof y === "number" && Number.isSafeInteger(x + y)) {
538
+ return x + y;
539
+ }
540
+ return rbBigNorm(BigInt(x) + BigInt(y));
541
+ }
542
+ if (rbFloatTypeP(y))
543
+ return rbDbl2num(Number(x) + y.valueOf());
544
+ if (y instanceof Complex)
545
+ return y.plus(x);
546
+ }
547
+ const coerce = y?.coerce;
548
+ if (typeof coerce !== "function") {
549
+ throw new TypeError(`${rbBuiltinClassName(y)} can't be coerced into ${rbObjClassname(x)}`);
550
+ }
551
+ const [a, b] = coerce.call(y, x);
552
+ return rbPlus(a, b);
553
+ }
554
+ /**
555
+ * `coerce_failed` (`vendor/ruby/v3.3.11/numeric.c:442`): names a special
556
+ * constant, Symbol or Float by its `inspect`, and anything else by its class.
557
+ */
558
+ function coerceFailed(x, y) {
559
+ let desc;
560
+ if (y == null ||
561
+ typeof y === "boolean" ||
562
+ typeof y === "number" ||
563
+ isSymbol(y) ||
564
+ rbFloatTypeP(y)) {
565
+ desc = rbInspect(y);
566
+ }
567
+ else {
568
+ desc = rbObjClassname(y);
569
+ }
570
+ throw new TypeError(`${desc} can't be coerced into ${rbObjClassname(x)}`);
571
+ }
572
+ /**
573
+ * `do_coerce` with `err` set (`vendor/ruby/v3.3.11/numeric.c:455`): sends
574
+ * `y.coerce(x)` and answers the pair, raising when `y` has no `coerce` or it
575
+ * answers anything but a two-element Array.
576
+ */
577
+ function doCoerce(x, y) {
578
+ const coerce = y?.coerce;
579
+ if (typeof coerce !== "function") {
580
+ coerceFailed(x, y);
581
+ }
582
+ const ary = coerce.call(y, x);
583
+ if (!Array.isArray(ary) || ary.length !== 2) {
584
+ throw new TypeError("coerce must return [x, y]");
585
+ }
586
+ return [ary[0], ary[1]];
587
+ }
588
+ /**
589
+ * Ruby `Integer#^` (`vendor/ruby/v3.3.11/numeric.c:5055` `int_xor`, over
590
+ * `fix_xor`, `numeric.c:5025`, and `rb_big_xor`): the bitwise exclusive OR of
591
+ * two Integers. Any other operand goes through `rb_num_coerce_bit`
592
+ * (`numeric.c:4923`): `y.coerce(x)` supplies a pair, and `^` is sent to its
593
+ * first member with the second. An operand with no `coerce`, or a pair whose
594
+ * first member has no `^`, raises `TypeError` naming the original operands,
595
+ * which is what `1 ^ nil` raises.
596
+ *
597
+ * @noRailsEquivalent PERMANENT
598
+ */
599
+ export function intXor(x, y) {
600
+ if (rbIntegerTypeP(x) && rbIntegerTypeP(y)) {
601
+ if (typeof x === "number" && typeof y === "number" && (x | 0) === x && (y | 0) === y) {
602
+ return x ^ y;
603
+ }
604
+ return rbBigNorm(BigInt(x) ^ BigInt(y));
605
+ }
606
+ return rbNumCoerceBit(x, y);
607
+ }
608
+ const numFuncallBit1Running = [];
609
+ /**
610
+ * `num_funcall_bit_1` (`vendor/ruby/v3.3.11/numeric.c:4912`) under the
611
+ * `rb_exec_recursive_paired` guard `rb_num_coerce_bit` runs it in
612
+ * (`numeric.c:4931`): sends `^` to `x` with `y`, answering `undefined` when
613
+ * `x` has no `^`, and raising `NameError` (`num_funcall_op_1_recursion`,
614
+ * `numeric.c:362`) when the same pair is already being sent.
615
+ */
616
+ function numFuncallBit1(y, x) {
617
+ if (numFuncallBit1Running.some(([obj, paired]) => obj === y && paired === x)) {
618
+ throw new NameError(`${toS(x)}^${toS(y)}`, "^");
619
+ }
620
+ numFuncallBit1Running.push([y, x]);
621
+ try {
622
+ if (rbIntegerTypeP(x))
623
+ return intXor(x, y);
624
+ const func = x?.["^"];
625
+ if (typeof func !== "function")
626
+ return undefined;
627
+ return func.call(x, y);
628
+ }
629
+ finally {
630
+ numFuncallBit1Running.pop();
631
+ }
632
+ }
633
+ /** `rb_num_coerce_bit` for `^` (`vendor/ruby/v3.3.11/numeric.c:4923`). */
634
+ function rbNumCoerceBit(x, y) {
635
+ const args = doCoerce(x, y);
636
+ const ret = numFuncallBit1(args[1], args[0]);
637
+ if (ret === undefined) {
638
+ coerceFailed(x, y);
639
+ }
640
+ return ret;
641
+ }
642
+ /**
643
+ * The `+` send (`rb_funcallv(v, idPLUS, 1, &i)`, `vendor/ruby/v3.3.11/enum.c:4583`),
644
+ * over `vm_opt_plus`'s String and Array arms (`vendor/ruby/v3.3.11/vm_insnhelper.c:6010`).
645
+ * @noRailsEquivalent PERMANENT
646
+ */
647
+ export function rbPlus(v, i) {
648
+ if (rbIntegerTypeP(v) || rbFloatTypeP(v) || v instanceof Rational)
649
+ return numericPlus(v, i);
650
+ if (typeof v === "string") {
651
+ if (typeof i !== "string") {
652
+ throw new TypeError(`no implicit conversion of ${rbBuiltinClassName(i)} into String`);
653
+ }
654
+ return v + i;
655
+ }
656
+ if (Array.isArray(v)) {
657
+ if (!Array.isArray(i)) {
658
+ throw new TypeError(`no implicit conversion of ${rbBuiltinClassName(i)} into Array`);
659
+ }
660
+ return [...v, ...i];
661
+ }
662
+ const plus = v?.plus;
663
+ if (typeof plus === "function")
664
+ return plus.call(v, i);
665
+ throw new NoMethodError(`undefined method '+' for ${v == null ? "nil" : `an instance of ${rbObjClassname(v)}`}`);
666
+ }
667
+ /**
668
+ * `Float::DIG` (`vendor/ruby/v3.3.11/numeric.c:6283`).
669
+ *
670
+ * @noRailsEquivalent PERMANENT
671
+ */
672
+ export const FLOAT_DIG = 15;
673
+ /**
674
+ * Ruby `Numeric#step(to, step) { |i| }` over the `number` seat, with a block
675
+ * (`num_step`, `vendor/ruby/v3.3.11/numeric.c:3034`). An integral `number` is a
676
+ * Fixnum and takes the `long` loop; any other takes `ruby_float_step`
677
+ * (`numeric.c:2767`), so an infinite or NaN bound yields nothing where a naive
678
+ * `for` loop would never end.
679
+ *
680
+ * @noRailsEquivalent PERMANENT
681
+ */
682
+ export function numStep(from, to, step, block) {
683
+ if (step === 0) {
684
+ throw new ArgumentError("step can't be 0");
685
+ }
686
+ const desc = step < 0;
687
+ let inf;
688
+ if (step === 0) {
689
+ inf = true;
690
+ }
691
+ else if (!Number.isInteger(to)) {
692
+ inf = !Number.isFinite(to) && !Number.isNaN(to) && (to < 0 ? desc : !desc);
693
+ }
694
+ else
695
+ inf = false;
696
+ if (Number.isInteger(from) && (inf || Number.isInteger(to)) && Number.isInteger(step)) {
697
+ let i = from;
698
+ if (inf) {
699
+ for (;; i += step)
700
+ block(i);
701
+ }
702
+ else if (desc) {
703
+ for (; i >= to; i += step)
704
+ block(i);
705
+ }
706
+ else {
707
+ for (; i <= to; i += step)
708
+ block(i);
709
+ }
710
+ }
711
+ else {
712
+ rubyFloatStep(from, to, step, false, block);
713
+ }
714
+ return from;
715
+ }
716
+ function rubyFloatStepSize(beg, end, unit, excl) {
717
+ const epsilon = Number.EPSILON;
718
+ let d;
719
+ let n;
720
+ let err;
721
+ if (unit === 0) {
722
+ return Infinity;
723
+ }
724
+ if (!Number.isFinite(unit)) {
725
+ return Number(unit > 0 ? beg <= end : beg >= end);
726
+ }
727
+ n = (end - beg) / unit;
728
+ err = ((Math.abs(beg) + Math.abs(end) + Math.abs(end - beg)) / Math.abs(unit)) * epsilon;
729
+ if (err > 0.5)
730
+ err = 0.5;
731
+ if (excl) {
732
+ if (n <= 0)
733
+ return 0;
734
+ if (n < 1)
735
+ n = 0;
736
+ else
737
+ n = Math.floor(n - err);
738
+ d = (n + 1) * unit + beg;
739
+ if (beg < end) {
740
+ if (d < end)
741
+ n++;
742
+ }
743
+ else if (beg > end) {
744
+ if (d > end)
745
+ n++;
746
+ }
747
+ }
748
+ else {
749
+ if (n < 0)
750
+ return 0;
751
+ n = Math.floor(n + err);
752
+ d = (n + 1) * unit + beg;
753
+ if (beg < end) {
754
+ if (d <= end)
755
+ n++;
756
+ }
757
+ else if (beg > end) {
758
+ if (d >= end)
759
+ n++;
760
+ }
761
+ }
762
+ return n + 1;
763
+ }
764
+ function rubyFloatStep(beg, end, unit, excl, block) {
765
+ const n = rubyFloatStepSize(beg, end, unit, excl);
766
+ if (!Number.isFinite(unit)) {
767
+ if (n)
768
+ block(beg);
769
+ }
770
+ else if (unit === 0) {
771
+ for (;;)
772
+ block(beg);
773
+ }
774
+ else {
775
+ for (let i = 0; i < n; i++) {
776
+ let d = i * unit + beg;
777
+ if (unit >= 0 ? end < d : d < end)
778
+ d = end;
779
+ block(d);
780
+ }
781
+ }
782
+ }
783
+ /**
784
+ * `ruby_num_interval_step_size` (`vendor/ruby/v3.3.11/numeric.c:2798`) with a step of 1.
785
+ *
786
+ * @noRailsEquivalent PERMANENT
787
+ */
788
+ export function rubyNumIntervalStepSize(from, to, excl) {
789
+ if (typeof from === "bigint" ||
790
+ typeof to === "bigint" ||
791
+ (Number.isInteger(from) && Number.isInteger(to))) {
792
+ let delta = BigInt(to) - BigInt(from);
793
+ if (excl)
794
+ delta--;
795
+ if (delta < 0n)
796
+ return 0;
797
+ const n = delta + 1n;
798
+ return n <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(n) : n;
799
+ }
800
+ return rubyFloatStepSize(Number(from), Number(to), 1, excl);
801
+ }
802
+ //# sourceMappingURL=numeric.js.map