@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
package/dist/zlib.js
ADDED
|
@@ -0,0 +1,679 @@
|
|
|
1
|
+
import { constSet } from "./include.js";
|
|
2
|
+
import { TopLevel, rbObjRespondTo } from "./object.js";
|
|
3
|
+
import { File } from "./file.js";
|
|
4
|
+
import { getZlib } from "./zlib-adapter.js";
|
|
5
|
+
import { b } from "./string/b.js";
|
|
6
|
+
import { binaryBytes, binaryString } from "./io.js";
|
|
7
|
+
import { StandardError } from "./standard-error.js";
|
|
8
|
+
import { ArgumentError } from "./argument-error.js";
|
|
9
|
+
class ZError extends StandardError {
|
|
10
|
+
}
|
|
11
|
+
/** `cGzError` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4828`). */
|
|
12
|
+
class GzError extends ZError {
|
|
13
|
+
}
|
|
14
|
+
/** `cNoFooter` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4834`). */
|
|
15
|
+
class NoFooter extends GzError {
|
|
16
|
+
}
|
|
17
|
+
/** `cCRCError` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4835`). */
|
|
18
|
+
class CRCError extends GzError {
|
|
19
|
+
}
|
|
20
|
+
/** `cLengthError` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4836`). */
|
|
21
|
+
class LengthError extends GzError {
|
|
22
|
+
}
|
|
23
|
+
const GZ_MAGIC1 = 0x1f;
|
|
24
|
+
const GZ_MAGIC2 = 0x8b;
|
|
25
|
+
const GZ_METHOD_DEFLATE = 8;
|
|
26
|
+
const GZ_FLAG_MULTIPART = 0x2;
|
|
27
|
+
const GZ_FLAG_EXTRA = 0x4;
|
|
28
|
+
const GZ_FLAG_ORIG_NAME = 0x8;
|
|
29
|
+
const GZ_FLAG_COMMENT = 0x10;
|
|
30
|
+
const GZ_FLAG_ENCRYPT = 0x20;
|
|
31
|
+
const GZ_FLAG_UNKNOWN_MASK = 0xc0;
|
|
32
|
+
const GZ_EXTRAFLAG_FAST = 0x4;
|
|
33
|
+
const GZ_EXTRAFLAG_SLOW = 0x2;
|
|
34
|
+
const Z_BEST_SPEED = 1;
|
|
35
|
+
const Z_BEST_COMPRESSION = 9;
|
|
36
|
+
/** `GZFILE_READ_SIZE` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2376`). */
|
|
37
|
+
const GZFILE_READ_SIZE = 2048;
|
|
38
|
+
/**
|
|
39
|
+
* `Zlib::GzipFile` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4838`). `gzfile_s_open`
|
|
40
|
+
* (`zlib.c:3233`) opens `filename` in the subclass' mode and hands the stream
|
|
41
|
+
* to `gzfile_wrap` (`zlib.c:3178`), which closes it on the way out of a block.
|
|
42
|
+
*/
|
|
43
|
+
class GzipFile {
|
|
44
|
+
io;
|
|
45
|
+
z;
|
|
46
|
+
static Error = GzError;
|
|
47
|
+
static NoFooter = NoFooter;
|
|
48
|
+
static CRCError = CRCError;
|
|
49
|
+
static LengthError = LengthError;
|
|
50
|
+
/** `GZFILE_FLAG_HEADER_FINISHED` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2369`), set by `gzfile_make_header`. */
|
|
51
|
+
headerFinished = false;
|
|
52
|
+
/** `GZFILE_FLAG_FOOTER_FINISHED` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2370`). */
|
|
53
|
+
footerFinished = false;
|
|
54
|
+
/** `ZSTREAM_FLAG_CLOSING` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:578`), set by `gzfile_writer_end`. */
|
|
55
|
+
zstreamClosing = false;
|
|
56
|
+
/** `ZSTREAM_FLAG_READY` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:575`), cleared by `zstream_end`. */
|
|
57
|
+
zstreamReady = true;
|
|
58
|
+
/** `GZFILE_FLAG_SYNC` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2368`). */
|
|
59
|
+
syncFlag = false;
|
|
60
|
+
/** `gz->mtime`, `nil` until it is set or read (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2352`). */
|
|
61
|
+
_mtime = null;
|
|
62
|
+
/** `gz->orig_name` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2353`). */
|
|
63
|
+
origName = null;
|
|
64
|
+
/** `gz->comment` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2354`). */
|
|
65
|
+
comment = null;
|
|
66
|
+
/** `gz->crc` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2355`). */
|
|
67
|
+
crc = 0;
|
|
68
|
+
constructor(io, z) {
|
|
69
|
+
this.io = io;
|
|
70
|
+
this.z = z;
|
|
71
|
+
}
|
|
72
|
+
/** `rb_gzfile_sync` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3514`). */
|
|
73
|
+
get sync() {
|
|
74
|
+
return this.syncFlag;
|
|
75
|
+
}
|
|
76
|
+
/** `rb_gzfile_set_sync` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3529`). */
|
|
77
|
+
set sync(mode) {
|
|
78
|
+
this.syncFlag = mode;
|
|
79
|
+
}
|
|
80
|
+
/** `rb_gzfile_close` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3446`). */
|
|
81
|
+
close() {
|
|
82
|
+
if (!this.zstreamReady) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
const io = this.io;
|
|
86
|
+
this.gzfileClose(true);
|
|
87
|
+
return io;
|
|
88
|
+
}
|
|
89
|
+
/** `rb_gzfile_finish` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3468`): ends the stream and answers the io, unclosed. */
|
|
90
|
+
finish() {
|
|
91
|
+
this.getGzfile();
|
|
92
|
+
const io = this.io;
|
|
93
|
+
this.gzfileClose(false);
|
|
94
|
+
return io;
|
|
95
|
+
}
|
|
96
|
+
/** `gzfile_get16` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2588`). */
|
|
97
|
+
static gzfileGet16(src) {
|
|
98
|
+
return new DataView(src.buffer, src.byteOffset, 2).getUint16(0, true);
|
|
99
|
+
}
|
|
100
|
+
/** `gzfile_get32` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2597`). */
|
|
101
|
+
static gzfileGet32(src) {
|
|
102
|
+
return new DataView(src.buffer, src.byteOffset, 4).getUint32(0, true);
|
|
103
|
+
}
|
|
104
|
+
/** `gzfile_set32` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2608`). */
|
|
105
|
+
static gzfileSet32(n, dst) {
|
|
106
|
+
new DataView(dst.buffer, dst.byteOffset, 4).setUint32(0, n >>> 0, true);
|
|
107
|
+
}
|
|
108
|
+
/** `get_gzfile` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3100`). */
|
|
109
|
+
getGzfile() {
|
|
110
|
+
if (!this.zstreamReady) {
|
|
111
|
+
throw new GzError("closed gzip stream");
|
|
112
|
+
}
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
/** `gzfile_close` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2482`). */
|
|
116
|
+
gzfileClose(closeflag) {
|
|
117
|
+
const io = this.io;
|
|
118
|
+
this.end();
|
|
119
|
+
this.origName = null;
|
|
120
|
+
this.comment = null;
|
|
121
|
+
if (closeflag && rbObjRespondTo(io, "close")) {
|
|
122
|
+
io.close();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** `zstream_ensure_end` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:1006`), run whether or not the endfunc raised. */
|
|
126
|
+
zstreamEnsureEnd() {
|
|
127
|
+
this.zstreamReady = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `Zlib::GzipReader` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4877`); `open` is
|
|
132
|
+
* `gzfile_s_open(argc, argv, klass, "rb")` (`zlib.c:3871`).
|
|
133
|
+
*/
|
|
134
|
+
class GzipReader extends GzipFile {
|
|
135
|
+
/** `rb_gzreader_initialize` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3944`). */
|
|
136
|
+
constructor(io) {
|
|
137
|
+
super(io, getZlib().inflateZStream(-Zlib.MAX_WBITS));
|
|
138
|
+
this.end = () => this.gzfileReaderEnd();
|
|
139
|
+
this.gzfileReadHeader();
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* `rb_gzfile_mtime` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3272`), as seconds
|
|
143
|
+
* since the epoch, the number `GzipWriter#mtime` answers too.
|
|
144
|
+
*/
|
|
145
|
+
get mtime() {
|
|
146
|
+
return this._mtime;
|
|
147
|
+
}
|
|
148
|
+
/** `rb_gzfile_s_wrap` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3222`). */
|
|
149
|
+
static wrap(io, block) {
|
|
150
|
+
return gzfileWrap(new GzipReader(io), block);
|
|
151
|
+
}
|
|
152
|
+
static open(filename, block) {
|
|
153
|
+
const io = File.open(filename, "rb");
|
|
154
|
+
const gz = new GzipReader(io);
|
|
155
|
+
if (!block)
|
|
156
|
+
return gz;
|
|
157
|
+
return gzfileWrap(gz, block);
|
|
158
|
+
}
|
|
159
|
+
read(len = null) {
|
|
160
|
+
this.getGzfile();
|
|
161
|
+
if (len == null) {
|
|
162
|
+
return this.gzfileReadAll();
|
|
163
|
+
}
|
|
164
|
+
if (len < 0) {
|
|
165
|
+
throw new ArgumentError(`negative length ${len} given`);
|
|
166
|
+
}
|
|
167
|
+
return this.gzfileRead(len);
|
|
168
|
+
}
|
|
169
|
+
/** `gzfile_reader_end` / `gzfile_reader_end_run` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3048-3068`). */
|
|
170
|
+
gzfileReaderEnd() {
|
|
171
|
+
if (this.zstreamClosing)
|
|
172
|
+
return;
|
|
173
|
+
this.zstreamClosing = true;
|
|
174
|
+
try {
|
|
175
|
+
if (this.isGzfileFinished() && !this.footerFinished) {
|
|
176
|
+
this.gzfileCheckFooter();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
finally {
|
|
180
|
+
this.zstreamEnsureEnd();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** `GZFILE_IS_FINISHED` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2373`). */
|
|
184
|
+
isGzfileFinished() {
|
|
185
|
+
return this.z.isFinished() && this.z.buf.length === 0;
|
|
186
|
+
}
|
|
187
|
+
/** `gzfile_read_raw` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2537`). */
|
|
188
|
+
gzfileReadRaw() {
|
|
189
|
+
const str = this.io.read(GZFILE_READ_SIZE);
|
|
190
|
+
if (str == null)
|
|
191
|
+
return null;
|
|
192
|
+
return typeof str === "string" ? binaryBytes(str) : str;
|
|
193
|
+
}
|
|
194
|
+
/** `gzfile_read_raw_ensure` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2551`). */
|
|
195
|
+
gzfileReadRawEnsure(size) {
|
|
196
|
+
while (this.z.input.length < size) {
|
|
197
|
+
const str = this.gzfileReadRaw();
|
|
198
|
+
if (str == null)
|
|
199
|
+
return false;
|
|
200
|
+
this.z.appendInput(str);
|
|
201
|
+
}
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
/** `gzfile_read_raw_until_zero` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2568`). */
|
|
205
|
+
gzfileReadRawUntilZero(offset) {
|
|
206
|
+
let p;
|
|
207
|
+
for (;;) {
|
|
208
|
+
p = this.z.input.indexOf(0, offset);
|
|
209
|
+
if (p >= 0)
|
|
210
|
+
break;
|
|
211
|
+
const str = this.gzfileReadRaw();
|
|
212
|
+
if (str == null) {
|
|
213
|
+
throw new GzError("unexpected end of file");
|
|
214
|
+
}
|
|
215
|
+
offset = this.z.input.length;
|
|
216
|
+
this.z.appendInput(str);
|
|
217
|
+
}
|
|
218
|
+
return p;
|
|
219
|
+
}
|
|
220
|
+
/** `gzfile_read_header` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2702`). */
|
|
221
|
+
gzfileReadHeader() {
|
|
222
|
+
if (!this.gzfileReadRawEnsure(10)) {
|
|
223
|
+
throw new GzError("not in gzip format");
|
|
224
|
+
}
|
|
225
|
+
const head = this.z.input;
|
|
226
|
+
if (head[0] !== GZ_MAGIC1 || head[1] !== GZ_MAGIC2) {
|
|
227
|
+
throw new GzError("not in gzip format");
|
|
228
|
+
}
|
|
229
|
+
if (head[2] !== GZ_METHOD_DEFLATE) {
|
|
230
|
+
throw new GzError(`unsupported compression method ${head[2]}`);
|
|
231
|
+
}
|
|
232
|
+
const flags = head[3];
|
|
233
|
+
if (flags & GZ_FLAG_MULTIPART) {
|
|
234
|
+
throw new GzError("multi-part gzip file is not supported");
|
|
235
|
+
}
|
|
236
|
+
else if (flags & GZ_FLAG_ENCRYPT) {
|
|
237
|
+
throw new GzError("encrypted gzip file is not supported");
|
|
238
|
+
}
|
|
239
|
+
else if (flags & GZ_FLAG_UNKNOWN_MASK) {
|
|
240
|
+
throw new GzError(`unknown flags 0x${flags.toString(16).padStart(2, "0")}`);
|
|
241
|
+
}
|
|
242
|
+
if (head[8] & GZ_EXTRAFLAG_FAST) {
|
|
243
|
+
this.level = Z_BEST_SPEED;
|
|
244
|
+
}
|
|
245
|
+
else if (head[8] & GZ_EXTRAFLAG_SLOW) {
|
|
246
|
+
this.level = Z_BEST_COMPRESSION;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
this.level = Zlib.DEFAULT_COMPRESSION;
|
|
250
|
+
}
|
|
251
|
+
this._mtime = GzipFile.gzfileGet32(head.subarray(4));
|
|
252
|
+
this.z.input = head.slice(10);
|
|
253
|
+
if (flags & GZ_FLAG_EXTRA) {
|
|
254
|
+
if (!this.gzfileReadRawEnsure(2)) {
|
|
255
|
+
throw new GzError("unexpected end of file");
|
|
256
|
+
}
|
|
257
|
+
const len = GzipFile.gzfileGet16(this.z.input);
|
|
258
|
+
if (!this.gzfileReadRawEnsure(2 + len)) {
|
|
259
|
+
throw new GzError("unexpected end of file");
|
|
260
|
+
}
|
|
261
|
+
this.z.input = this.z.input.slice(2 + len);
|
|
262
|
+
}
|
|
263
|
+
if (flags & GZ_FLAG_ORIG_NAME) {
|
|
264
|
+
if (!this.gzfileReadRawEnsure(1)) {
|
|
265
|
+
throw new GzError("unexpected end of file");
|
|
266
|
+
}
|
|
267
|
+
const len = this.gzfileReadRawUntilZero(0);
|
|
268
|
+
this.origName = this.z.input.slice(0, len);
|
|
269
|
+
this.z.input = this.z.input.slice(len + 1);
|
|
270
|
+
}
|
|
271
|
+
if (flags & GZ_FLAG_COMMENT) {
|
|
272
|
+
if (!this.gzfileReadRawEnsure(1)) {
|
|
273
|
+
throw new GzError("unexpected end of file");
|
|
274
|
+
}
|
|
275
|
+
const len = this.gzfileReadRawUntilZero(0);
|
|
276
|
+
this.comment = this.z.input.slice(0, len);
|
|
277
|
+
this.z.input = this.z.input.slice(len + 1);
|
|
278
|
+
}
|
|
279
|
+
if (this.z.input.length > 0) {
|
|
280
|
+
this.z.run(new Uint8Array(), Zlib.SYNC_FLUSH);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** `gzfile_check_footer` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2780`). */
|
|
284
|
+
gzfileCheckFooter() {
|
|
285
|
+
this.footerFinished = true;
|
|
286
|
+
if (!this.gzfileReadRawEnsure(8)) {
|
|
287
|
+
throw new NoFooter("footer is not found");
|
|
288
|
+
}
|
|
289
|
+
const crc = GzipFile.gzfileGet32(this.z.input);
|
|
290
|
+
const length = GzipFile.gzfileGet32(this.z.input.subarray(4));
|
|
291
|
+
this.z.totalIn += 8;
|
|
292
|
+
this.z.input = this.z.input.slice(8);
|
|
293
|
+
if (this.crc !== crc) {
|
|
294
|
+
throw new CRCError("invalid compressed data -- crc error");
|
|
295
|
+
}
|
|
296
|
+
if (this.z.totalOut >>> 0 !== length) {
|
|
297
|
+
throw new LengthError("invalid compressed data -- length error");
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** `gzfile_read_more` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2823`). */
|
|
301
|
+
gzfileReadMore() {
|
|
302
|
+
while (!this.z.isFinished()) {
|
|
303
|
+
const str = this.gzfileReadRaw();
|
|
304
|
+
if (str == null) {
|
|
305
|
+
if (!this.z.isFinished(true)) {
|
|
306
|
+
throw new GzError("unexpected end of file");
|
|
307
|
+
}
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
if (str.length > 0) {
|
|
311
|
+
this.z.run(str, Zlib.SYNC_FLUSH);
|
|
312
|
+
}
|
|
313
|
+
if (this.z.buf.length > 0)
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
return this.z.buf.length;
|
|
317
|
+
}
|
|
318
|
+
/** `gzfile_calc_crc` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2846`). */
|
|
319
|
+
gzfileCalcCrc(str) {
|
|
320
|
+
this.crc = Zlib.crc32(str, this.crc);
|
|
321
|
+
}
|
|
322
|
+
/** `gzfile_fill` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2875`). */
|
|
323
|
+
gzfileFill(len) {
|
|
324
|
+
if (len === 0)
|
|
325
|
+
return 0;
|
|
326
|
+
while (!this.z.isFinished() && this.z.buf.length < len) {
|
|
327
|
+
this.gzfileReadMore();
|
|
328
|
+
}
|
|
329
|
+
if (this.isGzfileFinished()) {
|
|
330
|
+
if (!this.footerFinished) {
|
|
331
|
+
this.gzfileCheckFooter();
|
|
332
|
+
}
|
|
333
|
+
return -1;
|
|
334
|
+
}
|
|
335
|
+
return len < this.z.buf.length ? len : this.z.buf.length;
|
|
336
|
+
}
|
|
337
|
+
/** `gzfile_read` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2894`). */
|
|
338
|
+
gzfileRead(len) {
|
|
339
|
+
len = this.gzfileFill(len);
|
|
340
|
+
if (len === 0)
|
|
341
|
+
return "";
|
|
342
|
+
if (len < 0)
|
|
343
|
+
return null;
|
|
344
|
+
const dst = this.z.shiftBuffer(len);
|
|
345
|
+
this.gzfileCalcCrc(dst);
|
|
346
|
+
return binaryString(dst);
|
|
347
|
+
}
|
|
348
|
+
/** `gzfile_read_all` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2946`). */
|
|
349
|
+
gzfileReadAll() {
|
|
350
|
+
while (!this.z.isFinished()) {
|
|
351
|
+
this.gzfileReadMore();
|
|
352
|
+
}
|
|
353
|
+
if (this.isGzfileFinished()) {
|
|
354
|
+
if (!this.footerFinished) {
|
|
355
|
+
this.gzfileCheckFooter();
|
|
356
|
+
}
|
|
357
|
+
return "";
|
|
358
|
+
}
|
|
359
|
+
const dst = this.z.detachBuffer();
|
|
360
|
+
this.gzfileCalcCrc(dst);
|
|
361
|
+
return binaryString(dst);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* `Zlib::GzipWriter` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4859`); `open` is
|
|
366
|
+
* `gzfile_s_open(argc, argv, klass, "wb")` (`zlib.c:3661`).
|
|
367
|
+
*/
|
|
368
|
+
class GzipWriter extends GzipFile {
|
|
369
|
+
/** `rb_gzwriter_initialize` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3680`). */
|
|
370
|
+
constructor(io, level = null, strategy = null) {
|
|
371
|
+
const lvl = level ?? Zlib.DEFAULT_COMPRESSION;
|
|
372
|
+
super(io, getZlib().deflateZStream(lvl, -Zlib.MAX_WBITS, strategy ?? Zlib.DEFAULT_STRATEGY));
|
|
373
|
+
this.level = lvl;
|
|
374
|
+
this.end = () => this.gzfileWriterEnd();
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* `rb_gzfile_mtime` / `rb_gzfile_set_mtime`
|
|
378
|
+
* (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3356,3576`) — the MTIME field of the gzip
|
|
379
|
+
* header, which `SchemaCache#open` zeroes so two dumps of the same cache are
|
|
380
|
+
* byte-identical (`schema_cache.rb:468`).
|
|
381
|
+
*/
|
|
382
|
+
get mtime() {
|
|
383
|
+
return this._mtime;
|
|
384
|
+
}
|
|
385
|
+
set mtime(mtime) {
|
|
386
|
+
if (this.headerFinished) {
|
|
387
|
+
throw new GzipFile.Error("header is already written");
|
|
388
|
+
}
|
|
389
|
+
this._mtime = mtime;
|
|
390
|
+
}
|
|
391
|
+
/** `rb_gzfile_s_wrap` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3222`). */
|
|
392
|
+
static wrap(io, block) {
|
|
393
|
+
return gzfileWrap(new GzipWriter(io), block);
|
|
394
|
+
}
|
|
395
|
+
static open(filename, block) {
|
|
396
|
+
const io = File.open(filename, "wb");
|
|
397
|
+
const gz = new GzipWriter(io);
|
|
398
|
+
if (!block)
|
|
399
|
+
return gz;
|
|
400
|
+
return gzfileWrap(gz, block);
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* `rb_gzwriter_write` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3745`). A
|
|
404
|
+
* `Uint8Array` is an ASCII-8BIT String's bytes, as for `IO#write`.
|
|
405
|
+
*/
|
|
406
|
+
write(string) {
|
|
407
|
+
this.getGzfile();
|
|
408
|
+
const str = typeof string === "string" ? new TextEncoder().encode(string) : string;
|
|
409
|
+
this.gzfileWrite(str);
|
|
410
|
+
return str.length;
|
|
411
|
+
}
|
|
412
|
+
/** `rb_gzwriter_flush` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3721`). */
|
|
413
|
+
async flush(flush = Zlib.SYNC_FLUSH) {
|
|
414
|
+
this.getGzfile();
|
|
415
|
+
if (flush !== Zlib.NO_FLUSH) {
|
|
416
|
+
this.z.run(new Uint8Array(), flush);
|
|
417
|
+
}
|
|
418
|
+
this.gzfileWriteRaw();
|
|
419
|
+
if (rbObjRespondTo(this.io, "flush")) {
|
|
420
|
+
this.io.flush();
|
|
421
|
+
}
|
|
422
|
+
return this;
|
|
423
|
+
}
|
|
424
|
+
/** `gzfile_writer_end` / `gzfile_writer_end_run` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3023-3045`). */
|
|
425
|
+
gzfileWriterEnd() {
|
|
426
|
+
if (this.zstreamClosing)
|
|
427
|
+
return;
|
|
428
|
+
this.zstreamClosing = true;
|
|
429
|
+
try {
|
|
430
|
+
if (!this.headerFinished) {
|
|
431
|
+
this.gzfileMakeHeader();
|
|
432
|
+
}
|
|
433
|
+
this.z.run(new Uint8Array(), Zlib.FINISH);
|
|
434
|
+
this.gzfileMakeFooter();
|
|
435
|
+
this.gzfileWriteRaw();
|
|
436
|
+
}
|
|
437
|
+
finally {
|
|
438
|
+
this.zstreamEnsureEnd();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
/** `gzfile_make_header` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2647`). */
|
|
442
|
+
gzfileMakeHeader() {
|
|
443
|
+
let extraflags = 0;
|
|
444
|
+
if (this._mtime == null) {
|
|
445
|
+
this._mtime = Math.floor(Date.now() / 1000);
|
|
446
|
+
}
|
|
447
|
+
if (this.level === Z_BEST_SPEED) {
|
|
448
|
+
extraflags |= GZ_EXTRAFLAG_FAST;
|
|
449
|
+
}
|
|
450
|
+
else if (this.level === Z_BEST_COMPRESSION) {
|
|
451
|
+
extraflags |= GZ_EXTRAFLAG_SLOW;
|
|
452
|
+
}
|
|
453
|
+
const buf = new Uint8Array(10);
|
|
454
|
+
buf[0] = GZ_MAGIC1;
|
|
455
|
+
buf[1] = GZ_MAGIC2;
|
|
456
|
+
buf[2] = GZ_METHOD_DEFLATE;
|
|
457
|
+
buf[3] = 0;
|
|
458
|
+
GzipFile.gzfileSet32(this._mtime, buf.subarray(4));
|
|
459
|
+
buf[8] = extraflags;
|
|
460
|
+
buf[9] = OS_CODE;
|
|
461
|
+
this.z.appendBuffer(buf);
|
|
462
|
+
this.headerFinished = true;
|
|
463
|
+
}
|
|
464
|
+
/** `gzfile_make_footer` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2691`). */
|
|
465
|
+
gzfileMakeFooter() {
|
|
466
|
+
const buf = new Uint8Array(8);
|
|
467
|
+
GzipFile.gzfileSet32(this.crc, buf);
|
|
468
|
+
GzipFile.gzfileSet32(this.z.totalIn, buf.subarray(4));
|
|
469
|
+
this.z.appendBuffer(buf);
|
|
470
|
+
this.footerFinished = true;
|
|
471
|
+
}
|
|
472
|
+
/** `gzfile_write` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2808`). */
|
|
473
|
+
gzfileWrite(str) {
|
|
474
|
+
if (!this.headerFinished) {
|
|
475
|
+
this.gzfileMakeHeader();
|
|
476
|
+
}
|
|
477
|
+
if (str.length > 0 || this.syncFlag) {
|
|
478
|
+
this.crc = Zlib.crc32(str, this.crc);
|
|
479
|
+
this.z.run(str, this.syncFlag ? Zlib.SYNC_FLUSH : Zlib.NO_FLUSH);
|
|
480
|
+
}
|
|
481
|
+
this.gzfileWriteRaw();
|
|
482
|
+
}
|
|
483
|
+
/** `gzfile_write_raw` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2496`). */
|
|
484
|
+
gzfileWriteRaw() {
|
|
485
|
+
if (this.z.buf.length > 0) {
|
|
486
|
+
const str = this.z.detachBuffer();
|
|
487
|
+
this.io.write(str);
|
|
488
|
+
if (this.syncFlag && rbObjRespondTo(this.io, "flush")) {
|
|
489
|
+
this.io.flush();
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/** `OS_CODE` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2337`), `OS_UNIX`, the code zlib's own gzip writer and Node's put in the header. */
|
|
495
|
+
const OS_CODE = 0x03;
|
|
496
|
+
/**
|
|
497
|
+
* `Zlib::Inflate` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4725`). Its one-shot
|
|
498
|
+
* `inflate` (`rb_inflate_s_inflate`, `zlib.c:2044`) answers the inflated bytes
|
|
499
|
+
* as a binary String, held as its bytes, raising `Zlib::Error` on a malformed
|
|
500
|
+
* stream. An instance (`rb_inflate_initialize`, `zlib.c:1991`) inflates a
|
|
501
|
+
* stream a chunk at a time, answering what each chunk completes.
|
|
502
|
+
*/
|
|
503
|
+
class Inflate {
|
|
504
|
+
z;
|
|
505
|
+
constructor(windowBits = 15) {
|
|
506
|
+
this.z = getZlib().inflateZStream(windowBits);
|
|
507
|
+
}
|
|
508
|
+
static inflate(src) {
|
|
509
|
+
try {
|
|
510
|
+
return getZlib().inflate(typeof src === "string" ? Uint8Array.from(src, (c) => c.charCodeAt(0)) : src);
|
|
511
|
+
}
|
|
512
|
+
catch (error) {
|
|
513
|
+
throw new ZError(error.message);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
/** `rb_inflate_inflate` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:2145`). */
|
|
517
|
+
inflate(string) {
|
|
518
|
+
const bytes = typeof string === "string" ? binaryBytes(string) : string;
|
|
519
|
+
try {
|
|
520
|
+
this.z.run(bytes, Zlib.SYNC_FLUSH);
|
|
521
|
+
return this.z.detachBuffer();
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
throw new ZError(error.message);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
/** `rb_zstream_total_in` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:1505`). */
|
|
528
|
+
totalIn() {
|
|
529
|
+
return this.z.totalIn;
|
|
530
|
+
}
|
|
531
|
+
/** `rb_zstream_total_out` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:1514`). */
|
|
532
|
+
totalOut() {
|
|
533
|
+
return this.z.totalOut;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* `rb_zstream_finish` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:1409`). Every
|
|
537
|
+
* chunk was inflated to a sync point as it arrived, so nothing is left.
|
|
538
|
+
*/
|
|
539
|
+
finish() {
|
|
540
|
+
return new Uint8Array();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
/** `gzfile_ensure_close` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:3165-3175`). */
|
|
544
|
+
function gzfileEnsureClose(gz) {
|
|
545
|
+
if (gz["zstreamReady"]) {
|
|
546
|
+
gz.close();
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
async function gzfileWrap(gz, block) {
|
|
550
|
+
try {
|
|
551
|
+
return await block(gz);
|
|
552
|
+
}
|
|
553
|
+
finally {
|
|
554
|
+
gzfileEnsureClose(gz);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* `Zlib` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4659`), the sliver of it trails calls.
|
|
559
|
+
*
|
|
560
|
+
* Rails reaches this module from more than one file — `Zlib.crc32(db_name_hash)`
|
|
561
|
+
* for the advisory-lock id in
|
|
562
|
+
* `vendor/rails/v8.0.5.2/activerecord/lib/active_record/migration.rb:1617`, and
|
|
563
|
+
* `host % (Zlib.crc32(source) % 4)` in
|
|
564
|
+
* `vendor/rails/v8.0.5.2/actionview/lib/action_view/helpers/asset_url_helper.rb:295`
|
|
565
|
+
* (its `require "zlib"` at `asset_url_helper.rb:3`) — and Ruby has exactly one
|
|
566
|
+
* `Zlib`, so trails has exactly one too.
|
|
567
|
+
*
|
|
568
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib`
|
|
569
|
+
* (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4659`), which Rails calls without defining, so
|
|
570
|
+
* no Rails or gem file declares the module this file's single export lives in.
|
|
571
|
+
*/
|
|
572
|
+
export const Zlib = {
|
|
573
|
+
/**
|
|
574
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:1004` — zlib.h's `Z_DEFAULT_COMPRESSION`, the
|
|
575
|
+
* level `ActiveSupport::Gzip.compress` defaults to (`gzip.rb:32`).
|
|
576
|
+
*
|
|
577
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::DEFAULT_COMPRESSION`.
|
|
578
|
+
*/
|
|
579
|
+
DEFAULT_COMPRESSION: -1,
|
|
580
|
+
/**
|
|
581
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:1035` — zlib.h's `Z_DEFAULT_STRATEGY`
|
|
582
|
+
* (`gzip.rb:32`).
|
|
583
|
+
*
|
|
584
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::DEFAULT_STRATEGY`.
|
|
585
|
+
*/
|
|
586
|
+
DEFAULT_STRATEGY: 0,
|
|
587
|
+
/**
|
|
588
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4827` `cGzipFile`.
|
|
589
|
+
*
|
|
590
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::GzipFile`.
|
|
591
|
+
*/
|
|
592
|
+
GzipFile,
|
|
593
|
+
/**
|
|
594
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4877` `rb_cGzipReader`.
|
|
595
|
+
*
|
|
596
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::GzipReader`.
|
|
597
|
+
*/
|
|
598
|
+
GzipReader,
|
|
599
|
+
/**
|
|
600
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4859` `rb_cGzipWriter`.
|
|
601
|
+
*
|
|
602
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::GzipWriter`.
|
|
603
|
+
*/
|
|
604
|
+
GzipWriter,
|
|
605
|
+
/**
|
|
606
|
+
* `Zlib::Error` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4646` `cZError`), a `StandardError`.
|
|
607
|
+
*
|
|
608
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::Error`.
|
|
609
|
+
*/
|
|
610
|
+
Error: ZError,
|
|
611
|
+
/**
|
|
612
|
+
* `Zlib::Deflate` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4713`), whose one-shot
|
|
613
|
+
* `deflate` (`rb_deflate_s_deflate`, `zlib.c:1730`) compresses the String's
|
|
614
|
+
* bytes (a text String's UTF-8 bytes) at `Z_DEFAULT_COMPRESSION` and answers them
|
|
615
|
+
* as a binary String.
|
|
616
|
+
*
|
|
617
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::Deflate`.
|
|
618
|
+
*/
|
|
619
|
+
Deflate: {
|
|
620
|
+
deflate(src) {
|
|
621
|
+
return b(getZlib().deflate(src instanceof Uint8Array ? src : new TextEncoder().encode(src)));
|
|
622
|
+
},
|
|
623
|
+
},
|
|
624
|
+
/**
|
|
625
|
+
* `Zlib::Inflate` (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:4725`), whose one-shot
|
|
626
|
+
* `inflate` (`rb_inflate_s_inflate`, `zlib.c:2044`) answers the inflated bytes
|
|
627
|
+
* as a binary String, held as its bytes, raising `Zlib::Error` on a malformed stream.
|
|
628
|
+
*
|
|
629
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::Inflate`.
|
|
630
|
+
*/
|
|
631
|
+
Inflate,
|
|
632
|
+
/**
|
|
633
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4797` — zlib.h's `Z_NO_FLUSH`.
|
|
634
|
+
*
|
|
635
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::NO_FLUSH`.
|
|
636
|
+
*/
|
|
637
|
+
NO_FLUSH: 0,
|
|
638
|
+
/**
|
|
639
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4804` — zlib.h's `Z_SYNC_FLUSH`.
|
|
640
|
+
*
|
|
641
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::SYNC_FLUSH`.
|
|
642
|
+
*/
|
|
643
|
+
SYNC_FLUSH: 2,
|
|
644
|
+
/**
|
|
645
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4815` — zlib.h's `Z_FINISH`.
|
|
646
|
+
*
|
|
647
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::FINISH`.
|
|
648
|
+
*/
|
|
649
|
+
FINISH: 4,
|
|
650
|
+
/**
|
|
651
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:4783` — zlib.h's `MAX_WBITS`.
|
|
652
|
+
*
|
|
653
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib::MAX_WBITS`.
|
|
654
|
+
*/
|
|
655
|
+
MAX_WBITS: 15,
|
|
656
|
+
/**
|
|
657
|
+
* `vendor/ruby/v3.3.11/ext/zlib/zlib.c:507` `rb_zlib_crc32`, which is
|
|
658
|
+
* `do_checksum(argc, argv, crc32)` (`zlib.c:410`): `crc` seeds `sum`, an
|
|
659
|
+
* omitted `string` answers that seed unchanged (`zlib.c:428`), and otherwise
|
|
660
|
+
* `sum` is folded over the String's BYTES (`zlib.c:441`) — so a multibyte
|
|
661
|
+
* String is digested as its UTF-8 encoding.
|
|
662
|
+
*
|
|
663
|
+
* @noRailsEquivalent PERMANENT — Ruby stdlib `Zlib.crc32`
|
|
664
|
+
* (`vendor/ruby/v3.3.11/ext/zlib/zlib.c:507`).
|
|
665
|
+
*/
|
|
666
|
+
crc32(string = "", crc = 0) {
|
|
667
|
+
let sum = ~crc >>> 0;
|
|
668
|
+
for (const byte of typeof string === "string" ? new TextEncoder().encode(string) : string) {
|
|
669
|
+
sum ^= byte;
|
|
670
|
+
for (let i = 0; i < 8; i++) {
|
|
671
|
+
sum = (sum >>> 1) ^ (sum & 1 ? 0xedb88320 : 0);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return (sum ^ 0xffffffff) >>> 0;
|
|
675
|
+
},
|
|
676
|
+
};
|
|
677
|
+
constSet(TopLevel, "Zlib", Zlib);
|
|
678
|
+
constSet(Zlib, "Error", ZError);
|
|
679
|
+
//# sourceMappingURL=zlib.js.map
|