@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,805 @@
|
|
|
1
|
+
import { ArgumentError } from "../argument-error.js";
|
|
2
|
+
import { cmp } from "../comparable.js";
|
|
3
|
+
import { Encoding } from "../encoding.js";
|
|
4
|
+
import { IndexError } from "../index-error.js";
|
|
5
|
+
import { format } from "../kernel-format.js";
|
|
6
|
+
import { NilClass } from "../nil-class.js";
|
|
7
|
+
import { NoMethodError } from "../no-method-error.js";
|
|
8
|
+
import { rbCString, rbObjClassname, rtest } from "../object.js";
|
|
9
|
+
import { Range } from "../range.js";
|
|
10
|
+
import { rbEqual, rbEql } from "../rb-equal.js";
|
|
11
|
+
import { EncodingError } from "../encoding-error.js";
|
|
12
|
+
import { rbHash } from "../rb-hash.js";
|
|
13
|
+
import { TypeError } from "../type-error.js";
|
|
14
|
+
import { rbStrBytes, rbStrChars, rbStrCodepoints, rbStrEachByte, rbStrEachChar, rbStrEachCodepoint, rbStrEachGraphemeCluster, rbStrEachLine, rbStrGraphemeClusters, rbStrLines, rbStrUpto, } from "./each.js";
|
|
15
|
+
import { byteslice, rbStrByteindexM, rbStrByterindexM, rbStrBytesplice, rbStrByteslice, } from "./byte-methods.js";
|
|
16
|
+
import { rbStrGetbyte, rbStrSetbyte, rbStrSum } from "./byte-methods.js";
|
|
17
|
+
import { b } from "./b.js";
|
|
18
|
+
import { bytes } from "./bytes.js";
|
|
19
|
+
import { capitalize, casecmp, downcase, isCasecmp, swapcase, upcase } from "./case-mapping.js";
|
|
20
|
+
import { chomp } from "./chomp.js";
|
|
21
|
+
import { rbStrDump, rbStrHex, rbStrOct, rbStrToF, rbStrToI, strUndump } from "./convert.js";
|
|
22
|
+
import { stringInspect } from "./inspect.js";
|
|
23
|
+
import { scrub } from "./scrub.js";
|
|
24
|
+
import { sliceBang } from "./slice.js";
|
|
25
|
+
import { stringSplit } from "./split.js";
|
|
26
|
+
import { rbStrMatchM, rbStrMatchMP, rbStrPartition, rbStrRpartition, rbStrScan, rbStrStartWith, rbStrEndWith, rbStrSub, rbStrSubBang, strGsub, } from "./sub.js";
|
|
27
|
+
import { succ } from "./succ.js";
|
|
28
|
+
import { bang, blockArg, checkArity, num2long, rbCheckStringType, rbErrorArity, rbRangeBegLen, rbRegBackrefNumber, rbRegSearch, rbStrCmp, rbStrSublen, strlen, strOffset, stringValue, } from "./support.js";
|
|
29
|
+
import { strCount, strDelete, strSqueeze, trTrans } from "./tr.js";
|
|
30
|
+
/**
|
|
31
|
+
* The public methods `Init_String` (`vendor/ruby/v3.3.11/string.c:12119`) defines on
|
|
32
|
+
* `rb_cString`, keyed by the camelCased Ruby name: an operator by the
|
|
33
|
+
* spelling trails gives it elsewhere (`<=>` `compareTo`, `==` `equals`, `===`
|
|
34
|
+
* `caseEquals`, `+` `plus`, `*` `multiply`, `%` `format`, `[]` `get`, `[]=`
|
|
35
|
+
* `set`, `=~` `matchOperator`, `<<` `append`, `+@` `uplus`, `-@` `uminus`), a
|
|
36
|
+
* predicate as `isX`, a bang form as `xBang`. Every position is a character
|
|
37
|
+
* (code point) offset, as MRI's are for a UTF-8 String; a block is a trailing
|
|
38
|
+
* function argument. A package that reopens String, as ActiveSupport's
|
|
39
|
+
* `core_ext/string` does, assigns an entry. `length` counts characters, as
|
|
40
|
+
* `size` does; a proxy forwarding to String reads it as a property, where the
|
|
41
|
+
* JS string's own `length` is.
|
|
42
|
+
*
|
|
43
|
+
* Not in the table, because a JS string cannot carry what they read or
|
|
44
|
+
* write: `force_encoding` and `b` retag the receiver's bytes, and a JS string
|
|
45
|
+
* has no encoding tag (it is always the UTF-8 `encoding` answers); `crypt`
|
|
46
|
+
* is the platform's `crypt(3)`; `initialize` and `initialize_copy` are
|
|
47
|
+
* private.
|
|
48
|
+
*
|
|
49
|
+
* @noRailsEquivalent PERMANENT
|
|
50
|
+
*/
|
|
51
|
+
export const STRING_METHOD_TABLE = Object.assign(Object.create(null), {
|
|
52
|
+
compareTo: rbDefineMethod(1, (self, other) => rbStrCmpM(self.string, other)),
|
|
53
|
+
equals: rbDefineMethod(1, (self, other) => rbStrEqual(self.string, other)),
|
|
54
|
+
caseEquals: rbDefineMethod(1, (self, other) => rbStrEqual(self.string, other)),
|
|
55
|
+
eql: rbDefineMethod(1, (self, other) => rbStrEql(self.string, other)),
|
|
56
|
+
hash: rbDefineMethod(0, (self) => rbHash(self.string)),
|
|
57
|
+
casecmp: rbDefineMethod(1, (self, other) => casecmp(self.string, other)),
|
|
58
|
+
isCasecmp: rbDefineMethod(1, (self, other) => isCasecmp(self.string, other)),
|
|
59
|
+
plus: rbDefineMethod(1, (self, str2) => self.string + stringValue(str2)),
|
|
60
|
+
multiply: rbDefineMethod(1, (self, times) => rbStrTimes(self.string, times)),
|
|
61
|
+
format: rbDefineMethod(1, (self, arg) => Array.isArray(arg) ? format(self.string, ...arg) : format(self.string, arg)),
|
|
62
|
+
get: rbStrArefM,
|
|
63
|
+
set: rbStrAsetM,
|
|
64
|
+
insert: rbDefineMethod(2, rbStrInsert),
|
|
65
|
+
length: rbDefineMethod(0, (self) => strlen(self.string)),
|
|
66
|
+
size: rbDefineMethod(0, (self) => strlen(self.string)),
|
|
67
|
+
bytesize: rbDefineMethod(0, (self) => bytes(self.string).length),
|
|
68
|
+
isEmpty: rbDefineMethod(0, (self) => self.string.length === 0),
|
|
69
|
+
matchOperator: rbDefineMethod(1, (self, y) => rbStrMatch(self.string, y)),
|
|
70
|
+
match: rbStrMatchM,
|
|
71
|
+
isMatch: rbStrMatchMP,
|
|
72
|
+
succ: rbDefineMethod(0, (self) => succ(self.string)),
|
|
73
|
+
succBang: rbDefineMethod(0, (self) => (self.string = succ(self.string))),
|
|
74
|
+
next: rbDefineMethod(0, (self) => succ(self.string)),
|
|
75
|
+
nextBang: rbDefineMethod(0, (self) => (self.string = succ(self.string))),
|
|
76
|
+
upto: rbStrUpto,
|
|
77
|
+
index: rbStrIndexM,
|
|
78
|
+
byteindex: (self, ...args) => rbStrByteindexM(self.string, ...args),
|
|
79
|
+
rindex: rbStrRindexM,
|
|
80
|
+
byterindex: (self, ...args) => rbStrByterindexM(self.string, ...args),
|
|
81
|
+
replace: rbDefineMethod(1, (self, str2) => (self.string = stringValue(str2))),
|
|
82
|
+
clear: rbDefineMethod(0, (self) => (self.string = "")),
|
|
83
|
+
chr: rbDefineMethod(0, (self) => [...self.string].slice(0, 1).join("")),
|
|
84
|
+
getbyte: rbDefineMethod(1, (self, index) => rbStrGetbyte(self.string, index)),
|
|
85
|
+
setbyte: rbDefineMethod(2, rbStrSetbyte),
|
|
86
|
+
byteslice: (self, ...args) => rbStrByteslice(self.string, ...args),
|
|
87
|
+
bytesplice: rbStrBytesplice,
|
|
88
|
+
scrub: (self, ...argv) => strScrub(self.string, argv),
|
|
89
|
+
scrubBang: (self, ...argv) => (self.string = strScrub(self.string, argv)),
|
|
90
|
+
freeze: rbDefineMethod(0, (self) => self.string),
|
|
91
|
+
uplus: rbDefineMethod(0, (self) => self.string),
|
|
92
|
+
uminus: rbDefineMethod(0, (self) => self.string),
|
|
93
|
+
dup: rbDefineMethod(0, (self) => self.string),
|
|
94
|
+
toI: (self, ...args) => rbStrToI(self.string, ...args),
|
|
95
|
+
toF: rbDefineMethod(0, (self) => rbStrToF(self.string)),
|
|
96
|
+
toS: rbDefineMethod(0, (self) => self.string),
|
|
97
|
+
toStr: rbDefineMethod(0, (self) => self.string),
|
|
98
|
+
inspect: rbDefineMethod(0, (self) => stringInspect(self.string)),
|
|
99
|
+
dump: rbDefineMethod(0, (self) => rbStrDump(self.string)),
|
|
100
|
+
undump: rbDefineMethod(0, (self) => strUndump(self.string)),
|
|
101
|
+
upcase: (self, ...args) => upcase(self.string, args),
|
|
102
|
+
downcase: (self, ...args) => downcase(self.string, args),
|
|
103
|
+
capitalize: (self, ...args) => capitalize(self.string, args),
|
|
104
|
+
swapcase: (self, ...args) => swapcase(self.string, args),
|
|
105
|
+
upcaseBang: (self, ...args) => bang(self, upcase(self.string, args)),
|
|
106
|
+
downcaseBang: (self, ...args) => bang(self, downcase(self.string, args)),
|
|
107
|
+
capitalizeBang: (self, ...args) => bang(self, capitalize(self.string, args)),
|
|
108
|
+
swapcaseBang: (self, ...args) => bang(self, swapcase(self.string, args)),
|
|
109
|
+
hex: rbDefineMethod(0, (self) => rbStrHex(self.string)),
|
|
110
|
+
oct: rbDefineMethod(0, (self) => rbStrOct(self.string)),
|
|
111
|
+
split: rbStrSplitM,
|
|
112
|
+
lines: rbStrLines,
|
|
113
|
+
eachLine: rbStrEachLine,
|
|
114
|
+
chars: rbStrChars,
|
|
115
|
+
eachChar: rbStrEachChar,
|
|
116
|
+
bytes: rbStrBytes,
|
|
117
|
+
eachByte: rbStrEachByte,
|
|
118
|
+
codepoints: rbStrCodepoints,
|
|
119
|
+
eachCodepoint: rbStrEachCodepoint,
|
|
120
|
+
graphemeClusters: rbStrGraphemeClusters,
|
|
121
|
+
eachGraphemeCluster: rbStrEachGraphemeCluster,
|
|
122
|
+
reverse: rbDefineMethod(0, (self) => [...self.string].reverse().join("")),
|
|
123
|
+
reverseBang: rbDefineMethod(0, (self) => (self.string = [...self.string].reverse().join(""))),
|
|
124
|
+
concat: rbStrConcatMulti,
|
|
125
|
+
append: rbDefineMethod(1, (self, str2) => (self.string = rbStrConcat(self.string, str2))),
|
|
126
|
+
prepend: (self, ...args) => (self.string = args.map(stringValue).join("") + self.string),
|
|
127
|
+
intern: rbDefineMethod(0, (self) => `:${self.string}`),
|
|
128
|
+
toSym: rbDefineMethod(0, (self) => `:${self.string}`),
|
|
129
|
+
ord: rbDefineMethod(0, rbStrOrd),
|
|
130
|
+
isInclude: rbDefineMethod(1, (self, arg) => rbStrInclude(self.string, arg)),
|
|
131
|
+
isStartWith: (self, ...prefixes) => rbStrStartWith(self.string, ...prefixes),
|
|
132
|
+
isEndWith: (self, ...suffixes) => rbStrEndWith(self.string, ...suffixes),
|
|
133
|
+
scan: rbStrScan,
|
|
134
|
+
ljust: (self, ...args) => rbStrJustify(args, self.string, "l"),
|
|
135
|
+
rjust: (self, ...args) => rbStrJustify(args, self.string, "r"),
|
|
136
|
+
center: (self, ...args) => rbStrJustify(args, self.string, "c"),
|
|
137
|
+
sub: rbStrSub,
|
|
138
|
+
gsub: (self, ...argv) => strGsub(self, argv, false),
|
|
139
|
+
chop: rbDefineMethod(0, (self) => rbStrChop(self.string)),
|
|
140
|
+
chomp: (self, ...args) => rbStrChomp(self.string, args),
|
|
141
|
+
strip: rbDefineMethod(0, (self) => strip(self.string)),
|
|
142
|
+
lstrip: rbDefineMethod(0, (self) => self.string.replace(LSTRIP, "")),
|
|
143
|
+
rstrip: rbDefineMethod(0, (self) => self.string.replace(RSTRIP, "")),
|
|
144
|
+
deletePrefix: rbDefineMethod(1, (self, prefix) => deletePrefix(self.string, prefix)),
|
|
145
|
+
deleteSuffix: rbDefineMethod(1, (self, suffix) => deleteSuffix(self.string, suffix)),
|
|
146
|
+
subBang: rbStrSubBang,
|
|
147
|
+
gsubBang: (self, ...argv) => strGsub(self, argv, true),
|
|
148
|
+
chopBang: rbDefineMethod(0, (self) => self.string.length === 0 ? null : (self.string = rbStrChop(self.string))),
|
|
149
|
+
chompBang: (self, ...args) => bang(self, rbStrChomp(self.string, args)),
|
|
150
|
+
stripBang: rbDefineMethod(0, (self) => bang(self, self.string.replace(LSTRIP, "").replace(RSTRIP, ""))),
|
|
151
|
+
lstripBang: rbDefineMethod(0, (self) => bang(self, self.string.replace(LSTRIP, ""))),
|
|
152
|
+
rstripBang: rbDefineMethod(0, (self) => bang(self, self.string.replace(RSTRIP, ""))),
|
|
153
|
+
deletePrefixBang: rbDefineMethod(1, (self, p) => bang(self, deletePrefix(self.string, p))),
|
|
154
|
+
deleteSuffixBang: rbDefineMethod(1, (self, s) => bang(self, deleteSuffix(self.string, s))),
|
|
155
|
+
tr: rbDefineMethod(2, (self, src, repl) => trTrans(self.string, src, repl, false)),
|
|
156
|
+
trS: rbDefineMethod(2, (self, src, repl) => trTrans(self.string, src, repl, true)),
|
|
157
|
+
delete: (self, ...args) => strDelete(self.string, args),
|
|
158
|
+
squeeze: (self, ...args) => strSqueeze(self.string, args),
|
|
159
|
+
count: (self, ...args) => strCount(self.string, args),
|
|
160
|
+
trBang: rbDefineMethod(2, (self, src, repl) => bang(self, trTrans(self.string, src, repl, false))),
|
|
161
|
+
trSBang: rbDefineMethod(2, (self, src, repl) => bang(self, trTrans(self.string, src, repl, true))),
|
|
162
|
+
deleteBang: (self, ...args) => bang(self, strDelete(self.string, args)),
|
|
163
|
+
squeezeBang: (self, ...args) => bang(self, strSqueeze(self.string, args)),
|
|
164
|
+
sum: (self, ...args) => rbStrSum(self.string, ...args),
|
|
165
|
+
slice: rbStrArefM,
|
|
166
|
+
sliceBang: rbStrSliceBang,
|
|
167
|
+
partition: rbDefineMethod(1, (self, sep) => rbStrPartition(self.string, sep)),
|
|
168
|
+
rpartition: rbDefineMethod(1, (self, sep) => rbStrRpartition(self.string, sep)),
|
|
169
|
+
encoding: rbDefineMethod(0, () => Encoding.UTF_8),
|
|
170
|
+
isValidEncoding: rbDefineMethod(0, (self) => !LONE_SURROGATE.test(self.string)),
|
|
171
|
+
// eslint-disable-next-line no-control-regex -- `rb_str_is_ascii_only_p` (string.c:11019)
|
|
172
|
+
isAsciiOnly: rbDefineMethod(0, (self) => /^[\x00-\x7f]*$/.test(self.string)),
|
|
173
|
+
unicodeNormalize: (self, ...args) => unicodeNormalize(self.string, args),
|
|
174
|
+
unicodeNormalizeBang: (self, ...args) => (self.string = unicodeNormalize(self.string, args)),
|
|
175
|
+
isUnicodeNormalized: (self, ...args) => unicodeNormalize(self.string, args) === self.string,
|
|
176
|
+
});
|
|
177
|
+
/**
|
|
178
|
+
* The {@link STRING_METHOD_TABLE} entries an ASCII-8BIT String, a `Uint8Array`
|
|
179
|
+
* (CLAUDE.md, "A String has no encoding tag either"), answers: `==` and
|
|
180
|
+
* `eql?` compare bytes (`rb_str_equal`, `vendor/ruby/v3.3.11/string.c:3742`;
|
|
181
|
+
* `rb_str_eql`, `:3773`), `bytesize` counts them (`rb_str_bytesize`,
|
|
182
|
+
* `:2225`), as `length` and `size` do (one character per byte), `getbyte`
|
|
183
|
+
* reads one, `empty?` asks whether there are any, `byteslice` slices them,
|
|
184
|
+
* `start_with?` compares a prefix of them, `include?` searches them,
|
|
185
|
+
* `+` joins them, and `dup` copies them (`rb_str_dup_m`, `:1798`).
|
|
186
|
+
*
|
|
187
|
+
* @noRailsEquivalent PERMANENT
|
|
188
|
+
*/
|
|
189
|
+
export const BINARY_METHOD_TABLE = {
|
|
190
|
+
equals: (self, other) => rbEqual(self, other),
|
|
191
|
+
caseEquals: (self, other) => rbEqual(self, other),
|
|
192
|
+
eql: (self, other) => rbEql(self, other),
|
|
193
|
+
plus: (self, str2) => rbStrPlus(self, str2),
|
|
194
|
+
length: (self) => self.length,
|
|
195
|
+
size: (self) => self.length,
|
|
196
|
+
bytesize: (self) => self.length,
|
|
197
|
+
getbyte: (self, index) => rbStrGetbyte(self, index),
|
|
198
|
+
isEmpty: (self) => self.length === 0,
|
|
199
|
+
byteslice: (self, ...args) => byteslice(self, ...args),
|
|
200
|
+
isStartWith: (self, ...prefixes) => rbStrStartWith(self, ...prefixes),
|
|
201
|
+
isInclude: (self, arg) => rbStrInclude(self, arg),
|
|
202
|
+
dup: (self) => self.slice(),
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* `String#+` (`vendor/ruby/v3.3.11/string.c:2259` `rb_str_plus`) with an
|
|
206
|
+
* ASCII-8BIT receiver. `rb_enc_check` (`encoding.c:1038`) admits a UTF-8
|
|
207
|
+
* operand only where one side is 7-bit, and the result takes the encoding of
|
|
208
|
+
* the side that is not.
|
|
209
|
+
*
|
|
210
|
+
* @noRailsEquivalent PERMANENT — Ruby core `String#+`
|
|
211
|
+
* (`vendor/ruby/v3.3.11/string.c:2259`).
|
|
212
|
+
*/
|
|
213
|
+
export function rbStrPlus(str1, str2) {
|
|
214
|
+
if (str2 instanceof Uint8Array) {
|
|
215
|
+
const str3 = new Uint8Array(str1.length + str2.length);
|
|
216
|
+
str3.set(str1);
|
|
217
|
+
str3.set(str2, str1.length);
|
|
218
|
+
return str3;
|
|
219
|
+
}
|
|
220
|
+
const text = stringValue(str2);
|
|
221
|
+
// eslint-disable-next-line no-control-regex -- `rb_enc_str_asciionly_p` (encoding.c:1038)
|
|
222
|
+
if (/^[\x00-\x7f]*$/.test(text))
|
|
223
|
+
return rbStrPlus(str1, new TextEncoder().encode(text));
|
|
224
|
+
if (str1.every((byte) => byte < 0x80))
|
|
225
|
+
return new TextDecoder().decode(str1) + text;
|
|
226
|
+
throw new EncodingError("incompatible character encodings: ASCII-8BIT and UTF-8");
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* `String#include?` (`vendor/ruby/v3.3.11/string.c:6558` `rb_str_include`). An
|
|
230
|
+
* ASCII-8BIT receiver, a `Uint8Array`, is searched by byte, after `rb_enc_check`
|
|
231
|
+
* (`vendor/ruby/v3.3.11/encoding.c:1038`) admits a UTF-8 needle only where one
|
|
232
|
+
* side is 7-bit.
|
|
233
|
+
*
|
|
234
|
+
* @noRailsEquivalent PERMANENT — Ruby core `String#include?`
|
|
235
|
+
* (`vendor/ruby/v3.3.11/string.c:6558`).
|
|
236
|
+
*/
|
|
237
|
+
export function rbStrInclude(str, arg) {
|
|
238
|
+
if (typeof str === "string")
|
|
239
|
+
return str.includes(stringValue(arg));
|
|
240
|
+
const sub = arg instanceof Uint8Array ? arg : b(stringValue(arg));
|
|
241
|
+
if (!(arg instanceof Uint8Array) &&
|
|
242
|
+
!sub.every((byte) => byte < 0x80) &&
|
|
243
|
+
!str.every((byte) => byte < 0x80)) {
|
|
244
|
+
throw new EncodingError("incompatible character encodings: ASCII-8BIT and UTF-8");
|
|
245
|
+
}
|
|
246
|
+
for (let i = 0; i + sub.length <= str.length; i++) {
|
|
247
|
+
if (sub.every((byte, j) => byte === str[i + j]))
|
|
248
|
+
return true;
|
|
249
|
+
}
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
const stringClasses = new WeakSet();
|
|
253
|
+
const RSTRING_PTR = Symbol("RSTRING_PTR");
|
|
254
|
+
function isTString(value) {
|
|
255
|
+
if (typeof value === "string")
|
|
256
|
+
return true;
|
|
257
|
+
if (typeof value !== "object" || value === null)
|
|
258
|
+
return false;
|
|
259
|
+
for (let proto = Object.getPrototypeOf(value); proto; proto = Object.getPrototypeOf(proto)) {
|
|
260
|
+
if (stringClasses.has(proto))
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
function rbStrEql(str1, str2) {
|
|
266
|
+
if (str2 instanceof Uint8Array)
|
|
267
|
+
return rbEql(str1, str2);
|
|
268
|
+
if (!isTString(str2))
|
|
269
|
+
return false;
|
|
270
|
+
return str1 === String(str2);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* `rb_cString` (`vendor/ruby/v3.3.11/string.c:12119`) as the superclass of
|
|
274
|
+
* `class X < String`: a class answering the String methods named, each sent
|
|
275
|
+
* through {@link STRING_METHOD_TABLE} at call time with the receiver's `to_s`
|
|
276
|
+
* as its string, so an entry a package reopening String assigns is found too.
|
|
277
|
+
* An instance is a `T_STRING` to `rb_str_eql`, holds the contents
|
|
278
|
+
* `String#initialize` gave it, and answers them from `to_s` (`rb_str_to_s`,
|
|
279
|
+
* `vendor/ruby/v3.3.11/string.c:6648`), which is a plain String for a subclass
|
|
280
|
+
* instance. One `initialize` never ran on is empty, as the String allocator
|
|
281
|
+
* leaves it (`empty_str_alloc`, `vendor/ruby/v3.3.11/string.c:858`).
|
|
282
|
+
*
|
|
283
|
+
* @noRailsEquivalent PERMANENT
|
|
284
|
+
*/
|
|
285
|
+
export function stringSuperclass(...methods) {
|
|
286
|
+
const klass = class extends rbCString {
|
|
287
|
+
/** `String#initialize` (`vendor/ruby/v3.3.11/string.c:1832` `rb_str_init`). */
|
|
288
|
+
constructor(orig = "") {
|
|
289
|
+
super();
|
|
290
|
+
this[RSTRING_PTR] = isTString(orig)
|
|
291
|
+
? String(orig)
|
|
292
|
+
: stringValue(orig);
|
|
293
|
+
}
|
|
294
|
+
toString() {
|
|
295
|
+
return this[RSTRING_PTR] ?? "";
|
|
296
|
+
}
|
|
297
|
+
[Symbol.iterator]() {
|
|
298
|
+
return this.toString()[Symbol.iterator]();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
stringClasses.add(klass.prototype);
|
|
302
|
+
for (const method of methods) {
|
|
303
|
+
Object.defineProperty(klass.prototype, method, {
|
|
304
|
+
value(...args) {
|
|
305
|
+
return rbStrSend(String(this), method, ...args)[0];
|
|
306
|
+
},
|
|
307
|
+
writable: true,
|
|
308
|
+
configurable: true,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
return klass;
|
|
312
|
+
}
|
|
313
|
+
const JS_STRING_METHODS = new Set(Object.getOwnPropertyNames(String.prototype));
|
|
314
|
+
/** @noRailsEquivalent PERMANENT — `rb_f_send` (`vendor/ruby/v3.3.11/vm_eval.c:1330`). */
|
|
315
|
+
export function rbStrSend(str, method, ...args) {
|
|
316
|
+
if (str instanceof Uint8Array) {
|
|
317
|
+
const binaryEntry = Object.hasOwn(BINARY_METHOD_TABLE, method)
|
|
318
|
+
? BINARY_METHOD_TABLE[method]
|
|
319
|
+
: undefined;
|
|
320
|
+
if (!binaryEntry) {
|
|
321
|
+
throw new NoMethodError(`undefined method '${method}' for an instance of String`);
|
|
322
|
+
}
|
|
323
|
+
return [binaryEntry(str, ...args), str];
|
|
324
|
+
}
|
|
325
|
+
const entry = STRING_METHOD_TABLE[method];
|
|
326
|
+
if (entry) {
|
|
327
|
+
const self = { string: str };
|
|
328
|
+
const result = entry(self, ...args);
|
|
329
|
+
return [result, self.string];
|
|
330
|
+
}
|
|
331
|
+
if (!rbStrRespondTo(str, method)) {
|
|
332
|
+
throw new NoMethodError(`undefined method '${method}' for an instance of String`);
|
|
333
|
+
}
|
|
334
|
+
const member = str[method];
|
|
335
|
+
return [typeof member === "function" ? member.apply(str, args) : member, str];
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* `str.respond_to?` (`vendor/ruby/v3.3.11/vm_method.c:2977` `obj_respond_to`) over
|
|
339
|
+
* {@link rbStrSend}'s names: JS's own `String.prototype` members are not
|
|
340
|
+
* Ruby's. See CLAUDE.md, "Method visibility is compile-time only".
|
|
341
|
+
*
|
|
342
|
+
* @noRailsEquivalent PERMANENT
|
|
343
|
+
*/
|
|
344
|
+
export function rbStrRespondTo(str, method,
|
|
345
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
346
|
+
includeAll = false) {
|
|
347
|
+
if (method in STRING_METHOD_TABLE)
|
|
348
|
+
return true;
|
|
349
|
+
return (Object.hasOwn(Object.getPrototypeOf(Object(str)), method) && !JS_STRING_METHODS.has(method));
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* `String#=~` (`vendor/ruby/v3.3.11/string.c:4523` `rb_str_match`): a match's character
|
|
353
|
+
* offset. This is Ruby core's String method, which Rails' `Chars#=~` delegates
|
|
354
|
+
* to (`activesupport/lib/active_support/multibyte/chars.rb:53`, ported as
|
|
355
|
+
* `Chars#matchOperator`); ruby-compat's package contract receipts every export,
|
|
356
|
+
* since no Rails file defines a Ruby core method.
|
|
357
|
+
*
|
|
358
|
+
* @noRailsEquivalent PERMANENT
|
|
359
|
+
*/
|
|
360
|
+
export function rbStrMatch(x, y) {
|
|
361
|
+
if (typeof y === "string")
|
|
362
|
+
throw new TypeError("type mismatch: String given");
|
|
363
|
+
if (y instanceof RegExp) {
|
|
364
|
+
const match = rbRegSearch(y, x, 0, false);
|
|
365
|
+
backref = match;
|
|
366
|
+
return match ? rbStrSublen(x, match.index) : null;
|
|
367
|
+
}
|
|
368
|
+
return y.matchOperator(x);
|
|
369
|
+
}
|
|
370
|
+
let backref = null;
|
|
371
|
+
/**
|
|
372
|
+
* `$&` (`last_match_getter`, `vendor/ruby/v3.3.11/re.c:1989`, over
|
|
373
|
+
* `rb_reg_last_match` at `vendor/ruby/v3.3.11/re.c:1882`): the text of the last
|
|
374
|
+
* match, `nil` when it failed. `$~` is the one `String#=~` ({@link rbStrMatch})
|
|
375
|
+
* sets, as `rb_reg_search_set_match` does (`vendor/ruby/v3.3.11/re.c:1750,1783`).
|
|
376
|
+
* MRI keeps `$~` per frame; JS has no frame-local seat, so this is the last
|
|
377
|
+
* `=~` of the whole program and is read straight after it.
|
|
378
|
+
*
|
|
379
|
+
* @noRailsEquivalent PERMANENT
|
|
380
|
+
*/
|
|
381
|
+
export function lastMatchGetter() {
|
|
382
|
+
return backref ? backref[0] : null;
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Ruby's `obj =~ pattern` send, dispatched on the receiver's class:
|
|
386
|
+
* `NilClass#=~` (`vendor/ruby/v3.3.11/object.c:4419` `nil_match`), which answers
|
|
387
|
+
* `nil` for any pattern, `String#=~` ({@link rbStrMatch}), else the receiver's
|
|
388
|
+
* own `matchOperator`. A receiver with none raises `NoMethodError`
|
|
389
|
+
* (`rb_method_missing`, `vendor/ruby/v3.3.11/vm_eval.c:919`): `Object#=~` is gone
|
|
390
|
+
* since Ruby 3.2.
|
|
391
|
+
*
|
|
392
|
+
* @noRailsEquivalent PERMANENT — a Ruby method send, which JS has no receiver
|
|
393
|
+
* for on `null` or a primitive.
|
|
394
|
+
*/
|
|
395
|
+
export function matchOperator(obj, pattern) {
|
|
396
|
+
if (obj == null)
|
|
397
|
+
return NilClass.matchOperator(pattern);
|
|
398
|
+
if (typeof obj === "string")
|
|
399
|
+
return rbStrMatch(obj, pattern);
|
|
400
|
+
const method = obj.matchOperator;
|
|
401
|
+
if (typeof method !== "function") {
|
|
402
|
+
throw new NoMethodError(`undefined method '=~' for an instance of ${rbObjClassname(obj)}`, "=~", { receiver: obj });
|
|
403
|
+
}
|
|
404
|
+
return method.call(obj, pattern);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* `Kernel#!~` (`vendor/ruby/v3.3.11/object.c:1639` `rb_obj_not_match`): the negation
|
|
408
|
+
* of the receiver's `=~`.
|
|
409
|
+
*
|
|
410
|
+
* @noRailsEquivalent PERMANENT
|
|
411
|
+
*/
|
|
412
|
+
export function rbObjNotMatch(obj1, obj2) {
|
|
413
|
+
const result = matchOperator(obj1, obj2);
|
|
414
|
+
return !rtest(result);
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* `String#strip` (`vendor/ruby/v3.3.11/string.c:10020` `rb_str_strip`): the receiver
|
|
418
|
+
* without its leading and trailing NUL and ASCII whitespace
|
|
419
|
+
* (`lstrip_offset`, `rstrip_offset`). JS `trim()` also removes NBSP, U+FEFF
|
|
420
|
+
* and the Unicode space separators, which Ruby keeps.
|
|
421
|
+
*
|
|
422
|
+
* @noRailsEquivalent PERMANENT — Ruby core `String#strip`, which Thor calls on
|
|
423
|
+
* a prompt's answer (`vendor/thor/v1.4.0/lib/thor/shell/basic.rb:339`).
|
|
424
|
+
*/
|
|
425
|
+
export function strip(str) {
|
|
426
|
+
return str.replace(LSTRIP, "").replace(RSTRIP, "");
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* `String#rstrip` (`vendor/ruby/v3.3.11/string.c:9952` `rb_str_rstrip`): the
|
|
430
|
+
* receiver without its trailing NUL and ASCII whitespace (`rstrip_offset`).
|
|
431
|
+
*
|
|
432
|
+
* @noRailsEquivalent PERMANENT — Ruby core `String#rstrip`, which mail's
|
|
433
|
+
* generated parsers call (`vendor/mail/2.8.1/lib/mail/parsers/envelope_from_parser.rb`).
|
|
434
|
+
*/
|
|
435
|
+
export function rstrip(str) {
|
|
436
|
+
return str.replace(RSTRIP, "");
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* `rb_define_method` (`vendor/ruby/v3.3.11/class.c:2134`) with a fixed `argc`, which MRI
|
|
440
|
+
* checks.
|
|
441
|
+
*
|
|
442
|
+
* @noRailsEquivalent PERMANENT
|
|
443
|
+
*/
|
|
444
|
+
export function rbDefineMethod(argc, func) {
|
|
445
|
+
return (self, ...args) => {
|
|
446
|
+
if (args.length !== argc)
|
|
447
|
+
rbErrorArity(args.length, argc, argc);
|
|
448
|
+
return func(self, ...args);
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
const LSTRIP = /^[\0\t\n\v\f\r ]+/;
|
|
452
|
+
const RSTRIP = /[\0\t\n\v\f\r ]+$/;
|
|
453
|
+
const LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/;
|
|
454
|
+
/** `String#<=>` (`vendor/ruby/v3.3.11/string.c:3803` `rb_str_cmp_m`, `rb_invcmp` at `vendor/ruby/v3.3.11/compar.c:50`). */
|
|
455
|
+
function rbStrCmpM(str1, str2) {
|
|
456
|
+
const s = rbCheckStringType(str2);
|
|
457
|
+
if (s === null) {
|
|
458
|
+
const invcmp = cmp(str2, str1);
|
|
459
|
+
return invcmp === null ? null : -Math.sign(invcmp);
|
|
460
|
+
}
|
|
461
|
+
return rbStrCmp(str1, s);
|
|
462
|
+
}
|
|
463
|
+
/** `String#==` (`vendor/ruby/v3.3.11/string.c:3742` `rb_str_equal`). */
|
|
464
|
+
function rbStrEqual(str1, str2) {
|
|
465
|
+
if (typeof str2 !== "string") {
|
|
466
|
+
if (typeof str2?.toStr !== "function")
|
|
467
|
+
return false;
|
|
468
|
+
return rbEqual(str2, str1);
|
|
469
|
+
}
|
|
470
|
+
return str1 === str2;
|
|
471
|
+
}
|
|
472
|
+
/** `String#*` (`vendor/ruby/v3.3.11/string.c:2331` `rb_str_times`). */
|
|
473
|
+
function rbStrTimes(str, times) {
|
|
474
|
+
const len = num2long(times);
|
|
475
|
+
if (len < 0)
|
|
476
|
+
throw new ArgumentError("negative argument");
|
|
477
|
+
if (str.length * len > 2 ** 29)
|
|
478
|
+
throw new ArgumentError("argument too big");
|
|
479
|
+
return str.repeat(len);
|
|
480
|
+
}
|
|
481
|
+
/** `String#chomp` (`vendor/ruby/v3.3.11/string.c:9786` `rb_str_chomp`, `chomp_rs` at `:9728`). */
|
|
482
|
+
function rbStrChomp(str, argv) {
|
|
483
|
+
if (argv.length === 0)
|
|
484
|
+
return chomp(str);
|
|
485
|
+
checkArity(argv.length, 0, 1);
|
|
486
|
+
if (argv[0] == null)
|
|
487
|
+
return str;
|
|
488
|
+
return chomp(str, stringValue(argv[0]));
|
|
489
|
+
}
|
|
490
|
+
/** `String#chop` (`vendor/ruby/v3.3.11/string.c:9613` `rb_str_chop`): a trailing `"\r\n"` as one. */
|
|
491
|
+
function rbStrChop(str) {
|
|
492
|
+
if (str.endsWith("\r\n"))
|
|
493
|
+
return str.slice(0, -2);
|
|
494
|
+
return [...str].slice(0, -1).join("");
|
|
495
|
+
}
|
|
496
|
+
/** `String#delete_prefix` (`vendor/ruby/v3.3.11/string.c:10795` `rb_str_delete_prefix`). */
|
|
497
|
+
function deletePrefix(str, prefix) {
|
|
498
|
+
const p = stringValue(prefix);
|
|
499
|
+
return str.startsWith(p) ? str.slice(p.length) : str;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* `String#delete_suffix` (`vendor/ruby/v3.3.11/string.c:10878` `rb_str_delete_suffix`).
|
|
503
|
+
*
|
|
504
|
+
* @noRailsEquivalent PERMANENT
|
|
505
|
+
*/
|
|
506
|
+
export function deleteSuffix(str, suffix) {
|
|
507
|
+
const s = stringValue(suffix);
|
|
508
|
+
return s.length && str.endsWith(s) ? str.slice(0, -s.length) : str;
|
|
509
|
+
}
|
|
510
|
+
/** `String#<<` (`vendor/ruby/v3.3.11/string.c:3511` `rb_str_concat`): an Integer is a code point. */
|
|
511
|
+
function rbStrConcat(str1, str2) {
|
|
512
|
+
if (typeof str2 === "number" || typeof str2 === "bigint") {
|
|
513
|
+
const code = Number(str2);
|
|
514
|
+
if (code < 0 || code > 0xffffffff)
|
|
515
|
+
throw new RangeError(`${str2} out of char range`);
|
|
516
|
+
if (code > 0x10ffff)
|
|
517
|
+
throw new RangeError(`${code} out of char range`);
|
|
518
|
+
if (code >= 0xd800 && code <= 0xdfff) {
|
|
519
|
+
throw new RangeError(`invalid codepoint 0x${code.toString(16).toUpperCase()} in UTF-8`);
|
|
520
|
+
}
|
|
521
|
+
return str1 + String.fromCodePoint(code);
|
|
522
|
+
}
|
|
523
|
+
return str1 + stringValue(str2);
|
|
524
|
+
}
|
|
525
|
+
/** `String#concat` (`vendor/ruby/v3.3.11/string.c:3472` `rb_str_concat_multi`). */
|
|
526
|
+
function rbStrConcatMulti(self, ...args) {
|
|
527
|
+
self.string += args.reduce((arg, value) => rbStrConcat(arg, value), "");
|
|
528
|
+
return self.string;
|
|
529
|
+
}
|
|
530
|
+
/** `String#split` (`vendor/ruby/v3.3.11/string.c:8757` `rb_str_split_m`): with a block, each field yielded. */
|
|
531
|
+
function rbStrSplitM(self, ...argv) {
|
|
532
|
+
const [args, block] = blockArg(argv);
|
|
533
|
+
checkArity(args.length, 0, 2);
|
|
534
|
+
const fields = stringSplit(self.string, ...args);
|
|
535
|
+
if (!block)
|
|
536
|
+
return fields;
|
|
537
|
+
fields.forEach((field) => block(field));
|
|
538
|
+
return self.string;
|
|
539
|
+
}
|
|
540
|
+
/** `String#slice!` (`vendor/ruby/v3.3.11/string.c:5588` `rb_str_slice_bang`). */
|
|
541
|
+
function rbStrSliceBang(self, ...args) {
|
|
542
|
+
checkArity(args.length, 1, 2);
|
|
543
|
+
const [sliced, rest] = sliceBang(self.string, ...args);
|
|
544
|
+
self.string = rest;
|
|
545
|
+
return sliced;
|
|
546
|
+
}
|
|
547
|
+
/** `String#scrub` (`vendor/ruby/v3.3.11/string.c:11354` `str_scrub`). */
|
|
548
|
+
function strScrub(str, argv) {
|
|
549
|
+
const [args, block] = blockArg(argv);
|
|
550
|
+
checkArity(args.length, 0, 1);
|
|
551
|
+
const repl = args.length && args[0] != null ? stringValue(args[0]) : null;
|
|
552
|
+
return scrub(str, repl, block ? (bad) => stringValue(block(bad)) : undefined);
|
|
553
|
+
}
|
|
554
|
+
const NORMALIZATION_FORMS = {
|
|
555
|
+
":nfc": "NFC",
|
|
556
|
+
":nfd": "NFD",
|
|
557
|
+
":nfkc": "NFKC",
|
|
558
|
+
":nfkd": "NFKD",
|
|
559
|
+
};
|
|
560
|
+
/**
|
|
561
|
+
* `String#unicode_normalize` (`vendor/ruby/v3.3.11/string.c:11432`, raising from
|
|
562
|
+
* `vendor/ruby/v3.3.11/lib/unicode_normalize/normalize.rb:140`).
|
|
563
|
+
*/
|
|
564
|
+
function unicodeNormalize(str, argv) {
|
|
565
|
+
checkArity(argv.length, 0, 1);
|
|
566
|
+
const form = argv.length ? argv[0] : ":nfc";
|
|
567
|
+
const js = NORMALIZATION_FORMS[form];
|
|
568
|
+
if (!js) {
|
|
569
|
+
const name = typeof form === "string" && form.startsWith(":") ? form.slice(1) : String(form);
|
|
570
|
+
throw new ArgumentError(`Invalid normalization form ${name}.`);
|
|
571
|
+
}
|
|
572
|
+
return str.normalize(js);
|
|
573
|
+
}
|
|
574
|
+
/** `str_substr` (`vendor/ruby/v3.3.11/string.c:2994`) over `rb_str_subpos`. */
|
|
575
|
+
function strSubstr(str, beg, len, empty) {
|
|
576
|
+
const chars = [...str];
|
|
577
|
+
const slen = chars.length;
|
|
578
|
+
if (len < 0)
|
|
579
|
+
return null;
|
|
580
|
+
if (beg > slen)
|
|
581
|
+
return null;
|
|
582
|
+
if (beg < 0) {
|
|
583
|
+
beg += slen;
|
|
584
|
+
if (beg < 0)
|
|
585
|
+
return null;
|
|
586
|
+
}
|
|
587
|
+
if (len > slen - beg)
|
|
588
|
+
len = slen - beg;
|
|
589
|
+
if (!len && !empty)
|
|
590
|
+
return null;
|
|
591
|
+
return chars.slice(beg, beg + len).join("");
|
|
592
|
+
}
|
|
593
|
+
/** `rb_str_subpat` (`vendor/ruby/v3.3.11/string.c:5220`). */
|
|
594
|
+
function rbStrSubpat(str, re, backref) {
|
|
595
|
+
const match = rbRegSearch(re, str, 0, false);
|
|
596
|
+
if (!match)
|
|
597
|
+
return null;
|
|
598
|
+
return match[rbRegBackrefNumber(match, backref)] ?? null;
|
|
599
|
+
}
|
|
600
|
+
/** `rb_str_aref` (`vendor/ruby/v3.3.11/string.c:5231`). */
|
|
601
|
+
function rbStrAref(str, indx) {
|
|
602
|
+
let idx;
|
|
603
|
+
if (typeof indx === "number") {
|
|
604
|
+
idx = Math.trunc(indx);
|
|
605
|
+
}
|
|
606
|
+
else if (indx instanceof RegExp) {
|
|
607
|
+
return rbStrSubpat(str, indx, 0);
|
|
608
|
+
}
|
|
609
|
+
else if (typeof indx === "string") {
|
|
610
|
+
if (str.includes(indx))
|
|
611
|
+
return indx;
|
|
612
|
+
return null;
|
|
613
|
+
}
|
|
614
|
+
else {
|
|
615
|
+
if (indx instanceof Range) {
|
|
616
|
+
const begLen = rbRangeBegLen(indx, strlen(str), 0);
|
|
617
|
+
if (begLen === null)
|
|
618
|
+
return null;
|
|
619
|
+
return strSubstr(str, begLen[0], begLen[1], true);
|
|
620
|
+
}
|
|
621
|
+
idx = num2long(indx);
|
|
622
|
+
}
|
|
623
|
+
return strSubstr(str, idx, 1, false);
|
|
624
|
+
}
|
|
625
|
+
/** `String#[]` / `String#slice` (`vendor/ruby/v3.3.11/string.c:5279` `rb_str_aref_m`). */
|
|
626
|
+
function rbStrArefM(self, ...args) {
|
|
627
|
+
if (args.length === 2) {
|
|
628
|
+
if (args[0] instanceof RegExp) {
|
|
629
|
+
return rbStrSubpat(self.string, args[0], args[1]);
|
|
630
|
+
}
|
|
631
|
+
else {
|
|
632
|
+
const beg = num2long(args[0]);
|
|
633
|
+
const len = num2long(args[1]);
|
|
634
|
+
return strSubstr(self.string, beg, len, true);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
checkArity(args.length, 1, 2);
|
|
638
|
+
return rbStrAref(self.string, args[0]);
|
|
639
|
+
}
|
|
640
|
+
/** `rb_str_update` (`vendor/ruby/v3.3.11/string.c:5378`), in character offsets. */
|
|
641
|
+
function rbStrUpdate(self, beg, len, val) {
|
|
642
|
+
if (len < 0)
|
|
643
|
+
throw new IndexError(`negative length ${len}`);
|
|
644
|
+
const str2 = stringValue(val);
|
|
645
|
+
const chars = [...self.string];
|
|
646
|
+
const slen = chars.length;
|
|
647
|
+
if (slen < beg || (beg < 0 && beg + slen < 0)) {
|
|
648
|
+
throw new IndexError(`index ${beg} out of string`);
|
|
649
|
+
}
|
|
650
|
+
if (beg < 0)
|
|
651
|
+
beg += slen;
|
|
652
|
+
if (len > slen - beg)
|
|
653
|
+
len = slen - beg;
|
|
654
|
+
chars.splice(beg, len, str2);
|
|
655
|
+
self.string = chars.join("");
|
|
656
|
+
}
|
|
657
|
+
/** `rb_str_subpat_set` (`vendor/ruby/v3.3.11/string.c:5418`). */
|
|
658
|
+
function rbStrSubpatSet(self, re, backref, val) {
|
|
659
|
+
const match = rbRegSearch(re, self.string, 0, false);
|
|
660
|
+
if (!match)
|
|
661
|
+
throw new IndexError("regexp not matched");
|
|
662
|
+
let nth = rbRegBackrefNumber(match, backref);
|
|
663
|
+
const numRegs = match.length;
|
|
664
|
+
if (nth >= numRegs || (nth < 0 && -nth >= numRegs)) {
|
|
665
|
+
throw new IndexError(`index ${nth} out of regexp`);
|
|
666
|
+
}
|
|
667
|
+
if (nth < 0)
|
|
668
|
+
nth += numRegs;
|
|
669
|
+
const span = match.indices[nth];
|
|
670
|
+
if (span === undefined)
|
|
671
|
+
throw new IndexError(`regexp group ${nth} not matched`);
|
|
672
|
+
const [start, end] = span;
|
|
673
|
+
const str2 = stringValue(val);
|
|
674
|
+
self.string = self.string.slice(0, start) + str2 + self.string.slice(end);
|
|
675
|
+
}
|
|
676
|
+
/** `rb_str_aset` (`vendor/ruby/v3.3.11/string.c:5443`). */
|
|
677
|
+
function rbStrAset(self, indx, val) {
|
|
678
|
+
if (indx instanceof RegExp) {
|
|
679
|
+
rbStrSubpatSet(self, indx, 0, val);
|
|
680
|
+
return val;
|
|
681
|
+
}
|
|
682
|
+
if (typeof indx === "string") {
|
|
683
|
+
const beg = self.string.indexOf(indx);
|
|
684
|
+
if (beg < 0)
|
|
685
|
+
throw new IndexError("string not matched");
|
|
686
|
+
rbStrUpdate(self, rbStrSublen(self.string, beg), strlen(indx), val);
|
|
687
|
+
return val;
|
|
688
|
+
}
|
|
689
|
+
if (indx instanceof Range) {
|
|
690
|
+
const [beg, len] = rbRangeBegLen(indx, strlen(self.string), 2);
|
|
691
|
+
rbStrUpdate(self, beg, len, val);
|
|
692
|
+
return val;
|
|
693
|
+
}
|
|
694
|
+
rbStrUpdate(self, num2long(indx), 1, val);
|
|
695
|
+
return val;
|
|
696
|
+
}
|
|
697
|
+
/** `String#[]=` (`vendor/ruby/v3.3.11/string.c:5516` `rb_str_aset_m`). */
|
|
698
|
+
function rbStrAsetM(self, ...args) {
|
|
699
|
+
if (args.length === 3) {
|
|
700
|
+
if (args[0] instanceof RegExp) {
|
|
701
|
+
rbStrSubpatSet(self, args[0], args[1], args[2]);
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
rbStrUpdate(self, num2long(args[0]), num2long(args[1]), args[2]);
|
|
705
|
+
}
|
|
706
|
+
return args[2];
|
|
707
|
+
}
|
|
708
|
+
checkArity(args.length, 2, 3);
|
|
709
|
+
return rbStrAset(self, args[0], args[1]);
|
|
710
|
+
}
|
|
711
|
+
/** `String#insert` (`vendor/ruby/v3.3.11/string.c:5550` `rb_str_insert`). */
|
|
712
|
+
function rbStrInsert(self, idx, str2) {
|
|
713
|
+
let pos = num2long(idx);
|
|
714
|
+
if (pos === -1) {
|
|
715
|
+
self.string += stringValue(str2);
|
|
716
|
+
return self.string;
|
|
717
|
+
}
|
|
718
|
+
else if (pos < 0) {
|
|
719
|
+
pos++;
|
|
720
|
+
}
|
|
721
|
+
rbStrUpdate(self, pos, 0, str2);
|
|
722
|
+
return self.string;
|
|
723
|
+
}
|
|
724
|
+
/** `String#index` (`vendor/ruby/v3.3.11/string.c:4034` `rb_str_index_m`). */
|
|
725
|
+
function rbStrIndexM(self, ...args) {
|
|
726
|
+
checkArity(args.length, 1, 2);
|
|
727
|
+
const str = self.string;
|
|
728
|
+
const [sub, initpos] = args;
|
|
729
|
+
let pos;
|
|
730
|
+
if (args.length === 2) {
|
|
731
|
+
const slen = strlen(str);
|
|
732
|
+
pos = num2long(initpos);
|
|
733
|
+
if (pos < 0 ? (pos += slen) < 0 : pos > slen)
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
pos = 0;
|
|
738
|
+
}
|
|
739
|
+
if (sub instanceof RegExp) {
|
|
740
|
+
const match = rbRegSearch(sub, str, pos, false);
|
|
741
|
+
if (match)
|
|
742
|
+
return rbStrSublen(str, match.index);
|
|
743
|
+
}
|
|
744
|
+
else {
|
|
745
|
+
const found = str.indexOf(stringValue(sub), strOffset(str, pos));
|
|
746
|
+
if (found >= 0)
|
|
747
|
+
return rbStrSublen(str, found);
|
|
748
|
+
}
|
|
749
|
+
return null;
|
|
750
|
+
}
|
|
751
|
+
/** `String#rindex` (`vendor/ruby/v3.3.11/string.c:4320` `rb_str_rindex_m`). */
|
|
752
|
+
function rbStrRindexM(self, ...args) {
|
|
753
|
+
checkArity(args.length, 1, 2);
|
|
754
|
+
const str = self.string;
|
|
755
|
+
const [sub, initpos] = args;
|
|
756
|
+
const len = strlen(str);
|
|
757
|
+
let pos;
|
|
758
|
+
if (args.length === 2) {
|
|
759
|
+
pos = num2long(initpos);
|
|
760
|
+
if (pos < 0 && (pos += len) < 0)
|
|
761
|
+
return null;
|
|
762
|
+
if (pos > len)
|
|
763
|
+
pos = len;
|
|
764
|
+
}
|
|
765
|
+
else {
|
|
766
|
+
pos = len;
|
|
767
|
+
}
|
|
768
|
+
if (sub instanceof RegExp) {
|
|
769
|
+
const match = rbRegSearch(sub, str, pos, true);
|
|
770
|
+
if (match)
|
|
771
|
+
return rbStrSublen(str, match.index);
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
const found = str.lastIndexOf(stringValue(sub), strOffset(str, pos));
|
|
775
|
+
if (found >= 0)
|
|
776
|
+
return rbStrSublen(str, found);
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
/** `ljust` / `rjust` / `center` (`vendor/ruby/v3.3.11/string.c:10424` `rb_str_justify`). */
|
|
781
|
+
function rbStrJustify(argv, str, jflag) {
|
|
782
|
+
checkArity(argv.length, 1, 2);
|
|
783
|
+
const width = num2long(argv[0]);
|
|
784
|
+
let f = [" "];
|
|
785
|
+
if (argv.length === 2) {
|
|
786
|
+
f = [...stringValue(argv[1])];
|
|
787
|
+
if (f.length === 0)
|
|
788
|
+
throw new ArgumentError("zero width padding");
|
|
789
|
+
}
|
|
790
|
+
const len = strlen(str);
|
|
791
|
+
if (width < 0 || len >= width)
|
|
792
|
+
return str;
|
|
793
|
+
const n = width - len;
|
|
794
|
+
const llen = jflag === "l" ? 0 : jflag === "r" ? n : Math.floor(n / 2);
|
|
795
|
+
const rlen = n - llen;
|
|
796
|
+
const fill = (count) => Array.from({ length: count }, (_, i) => f[i % f.length]).join("");
|
|
797
|
+
return fill(llen) + str + fill(rlen);
|
|
798
|
+
}
|
|
799
|
+
/** `String#ord` (`vendor/ruby/v3.3.11/string.c:10355` `rb_str_ord`). */
|
|
800
|
+
function rbStrOrd(self) {
|
|
801
|
+
if (self.string.length === 0)
|
|
802
|
+
throw new ArgumentError("empty string");
|
|
803
|
+
return self.string.codePointAt(0);
|
|
804
|
+
}
|
|
805
|
+
//# sourceMappingURL=method-table.js.map
|