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