@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.
- 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 +78 -0
- package/dist/backtrace-location.js +158 -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 +111 -0
- package/dist/big-decimal.js +584 -0
- package/dist/big-decimal.js.map +1 -0
- package/dist/bundler.d.ts +44 -0
- package/dist/bundler.js +97 -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 +93 -0
- package/dist/classpath.js +210 -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 +49 -0
- package/dist/complex.js +164 -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 +225 -0
- package/dist/dir.js +608 -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 +1102 -0
- package/dist/enumerable.js.map +1 -0
- package/dist/enumerator.d.ts +324 -0
- package/dist/enumerator.js +625 -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 +447 -0
- package/dist/errno.js +616 -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 +44 -0
- package/dist/exception.js +115 -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 +1824 -0
- package/dist/file-utils.js.map +1 -0
- package/dist/file.d.ts +643 -0
- package/dist/file.js +1334 -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 +41 -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 +55 -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 +124 -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 +2208 -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 +70 -0
- package/dist/json.js +181 -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 +39 -0
- package/dist/kernel-system.js +103 -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 +128 -0
- package/dist/load.js +278 -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 +218 -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 +81 -0
- package/dist/method-cache.js +109 -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 +13 -0
- package/dist/not-implemented-error.js.map +1 -0
- package/dist/numeric-class.d.ts +29 -0
- package/dist/numeric-class.js +41 -0
- package/dist/numeric-class.js.map +1 -0
- package/dist/numeric.d.ts +226 -0
- package/dist/numeric.js +848 -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 +833 -0
- package/dist/object.js +2131 -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 +73 -0
- package/dist/pathname.js +412 -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 +229 -0
- package/dist/process-adapter.js +889 -0
- package/dist/process-adapter.js.map +1 -0
- package/dist/process.d.ts +202 -0
- package/dist/process.js +433 -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 +31 -0
- package/dist/psych/scalar-scanner.js +169 -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 +137 -0
- package/dist/queue.js +236 -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 +168 -0
- package/dist/rational.js +587 -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 +262 -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 +270 -0
- package/dist/repl-adapter.js +562 -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 +15 -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 +50 -0
- package/dist/secure-random.js +141 -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 +43 -0
- package/dist/signal-exception.js +88 -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 +27 -0
- package/dist/standard-error.js +49 -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 +142 -0
- package/dist/string/support.js +296 -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 +295 -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 +121 -0
- package/dist/thread-pool-executor.js +254 -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 +66 -0
- package/dist/tse.js.map +1 -0
- package/dist/type-error.d.ts +14 -0
- package/dist/type-error.js +14 -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 +280 -0
- package/dist/uri/generic.js +806 -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 +39 -0
- package/dist/verbose.js +49 -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 +119 -0
- package/dist/zlib-adapter.js +230 -0
- package/dist/zlib-adapter.js.map +1 -0
- package/dist/zlib.d.ts +299 -0
- package/dist/zlib.js +679 -0
- package/dist/zlib.js.map +1 -0
- package/package.json +172 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { File } from "./file.js";
|
|
2
|
+
import { getOs } from "./os-adapter.js";
|
|
3
|
+
import { getProcessAdapter } from "./process-adapter.js";
|
|
4
|
+
/**
|
|
5
|
+
* `vendor/ruby/v3.3.11/tool/mkconfig.rb:21` — `RbConfig::CONFIG`, the build configuration hash Ruby's `rbconfig.rb`
|
|
6
|
+
* defines. Only the keys trails' ports read are answered; `EXEEXT` is the
|
|
7
|
+
* executable suffix a DOSISH build appends and the empty string everywhere
|
|
8
|
+
* else, which is what `ActiveRecord::ConnectionAdapters::AbstractAdapter
|
|
9
|
+
* .find_cmd_and_exec` (`abstract_adapter.rb:95`) tests for emptiness.
|
|
10
|
+
* `rubylibdir` is where the standard library's frames come from, which in
|
|
11
|
+
* Node is the `node:` scheme. `bindir` and `ruby_install_name` locate the
|
|
12
|
+
* running interpreter, which here is the JS runtime's executable: its
|
|
13
|
+
* directory, and its file name less `EXEEXT`, so that
|
|
14
|
+
* `File.join(bindir, ruby_install_name) + EXEEXT` is the executable's path, as
|
|
15
|
+
* `Thor::Util.ruby_command` (`vendor/thor/v1.4.0/lib/thor/util.rb:223-225`)
|
|
16
|
+
* builds it. Both are read from the process adapter on access, and are empty
|
|
17
|
+
* where the host names no executable.
|
|
18
|
+
*
|
|
19
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `RbConfig`.
|
|
20
|
+
*/
|
|
21
|
+
export const RbConfig = {
|
|
22
|
+
/**
|
|
23
|
+
* `vendor/ruby/v3.3.11/tool/mkconfig.rb:394` — the config hash itself, read as
|
|
24
|
+
* `RbConfig::CONFIG["EXEEXT"]` and `RbConfig::CONFIG["host_os"]`.
|
|
25
|
+
*
|
|
26
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `RbConfig::CONFIG`.
|
|
27
|
+
*/
|
|
28
|
+
get CONFIG() {
|
|
29
|
+
const platform = getOs().platform();
|
|
30
|
+
const EXEEXT = platform === "win32" ? ".exe" : "";
|
|
31
|
+
const execPath = () => getProcessAdapter().execPath?.() ?? "";
|
|
32
|
+
return {
|
|
33
|
+
EXEEXT,
|
|
34
|
+
host_os: platform === "win32" ? "mingw32" : platform,
|
|
35
|
+
rubylibdir: "node:",
|
|
36
|
+
get bindir() {
|
|
37
|
+
return execPath() === "" ? "" : File.dirname(execPath());
|
|
38
|
+
},
|
|
39
|
+
get ruby_install_name() {
|
|
40
|
+
return File.basename(execPath(), EXEEXT);
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* `vendor/ruby/v3.3.11/tool/mkconfig.rb:391` — `RbConfig.ruby`.
|
|
46
|
+
*
|
|
47
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `RbConfig.ruby`.
|
|
48
|
+
*/
|
|
49
|
+
ruby() {
|
|
50
|
+
return File.join(RbConfig.CONFIG["bindir"], RbConfig.CONFIG["ruby_install_name"] + RbConfig.CONFIG["EXEEXT"]);
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=rb-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rb-config.js","sourceRoot":"","sources":["../lib/rb-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB;;;;;OAKG;IACH,IAAI,MAAM;QACR,MAAM,QAAQ,GAAG,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC;QACpC,MAAM,MAAM,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC;QAC9D,OAAO;YACL,MAAM;YACN,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;YACpD,UAAU,EAAE,OAAO;YACnB,IAAI,MAAM;gBACR,OAAO,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC3D,CAAC;YACD,IAAI,iBAAiB;gBACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;YAC3C,CAAC;SACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CACd,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EACzB,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CACjE,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby's `rb_equal` (`vendor/ruby/v3.3.11/object.c:147`) — the C primitive behind every `==` send: identity first,
|
|
3
|
+
* then the receiver's own `==`. Ported callers (`Range#==`'s endpoint
|
|
4
|
+
* comparison, `Duration#==`'s non-Duration arm) all need the same dispatch,
|
|
5
|
+
* and JS `===` only covers its first arm.
|
|
6
|
+
*
|
|
7
|
+
* `rb_str_equal` (`vendor/ruby/v3.3.11/string.c:3742`) compares a UTF-8 String
|
|
8
|
+
* with a binary one, whose seat is a `Uint8Array`, only where
|
|
9
|
+
* `rb_str_comparable` (`string.c:3671`) allows it, which is when one of them is
|
|
10
|
+
* 7-bit, and then by their bytes.
|
|
11
|
+
*
|
|
12
|
+
* @noRailsEquivalent PERMANENT — `rb_equal` is a C primitive
|
|
13
|
+
* (`vendor/ruby/v3.3.11/object.c:147`), not a
|
|
14
|
+
* Ruby method, so it has no counterpart file; JS has no `==` send at all, so
|
|
15
|
+
* one copy serves every ported `==`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rbEqual(a: unknown, b: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Ruby's `rb_eql` (`vendor/ruby/v3.3.11/object.c:159`) — the C primitive behind every
|
|
20
|
+
* `eql?` send, and the equality a Hash keys on. It is `rb_equal` with one arm
|
|
21
|
+
* removed: `Kernel#eql?` defaults to `rb_obj_equal`
|
|
22
|
+
* (`vendor/ruby/v3.3.11/object.c:4374`), identity, so a class that defines `==` and no
|
|
23
|
+
* `eql?` is `eql?` only to itself, where `==` may answer true. The value
|
|
24
|
+
* classes that override it — String, Array, Hash, Integer, Date, Time — are
|
|
25
|
+
* shared with `rb_equal` and compare the same, which is why MRI threads the
|
|
26
|
+
* difference as a flag through one body (`hash_equal`'s `int eql`,
|
|
27
|
+
* `vendor/ruby/v3.3.11/hash.c:3746`) rather than writing the walk twice.
|
|
28
|
+
*
|
|
29
|
+
* @noRailsEquivalent PERMANENT — `rb_eql` is a C primitive
|
|
30
|
+
* (`vendor/ruby/v3.3.11/object.c:159`), not a Ruby method, so it has no counterpart
|
|
31
|
+
* file; JS has no `eql?` send at all, so one copy serves every ported
|
|
32
|
+
* `eql?`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rbEql(a: unknown, b: unknown): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The `RHASH` of `hash_equal` (`vendor/ruby/v3.3.11/hash.c:3746`) over both JS seats.
|
|
37
|
+
*
|
|
38
|
+
* @noRailsEquivalent PERMANENT
|
|
39
|
+
*/
|
|
40
|
+
export declare function hashEntries(value: unknown): [unknown, unknown][] | null;
|
|
41
|
+
/**
|
|
42
|
+
* The `===` send (`rb_funcall(pattern, idEqq, 1, target)`, what
|
|
43
|
+
* `check_match` issues for a `case`/`when`, `vendor/ruby/v3.3.11/vm_insnhelper.c:2445-2446`),
|
|
44
|
+
* dispatched over the JS seats of the classes that define it: a receiver's own
|
|
45
|
+
* `caseEquals` (Range's `range_eqq`, `vendor/ruby/v3.3.11/range.c:2644`), Regexp's
|
|
46
|
+
* `rb_reg_eqq` (`vendor/ruby/v3.3.11/re.c:3676`, a non-String operand is `false`),
|
|
47
|
+
* Set's `include?` alias, `Module#===` (`rb_mod_eqq`, `vendor/ruby/v3.3.11/object.c:1771`)
|
|
48
|
+
* for a constructor, `Proc#===` (`proc_call`, `vendor/ruby/v3.3.11/proc.c:4302`) for
|
|
49
|
+
* any other function, and `Kernel#===` (`case_equal`, `object.c:4372`), which
|
|
50
|
+
* is `rb_equal`, for everything else.
|
|
51
|
+
*
|
|
52
|
+
* @noRailsEquivalent PERMANENT — the `===` send is a C method dispatch
|
|
53
|
+
* (`vendor/ruby/v3.3.11/vm_insnhelper.c:2446`); JS has no `===` send at all, so one
|
|
54
|
+
* copy serves every ported `===`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function rbEqq(pattern: unknown, target: unknown): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* `k_date_p` (`vendor/ruby/v3.3.11/ext/date/date_core.c:1992`), `f_kind_of_p(x, cDate)`.
|
|
59
|
+
* Read off `rbObjClass` rather than `rbObjIsKindOf`, whose module would close an
|
|
60
|
+
* import cycle through include.ts.
|
|
61
|
+
*
|
|
62
|
+
* @internal
|
|
63
|
+
* @noRailsEquivalent PERMANENT
|
|
64
|
+
*/
|
|
65
|
+
export declare function kDateP(x: unknown): boolean;
|
|
66
|
+
//# sourceMappingURL=rb-equal.d.ts.map
|
package/dist/rb-equal.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { rbCDate, rbCString, rbObjClass, rbObjIsProc, rbObjRespondTo, rtest } from "./object.js";
|
|
2
|
+
import { isModuleObject } from "./classpath.js";
|
|
3
|
+
import { rbRegEqual } from "./regexp.js";
|
|
4
|
+
import { temporalTag, widenPlainDate } from "./temporal-tag.js";
|
|
5
|
+
/**
|
|
6
|
+
* Ruby's `rb_equal` (`vendor/ruby/v3.3.11/object.c:147`) — the C primitive behind every `==` send: identity first,
|
|
7
|
+
* then the receiver's own `==`. Ported callers (`Range#==`'s endpoint
|
|
8
|
+
* comparison, `Duration#==`'s non-Duration arm) all need the same dispatch,
|
|
9
|
+
* and JS `===` only covers its first arm.
|
|
10
|
+
*
|
|
11
|
+
* `rb_str_equal` (`vendor/ruby/v3.3.11/string.c:3742`) compares a UTF-8 String
|
|
12
|
+
* with a binary one, whose seat is a `Uint8Array`, only where
|
|
13
|
+
* `rb_str_comparable` (`string.c:3671`) allows it, which is when one of them is
|
|
14
|
+
* 7-bit, and then by their bytes.
|
|
15
|
+
*
|
|
16
|
+
* @noRailsEquivalent PERMANENT — `rb_equal` is a C primitive
|
|
17
|
+
* (`vendor/ruby/v3.3.11/object.c:147`), not a
|
|
18
|
+
* Ruby method, so it has no counterpart file; JS has no `==` send at all, so
|
|
19
|
+
* one copy serves every ported `==`.
|
|
20
|
+
*/
|
|
21
|
+
export function rbEqual(a, b) {
|
|
22
|
+
return equalOrEql(a, b, false);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Ruby's `rb_eql` (`vendor/ruby/v3.3.11/object.c:159`) — the C primitive behind every
|
|
26
|
+
* `eql?` send, and the equality a Hash keys on. It is `rb_equal` with one arm
|
|
27
|
+
* removed: `Kernel#eql?` defaults to `rb_obj_equal`
|
|
28
|
+
* (`vendor/ruby/v3.3.11/object.c:4374`), identity, so a class that defines `==` and no
|
|
29
|
+
* `eql?` is `eql?` only to itself, where `==` may answer true. The value
|
|
30
|
+
* classes that override it — String, Array, Hash, Integer, Date, Time — are
|
|
31
|
+
* shared with `rb_equal` and compare the same, which is why MRI threads the
|
|
32
|
+
* difference as a flag through one body (`hash_equal`'s `int eql`,
|
|
33
|
+
* `vendor/ruby/v3.3.11/hash.c:3746`) rather than writing the walk twice.
|
|
34
|
+
*
|
|
35
|
+
* @noRailsEquivalent PERMANENT — `rb_eql` is a C primitive
|
|
36
|
+
* (`vendor/ruby/v3.3.11/object.c:159`), not a Ruby method, so it has no counterpart
|
|
37
|
+
* file; JS has no `eql?` send at all, so one copy serves every ported
|
|
38
|
+
* `eql?`.
|
|
39
|
+
*/
|
|
40
|
+
export function rbEql(a, b) {
|
|
41
|
+
return equalOrEql(a, b, true);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* `rb_equal` (`vendor/ruby/v3.3.11/object.c:147`) and `rb_eql`
|
|
45
|
+
* (`object.c:159`) over one body, the way `hash_equal`
|
|
46
|
+
* (`vendor/ruby/v3.3.11/hash.c:3746`) carries both behind its `int eql`.
|
|
47
|
+
*/
|
|
48
|
+
function equalOrEql(a, b, eql) {
|
|
49
|
+
if (a === b)
|
|
50
|
+
return true;
|
|
51
|
+
if (a == null || b == null)
|
|
52
|
+
return false;
|
|
53
|
+
if (a instanceof Set && b instanceof Set) {
|
|
54
|
+
if (a.size !== b.size)
|
|
55
|
+
return false;
|
|
56
|
+
const members = [...a];
|
|
57
|
+
return [...b].every((o) => a.has(o) || members.some((m) => equalOrEql(m, o, true)));
|
|
58
|
+
}
|
|
59
|
+
if (a instanceof String || b instanceof String) {
|
|
60
|
+
return equalOrEql(a instanceof String ? a.valueOf() : a, b instanceof String ? b.valueOf() : b, eql);
|
|
61
|
+
}
|
|
62
|
+
if (typeof a === "string" && b instanceof Uint8Array) {
|
|
63
|
+
return a.length === b.length && b.every((byte, i) => byte < 0x80 && byte === a.charCodeAt(i));
|
|
64
|
+
}
|
|
65
|
+
if (a instanceof Uint8Array && typeof b === "string")
|
|
66
|
+
return equalOrEql(b, a, eql);
|
|
67
|
+
/* A `Uint8Array` stands in for a Ruby binary String (the representation
|
|
68
|
+
`ActiveModel::Type::Binary#cast` produces, binary.rb:20-27). `rb_str_equal`
|
|
69
|
+
(`vendor/ruby/v3.3.11/string.c:3742`) compares two of them by their bytes,
|
|
70
|
+
and asks a non-String `other == self` only when it answers `to_str`;
|
|
71
|
+
`rb_str_eql` (`string.c:3773`) answers false for any non-String. Tried
|
|
72
|
+
ahead of the `equals` arm: a Node `Buffer` carries an `equals` of its own,
|
|
73
|
+
which raises for a non-buffer operand. */
|
|
74
|
+
if (a instanceof Uint8Array) {
|
|
75
|
+
if (b instanceof Uint8Array) {
|
|
76
|
+
return a.length === b.length && a.every((byte, i) => byte === b[i]);
|
|
77
|
+
}
|
|
78
|
+
if (eql || !rbObjRespondTo(b, "toStr"))
|
|
79
|
+
return false;
|
|
80
|
+
return equalOrEql(b, a, eql);
|
|
81
|
+
}
|
|
82
|
+
/* `rb_str_equal` (`vendor/ruby/v3.3.11/string.c:3742`): a non-String answering
|
|
83
|
+
`to_str` is asked `other == self` in turn. */
|
|
84
|
+
if (typeof a === "string" && typeof b !== "string") {
|
|
85
|
+
if (!(b instanceof rbCString) && !rbObjRespondTo(b, "toStr"))
|
|
86
|
+
return false;
|
|
87
|
+
return equalOrEql(b, a, eql);
|
|
88
|
+
}
|
|
89
|
+
/* `rb_int_equal` (`vendor/ruby/v3.3.11/numeric.c:4634`) compares by value, and Ruby
|
|
90
|
+
has one Integer for every magnitude. JS splits that seat across `number`
|
|
91
|
+
and `bigint`, so `===` answers false for two seats of the same Ruby
|
|
92
|
+
Integer. */
|
|
93
|
+
if (typeof a === "bigint" || typeof b === "bigint") {
|
|
94
|
+
if (typeof a === "number")
|
|
95
|
+
return Number.isInteger(a) && BigInt(a) === b;
|
|
96
|
+
if (typeof b === "number")
|
|
97
|
+
return Number.isInteger(b) && a === BigInt(b);
|
|
98
|
+
}
|
|
99
|
+
if (a instanceof Number || b instanceof Number) {
|
|
100
|
+
const x = a instanceof Number ? a.valueOf() : a;
|
|
101
|
+
const y = b instanceof Number ? b.valueOf() : b;
|
|
102
|
+
if (eql) {
|
|
103
|
+
return ((a instanceof Number || (typeof x === "number" && !Number.isInteger(x))) &&
|
|
104
|
+
(b instanceof Number || (typeof y === "number" && !Number.isInteger(y))) &&
|
|
105
|
+
x === y);
|
|
106
|
+
}
|
|
107
|
+
return equalOrEql(x, y, eql);
|
|
108
|
+
}
|
|
109
|
+
if (!eql && (typeof a === "number" || typeof a === "bigint") && typeof b === "object") {
|
|
110
|
+
return equalOrEql(b, a, eql);
|
|
111
|
+
}
|
|
112
|
+
/* Ruby's `Date#==` (`vendor/ruby/v3.3.11/ext/date/date_core.c:6902` `d_lite_equal`) is
|
|
113
|
+
`<=>`-based (`vendor/ruby/v3.3.11/ext/date/date_core.c:6810` `d_lite_cmp`), so it
|
|
114
|
+
answers `false` for an operand of another class instead of raising, and a
|
|
115
|
+
Date equals a DateTime at the same instant. Temporal's own `equals` has
|
|
116
|
+
neither half — it coerces its argument, so `PlainDate#equals` raises
|
|
117
|
+
`TypeError: year is required` for an Instant — which is why this is tried
|
|
118
|
+
before the `equals` arm below, mirroring `cmp`'s Temporal arm. */
|
|
119
|
+
const tag = temporalTag(a);
|
|
120
|
+
if (tag !== null) {
|
|
121
|
+
if (temporalTag(b) === null) {
|
|
122
|
+
if (kDateP(a) && kDateP(b))
|
|
123
|
+
return b.cmp(a) === 0;
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const x = widenPlainDate(a);
|
|
127
|
+
const y = widenPlainDate(b);
|
|
128
|
+
if (temporalTag(x) !== temporalTag(y))
|
|
129
|
+
return false;
|
|
130
|
+
return (x.constructor.compare(x, y) === 0);
|
|
131
|
+
}
|
|
132
|
+
/* `Kernel#eql?` is `rb_obj_equal` (`vendor/ruby/v3.3.11/object.c:4374`), identity, so
|
|
133
|
+
a class's `==` answers only the `rb_equal` send; the `eql` arm below is the
|
|
134
|
+
one an `eql?` send reaches. */
|
|
135
|
+
if (!eql && typeof a.equals === "function") {
|
|
136
|
+
return a.equals(b);
|
|
137
|
+
}
|
|
138
|
+
/* `vendor/ruby/v3.3.11/object.c:147`. A class whose Ruby `==` is `alias :== :eql?`
|
|
139
|
+
(Arel::Nodes::Casted, arel/nodes/casted.rb:33; Arel::Table) has only the
|
|
140
|
+
`eql` half in TS, so that IS its `==`. Tried second on purpose: a class
|
|
141
|
+
carrying both spellings (Duration, TimeWithZone) means the two by their
|
|
142
|
+
Ruby names, and `equals` above is the `==` of the pair. */
|
|
143
|
+
if (typeof a.eql === "function") {
|
|
144
|
+
return a.eql(b);
|
|
145
|
+
}
|
|
146
|
+
/* Ruby's `Array#==` (`vendor/ruby/v3.3.11/array.c:5120` `rb_ary_equal`) compares
|
|
147
|
+
elementwise with `==`, and `Date#==` / `Time#==` compare by value — both
|
|
148
|
+
are `rb_equal` sends of their own, and a JS `===` on either is reference
|
|
149
|
+
equality. */
|
|
150
|
+
if (Array.isArray(a)) {
|
|
151
|
+
return (Array.isArray(b) &&
|
|
152
|
+
a.length === b.length &&
|
|
153
|
+
a.every((element, i) => equalOrEql(element, b[i], eql)));
|
|
154
|
+
}
|
|
155
|
+
/* boundary: a JS Date is one of the values a ported `==` is handed, and
|
|
156
|
+
Ruby's `Date#==` / `Time#==` (`vendor/ruby/v3.3.11/time.c:3951` `time_cmp`)
|
|
157
|
+
compare by value where JS `===` does not. */
|
|
158
|
+
if (a instanceof RegExp)
|
|
159
|
+
return rbRegEqual(a, b);
|
|
160
|
+
if (a instanceof Date)
|
|
161
|
+
return b instanceof Date && a.getTime() === b.getTime();
|
|
162
|
+
/* `rb_hash_equal` (`vendor/ruby/v3.3.11/hash.c:3808`), which `hash_equal`
|
|
163
|
+
(`hash.c:3746`) answers by size and then by `rb_equal` per key. A Ruby
|
|
164
|
+
Hash has two JS seats — a plain object and a `Map` (ruby-compat's `Hash`,
|
|
165
|
+
and `HashWithIndifferentAccess` under it) — and both stand for the same
|
|
166
|
+
Ruby value, so the arm reads whichever the operand is. */
|
|
167
|
+
if (isHash(a)) {
|
|
168
|
+
if (!isHash(b)) {
|
|
169
|
+
if (!rbObjRespondTo(b, "toHash"))
|
|
170
|
+
return false;
|
|
171
|
+
return equalOrEql(b, a, eql);
|
|
172
|
+
}
|
|
173
|
+
const entriesA = hashEntries(a);
|
|
174
|
+
const entriesB = hashEntries(b);
|
|
175
|
+
if (entriesA.length !== entriesB.length)
|
|
176
|
+
return false;
|
|
177
|
+
/* `eql_i` (`vendor/ruby/v3.3.11/hash.c:3714`) finds hash2's entry with
|
|
178
|
+
`hash_stlike_lookup` (`hash.c:3719`), by
|
|
179
|
+
the Hash's own key semantics — `hash` then `eql?`, never `==` — not by
|
|
180
|
+
identity, so a separately allocated but `eql?` key (an Array key, say)
|
|
181
|
+
still hits. The VALUES then compare with whichever send this call is
|
|
182
|
+
(`eql_i`'s `data->eql ? rb_eql : rb_equal`, `hash.c:3724`). */
|
|
183
|
+
return entriesA.every(([key, value]) => {
|
|
184
|
+
const found = entriesB.find(([otherKey]) => rbEql(key, otherKey));
|
|
185
|
+
return found !== undefined && equalOrEql(value, found[1], eql);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The `RHASH` of `hash_equal` (`vendor/ruby/v3.3.11/hash.c:3746`) over both JS seats.
|
|
192
|
+
*
|
|
193
|
+
* @noRailsEquivalent PERMANENT
|
|
194
|
+
*/
|
|
195
|
+
export function hashEntries(value) {
|
|
196
|
+
if (value instanceof Map)
|
|
197
|
+
return [...value.entries()];
|
|
198
|
+
if (isHash(value))
|
|
199
|
+
return Object.entries(value);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
/* `RB_TYPE_P(hash2, T_HASH)` (`vendor/ruby/v3.3.11/hash.c:3751`), which
|
|
203
|
+
`hash_equal` asks of the other operand before it reads either table; a
|
|
204
|
+
non-Hash operand answering `to_hash` is asked `hash2 == hash1` in turn
|
|
205
|
+
(`hash.c:3752-3764`).
|
|
206
|
+
A plain object {@link isModuleObject} recognises is a Module, whose `==` is
|
|
207
|
+
`rb_obj_equal` (`vendor/ruby/v3.3.11/object.c:4374`), not a Hash. */
|
|
208
|
+
function isHash(value) {
|
|
209
|
+
return (value instanceof Map ||
|
|
210
|
+
(typeof value === "object" &&
|
|
211
|
+
value !== null &&
|
|
212
|
+
[Object.prototype, null].includes(Object.getPrototypeOf(value)) &&
|
|
213
|
+
!isModuleObject(value)));
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* The `===` send (`rb_funcall(pattern, idEqq, 1, target)`, what
|
|
217
|
+
* `check_match` issues for a `case`/`when`, `vendor/ruby/v3.3.11/vm_insnhelper.c:2445-2446`),
|
|
218
|
+
* dispatched over the JS seats of the classes that define it: a receiver's own
|
|
219
|
+
* `caseEquals` (Range's `range_eqq`, `vendor/ruby/v3.3.11/range.c:2644`), Regexp's
|
|
220
|
+
* `rb_reg_eqq` (`vendor/ruby/v3.3.11/re.c:3676`, a non-String operand is `false`),
|
|
221
|
+
* Set's `include?` alias, `Module#===` (`rb_mod_eqq`, `vendor/ruby/v3.3.11/object.c:1771`)
|
|
222
|
+
* for a constructor, `Proc#===` (`proc_call`, `vendor/ruby/v3.3.11/proc.c:4302`) for
|
|
223
|
+
* any other function, and `Kernel#===` (`case_equal`, `object.c:4372`), which
|
|
224
|
+
* is `rb_equal`, for everything else.
|
|
225
|
+
*
|
|
226
|
+
* @noRailsEquivalent PERMANENT — the `===` send is a C method dispatch
|
|
227
|
+
* (`vendor/ruby/v3.3.11/vm_insnhelper.c:2446`); JS has no `===` send at all, so one
|
|
228
|
+
* copy serves every ported `===`.
|
|
229
|
+
*/
|
|
230
|
+
export function rbEqq(pattern, target) {
|
|
231
|
+
if (pattern != null && typeof pattern.caseEquals === "function") {
|
|
232
|
+
return pattern.caseEquals(target);
|
|
233
|
+
}
|
|
234
|
+
if (pattern instanceof RegExp) {
|
|
235
|
+
if (typeof target !== "string")
|
|
236
|
+
return false;
|
|
237
|
+
pattern.lastIndex = 0;
|
|
238
|
+
return pattern.test(target);
|
|
239
|
+
}
|
|
240
|
+
if (pattern instanceof Set)
|
|
241
|
+
return pattern.has(target);
|
|
242
|
+
if (typeof pattern === "function") {
|
|
243
|
+
if (!rbObjIsProc(pattern)) {
|
|
244
|
+
return rbObjClass(target) === pattern || Object(target) instanceof pattern;
|
|
245
|
+
}
|
|
246
|
+
return rtest(pattern(target));
|
|
247
|
+
}
|
|
248
|
+
return rbEqual(pattern, target);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* `k_date_p` (`vendor/ruby/v3.3.11/ext/date/date_core.c:1992`), `f_kind_of_p(x, cDate)`.
|
|
252
|
+
* Read off `rbObjClass` rather than `rbObjIsKindOf`, whose module would close an
|
|
253
|
+
* import cycle through include.ts.
|
|
254
|
+
*
|
|
255
|
+
* @internal
|
|
256
|
+
* @noRailsEquivalent PERMANENT
|
|
257
|
+
*/
|
|
258
|
+
export function kDateP(x) {
|
|
259
|
+
const klass = rbObjClass(x);
|
|
260
|
+
return klass === rbCDate || klass.prototype instanceof rbCDate;
|
|
261
|
+
}
|
|
262
|
+
//# sourceMappingURL=rb-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rb-equal.js","sourceRoot":"","sources":["../lib/rb-equal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEhE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,OAAO,CAAC,CAAU,EAAE,CAAU;IAC5C,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,KAAK,CAAC,CAAU,EAAE,CAAU;IAC1C,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,SAAS,UAAU,CAAC,CAAU,EAAE,CAAU,EAAE,GAAY;IACtD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACzC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;YAAE,OAAO,KA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
* (`vendor/ruby/v3.3.11/array.c:5205` `rb_ary_hash`) and `String#hash`
|
|
5
|
+
* (`vendor/ruby/v3.3.11/string.c:3629` `rb_str_hash`) arms the ports send — the value
|
|
6
|
+
* every `eql?`-pairing `hash` body composes with. Ported node bodies spell
|
|
7
|
+
* `[self.class, @left, @right].hash`, and JS has no `hash` on Object, Array,
|
|
8
|
+
* String or Class at all, so one copy serves every ported `hash`.
|
|
9
|
+
*
|
|
10
|
+
* Like Ruby, it is consistent with `rbEqual`: two objects that are `==` hash
|
|
11
|
+
* alike, and an object whose class defines no `hash` falls back to identity.
|
|
12
|
+
*
|
|
13
|
+
* @noRailsEquivalent PERMANENT — `Object#hash` / `Array#hash` / `String#hash`
|
|
14
|
+
* are C primitives (`vendor/ruby/v3.3.11/object.c:4375`, `array.c:5205`,
|
|
15
|
+
* `string.c:3629`), not Ruby methods, so they have no counterpart file.
|
|
16
|
+
*/
|
|
17
|
+
export declare function rbHash(value: unknown): number;
|
|
18
|
+
/**
|
|
19
|
+
* `Kernel#hash`'s identity arm (`vendor/ruby/v3.3.11/hash.c:344` `rb_obj_hash`, over
|
|
20
|
+
* `objid_hash`): a per-object Integer that `super` from a `hash` override
|
|
21
|
+
* reaches.
|
|
22
|
+
*
|
|
23
|
+
* @noRailsEquivalent PERMANENT
|
|
24
|
+
*/
|
|
25
|
+
export declare function rbObjHash(object: object): number;
|
|
26
|
+
//# sourceMappingURL=rb-hash.d.ts.map
|
package/dist/rb-hash.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { hashEntries } from "./rb-equal.js";
|
|
2
|
+
/**
|
|
3
|
+
* Ruby's `Object#hash` (`vendor/ruby/v3.3.11/object.c:4375`, `rb_define_method(rb_mKernel,
|
|
4
|
+
* "hash", rb_obj_hash, 0)`), with the `Array#hash`
|
|
5
|
+
* (`vendor/ruby/v3.3.11/array.c:5205` `rb_ary_hash`) and `String#hash`
|
|
6
|
+
* (`vendor/ruby/v3.3.11/string.c:3629` `rb_str_hash`) arms the ports send — the value
|
|
7
|
+
* every `eql?`-pairing `hash` body composes with. Ported node bodies spell
|
|
8
|
+
* `[self.class, @left, @right].hash`, and JS has no `hash` on Object, Array,
|
|
9
|
+
* String or Class at all, so one copy serves every ported `hash`.
|
|
10
|
+
*
|
|
11
|
+
* Like Ruby, it is consistent with `rbEqual`: two objects that are `==` hash
|
|
12
|
+
* alike, and an object whose class defines no `hash` falls back to identity.
|
|
13
|
+
*
|
|
14
|
+
* @noRailsEquivalent PERMANENT — `Object#hash` / `Array#hash` / `String#hash`
|
|
15
|
+
* are C primitives (`vendor/ruby/v3.3.11/object.c:4375`, `array.c:5205`,
|
|
16
|
+
* `string.c:3629`), not Ruby methods, so they have no counterpart file.
|
|
17
|
+
*/
|
|
18
|
+
export function rbHash(value) {
|
|
19
|
+
if (value === null || value === undefined)
|
|
20
|
+
return 0x9e3779b9;
|
|
21
|
+
switch (typeof value) {
|
|
22
|
+
case "string":
|
|
23
|
+
return stringHash(value);
|
|
24
|
+
case "number":
|
|
25
|
+
case "bigint":
|
|
26
|
+
return stringHash(`\0${String(value)}`);
|
|
27
|
+
case "boolean":
|
|
28
|
+
return value ? 0x5bf03635 : 0x27d4eb2f;
|
|
29
|
+
case "symbol":
|
|
30
|
+
return stringHash(String(value));
|
|
31
|
+
case "function":
|
|
32
|
+
/* A class object — Ruby's `self.class.hash` (`vendor/ruby/v3.3.11/object.c:4375`). */
|
|
33
|
+
return stringHash(`class:${value.name}`);
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
let h = 0x811c9dc5;
|
|
37
|
+
for (const element of value) {
|
|
38
|
+
h ^= rbHash(element);
|
|
39
|
+
h = Math.imul(h, 0x01000193);
|
|
40
|
+
}
|
|
41
|
+
return h >>> 0;
|
|
42
|
+
}
|
|
43
|
+
if (value instanceof Uint8Array) {
|
|
44
|
+
let h = 0x811c9dc5;
|
|
45
|
+
for (const byte of value) {
|
|
46
|
+
h ^= byte;
|
|
47
|
+
h = Math.imul(h, 0x01000193);
|
|
48
|
+
}
|
|
49
|
+
return h >>> 0;
|
|
50
|
+
}
|
|
51
|
+
const object = value;
|
|
52
|
+
if (typeof object.hash === "function") {
|
|
53
|
+
return object.hash();
|
|
54
|
+
}
|
|
55
|
+
/* A value object whose Ruby `==` is `equals` (Temporal, Duration) has to hash
|
|
56
|
+
by that same value, or two `==` objects land in different buckets — Ruby's
|
|
57
|
+
`hash`/`eql?` contract (`vendor/ruby/v3.3.11/object.c:4375`). */
|
|
58
|
+
if (typeof value.equals === "function") {
|
|
59
|
+
return stringHash(`${value.constructor.name}(${String(value)})`);
|
|
60
|
+
}
|
|
61
|
+
/* boundary: a JS Date reaches a ported `hash` the same way it reaches
|
|
62
|
+
`rbEqual`, and Ruby hashes it by value. */
|
|
63
|
+
if (value instanceof Date)
|
|
64
|
+
return stringHash(`Date(${value.toISOString()})`);
|
|
65
|
+
if (value instanceof RegExp)
|
|
66
|
+
return stringHash(`/${value.source}/${value.flags}`);
|
|
67
|
+
/* A Ruby Hash, whose `hash` (`vendor/ruby/v3.3.11/hash.c:3865` `rb_hash_hash`) folds
|
|
68
|
+
every key and value; the sort keeps it insertion-order independent, as
|
|
69
|
+
Ruby's is. It has two JS seats — a plain object and a `Map` — and `rbEqual`
|
|
70
|
+
answers true across them, so both must hash alike or the `hash`/`eql?`
|
|
71
|
+
contract breaks. */
|
|
72
|
+
const pairs = hashEntries(value);
|
|
73
|
+
if (pairs !== null) {
|
|
74
|
+
let h = 0x811c9dc5;
|
|
75
|
+
for (const pair of pairs.map(([key, val]) => rbHash(key) ^ rbHash(val)).sort((l, r) => l - r)) {
|
|
76
|
+
h ^= pair;
|
|
77
|
+
h = Math.imul(h, 0x01000193);
|
|
78
|
+
}
|
|
79
|
+
return h >>> 0;
|
|
80
|
+
}
|
|
81
|
+
return rbObjHash(value);
|
|
82
|
+
}
|
|
83
|
+
function stringHash(input) {
|
|
84
|
+
let h = 0x811c9dc5;
|
|
85
|
+
for (let i = 0; i < input.length; i++) {
|
|
86
|
+
h ^= input.charCodeAt(i);
|
|
87
|
+
h = Math.imul(h, 0x01000193);
|
|
88
|
+
}
|
|
89
|
+
return h >>> 0;
|
|
90
|
+
}
|
|
91
|
+
const identityHashes = new WeakMap();
|
|
92
|
+
let nextIdentityHash = 1;
|
|
93
|
+
/**
|
|
94
|
+
* `Kernel#hash`'s identity arm (`vendor/ruby/v3.3.11/hash.c:344` `rb_obj_hash`, over
|
|
95
|
+
* `objid_hash`): a per-object Integer that `super` from a `hash` override
|
|
96
|
+
* reaches.
|
|
97
|
+
*
|
|
98
|
+
* @noRailsEquivalent PERMANENT
|
|
99
|
+
*/
|
|
100
|
+
export function rbObjHash(object) {
|
|
101
|
+
let h = identityHashes.get(object);
|
|
102
|
+
if (h === undefined) {
|
|
103
|
+
h = Math.imul(nextIdentityHash++, 0x01000193) >>> 0;
|
|
104
|
+
identityHashes.set(object, h);
|
|
105
|
+
}
|
|
106
|
+
return h;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=rb-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rb-hash.js","sourceRoot":"","sources":["../lib/rb-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,UAAU,CAAC;IAC7D,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3B,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,UAAU,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1C,KAAK,SAAS;YACZ,OAAO,KAAK,CAAC,CAAC,CAAC,UAAU,CAA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,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,IAAI,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACnC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;QACpB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QACpD,cAAc,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/regexp.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ruby's `Regexp.escape` (`re.c` `rb_reg_s_quote`,
|
|
3
|
+
* `vendor/ruby/v3.3.11/re.c:4144`): the metacharacters of `string` escaped so it
|
|
4
|
+
* matches itself literally when spliced into a pattern.
|
|
5
|
+
*
|
|
6
|
+
* @noRailsEquivalent PERMANENT — `Regexp.escape` is Ruby CORE, implemented in
|
|
7
|
+
* C, and JS has no `RegExp.escape`, so the ports that need it cannot call it.
|
|
8
|
+
*
|
|
9
|
+
* Escapes what a JS `RegExp` gives meaning to, which is a SUBSET of what MRI
|
|
10
|
+
* escapes: MRI also escapes `-`, `#` and whitespace, and `\-` / `\#` / `\ `
|
|
11
|
+
* are invalid identity escapes under a `u`-flagged JS pattern
|
|
12
|
+
* (`new RegExp("a\\-b", "u")` throws), which `ParameterFilter#precompileFilters`
|
|
13
|
+
* builds. All three are literal outside a character class in JS, so the subset
|
|
14
|
+
* matches the same strings MRI's output does.
|
|
15
|
+
*/
|
|
16
|
+
export declare function regexpEscape(string: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* `Regexp.union` (`rb_reg_s_union_m` / `rb_reg_s_union`,
|
|
19
|
+
* `vendor/ruby/v3.3.11/re.c:4192`): the alternation of `args0`, or of the one
|
|
20
|
+
* array passed alone. A String is escaped ({@link regexpEscape}) and a Regexp
|
|
21
|
+
* is embedded as its `to_s` ({@link rbRegToS}), which carries its own options
|
|
22
|
+
* in JS's modifier syntax, so the union is a pattern only where the engine has
|
|
23
|
+
* modifiers. No pattern is `/(?!)/`, and a lone Regexp is returned itself. MRI's
|
|
24
|
+
* encoding compatibility checks have nothing to read (CLAUDE.md, "A String has
|
|
25
|
+
* no encoding tag either").
|
|
26
|
+
*
|
|
27
|
+
* @noRailsEquivalent PERMANENT
|
|
28
|
+
*/
|
|
29
|
+
export declare function rbRegSUnion(...args0: (string | RegExp)[] | [readonly (string | RegExp)[]]): RegExp;
|
|
30
|
+
/**
|
|
31
|
+
* `rb_reg_to_s` (`vendor/ruby/v3.3.11/re.c:565`): the source in a non-capturing
|
|
32
|
+
* group carrying the pattern's own options, so it means the same spliced into
|
|
33
|
+
* another pattern. Ruby's `m` is JS's `s`, and JS's `m` (Ruby's always-on line
|
|
34
|
+
* anchors) is carried too, so a `^` ported from `\A` stays `\A`. The group is
|
|
35
|
+
* spelled with JS's modifiers (`(?i-ms:a)` for MRI's `(?i-mx:a)`), so it is a
|
|
36
|
+
* pattern only where the engine has them: Node 23, Chrome 125, Firefox 132,
|
|
37
|
+
* Safari 18.4.
|
|
38
|
+
*
|
|
39
|
+
* `syntax: "onig"` spells the group with MRI's own option letters instead
|
|
40
|
+
* (`option_to_str`, `vendor/ruby/v3.3.11/re.c:322`), the bytes MRI's `to_s`
|
|
41
|
+
* writes: JS's `s` is MRI's `m`, and JS has no `x`. That string is a pattern
|
|
42
|
+
* for MRI, not for JS, and {@link rbRegInitStr} reads it back. MRI has three
|
|
43
|
+
* options, so a JS flag that is none of them is not written: `m`, since an MRI
|
|
44
|
+
* `^` / `$` is a line anchor under every option, and `g`, `y`, `d`, `u` and
|
|
45
|
+
* `v`, which {@link rbRegEqual} does not compare either.
|
|
46
|
+
*
|
|
47
|
+
* @noRailsEquivalent PERMANENT
|
|
48
|
+
*/
|
|
49
|
+
export declare function rbRegToS(re: RegExp, syntax?: "js" | "onig"): string;
|
|
50
|
+
/**
|
|
51
|
+
* `Regexp.new(string)` (`rb_reg_init_str`, `vendor/ruby/v3.3.11/re.c:3360`) for
|
|
52
|
+
* a pattern in MRI's syntax. MRI keeps a `(?on-off:…)` wrapper in the source
|
|
53
|
+
* and folds it into the options again in `rb_reg_str_with_term`
|
|
54
|
+
* (`vendor/ruby/v3.3.11/re.c:582-640`); a JS pattern cannot hold MRI's option
|
|
55
|
+
* letters, so that fold is made here: a pattern that is wholly one such group
|
|
56
|
+
* becomes the group's body under the JS flags its options name. Anything else
|
|
57
|
+
* is compiled as it stands, so an MRI-only construct (`(?x:…)`) is a
|
|
58
|
+
* `SyntaxError`.
|
|
59
|
+
*
|
|
60
|
+
* @noRailsEquivalent PERMANENT
|
|
61
|
+
*/
|
|
62
|
+
export declare function rbRegInitStr(s: string | Uint8Array): RegExp;
|
|
63
|
+
/**
|
|
64
|
+
* `rb_reg_equal` (`vendor/ruby/v3.3.11/re.c:3486`): the same source under the
|
|
65
|
+
* same options. `g`, `y`, `d`, `u` and `v` are how a JS pattern is run, not
|
|
66
|
+
* options Ruby has, and are not compared.
|
|
67
|
+
*
|
|
68
|
+
* @noRailsEquivalent PERMANENT
|
|
69
|
+
*/
|
|
70
|
+
export declare function rbRegEqual(re1: RegExp, re2: unknown): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* `Regexp#match?` (`rb_reg_match_p`, `vendor/ruby/v3.3.11/re.c:3811`): whether
|
|
73
|
+
* `re` matches `str`, keeping no state. A JS pattern carrying `g` or `y`
|
|
74
|
+
* searches from its `lastIndex` and advances it on a match, which MRI has no
|
|
75
|
+
* counterpart for, so the search starts at 0 and `lastIndex` is put back.
|
|
76
|
+
* An ASCII-8BIT String, a `Uint8Array`, is searched a byte per character, as
|
|
77
|
+
* `rb_reg_prepare_enc` (`re.c:1548`) searches a binary String.
|
|
78
|
+
*
|
|
79
|
+
* @noRailsEquivalent PERMANENT
|
|
80
|
+
*/
|
|
81
|
+
export declare function rbRegMatchP(re: RegExp, str: string | Uint8Array | null | undefined): boolean;
|
|
82
|
+
//# sourceMappingURL=regexp.d.ts.map
|