@blazetrails/ruby-compat 0.0.0-stage → 0.1.0-alpha0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +6 -0
- package/README.md +440 -2
- package/dist/argument-error.d.ts +15 -0
- package/dist/argument-error.js +15 -0
- package/dist/argument-error.js.map +1 -0
- package/dist/array.d.ts +415 -0
- package/dist/array.js +1330 -0
- package/dist/array.js.map +1 -0
- package/dist/async-context-adapter.d.ts +19 -0
- package/dist/async-context-adapter.js +139 -0
- package/dist/async-context-adapter.js.map +1 -0
- package/dist/backtrace-location.d.ts +77 -0
- package/dist/backtrace-location.js +155 -0
- package/dist/backtrace-location.js.map +1 -0
- package/dist/base64.d.ts +73 -0
- package/dist/base64.js +164 -0
- package/dist/base64.js.map +1 -0
- package/dist/benchmark.d.ts +19 -0
- package/dist/benchmark.js +16 -0
- package/dist/benchmark.js.map +1 -0
- package/dist/big-decimal.d.ts +110 -0
- package/dist/big-decimal.js +582 -0
- package/dist/big-decimal.js.map +1 -0
- package/dist/bundler.d.ts +44 -0
- package/dist/bundler.js +101 -0
- package/dist/bundler.js.map +1 -0
- package/dist/cgi.d.ts +89 -0
- package/dist/cgi.js +168 -0
- package/dist/cgi.js.map +1 -0
- package/dist/child-process-adapter.d.ts +110 -0
- package/dist/child-process-adapter.js +272 -0
- package/dist/child-process-adapter.js.map +1 -0
- package/dist/class-module.d.ts +10 -0
- package/dist/class-module.js +10 -0
- package/dist/class-module.js.map +1 -0
- package/dist/classpath.d.ts +90 -0
- package/dist/classpath.js +207 -0
- package/dist/classpath.js.map +1 -0
- package/dist/closed-queue-error.d.ts +10 -0
- package/dist/closed-queue-error.js +10 -0
- package/dist/closed-queue-error.js.map +1 -0
- package/dist/comparable.d.ts +127 -0
- package/dist/comparable.js +376 -0
- package/dist/comparable.js.map +1 -0
- package/dist/complex.d.ts +48 -0
- package/dist/complex.js +162 -0
- package/dist/complex.js.map +1 -0
- package/dist/concurrent/atomic-boolean.d.ts +24 -0
- package/dist/concurrent/atomic-boolean.js +43 -0
- package/dist/concurrent/atomic-boolean.js.map +1 -0
- package/dist/concurrent/atomic-fixnum.d.ts +21 -0
- package/dist/concurrent/atomic-fixnum.js +35 -0
- package/dist/concurrent/atomic-fixnum.js.map +1 -0
- package/dist/concurrent/count-down-latch.d.ts +20 -0
- package/dist/concurrent/count-down-latch.js +50 -0
- package/dist/concurrent/count-down-latch.js.map +1 -0
- package/dist/concurrent/cyclic-barrier.d.ts +18 -0
- package/dist/concurrent/cyclic-barrier.js +50 -0
- package/dist/concurrent/cyclic-barrier.js.map +1 -0
- package/dist/concurrent/event.d.ts +19 -0
- package/dist/concurrent/event.js +31 -0
- package/dist/concurrent/event.js.map +1 -0
- package/dist/concurrent/map.d.ts +149 -0
- package/dist/concurrent/map.js +202 -0
- package/dist/concurrent/map.js.map +1 -0
- package/dist/concurrent/read-write-lock.d.ts +25 -0
- package/dist/concurrent/read-write-lock.js +70 -0
- package/dist/concurrent/read-write-lock.js.map +1 -0
- package/dist/concurrent/semaphore.d.ts +24 -0
- package/dist/concurrent/semaphore.js +74 -0
- package/dist/concurrent/semaphore.js.map +1 -0
- package/dist/concurrent/timer-task.d.ts +52 -0
- package/dist/concurrent/timer-task.js +112 -0
- package/dist/concurrent/timer-task.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +64 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/converter-not-found-error.d.ts +14 -0
- package/dist/converter-not-found-error.js +14 -0
- package/dist/converter-not-found-error.js.map +1 -0
- package/dist/crypto-adapter.d.ts +64 -0
- package/dist/crypto-adapter.js +365 -0
- package/dist/crypto-adapter.js.map +1 -0
- package/dist/delegate.d.ts +156 -0
- package/dist/delegate.js +306 -0
- package/dist/delegate.js.map +1 -0
- package/dist/digest.d.ts +99 -0
- package/dist/digest.js +131 -0
- package/dist/digest.js.map +1 -0
- package/dist/dir.d.ts +218 -0
- package/dist/dir.js +599 -0
- package/dist/dir.js.map +1 -0
- package/dist/encoding-error.d.ts +14 -0
- package/dist/encoding-error.js +17 -0
- package/dist/encoding-error.js.map +1 -0
- package/dist/encoding.d.ts +121 -0
- package/dist/encoding.js +306 -0
- package/dist/encoding.js.map +1 -0
- package/dist/ensure.d.ts +15 -0
- package/dist/ensure.js +35 -0
- package/dist/ensure.js.map +1 -0
- package/dist/enumerable.d.ts +375 -0
- package/dist/enumerable.js +1100 -0
- package/dist/enumerable.js.map +1 -0
- package/dist/enumerator.d.ts +321 -0
- package/dist/enumerator.js +642 -0
- package/dist/enumerator.js.map +1 -0
- package/dist/eof-error.d.ts +14 -0
- package/dist/eof-error.js +14 -0
- package/dist/eof-error.js.map +1 -0
- package/dist/errno.d.ts +327 -0
- package/dist/errno.js +452 -0
- package/dist/errno.js.map +1 -0
- package/dist/exc-detailed-message.d.ts +15 -0
- package/dist/exc-detailed-message.js +106 -0
- package/dist/exc-detailed-message.js.map +1 -0
- package/dist/exc-to-s.d.ts +10 -0
- package/dist/exc-to-s.js +21 -0
- package/dist/exc-to-s.js.map +1 -0
- package/dist/exception.d.ts +34 -0
- package/dist/exception.js +99 -0
- package/dist/exception.js.map +1 -0
- package/dist/fiber-error.d.ts +12 -0
- package/dist/fiber-error.js +12 -0
- package/dist/fiber-error.js.map +1 -0
- package/dist/fiber.d.ts +51 -0
- package/dist/fiber.js +178 -0
- package/dist/fiber.js.map +1 -0
- package/dist/file-utils.d.ts +480 -0
- package/dist/file-utils.js +1823 -0
- package/dist/file-utils.js.map +1 -0
- package/dist/file.d.ts +635 -0
- package/dist/file.js +1312 -0
- package/dist/file.js.map +1 -0
- package/dist/float-domain-error.d.ts +17 -0
- package/dist/float-domain-error.js +17 -0
- package/dist/float-domain-error.js.map +1 -0
- package/dist/fork-children.d.ts +23 -0
- package/dist/fork-children.js +32 -0
- package/dist/fork-children.js.map +1 -0
- package/dist/frozen-error.d.ts +33 -0
- package/dist/frozen-error.js +42 -0
- package/dist/frozen-error.js.map +1 -0
- package/dist/fs-adapter.d.ts +158 -0
- package/dist/fs-adapter.js +253 -0
- package/dist/fs-adapter.js.map +1 -0
- package/dist/gem/deprecate.d.ts +10 -0
- package/dist/gem/deprecate.js +8 -0
- package/dist/gem/deprecate.js.map +1 -0
- package/dist/gem/requirement.d.ts +64 -0
- package/dist/gem/requirement.js +91 -0
- package/dist/gem/requirement.js.map +1 -0
- package/dist/gem/version.d.ts +50 -0
- package/dist/gem/version.js +148 -0
- package/dist/gem/version.js.map +1 -0
- package/dist/gem.d.ts +59 -0
- package/dist/gem.js +82 -0
- package/dist/gem.js.map +1 -0
- package/dist/hash.d.ts +967 -0
- package/dist/hash.js +1572 -0
- package/dist/hash.js.map +1 -0
- package/dist/http-adapter.d.ts +123 -0
- package/dist/http-adapter.js +220 -0
- package/dist/http-adapter.js.map +1 -0
- package/dist/immediate-executor.d.ts +20 -0
- package/dist/immediate-executor.js +39 -0
- package/dist/immediate-executor.js.map +1 -0
- package/dist/include.d.ts +778 -0
- package/dist/include.js +2195 -0
- package/dist/include.js.map +1 -0
- package/dist/index-error.d.ts +13 -0
- package/dist/index-error.js +13 -0
- package/dist/index-error.js.map +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +166 -0
- package/dist/index.js.map +1 -0
- package/dist/invalid-byte-sequence-error.d.ts +62 -0
- package/dist/invalid-byte-sequence-error.js +75 -0
- package/dist/invalid-byte-sequence-error.js.map +1 -0
- package/dist/io-error.d.ts +14 -0
- package/dist/io-error.js +17 -0
- package/dist/io-error.js.map +1 -0
- package/dist/io.d.ts +867 -0
- package/dist/io.js +1960 -0
- package/dist/io.js.map +1 -0
- package/dist/ipaddr.d.ts +79 -0
- package/dist/ipaddr.js +405 -0
- package/dist/ipaddr.js.map +1 -0
- package/dist/json.d.ts +67 -0
- package/dist/json.js +185 -0
- package/dist/json.js.map +1 -0
- package/dist/kernel-catch.d.ts +59 -0
- package/dist/kernel-catch.js +184 -0
- package/dist/kernel-catch.js.map +1 -0
- package/dist/kernel-float.d.ts +19 -0
- package/dist/kernel-float.js +54 -0
- package/dist/kernel-float.js.map +1 -0
- package/dist/kernel-fork.d.ts +30 -0
- package/dist/kernel-fork.js +72 -0
- package/dist/kernel-fork.js.map +1 -0
- package/dist/kernel-format.d.ts +27 -0
- package/dist/kernel-format.js +901 -0
- package/dist/kernel-format.js.map +1 -0
- package/dist/kernel-hash.d.ts +7 -0
- package/dist/kernel-hash.js +33 -0
- package/dist/kernel-hash.js.map +1 -0
- package/dist/kernel-integer.d.ts +49 -0
- package/dist/kernel-integer.js +170 -0
- package/dist/kernel-integer.js.map +1 -0
- package/dist/kernel-rand.d.ts +16 -0
- package/dist/kernel-rand.js +237 -0
- package/dist/kernel-rand.js.map +1 -0
- package/dist/kernel-system.d.ts +40 -0
- package/dist/kernel-system.js +97 -0
- package/dist/kernel-system.js.map +1 -0
- package/dist/kernel-warn.d.ts +35 -0
- package/dist/kernel-warn.js +73 -0
- package/dist/kernel-warn.js.map +1 -0
- package/dist/key-error.d.ts +44 -0
- package/dist/key-error.js +59 -0
- package/dist/key-error.js.map +1 -0
- package/dist/keyword-splat.d.ts +41 -0
- package/dist/keyword-splat.js +65 -0
- package/dist/keyword-splat.js.map +1 -0
- package/dist/load-error.d.ts +19 -0
- package/dist/load-error.js +19 -0
- package/dist/load-error.js.map +1 -0
- package/dist/load.d.ts +121 -0
- package/dist/load.js +263 -0
- package/dist/load.js.map +1 -0
- package/dist/loaded-features.d.ts +13 -0
- package/dist/loaded-features.js +15 -0
- package/dist/loaded-features.js.map +1 -0
- package/dist/local-jump-error.d.ts +12 -0
- package/dist/local-jump-error.js +12 -0
- package/dist/local-jump-error.js.map +1 -0
- package/dist/logger/formatter.d.ts +21 -0
- package/dist/logger/formatter.js +43 -0
- package/dist/logger/formatter.js.map +1 -0
- package/dist/logger/log-device.d.ts +52 -0
- package/dist/logger/log-device.js +104 -0
- package/dist/logger/log-device.js.map +1 -0
- package/dist/logger/severity.d.ts +23 -0
- package/dist/logger/severity.js +42 -0
- package/dist/logger/severity.js.map +1 -0
- package/dist/logger.d.ts +127 -0
- package/dist/logger.js +215 -0
- package/dist/logger.js.map +1 -0
- package/dist/marshal.d.ts +83 -0
- package/dist/marshal.js +1487 -0
- package/dist/marshal.js.map +1 -0
- package/dist/match-data.d.ts +161 -0
- package/dist/match-data.js +284 -0
- package/dist/match-data.js.map +1 -0
- package/dist/method-cache.d.ts +17 -0
- package/dist/method-cache.js +19 -0
- package/dist/method-cache.js.map +1 -0
- package/dist/method-missing-proxy.d.ts +53 -0
- package/dist/method-missing-proxy.js +154 -0
- package/dist/method-missing-proxy.js.map +1 -0
- package/dist/method.d.ts +132 -0
- package/dist/method.js +320 -0
- package/dist/method.js.map +1 -0
- package/dist/monitor.d.ts +114 -0
- package/dist/monitor.js +270 -0
- package/dist/monitor.js.map +1 -0
- package/dist/mutex.d.ts +51 -0
- package/dist/mutex.js +150 -0
- package/dist/mutex.js.map +1 -0
- package/dist/name-error.d.ts +45 -0
- package/dist/name-error.js +54 -0
- package/dist/name-error.js.map +1 -0
- package/dist/net/http/exceptions.d.ts +31 -0
- package/dist/net/http/exceptions.js +46 -0
- package/dist/net/http/exceptions.js.map +1 -0
- package/dist/net/http/request.d.ts +137 -0
- package/dist/net/http/request.js +559 -0
- package/dist/net/http/request.js.map +1 -0
- package/dist/net/http/requests.d.ts +197 -0
- package/dist/net/http/requests.js +197 -0
- package/dist/net/http/requests.js.map +1 -0
- package/dist/net/http/response.d.ts +141 -0
- package/dist/net/http/response.js +416 -0
- package/dist/net/http/response.js.map +1 -0
- package/dist/net/http/responses.d.ts +345 -0
- package/dist/net/http/responses.js +486 -0
- package/dist/net/http/responses.js.map +1 -0
- package/dist/net/http.d.ts +278 -0
- package/dist/net/http.js +760 -0
- package/dist/net/http.js.map +1 -0
- package/dist/net/protocol.d.ts +227 -0
- package/dist/net/protocol.js +392 -0
- package/dist/net/protocol.js.map +1 -0
- package/dist/nil-class.d.ts +10 -0
- package/dist/nil-class.js +27 -0
- package/dist/nil-class.js.map +1 -0
- package/dist/no-method-error.d.ts +38 -0
- package/dist/no-method-error.js +45 -0
- package/dist/no-method-error.js.map +1 -0
- package/dist/not-implemented-error.d.ts +13 -0
- package/dist/not-implemented-error.js +14 -0
- package/dist/not-implemented-error.js.map +1 -0
- package/dist/numeric.d.ts +211 -0
- package/dist/numeric.js +802 -0
- package/dist/numeric.js.map +1 -0
- package/dist/object-space.d.ts +34 -0
- package/dist/object-space.js +152 -0
- package/dist/object-space.js.map +1 -0
- package/dist/object.d.ts +908 -0
- package/dist/object.js +2238 -0
- package/dist/object.js.map +1 -0
- package/dist/open-uri.d.ts +180 -0
- package/dist/open-uri.js +402 -0
- package/dist/open-uri.js.map +1 -0
- package/dist/open3.d.ts +69 -0
- package/dist/open3.js +134 -0
- package/dist/open3.js.map +1 -0
- package/dist/openssl.d.ts +479 -0
- package/dist/openssl.js +1052 -0
- package/dist/openssl.js.map +1 -0
- package/dist/optparse.d.ts +130 -0
- package/dist/optparse.js +457 -0
- package/dist/optparse.js.map +1 -0
- package/dist/os-adapter.d.ts +20 -0
- package/dist/os-adapter.js +95 -0
- package/dist/os-adapter.js.map +1 -0
- package/dist/pathname.d.ts +71 -0
- package/dist/pathname.js +394 -0
- package/dist/pathname.js.map +1 -0
- package/dist/pp.d.ts +60 -0
- package/dist/pp.js +195 -0
- package/dist/pp.js.map +1 -0
- package/dist/pretty-print.d.ts +89 -0
- package/dist/pretty-print.js +232 -0
- package/dist/pretty-print.js.map +1 -0
- package/dist/process-adapter.d.ts +224 -0
- package/dist/process-adapter.js +878 -0
- package/dist/process-adapter.js.map +1 -0
- package/dist/process.d.ts +192 -0
- package/dist/process.js +403 -0
- package/dist/process.js.map +1 -0
- package/dist/psych/class-loader.d.ts +92 -0
- package/dist/psych/class-loader.js +139 -0
- package/dist/psych/class-loader.js.map +1 -0
- package/dist/psych/coder.d.ts +144 -0
- package/dist/psych/coder.js +176 -0
- package/dist/psych/coder.js.map +1 -0
- package/dist/psych/core-ext.d.ts +8 -0
- package/dist/psych/core-ext.js +10 -0
- package/dist/psych/core-ext.js.map +1 -0
- package/dist/psych/emitter.d.ts +116 -0
- package/dist/psych/emitter.js +1130 -0
- package/dist/psych/emitter.js.map +1 -0
- package/dist/psych/exception.d.ts +43 -0
- package/dist/psych/exception.js +54 -0
- package/dist/psych/exception.js.map +1 -0
- package/dist/psych/handler.d.ts +59 -0
- package/dist/psych/handler.js +95 -0
- package/dist/psych/handler.js.map +1 -0
- package/dist/psych/handlers/document-stream.d.ts +17 -0
- package/dist/psych/handlers/document-stream.js +26 -0
- package/dist/psych/handlers/document-stream.js.map +1 -0
- package/dist/psych/nodes/alias.d.ts +15 -0
- package/dist/psych/nodes/alias.js +22 -0
- package/dist/psych/nodes/alias.js.map +1 -0
- package/dist/psych/nodes/document.d.ts +23 -0
- package/dist/psych/nodes/document.js +35 -0
- package/dist/psych/nodes/document.js.map +1 -0
- package/dist/psych/nodes/mapping.d.ts +25 -0
- package/dist/psych/nodes/mapping.js +35 -0
- package/dist/psych/nodes/mapping.js.map +1 -0
- package/dist/psych/nodes/node.d.ts +59 -0
- package/dist/psych/nodes/node.js +79 -0
- package/dist/psych/nodes/node.js.map +1 -0
- package/dist/psych/nodes/scalar.d.ts +35 -0
- package/dist/psych/nodes/scalar.js +47 -0
- package/dist/psych/nodes/scalar.js.map +1 -0
- package/dist/psych/nodes/sequence.d.ts +25 -0
- package/dist/psych/nodes/sequence.js +35 -0
- package/dist/psych/nodes/sequence.js.map +1 -0
- package/dist/psych/nodes/stream.d.ts +23 -0
- package/dist/psych/nodes/stream.js +31 -0
- package/dist/psych/nodes/stream.js.map +1 -0
- package/dist/psych/omap.d.ts +9 -0
- package/dist/psych/omap.js +9 -0
- package/dist/psych/omap.js.map +1 -0
- package/dist/psych/parser.d.ts +41 -0
- package/dist/psych/parser.js +139 -0
- package/dist/psych/parser.js.map +1 -0
- package/dist/psych/scalar-scanner.d.ts +35 -0
- package/dist/psych/scalar-scanner.js +173 -0
- package/dist/psych/scalar-scanner.js.map +1 -0
- package/dist/psych/syntax-error.d.ts +23 -0
- package/dist/psych/syntax-error.js +35 -0
- package/dist/psych/syntax-error.js.map +1 -0
- package/dist/psych/tree-builder.d.ts +51 -0
- package/dist/psych/tree-builder.js +118 -0
- package/dist/psych/tree-builder.js.map +1 -0
- package/dist/psych/visitors/depth-first.d.ts +27 -0
- package/dist/psych/visitors/depth-first.js +37 -0
- package/dist/psych/visitors/depth-first.js.map +1 -0
- package/dist/psych/visitors/emitter.d.ts +32 -0
- package/dist/psych/visitors/emitter.js +63 -0
- package/dist/psych/visitors/emitter.js.map +1 -0
- package/dist/psych/visitors/to-ruby.d.ts +110 -0
- package/dist/psych/visitors/to-ruby.js +396 -0
- package/dist/psych/visitors/to-ruby.js.map +1 -0
- package/dist/psych/visitors/visitor.d.ts +11 -0
- package/dist/psych/visitors/visitor.js +17 -0
- package/dist/psych/visitors/visitor.js.map +1 -0
- package/dist/psych/visitors/yaml-tree.d.ts +182 -0
- package/dist/psych/visitors/yaml-tree.js +593 -0
- package/dist/psych/visitors/yaml-tree.js.map +1 -0
- package/dist/psych-adapter.d.ts +65 -0
- package/dist/psych-adapter.js +121 -0
- package/dist/psych-adapter.js.map +1 -0
- package/dist/psych-yaml.d.ts +2 -0
- package/dist/psych-yaml.js +5 -0
- package/dist/psych-yaml.js.map +1 -0
- package/dist/psych.d.ts +257 -0
- package/dist/psych.js +332 -0
- package/dist/psych.js.map +1 -0
- package/dist/queue.d.ts +129 -0
- package/dist/queue.js +215 -0
- package/dist/queue.js.map +1 -0
- package/dist/racc/parser.d.ts +70 -0
- package/dist/racc/parser.js +206 -0
- package/dist/racc/parser.js.map +1 -0
- package/dist/range-error.d.ts +15 -0
- package/dist/range-error.js +15 -0
- package/dist/range-error.js.map +1 -0
- package/dist/range.d.ts +166 -0
- package/dist/range.js +421 -0
- package/dist/range.js.map +1 -0
- package/dist/rational.d.ts +167 -0
- package/dist/rational.js +379 -0
- package/dist/rational.js.map +1 -0
- package/dist/rb-config.d.ts +33 -0
- package/dist/rb-config.js +53 -0
- package/dist/rb-config.js.map +1 -0
- package/dist/rb-equal.d.ts +66 -0
- package/dist/rb-equal.js +261 -0
- package/dist/rb-equal.js.map +1 -0
- package/dist/rb-hash.d.ts +26 -0
- package/dist/rb-hash.js +108 -0
- package/dist/rb-hash.js.map +1 -0
- package/dist/regexp.d.ts +82 -0
- package/dist/regexp.js +191 -0
- package/dist/regexp.js.map +1 -0
- package/dist/repl-adapter.d.ts +188 -0
- package/dist/repl-adapter.js +388 -0
- package/dist/repl-adapter.js.map +1 -0
- package/dist/resolv.d.ts +30 -0
- package/dist/resolv.js +48 -0
- package/dist/resolv.js.map +1 -0
- package/dist/ruby-empty.d.ts +28 -0
- package/dist/ruby-empty.js +40 -0
- package/dist/ruby-empty.js.map +1 -0
- package/dist/ruby-platform.d.ts +39 -0
- package/dist/ruby-platform.js +49 -0
- package/dist/ruby-platform.js.map +1 -0
- package/dist/runtime-error.d.ts +15 -0
- package/dist/runtime-error.js +16 -0
- package/dist/runtime-error.js.map +1 -0
- package/dist/scheduled-task.d.ts +73 -0
- package/dist/scheduled-task.js +150 -0
- package/dist/scheduled-task.js.map +1 -0
- package/dist/secure-random.d.ts +33 -0
- package/dist/secure-random.js +78 -0
- package/dist/secure-random.js.map +1 -0
- package/dist/set.d.ts +158 -0
- package/dist/set.js +352 -0
- package/dist/set.js.map +1 -0
- package/dist/shellwords.d.ts +27 -0
- package/dist/shellwords.js +53 -0
- package/dist/shellwords.js.map +1 -0
- package/dist/signal-exception.d.ts +21 -0
- package/dist/signal-exception.js +21 -0
- package/dist/signal-exception.js.map +1 -0
- package/dist/socket.d.ts +230 -0
- package/dist/socket.js +484 -0
- package/dist/socket.js.map +1 -0
- package/dist/standard-error.d.ts +18 -0
- package/dist/standard-error.js +23 -0
- package/dist/standard-error.js.map +1 -0
- package/dist/stop-iteration.d.ts +10 -0
- package/dist/stop-iteration.js +10 -0
- package/dist/stop-iteration.js.map +1 -0
- package/dist/string/b.d.ts +19 -0
- package/dist/string/b.js +28 -0
- package/dist/string/b.js.map +1 -0
- package/dist/string/byte-methods.d.ts +57 -0
- package/dist/string/byte-methods.js +266 -0
- package/dist/string/byte-methods.js.map +1 -0
- package/dist/string/bytes.d.ts +35 -0
- package/dist/string/bytes.js +123 -0
- package/dist/string/bytes.js.map +1 -0
- package/dist/string/case-mapping.d.ts +57 -0
- package/dist/string/case-mapping.js +192 -0
- package/dist/string/case-mapping.js.map +1 -0
- package/dist/string/chomp.d.ts +15 -0
- package/dist/string/chomp.js +32 -0
- package/dist/string/chomp.js.map +1 -0
- package/dist/string/convert.d.ts +55 -0
- package/dist/string/convert.js +316 -0
- package/dist/string/convert.js.map +1 -0
- package/dist/string/delete.d.ts +14 -0
- package/dist/string/delete.js +17 -0
- package/dist/string/delete.js.map +1 -0
- package/dist/string/each.d.ts +108 -0
- package/dist/string/each.js +305 -0
- package/dist/string/each.js.map +1 -0
- package/dist/string/encode.d.ts +37 -0
- package/dist/string/encode.js +268 -0
- package/dist/string/encode.js.map +1 -0
- package/dist/string/force-encoding.d.ts +72 -0
- package/dist/string/force-encoding.js +147 -0
- package/dist/string/force-encoding.js.map +1 -0
- package/dist/string/inspect.d.ts +17 -0
- package/dist/string/inspect.js +81 -0
- package/dist/string/inspect.js.map +1 -0
- package/dist/string/method-table.d.ts +174 -0
- package/dist/string/method-table.js +805 -0
- package/dist/string/method-table.js.map +1 -0
- package/dist/string/scrub.d.ts +12 -0
- package/dist/string/scrub.js +33 -0
- package/dist/string/scrub.js.map +1 -0
- package/dist/string/slice.d.ts +26 -0
- package/dist/string/slice.js +73 -0
- package/dist/string/slice.js.map +1 -0
- package/dist/string/split.d.ts +11 -0
- package/dist/string/split.js +44 -0
- package/dist/string/split.js.map +1 -0
- package/dist/string/sub.d.ts +114 -0
- package/dist/string/sub.js +371 -0
- package/dist/string/sub.js.map +1 -0
- package/dist/string/succ.d.ts +14 -0
- package/dist/string/succ.js +118 -0
- package/dist/string/succ.js.map +1 -0
- package/dist/string/support.d.ts +135 -0
- package/dist/string/support.js +283 -0
- package/dist/string/support.js.map +1 -0
- package/dist/string/tr.d.ts +46 -0
- package/dist/string/tr.js +156 -0
- package/dist/string/tr.js.map +1 -0
- package/dist/string-io.d.ts +166 -0
- package/dist/string-io.js +248 -0
- package/dist/string-io.js.map +1 -0
- package/dist/string-scanner.d.ts +133 -0
- package/dist/string-scanner.js +248 -0
- package/dist/string-scanner.js.map +1 -0
- package/dist/struct.d.ts +54 -0
- package/dist/struct.js +222 -0
- package/dist/struct.js.map +1 -0
- package/dist/symbol.d.ts +48 -0
- package/dist/symbol.js +107 -0
- package/dist/symbol.js.map +1 -0
- package/dist/tempfile.d.ts +173 -0
- package/dist/tempfile.js +290 -0
- package/dist/tempfile.js.map +1 -0
- package/dist/temporal-tag.d.ts +23 -0
- package/dist/temporal-tag.js +29 -0
- package/dist/temporal-tag.js.map +1 -0
- package/dist/thread-error.d.ts +13 -0
- package/dist/thread-error.js +13 -0
- package/dist/thread-error.js.map +1 -0
- package/dist/thread-pool-executor.d.ts +119 -0
- package/dist/thread-pool-executor.js +250 -0
- package/dist/thread-pool-executor.js.map +1 -0
- package/dist/thread.d.ts +211 -0
- package/dist/thread.js +495 -0
- package/dist/thread.js.map +1 -0
- package/dist/timeout.d.ts +29 -0
- package/dist/timeout.js +41 -0
- package/dist/timeout.js.map +1 -0
- package/dist/tse.d.ts +40 -0
- package/dist/tse.js +62 -0
- package/dist/tse.js.map +1 -0
- package/dist/type-error.d.ts +14 -0
- package/dist/type-error.js +15 -0
- package/dist/type-error.js.map +1 -0
- package/dist/undefined-conversion-error.d.ts +10 -0
- package/dist/undefined-conversion-error.js +10 -0
- package/dist/undefined-conversion-error.js.map +1 -0
- package/dist/uri/common.d.ts +209 -0
- package/dist/uri/common.js +369 -0
- package/dist/uri/common.js.map +1 -0
- package/dist/uri/generic.d.ts +283 -0
- package/dist/uri/generic.js +810 -0
- package/dist/uri/generic.js.map +1 -0
- package/dist/uri/http.d.ts +23 -0
- package/dist/uri/http.js +30 -0
- package/dist/uri/http.js.map +1 -0
- package/dist/uri/https.d.ts +13 -0
- package/dist/uri/https.js +15 -0
- package/dist/uri/https.js.map +1 -0
- package/dist/uri/rfc2396-parser.d.ts +70 -0
- package/dist/uri/rfc2396-parser.js +264 -0
- package/dist/uri/rfc2396-parser.js.map +1 -0
- package/dist/uri/rfc3986-parser.d.ts +46 -0
- package/dist/uri/rfc3986-parser.js +171 -0
- package/dist/uri/rfc3986-parser.js.map +1 -0
- package/dist/uri.d.ts +13 -0
- package/dist/uri.js +13 -0
- package/dist/uri.js.map +1 -0
- package/dist/variable.d.ts +183 -0
- package/dist/variable.js +463 -0
- package/dist/variable.js.map +1 -0
- package/dist/verbose.d.ts +21 -0
- package/dist/verbose.js +26 -0
- package/dist/verbose.js.map +1 -0
- package/dist/yaml.d.ts +9 -0
- package/dist/yaml.js +9 -0
- package/dist/yaml.js.map +1 -0
- package/dist/zlib-adapter.d.ts +117 -0
- package/dist/zlib-adapter.js +250 -0
- package/dist/zlib-adapter.js.map +1 -0
- package/dist/zlib.d.ts +248 -0
- package/dist/zlib.js +362 -0
- package/dist/zlib.js.map +1 -0
- package/package.json +82 -3
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { ArgumentError } from "../argument-error.js";
|
|
2
|
+
import { IndexError } from "../index-error.js";
|
|
3
|
+
import { conversionMismatch, rbBuiltinClassName } from "../object.js";
|
|
4
|
+
import { RangeError as RbRangeError } from "../range-error.js";
|
|
5
|
+
import { TypeError } from "../type-error.js";
|
|
6
|
+
/**
|
|
7
|
+
* Split a trailing block off `args` (`rb_block_given_p`, `vendor/ruby/v3.3.11/eval.c:866`),
|
|
8
|
+
* for the methods whose MRI body takes one. JS has no block syntax apart from
|
|
9
|
+
* its arguments, so a trailing function IS the block there; every other table
|
|
10
|
+
* entry reads a function as an ordinary argument.
|
|
11
|
+
*
|
|
12
|
+
* @noRailsEquivalent PERMANENT
|
|
13
|
+
*/
|
|
14
|
+
export function blockArg(args) {
|
|
15
|
+
const last = args[args.length - 1];
|
|
16
|
+
if (typeof last === "function") {
|
|
17
|
+
return [args.slice(0, -1), last];
|
|
18
|
+
}
|
|
19
|
+
return [args, null];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `rb_str_length` (`vendor/ruby/v3.3.11/string.c:2211`): the character count.
|
|
23
|
+
*
|
|
24
|
+
* @noRailsEquivalent PERMANENT
|
|
25
|
+
*/
|
|
26
|
+
export function strlen(str) {
|
|
27
|
+
return [...str].length;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `rb_str_sublen` (`vendor/ruby/v3.3.11/string.c:2841`): a UTF-16 offset as a character offset.
|
|
31
|
+
*
|
|
32
|
+
* @noRailsEquivalent PERMANENT
|
|
33
|
+
*/
|
|
34
|
+
export function rbStrSublen(str, pos) {
|
|
35
|
+
return strlen(str.slice(0, pos));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `str_offset` (`vendor/ruby/v3.3.11/string.c:2786`): a character offset as a UTF-16 offset.
|
|
39
|
+
*
|
|
40
|
+
* @noRailsEquivalent PERMANENT
|
|
41
|
+
*/
|
|
42
|
+
export function strOffset(str, pos) {
|
|
43
|
+
return [...str].slice(0, pos).join("").length;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `StringValue` (`vendor/ruby/v3.3.11/string.c:2551` `rb_string_value`): a String, or its `to_str`.
|
|
47
|
+
* A `Uint8Array` is a binary String (`rbObjClass` answers `rbCString` for it), read as UTF-8.
|
|
48
|
+
*
|
|
49
|
+
* @noRailsEquivalent PERMANENT
|
|
50
|
+
*/
|
|
51
|
+
export function stringValue(val) {
|
|
52
|
+
if (typeof val === "string")
|
|
53
|
+
return val;
|
|
54
|
+
if (val instanceof Uint8Array)
|
|
55
|
+
return new TextDecoder("utf-8", { ignoreBOM: true }).decode(val);
|
|
56
|
+
const toStr = val?.toStr;
|
|
57
|
+
if (typeof toStr === "function")
|
|
58
|
+
return toStr.call(val);
|
|
59
|
+
throw new TypeError(`no implicit conversion of ${rbBuiltinClassName(val)} into String`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `rb_check_string_type` (`vendor/ruby/v3.3.11/string.c:2690`): a String, its `to_str`, or nil.
|
|
63
|
+
*
|
|
64
|
+
* @noRailsEquivalent PERMANENT
|
|
65
|
+
*/
|
|
66
|
+
export function rbCheckStringType(val) {
|
|
67
|
+
if (typeof val === "string")
|
|
68
|
+
return val;
|
|
69
|
+
const toStr = val?.toStr;
|
|
70
|
+
if (typeof toStr !== "function")
|
|
71
|
+
return null;
|
|
72
|
+
const v = toStr.call(val);
|
|
73
|
+
if (v == null)
|
|
74
|
+
return null;
|
|
75
|
+
if (typeof v !== "string")
|
|
76
|
+
conversionMismatch(val, "String", "to_str", v);
|
|
77
|
+
return v;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* `NUM2LONG` (`vendor/ruby/v3.3.11/numeric.c:3135` `rb_num2long`): a Float
|
|
81
|
+
* outside `long` raises `RangeError` with `out_of_range_float`'s `%-.10g`
|
|
82
|
+
* (`numeric.c:3109-3124`), a `bigint` (Ruby's Bignum) outside it raises
|
|
83
|
+
* `rb_big2long`'s, and anything else goes through `rb_to_int`. The result
|
|
84
|
+
* is a JS `number`, the one integer type an index or length takes, so an
|
|
85
|
+
* in-range `bigint` past `Number.MAX_SAFE_INTEGER` arrives rounded to the
|
|
86
|
+
* nearest double.
|
|
87
|
+
*
|
|
88
|
+
* @noRailsEquivalent PERMANENT
|
|
89
|
+
*/
|
|
90
|
+
export function num2long(val) {
|
|
91
|
+
for (;;) {
|
|
92
|
+
if (val == null)
|
|
93
|
+
throw new TypeError("no implicit conversion from nil to integer");
|
|
94
|
+
if (typeof val === "number") {
|
|
95
|
+
if (val < 2 ** 63 && -(2 ** 63) <= val)
|
|
96
|
+
return Math.trunc(val);
|
|
97
|
+
const g = Number.isNaN(val)
|
|
98
|
+
? "NaN"
|
|
99
|
+
: Number.isFinite(val)
|
|
100
|
+
? val.toPrecision(10).replace(/\.?0*e/, "e")
|
|
101
|
+
: val > 0
|
|
102
|
+
? "Inf"
|
|
103
|
+
: "-Inf";
|
|
104
|
+
throw new RbRangeError(`float ${g} out of range of integer`);
|
|
105
|
+
}
|
|
106
|
+
if (typeof val === "bigint") {
|
|
107
|
+
if (val < 2n ** 63n && -(2n ** 63n) <= val)
|
|
108
|
+
return Number(val);
|
|
109
|
+
throw new RbRangeError("bignum too big to convert into `long'");
|
|
110
|
+
}
|
|
111
|
+
const toInt = val.toInt;
|
|
112
|
+
if (typeof toInt !== "function") {
|
|
113
|
+
throw new TypeError(`no implicit conversion of ${rbBuiltinClassName(val)} into Integer`);
|
|
114
|
+
}
|
|
115
|
+
const v = toInt.call(val);
|
|
116
|
+
if (typeof v !== "bigint" && (typeof v !== "number" || !Number.isInteger(v))) {
|
|
117
|
+
const klass = rbBuiltinClassName(val);
|
|
118
|
+
throw new TypeError(`can't convert ${klass} to Integer (${klass}#to_int gives ${rbBuiltinClassName(v)})`);
|
|
119
|
+
}
|
|
120
|
+
val = v;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* `rb_error_arity` (`vendor/ruby/v3.3.11/vm_insnhelper.c:466` `rb_arity_error_new`).
|
|
125
|
+
*
|
|
126
|
+
* @noRailsEquivalent PERMANENT
|
|
127
|
+
*/
|
|
128
|
+
export function rbErrorArity(argc, min, max) {
|
|
129
|
+
const expected = min === max ? `${min}` : max === Infinity ? `${min}+` : `${min}..${max}`;
|
|
130
|
+
throw new ArgumentError(`wrong number of arguments (given ${argc}, expected ${expected})`);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* `rb_check_arity` (`vendor/ruby/v3.3.11/include/ruby/internal/intern/error.h:280`).
|
|
134
|
+
*
|
|
135
|
+
* @noRailsEquivalent PERMANENT
|
|
136
|
+
*/
|
|
137
|
+
export function checkArity(argc, min, max) {
|
|
138
|
+
if (argc < min || argc > max)
|
|
139
|
+
rbErrorArity(argc, min, max);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* A bang form's nil-when-unchanged return (`vendor/ruby/v3.3.11/string.c:7535` `rb_str_upcase_bang`).
|
|
143
|
+
*
|
|
144
|
+
* @noRailsEquivalent PERMANENT
|
|
145
|
+
*/
|
|
146
|
+
export function bang(self, string) {
|
|
147
|
+
if (string === self.string)
|
|
148
|
+
return null;
|
|
149
|
+
self.string = string;
|
|
150
|
+
return string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* `rb_reg_prepare_re` (`vendor/ruby/v3.3.11/re.c:1587`): a pattern matched by character, not
|
|
154
|
+
* UTF-16 unit, with `flags` added.
|
|
155
|
+
*
|
|
156
|
+
* @noRailsEquivalent PERMANENT
|
|
157
|
+
*/
|
|
158
|
+
export function rbRegexp(re, flags) {
|
|
159
|
+
const base = re.flags.replace(/[gyd]/g, "") + flags;
|
|
160
|
+
if (/[uv]/.test(base))
|
|
161
|
+
return new RegExp(re.source, base);
|
|
162
|
+
try {
|
|
163
|
+
return new RegExp(re.source, base + "u");
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
return new RegExp(re.source, base);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* `rb_reg_search` (`vendor/ruby/v3.3.11/re.c:1796`) from character offset `pos`, forward or reverse.
|
|
171
|
+
*
|
|
172
|
+
* @noRailsEquivalent PERMANENT
|
|
173
|
+
*/
|
|
174
|
+
export function rbRegSearch(re, str, pos, reverse) {
|
|
175
|
+
if (!reverse) {
|
|
176
|
+
const global = rbRegexp(re, "dg");
|
|
177
|
+
global.lastIndex = strOffset(str, pos);
|
|
178
|
+
return global.exec(str);
|
|
179
|
+
}
|
|
180
|
+
const sticky = rbRegexp(re, "dy");
|
|
181
|
+
for (let start = pos; start >= 0; start--) {
|
|
182
|
+
sticky.lastIndex = strOffset(str, start);
|
|
183
|
+
const match = sticky.exec(str);
|
|
184
|
+
if (match)
|
|
185
|
+
return match;
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* `rb_reg_backref_number` (`vendor/ruby/v3.3.11/re.c:1235`).
|
|
191
|
+
*
|
|
192
|
+
* @noRailsEquivalent PERMANENT
|
|
193
|
+
*/
|
|
194
|
+
export function rbRegBackrefNumber(match, backref) {
|
|
195
|
+
if (typeof backref !== "string")
|
|
196
|
+
return num2long(backref);
|
|
197
|
+
const span = match.indices?.groups?.[backref];
|
|
198
|
+
if (!match.groups || !(backref in match.groups)) {
|
|
199
|
+
throw new IndexError(`undefined group name reference: ${backref}`);
|
|
200
|
+
}
|
|
201
|
+
return match.indices.findIndex((s) => s === span);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* `get_pat_quoted` (`vendor/ruby/v3.3.11/string.c:5698`): a Regexp as is, else a String
|
|
205
|
+
* (or `to_str`) matched literally, else `Check_Type`'s `TypeError`.
|
|
206
|
+
*
|
|
207
|
+
* @noRailsEquivalent PERMANENT
|
|
208
|
+
*/
|
|
209
|
+
export function getPatQuoted(pat) {
|
|
210
|
+
if (pat instanceof RegExp)
|
|
211
|
+
return pat;
|
|
212
|
+
const val = rbCheckStringType(pat);
|
|
213
|
+
if (val === null) {
|
|
214
|
+
throw new TypeError(`wrong argument type ${rbBuiltinClassName(pat)} (expected Regexp)`);
|
|
215
|
+
}
|
|
216
|
+
return val;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* `get_pat` (`vendor/ruby/v3.3.11/string.c:5675`): {@link getPatQuoted}, with a String
|
|
220
|
+
* compiled as a pattern (`rb_reg_regcomp`).
|
|
221
|
+
*
|
|
222
|
+
* @noRailsEquivalent PERMANENT
|
|
223
|
+
*/
|
|
224
|
+
export function getPat(pat) {
|
|
225
|
+
const val = getPatQuoted(pat);
|
|
226
|
+
return typeof val === "string" ? new RegExp(val) : val;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* A literal String as the Regexp `rb_pat_search` (`vendor/ruby/v3.3.11/string.c:5723`)
|
|
230
|
+
* searches for it by.
|
|
231
|
+
*
|
|
232
|
+
* @noRailsEquivalent PERMANENT
|
|
233
|
+
*/
|
|
234
|
+
export function literalRegexp(str) {
|
|
235
|
+
return new RegExp(str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "u");
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* `rb_range_beg_len` (`vendor/ruby/v3.3.11/range.c:1744`), `err` 0 or 2.
|
|
239
|
+
*
|
|
240
|
+
* @noRailsEquivalent PERMANENT
|
|
241
|
+
*/
|
|
242
|
+
export function rbRangeBegLen(range, len, err) {
|
|
243
|
+
let beg = range.begin == null ? 0 : num2long(range.begin);
|
|
244
|
+
let end = range.end == null ? -1 : num2long(range.end);
|
|
245
|
+
const excl = range.end == null ? false : range.excludeEnd;
|
|
246
|
+
outOfRange: {
|
|
247
|
+
if (beg < 0) {
|
|
248
|
+
beg += len;
|
|
249
|
+
if (beg < 0)
|
|
250
|
+
break outOfRange;
|
|
251
|
+
}
|
|
252
|
+
if (end < 0)
|
|
253
|
+
end += len;
|
|
254
|
+
if (!excl)
|
|
255
|
+
end++;
|
|
256
|
+
if (beg > len)
|
|
257
|
+
break outOfRange;
|
|
258
|
+
if (end > len)
|
|
259
|
+
end = len;
|
|
260
|
+
return [beg, Math.max(end - beg, 0)];
|
|
261
|
+
}
|
|
262
|
+
if (err)
|
|
263
|
+
throw new RangeError(`${range.toS()} out of range`);
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* `rb_str_cmp` (`vendor/ruby/v3.3.11/string.c:3696`): byte order, then length. UTF-8
|
|
268
|
+
* byte order is code point order.
|
|
269
|
+
*
|
|
270
|
+
* @noRailsEquivalent PERMANENT
|
|
271
|
+
*/
|
|
272
|
+
export function rbStrCmp(str1, str2) {
|
|
273
|
+
const a = [...str1];
|
|
274
|
+
const b = [...str2];
|
|
275
|
+
for (let i = 0; i < a.length && i < b.length; i++) {
|
|
276
|
+
const c1 = a[i].codePointAt(0);
|
|
277
|
+
const c2 = b[i].codePointAt(0);
|
|
278
|
+
if (c1 !== c2)
|
|
279
|
+
return c1 < c2 ? -1 : 1;
|
|
280
|
+
}
|
|
281
|
+
return a.length === b.length ? 0 : a.length < b.length ? -1 : 1;
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=support.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"support.js","sourceRoot":"","sources":["../../lib/string/support.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEtE,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAa7C;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAe;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACnC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAuC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC,MAAM,CAAC;AACzB,CAAC;AAED;;;;GAIG;AACH,MAAM,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,CAAC,IAAY,EAAE,IAAY;IACjD,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClD,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QAChC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QAChC,IAAI,EAAE,KAAK,EAAE;YAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `trnext` (`vendor/ruby/v3.3.11/string.c:7866`): the code points a `tr` / `count` /
|
|
3
|
+
* `delete` / `squeeze` character set names, with `a-z` ranges expanded and a
|
|
4
|
+
* backslash quoting the next character.
|
|
5
|
+
*
|
|
6
|
+
* @noRailsEquivalent PERMANENT
|
|
7
|
+
*/
|
|
8
|
+
export declare function trnext(cps: number[]): Generator<number>;
|
|
9
|
+
/**
|
|
10
|
+
* `tr_setup_table` (`vendor/ruby/v3.3.11/string.c:8236`) over every set, with
|
|
11
|
+
* `tr_find`'s lookup: a character is selected when each set selects it; a set
|
|
12
|
+
* led by `^` (and longer than one character) selects its complement.
|
|
13
|
+
*
|
|
14
|
+
* @noRailsEquivalent PERMANENT
|
|
15
|
+
*/
|
|
16
|
+
export declare function trSetupTable(sets: unknown[]): (cp: number) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* `tr_trans` (`vendor/ruby/v3.3.11/string.c:7924`), for `tr` and — with `sflag` —
|
|
19
|
+
* `tr_s`, which squeezes each run of one translated character. MRI rebuilds
|
|
20
|
+
* its 256-entry table per call; the compiled tables here are cached per
|
|
21
|
+
* `(src, repl)` pair, since building them dominates builder's escaping.
|
|
22
|
+
*
|
|
23
|
+
* @noRailsEquivalent PERMANENT
|
|
24
|
+
*/
|
|
25
|
+
export declare function trTrans(str: string, src: unknown, repl: unknown, sflag: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* `rb_str_delete_bang` (`vendor/ruby/v3.3.11/string.c:8331`): the characters every set
|
|
28
|
+
* selects, removed.
|
|
29
|
+
*
|
|
30
|
+
* @noRailsEquivalent PERMANENT
|
|
31
|
+
*/
|
|
32
|
+
export declare function strDelete(str: string, sets: unknown[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* `rb_str_squeeze_bang` (`vendor/ruby/v3.3.11/string.c:8424`): each run of one
|
|
35
|
+
* selected character (every character, with no sets) cut to one.
|
|
36
|
+
*
|
|
37
|
+
* @noRailsEquivalent PERMANENT
|
|
38
|
+
*/
|
|
39
|
+
export declare function strSqueeze(str: string, sets: unknown[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* `String#count` (`vendor/ruby/v3.3.11/string.c:8590` `rb_str_count`).
|
|
42
|
+
*
|
|
43
|
+
* @noRailsEquivalent PERMANENT
|
|
44
|
+
*/
|
|
45
|
+
export declare function strCount(str: string, sets: unknown[]): number;
|
|
46
|
+
//# sourceMappingURL=tr.d.ts.map
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ArgumentError } from "../argument-error.js";
|
|
2
|
+
import { rbErrorArity, stringValue } from "./support.js";
|
|
3
|
+
/**
|
|
4
|
+
* `trnext` (`vendor/ruby/v3.3.11/string.c:7866`): the code points a `tr` / `count` /
|
|
5
|
+
* `delete` / `squeeze` character set names, with `a-z` ranges expanded and a
|
|
6
|
+
* backslash quoting the next character.
|
|
7
|
+
*
|
|
8
|
+
* @noRailsEquivalent PERMANENT
|
|
9
|
+
*/
|
|
10
|
+
export function* trnext(cps) {
|
|
11
|
+
let i = 0;
|
|
12
|
+
while (i < cps.length) {
|
|
13
|
+
if (cps[i] === 0x5c && i + 1 < cps.length)
|
|
14
|
+
i++;
|
|
15
|
+
const now = cps[i++];
|
|
16
|
+
if (cps[i] === 0x2d && i + 1 < cps.length) {
|
|
17
|
+
const c = cps[i + 1];
|
|
18
|
+
i += 2;
|
|
19
|
+
if (now > c) {
|
|
20
|
+
if (now < 0x80 && c < 0x80) {
|
|
21
|
+
const range = `${String.fromCodePoint(now)}-${String.fromCodePoint(c)}`;
|
|
22
|
+
throw new ArgumentError(`invalid range "${range}" in string transliteration`);
|
|
23
|
+
}
|
|
24
|
+
throw new ArgumentError("invalid range in string transliteration");
|
|
25
|
+
}
|
|
26
|
+
for (let cp = now; cp <= c; cp++)
|
|
27
|
+
yield cp;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
yield now;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `tr_setup_table` (`vendor/ruby/v3.3.11/string.c:8236`) over every set, with
|
|
35
|
+
* `tr_find`'s lookup: a character is selected when each set selects it; a set
|
|
36
|
+
* led by `^` (and longer than one character) selects its complement.
|
|
37
|
+
*
|
|
38
|
+
* @noRailsEquivalent PERMANENT
|
|
39
|
+
*/
|
|
40
|
+
export function trSetupTable(sets) {
|
|
41
|
+
const tables = sets.map((set) => {
|
|
42
|
+
const cps = Array.from(stringValue(set), (c) => c.codePointAt(0));
|
|
43
|
+
const cflag = cps.length > 1 && cps[0] === 0x5e;
|
|
44
|
+
const members = new Set(trnext(cflag ? cps.slice(1) : cps));
|
|
45
|
+
return (cp) => members.has(cp) !== cflag;
|
|
46
|
+
});
|
|
47
|
+
return (cp) => tables.every((t) => t(cp));
|
|
48
|
+
}
|
|
49
|
+
const TR_CACHE_MAX = 64;
|
|
50
|
+
const trCache = new Map();
|
|
51
|
+
let trCacheSize = 0;
|
|
52
|
+
function _trCompile(srcStr, replStr) {
|
|
53
|
+
let byRepl = trCache.get(srcStr);
|
|
54
|
+
const cached = byRepl?.get(replStr);
|
|
55
|
+
if (cached)
|
|
56
|
+
return cached;
|
|
57
|
+
const srcCps = Array.from(srcStr, (c) => c.codePointAt(0));
|
|
58
|
+
const cflag = srcCps.length > 1 && srcCps[0] === 0x5e;
|
|
59
|
+
const replCps = [...trnext(Array.from(replStr, (c) => c.codePointAt(0)))];
|
|
60
|
+
const last = replCps[replCps.length - 1];
|
|
61
|
+
const trans = new Map();
|
|
62
|
+
const from = [...trnext(cflag ? srcCps.slice(1) : srcCps)];
|
|
63
|
+
if (!cflag)
|
|
64
|
+
from.forEach((c, i) => trans.set(c, i < replCps.length ? replCps[i] : last));
|
|
65
|
+
const table = { trans, members: new Set(from), last, cflag };
|
|
66
|
+
if (trCacheSize >= TR_CACHE_MAX) {
|
|
67
|
+
trCache.clear();
|
|
68
|
+
trCacheSize = 0;
|
|
69
|
+
byRepl = undefined;
|
|
70
|
+
}
|
|
71
|
+
if (!byRepl)
|
|
72
|
+
trCache.set(srcStr, (byRepl = new Map()));
|
|
73
|
+
byRepl.set(replStr, table);
|
|
74
|
+
trCacheSize++;
|
|
75
|
+
return table;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* `tr_trans` (`vendor/ruby/v3.3.11/string.c:7924`), for `tr` and — with `sflag` —
|
|
79
|
+
* `tr_s`, which squeezes each run of one translated character. MRI rebuilds
|
|
80
|
+
* its 256-entry table per call; the compiled tables here are cached per
|
|
81
|
+
* `(src, repl)` pair, since building them dominates builder's escaping.
|
|
82
|
+
*
|
|
83
|
+
* @noRailsEquivalent PERMANENT
|
|
84
|
+
*/
|
|
85
|
+
export function trTrans(str, src, repl, sflag) {
|
|
86
|
+
const srcStr = stringValue(src);
|
|
87
|
+
const replStr = stringValue(repl);
|
|
88
|
+
if (replStr.length === 0)
|
|
89
|
+
return strDelete(str, [src]);
|
|
90
|
+
const { trans, members, last, cflag } = _trCompile(srcStr, replStr);
|
|
91
|
+
let out = "";
|
|
92
|
+
let save = -1;
|
|
93
|
+
for (const ch of str) {
|
|
94
|
+
const c = ch.codePointAt(0);
|
|
95
|
+
const r = cflag ? (members.has(c) ? -1 : last) : (trans.get(c) ?? -1);
|
|
96
|
+
if (r === -1) {
|
|
97
|
+
save = -1;
|
|
98
|
+
out += ch;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (sflag && save === r)
|
|
102
|
+
continue;
|
|
103
|
+
save = r;
|
|
104
|
+
out += String.fromCodePoint(r);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `rb_str_delete_bang` (`vendor/ruby/v3.3.11/string.c:8331`): the characters every set
|
|
110
|
+
* selects, removed.
|
|
111
|
+
*
|
|
112
|
+
* @noRailsEquivalent PERMANENT
|
|
113
|
+
*/
|
|
114
|
+
export function strDelete(str, sets) {
|
|
115
|
+
if (sets.length < 1)
|
|
116
|
+
rbErrorArity(sets.length, 1, Infinity);
|
|
117
|
+
const selected = trSetupTable(sets);
|
|
118
|
+
return Array.from(str)
|
|
119
|
+
.filter((c) => !selected(c.codePointAt(0)))
|
|
120
|
+
.join("");
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* `rb_str_squeeze_bang` (`vendor/ruby/v3.3.11/string.c:8424`): each run of one
|
|
124
|
+
* selected character (every character, with no sets) cut to one.
|
|
125
|
+
*
|
|
126
|
+
* @noRailsEquivalent PERMANENT
|
|
127
|
+
*/
|
|
128
|
+
export function strSqueeze(str, sets) {
|
|
129
|
+
const selected = sets.length === 0 ? () => true : trSetupTable(sets);
|
|
130
|
+
let out = "";
|
|
131
|
+
let save = -1;
|
|
132
|
+
for (const ch of str) {
|
|
133
|
+
const c = ch.codePointAt(0);
|
|
134
|
+
if (c === save && selected(c))
|
|
135
|
+
continue;
|
|
136
|
+
save = c;
|
|
137
|
+
out += ch;
|
|
138
|
+
}
|
|
139
|
+
return out;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* `String#count` (`vendor/ruby/v3.3.11/string.c:8590` `rb_str_count`).
|
|
143
|
+
*
|
|
144
|
+
* @noRailsEquivalent PERMANENT
|
|
145
|
+
*/
|
|
146
|
+
export function strCount(str, sets) {
|
|
147
|
+
if (sets.length < 1)
|
|
148
|
+
rbErrorArity(sets.length, 1, Infinity);
|
|
149
|
+
const selected = trSetupTable(sets);
|
|
150
|
+
let n = 0;
|
|
151
|
+
for (const ch of str)
|
|
152
|
+
if (selected(ch.codePointAt(0)))
|
|
153
|
+
n++;
|
|
154
|
+
return n;
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=tr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tr.js","sourceRoot":"","sources":["../../lib/string/tr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC,GAAa;IACnC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC;QACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM;YAAE,CAAC,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;QACrB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI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;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAe;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACrE,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IACd,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QAC7B,IAAI,CAAC,KAAK,IAAI,IAAI,QAAQ,CAAC,CAAC,CAAC;YAAE,SAAS;QACxC,IAAI,GAAG,CAAC,CAAC;QACT,GAAG,IAAI,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,IAAe;IACnD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,EAAE,IAAI,GAAG;QAAE,IAAI,QAAQ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;YAAE,CAAC,EAAE,CAAC;IAC5D,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { Encoding } from "./encoding.js";
|
|
2
|
+
import { print as ioPrint, puts as ioPuts } from "./io.js";
|
|
3
|
+
/**
|
|
4
|
+
* Ruby's `StringIO` (stdlib), the readable/writable in-memory IO that
|
|
5
|
+
* `XmlMini._parse_file` (`activesupport/lib/active_support/xml_mini.rb:180-186`)
|
|
6
|
+
* and `Rack::MockRequest` hand to their callers. Only the members Ruby code in
|
|
7
|
+
* this repo sends are ported.
|
|
8
|
+
*
|
|
9
|
+
* The buffer holds bytes, so `size`, `read`'s length and `write`'s return
|
|
10
|
+
* value count bytes exactly as Ruby's do. A StringIO opened on an ASCII-8BIT
|
|
11
|
+
* String, a `Uint8Array`, answers its whole-buffer reads as one, and every
|
|
12
|
+
* other answers them as the UTF-8 text the bytes spell; `read`'s length arm
|
|
13
|
+
* answers a `Uint8Array` whatever the buffer, as `strio_read`
|
|
14
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1539`) tags it ASCII-8BIT.
|
|
15
|
+
*
|
|
16
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib, not Rails: `StringIO`
|
|
17
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1432`) ships with the interpreter, so
|
|
18
|
+
* no Rails file defines it and no port can remove the need for it while
|
|
19
|
+
* `_parse_file` and `Rack::MockRequest` hand callers an IO.
|
|
20
|
+
*/
|
|
21
|
+
export declare class StringIO<S extends string | Uint8Array = string> {
|
|
22
|
+
#private;
|
|
23
|
+
constructor(string?: S);
|
|
24
|
+
/**
|
|
25
|
+
* `strio_copy` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:620`), bound to
|
|
26
|
+
* `initialize_copy` (`:1869`): the copy shares the original's struct, so
|
|
27
|
+
* both read and write one buffer and one position.
|
|
28
|
+
*
|
|
29
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib, not Rails: `StringIO#initialize_copy`.
|
|
30
|
+
*/
|
|
31
|
+
initializeCopy(orig: StringIO<S>): this;
|
|
32
|
+
string(): S;
|
|
33
|
+
size(): number;
|
|
34
|
+
/**
|
|
35
|
+
* `strio_read` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1539`). The `str` buffer
|
|
36
|
+
* of its two-argument form (`stringio.c:1548-1552`) receives the bytes, and
|
|
37
|
+
* at EOF Ruby empties it with `rb_str_resize(str, 0)` (`stringio.c:1561`)
|
|
38
|
+
* before answering `nil`.
|
|
39
|
+
*
|
|
40
|
+
* A `Uint8Array` cannot be resized, so — exactly as {@link IO.read} already
|
|
41
|
+
* does for `io_read`'s identical `str` argument (`vendor/ruby/v3.3.11/io.c:3800`) —
|
|
42
|
+
* it is filled up to its own length instead, and zero-filled where Ruby
|
|
43
|
+
* truncates. That deviation is recorded once there; this is the same fact
|
|
44
|
+
* about the same buffer.
|
|
45
|
+
*/
|
|
46
|
+
read(): S;
|
|
47
|
+
read(length: number, str?: Uint8Array | null): Uint8Array | null;
|
|
48
|
+
write(string: string | Uint8Array): number;
|
|
49
|
+
/**
|
|
50
|
+
* `IO::generic_writable#<<` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1955`
|
|
51
|
+
* `strio_addstr`, which is `rb_io_addstr`, `vendor/ruby/v3.3.11/io.c:2323-2327`).
|
|
52
|
+
*
|
|
53
|
+
* @noRailsEquivalent PERMANENT
|
|
54
|
+
*/
|
|
55
|
+
append(str: string | Uint8Array): this;
|
|
56
|
+
/**
|
|
57
|
+
* `IO::generic_writable#puts` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1530`
|
|
58
|
+
* aliases it to `rb_io_puts`, `vendor/ruby/v3.3.11/io.c:8947`), which is how
|
|
59
|
+
* `Rack::Session::Abstract::Persisted#commit_session` writes to
|
|
60
|
+
* `rack.errors`. One body, shared with `IO#puts` — see `./io.js`.
|
|
61
|
+
*
|
|
62
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib, not Rails:
|
|
63
|
+
* `IO::generic_writable#puts` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1530`).
|
|
64
|
+
*/
|
|
65
|
+
puts: typeof ioPuts;
|
|
66
|
+
/**
|
|
67
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib, not Rails:
|
|
68
|
+
* `IO::generic_writable#print` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1956`
|
|
69
|
+
* aliases it to `rb_io_print`, `vendor/ruby/v3.3.11/io.c:8715`).
|
|
70
|
+
*/
|
|
71
|
+
print: typeof ioPrint;
|
|
72
|
+
/**
|
|
73
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib, not Rails: `strio_flush`
|
|
74
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1891`) returns the StringIO itself,
|
|
75
|
+
* which is how `Rack::ShowExceptions#call` flushes `rack.errors`.
|
|
76
|
+
*/
|
|
77
|
+
flush(): this;
|
|
78
|
+
/**
|
|
79
|
+
* `strio_get_pos` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:940`), the offset
|
|
80
|
+
* {@link rewind} puts back to zero.
|
|
81
|
+
*
|
|
82
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#pos`
|
|
83
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:940`).
|
|
84
|
+
*/
|
|
85
|
+
get pos(): number;
|
|
86
|
+
rewind(): number;
|
|
87
|
+
/**
|
|
88
|
+
* `strio_binmode` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1863`) — it records
|
|
89
|
+
* ASCII-8BIT on the stream and, when the StringIO is writable, associates it
|
|
90
|
+
* with the buffer String, then answers the StringIO, whose whole-buffer reads
|
|
91
|
+
* then answer a `Uint8Array` (see the class comment).
|
|
92
|
+
*
|
|
93
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#binmode`
|
|
94
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1879`).
|
|
95
|
+
*/
|
|
96
|
+
binmode(): this;
|
|
97
|
+
/**
|
|
98
|
+
* `strio_set_encoding` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1801`) in its
|
|
99
|
+
* one-argument form — the encoding is recorded on the stream and, when the
|
|
100
|
+
* StringIO is writable, associated with the buffer String
|
|
101
|
+
* (`stringio.c:1823-1826`); it answers the StringIO. `int_enc` and `opt` are
|
|
102
|
+
* ignored by MRI itself (`stringio.c:1796-1797`), so neither is ported.
|
|
103
|
+
*
|
|
104
|
+
* Associated with `BINARY`, the buffer's whole-buffer reads answer a
|
|
105
|
+
* `Uint8Array` (see the class comment), and the recorded encoding is what
|
|
106
|
+
* `Rack::Test::Utils.build_file_part`'s `set_encoding(Encoding::BINARY)`
|
|
107
|
+
* (`vendor/rack-test/v2.2.0/lib/rack/test/utils.rb:148`) is asking for.
|
|
108
|
+
*
|
|
109
|
+
* `rb_find_encoding` (`vendor/ruby/v3.3.11/encoding.c:325-332`) answers a NULL
|
|
110
|
+
* `rb_encoding *` for a name that resolves to `UNSPECIFIED_ENCODING` — the
|
|
111
|
+
* `internal` alias while `Encoding.default_internal` is unset — and
|
|
112
|
+
* `strio_set_encoding` then falls through the mode-string path to no
|
|
113
|
+
* encoding at all, which the stream reports as `ASCII-8BIT` (verified
|
|
114
|
+
* against ruby 3.3: `StringIO.new("x").set_encoding("internal")
|
|
115
|
+
* .external_encoding` is `#<Encoding:ASCII-8BIT>`).
|
|
116
|
+
*
|
|
117
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#set_encoding`
|
|
118
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1801`).
|
|
119
|
+
*/
|
|
120
|
+
setEncoding(extEnc: Encoding | string): this;
|
|
121
|
+
/**
|
|
122
|
+
* `strio_sysread` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1664`), which
|
|
123
|
+
* `StringIO#readpartial` is defined as (`stringio.c:1949`): `read` with a
|
|
124
|
+
* `rb_eof_error()` (`vendor/ruby/v3.3.11/io.c:756`) where that answers `nil` — the
|
|
125
|
+
* member
|
|
126
|
+
* `Rack::Test::UploadedFile#append_to`
|
|
127
|
+
* (`vendor/rack-test/v2.2.0/lib/rack/test/uploaded_file.rb:64`) walks a StringIO
|
|
128
|
+
* body with.
|
|
129
|
+
*
|
|
130
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#readpartial`
|
|
131
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1949`).
|
|
132
|
+
*/
|
|
133
|
+
readpartial(maxlen: number, outbuf?: Uint8Array | null): Uint8Array;
|
|
134
|
+
/**
|
|
135
|
+
* `strio_gets` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1322`) with no
|
|
136
|
+
* separator argument: the next line, newline included, or `nil` at EOF.
|
|
137
|
+
*
|
|
138
|
+
* @noRailsEquivalent PERMANENT
|
|
139
|
+
*/
|
|
140
|
+
gets(): S | null;
|
|
141
|
+
/**
|
|
142
|
+
* `strio_each` (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:1366`) with no
|
|
143
|
+
* separator argument: yields each remaining line and leaves the stream at EOF.
|
|
144
|
+
*
|
|
145
|
+
* @noRailsEquivalent PERMANENT
|
|
146
|
+
*/
|
|
147
|
+
each(block: (line: S) => void): this;
|
|
148
|
+
isEof(): boolean;
|
|
149
|
+
close(): void;
|
|
150
|
+
/**
|
|
151
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#close_read`
|
|
152
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:520`).
|
|
153
|
+
*/
|
|
154
|
+
closeRead(): null;
|
|
155
|
+
/**
|
|
156
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#close_write`
|
|
157
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:541`).
|
|
158
|
+
*/
|
|
159
|
+
closeWrite(): null;
|
|
160
|
+
/**
|
|
161
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `StringIO#closed?`
|
|
162
|
+
* (`vendor/ruby/v3.3.11/ext/stringio/stringio.c:559`).
|
|
163
|
+
*/
|
|
164
|
+
isClosed(): boolean;
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=string-io.d.ts.map
|