@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.
- package/LICENSE +21 -0
- package/NOTICE +6 -0
- package/README.md +440 -2
- package/dist/argument-error.d.ts +15 -0
- package/dist/argument-error.js +15 -0
- package/dist/argument-error.js.map +1 -0
- package/dist/array.d.ts +415 -0
- package/dist/array.js +1330 -0
- package/dist/array.js.map +1 -0
- package/dist/async-context-adapter.d.ts +19 -0
- package/dist/async-context-adapter.js +139 -0
- package/dist/async-context-adapter.js.map +1 -0
- package/dist/backtrace-location.d.ts +77 -0
- package/dist/backtrace-location.js +155 -0
- package/dist/backtrace-location.js.map +1 -0
- package/dist/base64.d.ts +73 -0
- package/dist/base64.js +164 -0
- package/dist/base64.js.map +1 -0
- package/dist/benchmark.d.ts +19 -0
- package/dist/benchmark.js +16 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/big-decimal.d.ts +110 -0
- package/dist/big-decimal.js +582 -0
- package/dist/big-decimal.js.map +1 -0
- package/dist/bundler.d.ts +44 -0
- package/dist/bundler.js +101 -0
- package/dist/bundler.js.map +1 -0
- package/dist/cgi.d.ts +89 -0
- package/dist/cgi.js +168 -0
- package/dist/cgi.js.map +1 -0
- package/dist/child-process-adapter.d.ts +110 -0
- package/dist/child-process-adapter.js +272 -0
- package/dist/child-process-adapter.js.map +1 -0
- package/dist/class-module.d.ts +10 -0
- package/dist/class-module.js +10 -0
- package/dist/class-module.js.map +1 -0
- package/dist/classpath.d.ts +90 -0
- package/dist/classpath.js +207 -0
- package/dist/classpath.js.map +1 -0
- package/dist/closed-queue-error.d.ts +10 -0
- package/dist/closed-queue-error.js +10 -0
- package/dist/closed-queue-error.js.map +1 -0
- package/dist/comparable.d.ts +127 -0
- package/dist/comparable.js +376 -0
- package/dist/comparable.js.map +1 -0
- package/dist/complex.d.ts +48 -0
- package/dist/complex.js +162 -0
- package/dist/complex.js.map +1 -0
- package/dist/concurrent/atomic-boolean.d.ts +24 -0
- package/dist/concurrent/atomic-boolean.js +43 -0
- package/dist/concurrent/atomic-boolean.js.map +1 -0
- package/dist/concurrent/atomic-fixnum.d.ts +21 -0
- package/dist/concurrent/atomic-fixnum.js +35 -0
- package/dist/concurrent/atomic-fixnum.js.map +1 -0
- package/dist/concurrent/count-down-latch.d.ts +20 -0
- package/dist/concurrent/count-down-latch.js +50 -0
- package/dist/concurrent/count-down-latch.js.map +1 -0
- package/dist/concurrent/cyclic-barrier.d.ts +18 -0
- package/dist/concurrent/cyclic-barrier.js +50 -0
- package/dist/concurrent/cyclic-barrier.js.map +1 -0
- package/dist/concurrent/event.d.ts +19 -0
- package/dist/concurrent/event.js +31 -0
- package/dist/concurrent/event.js.map +1 -0
- package/dist/concurrent/map.d.ts +149 -0
- package/dist/concurrent/map.js +202 -0
- package/dist/concurrent/map.js.map +1 -0
- package/dist/concurrent/read-write-lock.d.ts +25 -0
- package/dist/concurrent/read-write-lock.js +70 -0
- package/dist/concurrent/read-write-lock.js.map +1 -0
- package/dist/concurrent/semaphore.d.ts +24 -0
- package/dist/concurrent/semaphore.js +74 -0
- package/dist/concurrent/semaphore.js.map +1 -0
- package/dist/concurrent/timer-task.d.ts +52 -0
- package/dist/concurrent/timer-task.js +112 -0
- package/dist/concurrent/timer-task.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +64 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/converter-not-found-error.d.ts +14 -0
- package/dist/converter-not-found-error.js +14 -0
- package/dist/converter-not-found-error.js.map +1 -0
- package/dist/crypto-adapter.d.ts +64 -0
- package/dist/crypto-adapter.js +365 -0
- package/dist/crypto-adapter.js.map +1 -0
- package/dist/delegate.d.ts +156 -0
- package/dist/delegate.js +306 -0
- package/dist/delegate.js.map +1 -0
- package/dist/digest.d.ts +99 -0
- package/dist/digest.js +131 -0
- package/dist/digest.js.map +1 -0
- package/dist/dir.d.ts +218 -0
- package/dist/dir.js +599 -0
- package/dist/dir.js.map +1 -0
- package/dist/encoding-error.d.ts +14 -0
- package/dist/encoding-error.js +17 -0
- package/dist/encoding-error.js.map +1 -0
- package/dist/encoding.d.ts +121 -0
- package/dist/encoding.js +306 -0
- package/dist/encoding.js.map +1 -0
- package/dist/ensure.d.ts +15 -0
- package/dist/ensure.js +35 -0
- package/dist/ensure.js.map +1 -0
- package/dist/enumerable.d.ts +375 -0
- package/dist/enumerable.js +1100 -0
- package/dist/enumerable.js.map +1 -0
- package/dist/enumerator.d.ts +321 -0
- package/dist/enumerator.js +642 -0
- package/dist/enumerator.js.map +1 -0
- package/dist/eof-error.d.ts +14 -0
- package/dist/eof-error.js +14 -0
- package/dist/eof-error.js.map +1 -0
- package/dist/errno.d.ts +327 -0
- package/dist/errno.js +452 -0
- package/dist/errno.js.map +1 -0
- package/dist/exc-detailed-message.d.ts +15 -0
- package/dist/exc-detailed-message.js +106 -0
- package/dist/exc-detailed-message.js.map +1 -0
- package/dist/exc-to-s.d.ts +10 -0
- package/dist/exc-to-s.js +21 -0
- package/dist/exc-to-s.js.map +1 -0
- package/dist/exception.d.ts +34 -0
- package/dist/exception.js +99 -0
- package/dist/exception.js.map +1 -0
- package/dist/fiber-error.d.ts +12 -0
- package/dist/fiber-error.js +12 -0
- package/dist/fiber-error.js.map +1 -0
- package/dist/fiber.d.ts +51 -0
- package/dist/fiber.js +178 -0
- package/dist/fiber.js.map +1 -0
- package/dist/file-utils.d.ts +480 -0
- package/dist/file-utils.js +1823 -0
- package/dist/file-utils.js.map +1 -0
- package/dist/file.d.ts +635 -0
- package/dist/file.js +1312 -0
- package/dist/file.js.map +1 -0
- package/dist/float-domain-error.d.ts +17 -0
- package/dist/float-domain-error.js +17 -0
- package/dist/float-domain-error.js.map +1 -0
- package/dist/fork-children.d.ts +23 -0
- package/dist/fork-children.js +32 -0
- package/dist/fork-children.js.map +1 -0
- package/dist/frozen-error.d.ts +33 -0
- package/dist/frozen-error.js +42 -0
- package/dist/frozen-error.js.map +1 -0
- package/dist/fs-adapter.d.ts +158 -0
- package/dist/fs-adapter.js +253 -0
- package/dist/fs-adapter.js.map +1 -0
- package/dist/gem/deprecate.d.ts +10 -0
- package/dist/gem/deprecate.js +8 -0
- package/dist/gem/deprecate.js.map +1 -0
- package/dist/gem/requirement.d.ts +64 -0
- package/dist/gem/requirement.js +91 -0
- package/dist/gem/requirement.js.map +1 -0
- package/dist/gem/version.d.ts +50 -0
- package/dist/gem/version.js +148 -0
- package/dist/gem/version.js.map +1 -0
- package/dist/gem.d.ts +59 -0
- package/dist/gem.js +82 -0
- package/dist/gem.js.map +1 -0
- package/dist/hash.d.ts +967 -0
- package/dist/hash.js +1572 -0
- package/dist/hash.js.map +1 -0
- package/dist/http-adapter.d.ts +123 -0
- package/dist/http-adapter.js +220 -0
- package/dist/http-adapter.js.map +1 -0
- package/dist/immediate-executor.d.ts +20 -0
- package/dist/immediate-executor.js +39 -0
- package/dist/immediate-executor.js.map +1 -0
- package/dist/include.d.ts +778 -0
- package/dist/include.js +2195 -0
- package/dist/include.js.map +1 -0
- package/dist/index-error.d.ts +13 -0
- package/dist/index-error.js +13 -0
- package/dist/index-error.js.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/invalid-byte-sequence-error.d.ts +62 -0
- package/dist/invalid-byte-sequence-error.js +75 -0
- package/dist/invalid-byte-sequence-error.js.map +1 -0
- package/dist/io-error.d.ts +14 -0
- package/dist/io-error.js +17 -0
- package/dist/io-error.js.map +1 -0
- package/dist/io.d.ts +867 -0
- package/dist/io.js +1960 -0
- package/dist/io.js.map +1 -0
- package/dist/ipaddr.d.ts +79 -0
- package/dist/ipaddr.js +405 -0
- package/dist/ipaddr.js.map +1 -0
- package/dist/json.d.ts +67 -0
- package/dist/json.js +185 -0
- package/dist/json.js.map +1 -0
- package/dist/kernel-catch.d.ts +59 -0
- package/dist/kernel-catch.js +184 -0
- package/dist/kernel-catch.js.map +1 -0
- package/dist/kernel-float.d.ts +19 -0
- package/dist/kernel-float.js +54 -0
- package/dist/kernel-float.js.map +1 -0
- package/dist/kernel-fork.d.ts +30 -0
- package/dist/kernel-fork.js +72 -0
- package/dist/kernel-fork.js.map +1 -0
- package/dist/kernel-format.d.ts +27 -0
- package/dist/kernel-format.js +901 -0
- package/dist/kernel-format.js.map +1 -0
- package/dist/kernel-hash.d.ts +7 -0
- package/dist/kernel-hash.js +33 -0
- package/dist/kernel-hash.js.map +1 -0
- package/dist/kernel-integer.d.ts +49 -0
- package/dist/kernel-integer.js +170 -0
- package/dist/kernel-integer.js.map +1 -0
- package/dist/kernel-rand.d.ts +16 -0
- package/dist/kernel-rand.js +237 -0
- package/dist/kernel-rand.js.map +1 -0
- package/dist/kernel-system.d.ts +40 -0
- package/dist/kernel-system.js +97 -0
- package/dist/kernel-system.js.map +1 -0
- package/dist/kernel-warn.d.ts +35 -0
- package/dist/kernel-warn.js +73 -0
- package/dist/kernel-warn.js.map +1 -0
- package/dist/key-error.d.ts +44 -0
- package/dist/key-error.js +59 -0
- package/dist/key-error.js.map +1 -0
- package/dist/keyword-splat.d.ts +41 -0
- package/dist/keyword-splat.js +65 -0
- package/dist/keyword-splat.js.map +1 -0
- package/dist/load-error.d.ts +19 -0
- package/dist/load-error.js +19 -0
- package/dist/load-error.js.map +1 -0
- package/dist/load.d.ts +121 -0
- package/dist/load.js +263 -0
- package/dist/load.js.map +1 -0
- package/dist/loaded-features.d.ts +13 -0
- package/dist/loaded-features.js +15 -0
- package/dist/loaded-features.js.map +1 -0
- package/dist/local-jump-error.d.ts +12 -0
- package/dist/local-jump-error.js +12 -0
- package/dist/local-jump-error.js.map +1 -0
- package/dist/logger/formatter.d.ts +21 -0
- package/dist/logger/formatter.js +43 -0
- package/dist/logger/formatter.js.map +1 -0
- package/dist/logger/log-device.d.ts +52 -0
- package/dist/logger/log-device.js +104 -0
- package/dist/logger/log-device.js.map +1 -0
- package/dist/logger/severity.d.ts +23 -0
- package/dist/logger/severity.js +42 -0
- package/dist/logger/severity.js.map +1 -0
- package/dist/logger.d.ts +127 -0
- package/dist/logger.js +215 -0
- package/dist/logger.js.map +1 -0
- package/dist/marshal.d.ts +83 -0
- package/dist/marshal.js +1487 -0
- package/dist/marshal.js.map +1 -0
- package/dist/match-data.d.ts +161 -0
- package/dist/match-data.js +284 -0
- package/dist/match-data.js.map +1 -0
- package/dist/method-cache.d.ts +17 -0
- package/dist/method-cache.js +19 -0
- package/dist/method-cache.js.map +1 -0
- package/dist/method-missing-proxy.d.ts +53 -0
- package/dist/method-missing-proxy.js +154 -0
- package/dist/method-missing-proxy.js.map +1 -0
- package/dist/method.d.ts +132 -0
- package/dist/method.js +320 -0
- package/dist/method.js.map +1 -0
- package/dist/monitor.d.ts +114 -0
- package/dist/monitor.js +270 -0
- package/dist/monitor.js.map +1 -0
- package/dist/mutex.d.ts +51 -0
- package/dist/mutex.js +150 -0
- package/dist/mutex.js.map +1 -0
- package/dist/name-error.d.ts +45 -0
- package/dist/name-error.js +54 -0
- package/dist/name-error.js.map +1 -0
- package/dist/net/http/exceptions.d.ts +31 -0
- package/dist/net/http/exceptions.js +46 -0
- package/dist/net/http/exceptions.js.map +1 -0
- package/dist/net/http/request.d.ts +137 -0
- package/dist/net/http/request.js +559 -0
- package/dist/net/http/request.js.map +1 -0
- package/dist/net/http/requests.d.ts +197 -0
- package/dist/net/http/requests.js +197 -0
- package/dist/net/http/requests.js.map +1 -0
- package/dist/net/http/response.d.ts +141 -0
- package/dist/net/http/response.js +416 -0
- package/dist/net/http/response.js.map +1 -0
- package/dist/net/http/responses.d.ts +345 -0
- package/dist/net/http/responses.js +486 -0
- package/dist/net/http/responses.js.map +1 -0
- package/dist/net/http.d.ts +278 -0
- package/dist/net/http.js +760 -0
- package/dist/net/http.js.map +1 -0
- package/dist/net/protocol.d.ts +227 -0
- package/dist/net/protocol.js +392 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/nil-class.d.ts +10 -0
- package/dist/nil-class.js +27 -0
- package/dist/nil-class.js.map +1 -0
- package/dist/no-method-error.d.ts +38 -0
- package/dist/no-method-error.js +45 -0
- package/dist/no-method-error.js.map +1 -0
- package/dist/not-implemented-error.d.ts +13 -0
- package/dist/not-implemented-error.js +14 -0
- package/dist/not-implemented-error.js.map +1 -0
- package/dist/numeric.d.ts +211 -0
- package/dist/numeric.js +802 -0
- package/dist/numeric.js.map +1 -0
- package/dist/object-space.d.ts +34 -0
- package/dist/object-space.js +152 -0
- package/dist/object-space.js.map +1 -0
- package/dist/object.d.ts +908 -0
- package/dist/object.js +2238 -0
- package/dist/object.js.map +1 -0
- package/dist/open-uri.d.ts +180 -0
- package/dist/open-uri.js +402 -0
- package/dist/open-uri.js.map +1 -0
- package/dist/open3.d.ts +69 -0
- package/dist/open3.js +134 -0
- package/dist/open3.js.map +1 -0
- package/dist/openssl.d.ts +479 -0
- package/dist/openssl.js +1052 -0
- package/dist/openssl.js.map +1 -0
- package/dist/optparse.d.ts +130 -0
- package/dist/optparse.js +457 -0
- package/dist/optparse.js.map +1 -0
- package/dist/os-adapter.d.ts +20 -0
- package/dist/os-adapter.js +95 -0
- package/dist/os-adapter.js.map +1 -0
- package/dist/pathname.d.ts +71 -0
- package/dist/pathname.js +394 -0
- package/dist/pathname.js.map +1 -0
- package/dist/pp.d.ts +60 -0
- package/dist/pp.js +195 -0
- package/dist/pp.js.map +1 -0
- package/dist/pretty-print.d.ts +89 -0
- package/dist/pretty-print.js +232 -0
- package/dist/pretty-print.js.map +1 -0
- package/dist/process-adapter.d.ts +224 -0
- package/dist/process-adapter.js +878 -0
- package/dist/process-adapter.js.map +1 -0
- package/dist/process.d.ts +192 -0
- package/dist/process.js +403 -0
- package/dist/process.js.map +1 -0
- package/dist/psych/class-loader.d.ts +92 -0
- package/dist/psych/class-loader.js +139 -0
- package/dist/psych/class-loader.js.map +1 -0
- package/dist/psych/coder.d.ts +144 -0
- package/dist/psych/coder.js +176 -0
- package/dist/psych/coder.js.map +1 -0
- package/dist/psych/core-ext.d.ts +8 -0
- package/dist/psych/core-ext.js +10 -0
- package/dist/psych/core-ext.js.map +1 -0
- package/dist/psych/emitter.d.ts +116 -0
- package/dist/psych/emitter.js +1130 -0
- package/dist/psych/emitter.js.map +1 -0
- package/dist/psych/exception.d.ts +43 -0
- package/dist/psych/exception.js +54 -0
- package/dist/psych/exception.js.map +1 -0
- package/dist/psych/handler.d.ts +59 -0
- package/dist/psych/handler.js +95 -0
- package/dist/psych/handler.js.map +1 -0
- package/dist/psych/handlers/document-stream.d.ts +17 -0
- package/dist/psych/handlers/document-stream.js +26 -0
- package/dist/psych/handlers/document-stream.js.map +1 -0
- package/dist/psych/nodes/alias.d.ts +15 -0
- package/dist/psych/nodes/alias.js +22 -0
- package/dist/psych/nodes/alias.js.map +1 -0
- package/dist/psych/nodes/document.d.ts +23 -0
- package/dist/psych/nodes/document.js +35 -0
- package/dist/psych/nodes/document.js.map +1 -0
- package/dist/psych/nodes/mapping.d.ts +25 -0
- package/dist/psych/nodes/mapping.js +35 -0
- package/dist/psych/nodes/mapping.js.map +1 -0
- package/dist/psych/nodes/node.d.ts +59 -0
- package/dist/psych/nodes/node.js +79 -0
- package/dist/psych/nodes/node.js.map +1 -0
- package/dist/psych/nodes/scalar.d.ts +35 -0
- package/dist/psych/nodes/scalar.js +47 -0
- package/dist/psych/nodes/scalar.js.map +1 -0
- package/dist/psych/nodes/sequence.d.ts +25 -0
- package/dist/psych/nodes/sequence.js +35 -0
- package/dist/psych/nodes/sequence.js.map +1 -0
- package/dist/psych/nodes/stream.d.ts +23 -0
- package/dist/psych/nodes/stream.js +31 -0
- package/dist/psych/nodes/stream.js.map +1 -0
- package/dist/psych/omap.d.ts +9 -0
- package/dist/psych/omap.js +9 -0
- package/dist/psych/omap.js.map +1 -0
- package/dist/psych/parser.d.ts +41 -0
- package/dist/psych/parser.js +139 -0
- package/dist/psych/parser.js.map +1 -0
- package/dist/psych/scalar-scanner.d.ts +35 -0
- package/dist/psych/scalar-scanner.js +173 -0
- package/dist/psych/scalar-scanner.js.map +1 -0
- package/dist/psych/syntax-error.d.ts +23 -0
- package/dist/psych/syntax-error.js +35 -0
- package/dist/psych/syntax-error.js.map +1 -0
- package/dist/psych/tree-builder.d.ts +51 -0
- package/dist/psych/tree-builder.js +118 -0
- package/dist/psych/tree-builder.js.map +1 -0
- package/dist/psych/visitors/depth-first.d.ts +27 -0
- package/dist/psych/visitors/depth-first.js +37 -0
- package/dist/psych/visitors/depth-first.js.map +1 -0
- package/dist/psych/visitors/emitter.d.ts +32 -0
- package/dist/psych/visitors/emitter.js +63 -0
- package/dist/psych/visitors/emitter.js.map +1 -0
- package/dist/psych/visitors/to-ruby.d.ts +110 -0
- package/dist/psych/visitors/to-ruby.js +396 -0
- package/dist/psych/visitors/to-ruby.js.map +1 -0
- package/dist/psych/visitors/visitor.d.ts +11 -0
- package/dist/psych/visitors/visitor.js +17 -0
- package/dist/psych/visitors/visitor.js.map +1 -0
- package/dist/psych/visitors/yaml-tree.d.ts +182 -0
- package/dist/psych/visitors/yaml-tree.js +593 -0
- package/dist/psych/visitors/yaml-tree.js.map +1 -0
- package/dist/psych-adapter.d.ts +65 -0
- package/dist/psych-adapter.js +121 -0
- package/dist/psych-adapter.js.map +1 -0
- package/dist/psych-yaml.d.ts +2 -0
- package/dist/psych-yaml.js +5 -0
- package/dist/psych-yaml.js.map +1 -0
- package/dist/psych.d.ts +257 -0
- package/dist/psych.js +332 -0
- package/dist/psych.js.map +1 -0
- package/dist/queue.d.ts +129 -0
- package/dist/queue.js +215 -0
- package/dist/queue.js.map +1 -0
- package/dist/racc/parser.d.ts +70 -0
- package/dist/racc/parser.js +206 -0
- package/dist/racc/parser.js.map +1 -0
- package/dist/range-error.d.ts +15 -0
- package/dist/range-error.js +15 -0
- package/dist/range-error.js.map +1 -0
- package/dist/range.d.ts +166 -0
- package/dist/range.js +421 -0
- package/dist/range.js.map +1 -0
- package/dist/rational.d.ts +167 -0
- package/dist/rational.js +379 -0
- package/dist/rational.js.map +1 -0
- package/dist/rb-config.d.ts +33 -0
- package/dist/rb-config.js +53 -0
- package/dist/rb-config.js.map +1 -0
- package/dist/rb-equal.d.ts +66 -0
- package/dist/rb-equal.js +261 -0
- package/dist/rb-equal.js.map +1 -0
- package/dist/rb-hash.d.ts +26 -0
- package/dist/rb-hash.js +108 -0
- package/dist/rb-hash.js.map +1 -0
- package/dist/regexp.d.ts +82 -0
- package/dist/regexp.js +191 -0
- package/dist/regexp.js.map +1 -0
- package/dist/repl-adapter.d.ts +188 -0
- package/dist/repl-adapter.js +388 -0
- package/dist/repl-adapter.js.map +1 -0
- package/dist/resolv.d.ts +30 -0
- package/dist/resolv.js +48 -0
- package/dist/resolv.js.map +1 -0
- package/dist/ruby-empty.d.ts +28 -0
- package/dist/ruby-empty.js +40 -0
- package/dist/ruby-empty.js.map +1 -0
- package/dist/ruby-platform.d.ts +39 -0
- package/dist/ruby-platform.js +49 -0
- package/dist/ruby-platform.js.map +1 -0
- package/dist/runtime-error.d.ts +15 -0
- package/dist/runtime-error.js +16 -0
- package/dist/runtime-error.js.map +1 -0
- package/dist/scheduled-task.d.ts +73 -0
- package/dist/scheduled-task.js +150 -0
- package/dist/scheduled-task.js.map +1 -0
- package/dist/secure-random.d.ts +33 -0
- package/dist/secure-random.js +78 -0
- package/dist/secure-random.js.map +1 -0
- package/dist/set.d.ts +158 -0
- package/dist/set.js +352 -0
- package/dist/set.js.map +1 -0
- package/dist/shellwords.d.ts +27 -0
- package/dist/shellwords.js +53 -0
- package/dist/shellwords.js.map +1 -0
- package/dist/signal-exception.d.ts +21 -0
- package/dist/signal-exception.js +21 -0
- package/dist/signal-exception.js.map +1 -0
- package/dist/socket.d.ts +230 -0
- package/dist/socket.js +484 -0
- package/dist/socket.js.map +1 -0
- package/dist/standard-error.d.ts +18 -0
- package/dist/standard-error.js +23 -0
- package/dist/standard-error.js.map +1 -0
- package/dist/stop-iteration.d.ts +10 -0
- package/dist/stop-iteration.js +10 -0
- package/dist/stop-iteration.js.map +1 -0
- package/dist/string/b.d.ts +19 -0
- package/dist/string/b.js +28 -0
- package/dist/string/b.js.map +1 -0
- package/dist/string/byte-methods.d.ts +57 -0
- package/dist/string/byte-methods.js +266 -0
- package/dist/string/byte-methods.js.map +1 -0
- package/dist/string/bytes.d.ts +35 -0
- package/dist/string/bytes.js +123 -0
- package/dist/string/bytes.js.map +1 -0
- package/dist/string/case-mapping.d.ts +57 -0
- package/dist/string/case-mapping.js +192 -0
- package/dist/string/case-mapping.js.map +1 -0
- package/dist/string/chomp.d.ts +15 -0
- package/dist/string/chomp.js +32 -0
- package/dist/string/chomp.js.map +1 -0
- package/dist/string/convert.d.ts +55 -0
- package/dist/string/convert.js +316 -0
- package/dist/string/convert.js.map +1 -0
- package/dist/string/delete.d.ts +14 -0
- package/dist/string/delete.js +17 -0
- package/dist/string/delete.js.map +1 -0
- package/dist/string/each.d.ts +108 -0
- package/dist/string/each.js +305 -0
- package/dist/string/each.js.map +1 -0
- package/dist/string/encode.d.ts +37 -0
- package/dist/string/encode.js +268 -0
- package/dist/string/encode.js.map +1 -0
- package/dist/string/force-encoding.d.ts +72 -0
- package/dist/string/force-encoding.js +147 -0
- package/dist/string/force-encoding.js.map +1 -0
- package/dist/string/inspect.d.ts +17 -0
- package/dist/string/inspect.js +81 -0
- package/dist/string/inspect.js.map +1 -0
- package/dist/string/method-table.d.ts +174 -0
- package/dist/string/method-table.js +805 -0
- package/dist/string/method-table.js.map +1 -0
- package/dist/string/scrub.d.ts +12 -0
- package/dist/string/scrub.js +33 -0
- package/dist/string/scrub.js.map +1 -0
- package/dist/string/slice.d.ts +26 -0
- package/dist/string/slice.js +73 -0
- package/dist/string/slice.js.map +1 -0
- package/dist/string/split.d.ts +11 -0
- package/dist/string/split.js +44 -0
- package/dist/string/split.js.map +1 -0
- package/dist/string/sub.d.ts +114 -0
- package/dist/string/sub.js +371 -0
- package/dist/string/sub.js.map +1 -0
- package/dist/string/succ.d.ts +14 -0
- package/dist/string/succ.js +118 -0
- package/dist/string/succ.js.map +1 -0
- package/dist/string/support.d.ts +135 -0
- package/dist/string/support.js +283 -0
- package/dist/string/support.js.map +1 -0
- package/dist/string/tr.d.ts +46 -0
- package/dist/string/tr.js +156 -0
- package/dist/string/tr.js.map +1 -0
- package/dist/string-io.d.ts +166 -0
- package/dist/string-io.js +248 -0
- package/dist/string-io.js.map +1 -0
- package/dist/string-scanner.d.ts +133 -0
- package/dist/string-scanner.js +248 -0
- package/dist/string-scanner.js.map +1 -0
- package/dist/struct.d.ts +54 -0
- package/dist/struct.js +222 -0
- package/dist/struct.js.map +1 -0
- package/dist/symbol.d.ts +48 -0
- package/dist/symbol.js +107 -0
- package/dist/symbol.js.map +1 -0
- package/dist/tempfile.d.ts +173 -0
- package/dist/tempfile.js +290 -0
- package/dist/tempfile.js.map +1 -0
- package/dist/temporal-tag.d.ts +23 -0
- package/dist/temporal-tag.js +29 -0
- package/dist/temporal-tag.js.map +1 -0
- package/dist/thread-error.d.ts +13 -0
- package/dist/thread-error.js +13 -0
- package/dist/thread-error.js.map +1 -0
- package/dist/thread-pool-executor.d.ts +119 -0
- package/dist/thread-pool-executor.js +250 -0
- package/dist/thread-pool-executor.js.map +1 -0
- package/dist/thread.d.ts +211 -0
- package/dist/thread.js +495 -0
- package/dist/thread.js.map +1 -0
- package/dist/timeout.d.ts +29 -0
- package/dist/timeout.js +41 -0
- package/dist/timeout.js.map +1 -0
- package/dist/tse.d.ts +40 -0
- package/dist/tse.js +62 -0
- package/dist/tse.js.map +1 -0
- package/dist/type-error.d.ts +14 -0
- package/dist/type-error.js +15 -0
- package/dist/type-error.js.map +1 -0
- package/dist/undefined-conversion-error.d.ts +10 -0
- package/dist/undefined-conversion-error.js +10 -0
- package/dist/undefined-conversion-error.js.map +1 -0
- package/dist/uri/common.d.ts +209 -0
- package/dist/uri/common.js +369 -0
- package/dist/uri/common.js.map +1 -0
- package/dist/uri/generic.d.ts +283 -0
- package/dist/uri/generic.js +810 -0
- package/dist/uri/generic.js.map +1 -0
- package/dist/uri/http.d.ts +23 -0
- package/dist/uri/http.js +30 -0
- package/dist/uri/http.js.map +1 -0
- package/dist/uri/https.d.ts +13 -0
- package/dist/uri/https.js +15 -0
- package/dist/uri/https.js.map +1 -0
- package/dist/uri/rfc2396-parser.d.ts +70 -0
- package/dist/uri/rfc2396-parser.js +264 -0
- package/dist/uri/rfc2396-parser.js.map +1 -0
- package/dist/uri/rfc3986-parser.d.ts +46 -0
- package/dist/uri/rfc3986-parser.js +171 -0
- package/dist/uri/rfc3986-parser.js.map +1 -0
- package/dist/uri.d.ts +13 -0
- package/dist/uri.js +13 -0
- package/dist/uri.js.map +1 -0
- package/dist/variable.d.ts +183 -0
- package/dist/variable.js +463 -0
- package/dist/variable.js.map +1 -0
- package/dist/verbose.d.ts +21 -0
- package/dist/verbose.js +26 -0
- package/dist/verbose.js.map +1 -0
- package/dist/yaml.d.ts +9 -0
- package/dist/yaml.js +9 -0
- package/dist/yaml.js.map +1 -0
- package/dist/zlib-adapter.d.ts +117 -0
- package/dist/zlib-adapter.js +250 -0
- package/dist/zlib-adapter.js.map +1 -0
- package/dist/zlib.d.ts +248 -0
- package/dist/zlib.js +362 -0
- package/dist/zlib.js.map +1 -0
- package/package.json +82 -3
package/dist/range.js
ADDED
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby's core `Range` class (`vendor/ruby/v3.3.11/range.c:31`), which Rails'
|
|
3
|
+
* `core_ext/range/*` files reopen. Those Rails files are ported one-for-one
|
|
4
|
+
* under `activesupport/lib/core-ext/range/`, and reopen this class the way
|
|
5
|
+
* Ruby reopens `Range`.
|
|
6
|
+
*
|
|
7
|
+
* @boundary-file: ordering goes through `comparable.ts`'s `cmp`, which coerces
|
|
8
|
+
* `Date` ↔ epoch number since Rails' `Range#cover?` accepts any
|
|
9
|
+
* `<=>`-comparable value. Temporal-typed ranges live elsewhere.
|
|
10
|
+
*/
|
|
11
|
+
import { ArgumentError } from "./argument-error.js";
|
|
12
|
+
import { cmp, rbCmpint } from "./comparable.js";
|
|
13
|
+
import { succ } from "./string/succ.js";
|
|
14
|
+
import { rbEqual } from "./rb-equal.js";
|
|
15
|
+
import { NameError } from "./name-error.js";
|
|
16
|
+
import { FrozenError } from "./frozen-error.js";
|
|
17
|
+
import { RObject, rbInspect, rbIvarGet, rbIvarSet, rbObjClassname } from "./object.js";
|
|
18
|
+
import { rubyNumIntervalStepSize } from "./numeric.js";
|
|
19
|
+
const inspectRecursing = new Set();
|
|
20
|
+
/** `INT_MAX`, the value `r_less` answers for a nil `<=>` (`vendor/ruby/v3.3.11/range.c:204`). */
|
|
21
|
+
const INT_MAX = 2147483647;
|
|
22
|
+
/**
|
|
23
|
+
* `vendor/ruby/v3.3.11/range.c:199` `r_less` — the comparison every endpoint check
|
|
24
|
+
* below makes. It is `a <=> b` ({@link cmp}) with one extra arm: an
|
|
25
|
+
* incomparable pair, whose `<=>` is nil, answers `INT_MAX` and so sorts as
|
|
26
|
+
* "greater" rather than raising.
|
|
27
|
+
*/
|
|
28
|
+
function rLess(a, b) {
|
|
29
|
+
const r = cmp(a, b);
|
|
30
|
+
if (r === null)
|
|
31
|
+
return INT_MAX;
|
|
32
|
+
return r;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `vendor/ruby/v3.3.11/range.c:369` `check_step_domain`. The comparison goes through
|
|
36
|
+
* `rb_cmpint` (`vendor/ruby/v3.3.11/bignum.c:2959`), NOT through {@link rLess}: a step
|
|
37
|
+
* that cannot be placed against 0 — `Float::NAN` — has a nil `<=>`, and
|
|
38
|
+
* `rb_cmpint` raises `ArgumentError` for it where `r_less` would answer
|
|
39
|
+
* `INT_MAX` and let it through. MRI: `(1..5).step(Float::NAN)` raises
|
|
40
|
+
* `comparison of Float with 0 failed`.
|
|
41
|
+
*/
|
|
42
|
+
function checkStepDomain(step) {
|
|
43
|
+
const c = rbCmpint(cmp(step, 0), step, 0);
|
|
44
|
+
if (c < 0)
|
|
45
|
+
throw new ArgumentError("step can't be negative");
|
|
46
|
+
if (c === 0)
|
|
47
|
+
throw new ArgumentError("step can't be 0");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `rb_funcall(v, id_succ, 0, 0)` as `range_step` and `range_each` reach it
|
|
51
|
+
* (`vendor/ruby/v3.3.11/range.c:556`). Ruby dispatches `succ` on the object; JS has no
|
|
52
|
+
* such method on the built-ins a Range is built over, so the discrete types
|
|
53
|
+
* trails ranges actually carry are spelled out. `Date#succ` is +1 day
|
|
54
|
+
* (`vendor/ruby/v3.3.11/ext/date/date_core.c` `d_lite_next`).
|
|
55
|
+
*
|
|
56
|
+
* A type with no `succ` is Ruby's `!discrete_object_p` arm, which raises
|
|
57
|
+
* `TypeError: can\'t iterate from <class>`.
|
|
58
|
+
*/
|
|
59
|
+
function objSucc(v) {
|
|
60
|
+
if (typeof v === "string")
|
|
61
|
+
return succ(v);
|
|
62
|
+
if (typeof v === "number")
|
|
63
|
+
return (v + 1);
|
|
64
|
+
const o = v;
|
|
65
|
+
if (typeof o?.succ === "function")
|
|
66
|
+
return o.succ();
|
|
67
|
+
if (typeof o?.add === "function")
|
|
68
|
+
return o.add({ days: 1 });
|
|
69
|
+
throw new TypeError(`can't iterate from ${v?.constructor?.name ?? String(v)}`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Ruby's core `Range`. Only the members Rails' reopenings and the framework
|
|
73
|
+
* call are defined; `begin`, `end` and `exclude_end?` are the three readers
|
|
74
|
+
* every one of them reads off the receiver.
|
|
75
|
+
*
|
|
76
|
+
* `vendor/ruby/v3.3.11/range.c:31` — `rb_cRange`.
|
|
77
|
+
*
|
|
78
|
+
* @noRailsEquivalent PERMANENT — `Range` is a core Ruby class, not a Rails
|
|
79
|
+
* declaration, so no Rails file declares it; the Rails-declared `Range`
|
|
80
|
+
* classes (`Arel::Nodes::Range`, PG `OID::Range`) are unrelated node/type
|
|
81
|
+
* classes.
|
|
82
|
+
*/
|
|
83
|
+
export class Range {
|
|
84
|
+
begin;
|
|
85
|
+
end;
|
|
86
|
+
excludeEnd;
|
|
87
|
+
constructor(
|
|
88
|
+
/**
|
|
89
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#begin`
|
|
90
|
+
* (`vendor/ruby/v3.3.11/range.c:1178` `range_begin`). No Rails file declares it, so
|
|
91
|
+
* `parity:api:extra` has no Ruby name to credit it against.
|
|
92
|
+
*/
|
|
93
|
+
begin, end,
|
|
94
|
+
/**
|
|
95
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#exclude_end?`
|
|
96
|
+
* (`vendor/ruby/v3.3.11/range.c:133` `range_exclude_end_p`). No Rails file declares
|
|
97
|
+
* it, so `parity:api:extra` has no Ruby name to credit it against.
|
|
98
|
+
*/
|
|
99
|
+
excludeEnd = false) {
|
|
100
|
+
this.begin = begin;
|
|
101
|
+
this.end = end;
|
|
102
|
+
this.excludeEnd = excludeEnd;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#size`
|
|
106
|
+
* (`vendor/ruby/v3.3.11/range.c:836` `range_size`), over
|
|
107
|
+
* `ruby_num_interval_step_size` (`numeric.c:2798`) with a step of 1.
|
|
108
|
+
*/
|
|
109
|
+
size() {
|
|
110
|
+
const b = this.begin;
|
|
111
|
+
const e = this.end;
|
|
112
|
+
if (typeof b === "number" || typeof b === "bigint") {
|
|
113
|
+
if (typeof e === "number" || typeof e === "bigint")
|
|
114
|
+
return rubyNumIntervalStepSize(b, e, this.excludeEnd);
|
|
115
|
+
if (e === null)
|
|
116
|
+
return Infinity;
|
|
117
|
+
}
|
|
118
|
+
else if (b === null) {
|
|
119
|
+
if (typeof e === "number" || typeof e === "bigint")
|
|
120
|
+
return Infinity;
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
/** Raises before any other check on a beginless range, as Ruby does
|
|
125
|
+
* (`vendor/ruby/v3.3.11/range.c:1243` `range_first`). */
|
|
126
|
+
first() {
|
|
127
|
+
if (this.begin === null) {
|
|
128
|
+
throw new RangeError("cannot get the first element of beginless range");
|
|
129
|
+
}
|
|
130
|
+
return this.begin;
|
|
131
|
+
}
|
|
132
|
+
/** `vendor/ruby/v3.3.11/range.c:1349` `range_last`. */
|
|
133
|
+
last() {
|
|
134
|
+
return this.end;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Ruby answers nil for an empty range and raises for a beginless one, since
|
|
138
|
+
* there is no least element to report.
|
|
139
|
+
*
|
|
140
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#min` (`vendor/ruby/v3.3.11/range.c:1450`), read by
|
|
141
|
+
* `length.rb:18`. No Rails file declares it, so `parity:api:extra` has no
|
|
142
|
+
* Ruby name to credit it against.
|
|
143
|
+
*/
|
|
144
|
+
min() {
|
|
145
|
+
if (this.begin === null) {
|
|
146
|
+
throw new RangeError("cannot get the minimum of beginless range");
|
|
147
|
+
}
|
|
148
|
+
/* `vendor/ruby/v3.3.11/range.c:1450` — Ruby answers nil for an empty range, and an
|
|
149
|
+
exclusive end makes `begin == end` empty: `(1...1).min` is nil where
|
|
150
|
+
`(1..1).min` is 1. */
|
|
151
|
+
if (this.end !== null && rLess(this.begin, this.end) >= (this.excludeEnd ? 0 : 1))
|
|
152
|
+
return null;
|
|
153
|
+
return this.begin;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Ruby raises `TypeError` for a non-Integer excluded end rather than
|
|
157
|
+
* silently reporting a fractional maximum.
|
|
158
|
+
*
|
|
159
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#max` (`vendor/ruby/v3.3.11/range.c:1558`), read by
|
|
160
|
+
* `compare_range.rb:24,50`. No Rails file declares it, so `parity:api:extra` has
|
|
161
|
+
* no Ruby name to credit it against.
|
|
162
|
+
*/
|
|
163
|
+
max() {
|
|
164
|
+
const end = this.end;
|
|
165
|
+
if (!this.excludeEnd || end === null)
|
|
166
|
+
return end;
|
|
167
|
+
if (typeof end === "number") {
|
|
168
|
+
// `vendor/ruby/v3.3.11/range.c:1558` — Ruby's own `Range#max` message.
|
|
169
|
+
if (!Number.isInteger(end))
|
|
170
|
+
throw new TypeError("cannot exclude non Integer end value");
|
|
171
|
+
return (end - 1);
|
|
172
|
+
}
|
|
173
|
+
// boundary: Date endpoints, as above
|
|
174
|
+
return new Date(end.getTime() - 1);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#to_s` (`vendor/ruby/v3.3.11/range.c:1782`), the fallback
|
|
178
|
+
* `conversions.rb:55` and `json.rb:160` reach. No Rails file declares it.
|
|
179
|
+
*/
|
|
180
|
+
toS() {
|
|
181
|
+
const begin = this.begin !== null ? String(this.begin) : "";
|
|
182
|
+
const end = this.end !== null ? String(this.end) : "";
|
|
183
|
+
return `${begin}${this.excludeEnd ? "..." : ".."}${end}`;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#inspect` (`vendor/ruby/v3.3.11/range.c:1841`
|
|
187
|
+
* `range_inspect`, over `inspect_range`, `:1796-1816`).
|
|
188
|
+
*/
|
|
189
|
+
inspect() {
|
|
190
|
+
if (inspectRecursing.has(this))
|
|
191
|
+
return this.excludeEnd ? "(... ... ...)" : "(... .. ...)";
|
|
192
|
+
inspectRecursing.add(this);
|
|
193
|
+
try {
|
|
194
|
+
let str = this.begin !== null || this.end === null ? rbInspect(this.begin) : "";
|
|
195
|
+
str += this.excludeEnd ? "..." : "..";
|
|
196
|
+
if (this.begin === null || this.end !== null)
|
|
197
|
+
str += rbInspect(this.end);
|
|
198
|
+
return str;
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
inspectRecursing.delete(this);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Endpoint comparison — true when the range covers the scalar value.
|
|
206
|
+
*
|
|
207
|
+
* @noRailsEquivalent PERMANENT — core Ruby `Range#cover?` (`vendor/ruby/v3.3.11/range.c:2107`), the method
|
|
208
|
+
* `clusivity.rb:40-50` selects between. No Rails file declares it.
|
|
209
|
+
*/
|
|
210
|
+
cover(value) {
|
|
211
|
+
if (this.begin !== null && rLess(this.begin, value) > 0)
|
|
212
|
+
return false;
|
|
213
|
+
if (this.end !== null) {
|
|
214
|
+
const c = rLess(value, this.end);
|
|
215
|
+
if (this.excludeEnd ? c >= 0 : c > 0)
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* For a String range, membership in the `succ`-enumerated sequence from
|
|
222
|
+
* `begin` to `end`, NOT a plain lexicographic cover. Ruby enumerates string
|
|
223
|
+
* ranges by `String#succ` (`vendor/ruby/v3.3.11/range.c:1960`
|
|
224
|
+
* `range_include_internal` → `vendor/ruby/v3.3.11/string.c:5042` `rb_str_upto_each`),
|
|
225
|
+
* so a value is a member only if it is actually
|
|
226
|
+
* *reachable* by repeatedly applying `succ` to `begin` before passing `end`.
|
|
227
|
+
* This mirrors that enumeration faithfully: `("a".."bbb").include?("z")` is
|
|
228
|
+
* true (`"z"` is produced before the length guard trips), and
|
|
229
|
+
* `("a".."bbb").include?("a1")` is false (`succ` mixes no character classes,
|
|
230
|
+
* so `"a1"` is never produced) — unlike a `(length, lex)` window, which
|
|
231
|
+
* would wrongly admit `"a1"`.
|
|
232
|
+
*
|
|
233
|
+
* Beginless/endless string ranges have no enumerable sequence; Ruby raises
|
|
234
|
+
* `TypeError: cannot determine inclusion in beginless/endless ranges`
|
|
235
|
+
* (`vendor/ruby/v3.3.11/range.c:1960` `range_include_internal`), so this throws to match rather than
|
|
236
|
+
* inventing an answer Ruby never produces.
|
|
237
|
+
*/
|
|
238
|
+
isInclude(value) {
|
|
239
|
+
if (typeof this.begin !== "string" && typeof this.end !== "string")
|
|
240
|
+
return this.cover(value);
|
|
241
|
+
const { begin, end, excludeEnd } = this;
|
|
242
|
+
if (begin === null || end === null) {
|
|
243
|
+
throw new TypeError("cannot determine inclusion in beginless/endless ranges");
|
|
244
|
+
}
|
|
245
|
+
/* Faithful `vendor/ruby/v3.3.11/string.c:5042` `rb_str_upto_each`: enumerate
|
|
246
|
+
begin..end via succ, stopping at `end.succ`, when the exclusive end is
|
|
247
|
+
reached, or when the current string grows past `end`'s length (succ is
|
|
248
|
+
non-decreasing in length). */
|
|
249
|
+
const n = rLess(begin, end);
|
|
250
|
+
if (n > 0 || (excludeEnd && n === 0))
|
|
251
|
+
return false;
|
|
252
|
+
const afterEnd = succ(end);
|
|
253
|
+
let current = begin;
|
|
254
|
+
let guard = 0;
|
|
255
|
+
while (current !== afterEnd) {
|
|
256
|
+
let next = null;
|
|
257
|
+
if (excludeEnd || current !== end)
|
|
258
|
+
next = succ(current);
|
|
259
|
+
if (current === value)
|
|
260
|
+
return true;
|
|
261
|
+
if (next === null)
|
|
262
|
+
break;
|
|
263
|
+
current = next;
|
|
264
|
+
if (excludeEnd && current === end)
|
|
265
|
+
break;
|
|
266
|
+
if (current.length > end.length || current.length === 0)
|
|
267
|
+
break;
|
|
268
|
+
/* The length guard above bounds enumeration to strings no longer than
|
|
269
|
+
`end`, so this only trips for spans wider than ~26^5.
|
|
270
|
+
`vendor/ruby/v3.3.11/string.c:5042` would keep iterating (slow but correct);
|
|
271
|
+
throw rather than return a wrong `false`. */
|
|
272
|
+
if (++guard > 5_000_000) {
|
|
273
|
+
throw new RangeError("string range too large to enumerate for include?");
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
/** `vendor/ruby/v3.3.11/range.c:1889` `range_eqq`. */
|
|
279
|
+
caseEquals(value) {
|
|
280
|
+
return this.cover(value);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Ruby `Range#==` (`vendor/ruby/v3.3.11/range.c:183` `range_eq`): another Range whose `begin`, `end`
|
|
284
|
+
* and `exclude_end?` are each `==`. Two separately-built `1..5` are equal in
|
|
285
|
+
* Ruby, where JS `===` sees two distinct objects.
|
|
286
|
+
*/
|
|
287
|
+
equals(other) {
|
|
288
|
+
if (!(other instanceof Range))
|
|
289
|
+
return false;
|
|
290
|
+
return (rbEqual(this.begin, other.begin) &&
|
|
291
|
+
rbEqual(this.end, other.end) &&
|
|
292
|
+
this.excludeEnd === other.excludeEnd);
|
|
293
|
+
}
|
|
294
|
+
each(block) {
|
|
295
|
+
if (this.begin === null)
|
|
296
|
+
throw new TypeError("can't iterate from NilClass");
|
|
297
|
+
if (block == null)
|
|
298
|
+
return this.step(1);
|
|
299
|
+
for (const v of this.step(1))
|
|
300
|
+
block(v);
|
|
301
|
+
return this;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* `vendor/ruby/v3.3.11/range.c:870` `range_to_a`, whose `rb_call_super` is
|
|
305
|
+
* `Enumerable#to_a` over {@link each}.
|
|
306
|
+
*
|
|
307
|
+
* @noRailsEquivalent PERMANENT
|
|
308
|
+
*/
|
|
309
|
+
toA() {
|
|
310
|
+
if (this.end === null) {
|
|
311
|
+
throw new RangeError("cannot convert endless range to an array");
|
|
312
|
+
}
|
|
313
|
+
return [...this.each()];
|
|
314
|
+
}
|
|
315
|
+
/** @noRailsEquivalent PERMANENT */
|
|
316
|
+
map(block) {
|
|
317
|
+
const ary = [];
|
|
318
|
+
for (const v of this.each())
|
|
319
|
+
ary.push(block(v));
|
|
320
|
+
return ary;
|
|
321
|
+
}
|
|
322
|
+
step(n = 1, block) {
|
|
323
|
+
checkStepDomain(n);
|
|
324
|
+
const values = function* () {
|
|
325
|
+
if (typeof this.begin !== "number" && this.begin !== null) {
|
|
326
|
+
/* `step_i_iter` (`vendor/ruby/v3.3.11/range.c:312-325`) counts DOWN from `iter[0]`,
|
|
327
|
+
which `range_step` seeds at 1 (`:465`), and reseeds it to `step` on each
|
|
328
|
+
yield. So the first element always yields, and a fractional step never
|
|
329
|
+
lands on 0 again — which is exactly what MRI does here. */
|
|
330
|
+
let iter = 1;
|
|
331
|
+
let v = this.begin;
|
|
332
|
+
while (this.end === null ||
|
|
333
|
+
(this.excludeEnd ? rLess(v, this.end) < 0 : rLess(v, this.end) <= 0)) {
|
|
334
|
+
if (--iter === 0) {
|
|
335
|
+
yield v;
|
|
336
|
+
iter = n;
|
|
337
|
+
}
|
|
338
|
+
v = objSucc(v);
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
let current = this.first();
|
|
343
|
+
while (true) {
|
|
344
|
+
if (this.end !== null) {
|
|
345
|
+
const end = this.end;
|
|
346
|
+
if (this.excludeEnd ? current >= end : current > end)
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
yield current;
|
|
350
|
+
current += n;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
if (block == null)
|
|
354
|
+
return values.call(this);
|
|
355
|
+
for (const v of values.call(this))
|
|
356
|
+
block(v);
|
|
357
|
+
return this;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* `range_init` (`vendor/ruby/v3.3.11/range.c:47-64`).
|
|
362
|
+
*
|
|
363
|
+
* @noRailsEquivalent PERMANENT
|
|
364
|
+
*/
|
|
365
|
+
export function rangeInit(range, beg, end, excludeEnd) {
|
|
366
|
+
if ((!Number.isInteger(beg) || !Number.isInteger(end)) && beg != null && end != null) {
|
|
367
|
+
const v = cmp(beg, end);
|
|
368
|
+
if (v == null)
|
|
369
|
+
throw new ArgumentError("bad value for range");
|
|
370
|
+
}
|
|
371
|
+
Object.assign(range, { excludeEnd, begin: beg, end });
|
|
372
|
+
if (range.constructor === Range) {
|
|
373
|
+
Object.freeze(range);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* `range_modify` (`vendor/ruby/v3.3.11/range.c:76-83`).
|
|
378
|
+
*
|
|
379
|
+
* @noRailsEquivalent PERMANENT
|
|
380
|
+
*/
|
|
381
|
+
export function rangeModify(range) {
|
|
382
|
+
if (Object.isFrozen(range)) {
|
|
383
|
+
throw new FrozenError(`can't modify frozen ${rbObjClassname(range)}: ${rbInspect(range)}`, {
|
|
384
|
+
receiver: range,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
if (range.excludeEnd != null) {
|
|
388
|
+
throw new NameError("`initialize' called twice", "initialize", { receiver: range });
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* `range_dumper` (`vendor/ruby/v3.3.11/range.c:2179-2188`).
|
|
393
|
+
*
|
|
394
|
+
* @noRailsEquivalent PERMANENT
|
|
395
|
+
*/
|
|
396
|
+
export function rangeDumper(range) {
|
|
397
|
+
const v = new RObject();
|
|
398
|
+
rbIvarSet(v, "excl", range.excludeEnd);
|
|
399
|
+
rbIvarSet(v, "begin", range.begin);
|
|
400
|
+
rbIvarSet(v, "end", range.end);
|
|
401
|
+
return v;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* `range_loader` (`vendor/ruby/v3.3.11/range.c:2190-2206`).
|
|
405
|
+
*
|
|
406
|
+
* @noRailsEquivalent PERMANENT
|
|
407
|
+
*/
|
|
408
|
+
export function rangeLoader(range, obj) {
|
|
409
|
+
if (!(obj instanceof RObject) || obj.constructor !== RObject) {
|
|
410
|
+
throw new TypeError("not a dumped range object");
|
|
411
|
+
}
|
|
412
|
+
rangeModify(range);
|
|
413
|
+
const beg = rbIvarGet(obj, "begin");
|
|
414
|
+
const end = rbIvarGet(obj, "end");
|
|
415
|
+
const excl = rbIvarGet(obj, "excl");
|
|
416
|
+
if (excl != null) {
|
|
417
|
+
rangeInit(range, beg, end, excl !== false);
|
|
418
|
+
}
|
|
419
|
+
return range;
|
|
420
|
+
}
|
|
421
|
+
//# sourceMappingURL=range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range.js","sourceRoot":"","sources":["../lib/range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,KAAK,CAAC,CAAC;IACnB,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/** Ruby core `ZeroDivisionError`, what `rb_num_zerodiv`
|
|
2
|
+
* (`vendor/ruby/v3.3.11/numeric.c:206`) raises for a denominator of zero.
|
|
3
|
+
*
|
|
4
|
+
* @noRailsEquivalent PERMANENT — Ruby core; Rails defines no such error. */
|
|
5
|
+
export declare class ZeroDivisionError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Ruby's `Rational` (`vendor/ruby/v3.3.11/rational.c`), as much of it as its callers
|
|
10
|
+
* need: the constructor canonicalizes to lowest terms
|
|
11
|
+
* (`vendor/ruby/v3.3.11/rational.c:481` `nurat_s_canonicalize_internal`), `+` adds an
|
|
12
|
+
* Integer (`vendor/ruby/v3.3.11/rational.c:724` `rb_rational_plus`), and
|
|
13
|
+
* `numerator`/`denominator` read the parts back out. A Rational stays a
|
|
14
|
+
* Rational under arithmetic in Ruby — on ruby 3.3.11 `(Rational(1,2) * 12).class`
|
|
15
|
+
* is `Rational`, `(6/1)`, and so is `Rational(9,3)` — so a ported `FIXNUM_P`
|
|
16
|
+
* branch is NOT reached by a reducible Rational and this class matches by
|
|
17
|
+
* staying a Rational too. Nothing in `rational.c` folds a denominator of one to
|
|
18
|
+
* an Integer; the date gem spells that fold out inline where it wants it
|
|
19
|
+
* (`date_parse.c:531-534`), and where a body TESTS for it it sends
|
|
20
|
+
* `wholenum_p`, which is a predicate, not a conversion.
|
|
21
|
+
*
|
|
22
|
+
* @noRailsEquivalent PERMANENT — Ruby core. Rails defines no Rational; it
|
|
23
|
+
* inherits Ruby's, and `Date._parse` answers one for a fractional-hour
|
|
24
|
+
* `:offset`, so trails needs the value type to answer the same.
|
|
25
|
+
*/
|
|
26
|
+
export declare class Rational {
|
|
27
|
+
/** `vendor/ruby/v3.3.11/rational.c:580` `nurat_numerator` (`Rational#numerator`).
|
|
28
|
+
*
|
|
29
|
+
* Ruby's is an Integer — arbitrary precision — so a `bigint` is the JS
|
|
30
|
+
* analogue, not a `number`: a `number` is exact only inside
|
|
31
|
+
* `Number.MAX_SAFE_INTEGER` and a parsed fraction literal of more than
|
|
32
|
+
* sixteen digits (`date_parse.c:2319-2325`) runs straight past it.
|
|
33
|
+
*
|
|
34
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
35
|
+
readonly numerator: bigint;
|
|
36
|
+
/** `vendor/ruby/v3.3.11/rational.c:598` `nurat_denominator` (`Rational#denominator`).
|
|
37
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
38
|
+
readonly denominator: bigint;
|
|
39
|
+
/** `Rational::compatible` (`vendor/ruby/v3.3.11/rational.c:2806`), pathed at
|
|
40
|
+
* the foot of include.ts.
|
|
41
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
42
|
+
static compatible: abstract new () => {
|
|
43
|
+
marshalLoad(a: unknown): unknown;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `vendor/ruby/v3.3.11/rational.c:481` `nurat_s_canonicalize_internal`, the C
|
|
47
|
+
* constructor every `Rational` goes through — there is no public
|
|
48
|
+
* `Rational.new` in Ruby, so this is `rb_rational_new`
|
|
49
|
+
* (`vendor/ruby/v3.3.11/rational.c:1969`) rather than a method with a Ruby name.
|
|
50
|
+
* A Float argument goes through `float_to_r` ({@link floatToR}) — the
|
|
51
|
+
* `nurat_convert` division arm, so `new Rational(0.5, 86400)` is `(1/172800)`
|
|
52
|
+
* on ruby 3.3.11.
|
|
53
|
+
*
|
|
54
|
+
* `nurat_canonicalize` (`vendor/ruby/v3.3.11/rational.c:457`) puts the SIGN on the
|
|
55
|
+
* numerator before `nurat_reduce` cancels: it negates BOTH parts on a
|
|
56
|
+
* negative denominator, which is why `Rational(3, -4)` is `(-3/4)` on ruby
|
|
57
|
+
* 3.3.11 and not `(3/-4)`, and raises `rb_num_zerodiv` on a zero one.
|
|
58
|
+
*
|
|
59
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
60
|
+
constructor(num: number | bigint, den: number | bigint);
|
|
61
|
+
/** `vendor/ruby/v3.3.11/rational.c:1075` `rb_rational_cmp` (`Rational#<=>`), which
|
|
62
|
+
* compares `a.num * b.den` against `b.num * a.den` — exact, where a `toF`
|
|
63
|
+
* comparison would not be. Its T_FLOAT arm, `f_cmp(f_to_f(self), other)`,
|
|
64
|
+
* takes both sides to Float instead, and it is the only arm a non-integral
|
|
65
|
+
* operand has.
|
|
66
|
+
*
|
|
67
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
68
|
+
cmp(other: number | bigint | Rational): number;
|
|
69
|
+
/** `vendor/ruby/v3.3.11/rational.c:724` `rb_rational_plus` (`Rational#+`), for the
|
|
70
|
+
* Integer and Rational addends this port needs.
|
|
71
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
72
|
+
add(other: number | bigint | Rational): Rational;
|
|
73
|
+
/** `vendor/ruby/v3.3.11/rational.c:1128` `nurat_eqeq_p` (`Rational#==`). A Float
|
|
74
|
+
* operand compares as a double; anything else is asked `other == self`.
|
|
75
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
76
|
+
equals(other: unknown): boolean;
|
|
77
|
+
/** `vendor/ruby/v3.3.11/rational.c:1170` `nurat_coerce` (`Rational#coerce`), for the
|
|
78
|
+
* Integer, Float and Rational operands this port needs.
|
|
79
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
80
|
+
coerce(other: unknown): [unknown, unknown];
|
|
81
|
+
/** `vendor/ruby/v3.3.11/rational.c:861` `rb_rational_mul` (`Rational#*`), for the
|
|
82
|
+
* Integer multiplier this port needs. `f_muldiv`
|
|
83
|
+
* (`vendor/ruby/v3.3.11/rational.c:794`) cancels the multiplier against the
|
|
84
|
+
* denominator BEFORE it multiplies.
|
|
85
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
86
|
+
mul(other: number | bigint): Rational;
|
|
87
|
+
/** `vendor/ruby/v3.3.11/rational.c:903` `rb_rational_div` (`Rational#/`), for the
|
|
88
|
+
* Integer divisor this port needs, cancelled the same way {@link mul} is.
|
|
89
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
90
|
+
quo(other: number | bigint): Rational;
|
|
91
|
+
/** `vendor/ruby/v3.3.11/numeric.c:828` `num_zero_p` (`Rational#zero?`, inherited from
|
|
92
|
+
* Numeric), what `date_core.c`'s `f_zero_p` dispatches to for a Rational.
|
|
93
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
94
|
+
isZero(): boolean;
|
|
95
|
+
/** `vendor/ruby/v3.3.11/numeric.c:659` `num_div` (`Rational#div`, inherited from
|
|
96
|
+
* Numeric), the floored quotient — the method `date_core.c`'s `f_idiv` macro
|
|
97
|
+
* sends (`date_core.c:43`) — for the Integer divisor this port needs.
|
|
98
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
99
|
+
div(other: number | bigint): number;
|
|
100
|
+
/** `vendor/ruby/v3.3.11/numeric.c:700` `num_modulo` (`Rational#%`, inherited from
|
|
101
|
+
* Numeric), which is `self - other * (self.div other)` there too — what
|
|
102
|
+
* `date_core.c`'s `f_mod` dispatches to for a Rational — for the Integer
|
|
103
|
+
* and Rational divisors this port needs (`time.c`'s `modv`).
|
|
104
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
105
|
+
mod(other: number | bigint | Rational): Rational;
|
|
106
|
+
/** `vendor/ruby/v3.3.11/rational.c:1278` `nurat_truncate` (`Rational#to_i`), which
|
|
107
|
+
* truncates toward zero.
|
|
108
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
109
|
+
toI(): number;
|
|
110
|
+
/** `vendor/ruby/v3.3.11/rational.c:1287` `nurat_round_half_up` (`Rational#round`),
|
|
111
|
+
* which rounds half away from zero.
|
|
112
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
113
|
+
round(): number;
|
|
114
|
+
/** The `Float` a Rational becomes at a `number` seam —
|
|
115
|
+
* `vendor/ruby/v3.3.11/rational.c:1576` `nurat_to_f`, which is what every reader that
|
|
116
|
+
* hands the value to a floating-point API needs.
|
|
117
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
118
|
+
toF(): number;
|
|
119
|
+
/** `vendor/ruby/v3.3.11/rational.c:1802` `nurat_to_s` (`Rational#to_s`).
|
|
120
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
121
|
+
toString(): string;
|
|
122
|
+
/** `vendor/ruby/v3.3.11/rational.c:1818` `nurat_inspect` (`Rational#inspect`), which
|
|
123
|
+
* parenthesizes where {@link toString} does not.
|
|
124
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
125
|
+
inspect(): string;
|
|
126
|
+
/** `vendor/ruby/v3.3.11/rational.c:1857` `nurat_marshal_dump` (`Rational#marshal_dump`).
|
|
127
|
+
* Its `rb_copy_generic_ivar(a, self)` has no ivar table to write: a JS Array
|
|
128
|
+
* holds no ivars, which is why `has_ivars` (`vendor/ruby/v3.3.11/marshal.c:713`)
|
|
129
|
+
* counts none on one.
|
|
130
|
+
* @noRailsEquivalent PERMANENT — Ruby core, part of the Rational above. */
|
|
131
|
+
marshalDump(): [bigint, bigint];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* `vendor/ruby/v3.3.11/rational.c:1831` `nurat_dumper`.
|
|
135
|
+
*
|
|
136
|
+
* @noRailsEquivalent PERMANENT
|
|
137
|
+
*/
|
|
138
|
+
export declare function nuratDumper(self: Rational): Rational;
|
|
139
|
+
/**
|
|
140
|
+
* `vendor/ruby/v3.3.11/rational.c:1838` `nurat_loader`. `nurat_marshal_load`
|
|
141
|
+
* leaves the pair canonical and not reduced, and so does this.
|
|
142
|
+
*
|
|
143
|
+
* @noRailsEquivalent PERMANENT
|
|
144
|
+
*/
|
|
145
|
+
export declare function nuratLoader(self: Rational, a: object): Rational;
|
|
146
|
+
/**
|
|
147
|
+
* `Kernel#Rational()` — `vendor/ruby/v3.3.11/rational.c:2691` `nurat_s_convert`, whose
|
|
148
|
+
* `rb_scan_args(argc, argv, "11", ...)` makes the denominator optional and
|
|
149
|
+
* defaults it to `ONE` (`vendor/ruby/v3.3.11/rational.c:2674`) before handing both to
|
|
150
|
+
* `nurat_s_canonicalize_internal`. It is the spelling Rails writes — 20 call
|
|
151
|
+
* sites across activesupport and activerecord — and it is NOT an Integer fold:
|
|
152
|
+
* on ruby 3.3.11 `Rational(6, 1)` is `(6/1)` and its class is `Rational`.
|
|
153
|
+
*
|
|
154
|
+
* A Rational numerator is NOT canonicalized against the denominator:
|
|
155
|
+
* `nurat_convert` (`vendor/ruby/v3.3.11/rational.c:2621`) returns it unchanged for an
|
|
156
|
+
* exact-one denominator, and otherwise leaves the canonicalizer for `f_div`
|
|
157
|
+
* (`vendor/ruby/v3.3.11/rational.c:2668`), so `Rational(r, 1000000)` is a division.
|
|
158
|
+
*
|
|
159
|
+
* A non-numeric operand is converted through its `to_r`
|
|
160
|
+
* (`vendor/ruby/v3.3.11/rational.c:2591,2647`), and `nil` raises TypeError (`:2564-2567`).
|
|
161
|
+
*
|
|
162
|
+
* @noRailsEquivalent PERMANENT — Ruby core `Kernel#Rational()`, which Rails
|
|
163
|
+
* calls and does not define. */
|
|
164
|
+
export declare function rational(numv: number | bigint | Rational | {
|
|
165
|
+
toR(): Rational;
|
|
166
|
+
}, denv?: number | bigint): Rational;
|
|
167
|
+
//# sourceMappingURL=rational.d.ts.map
|