zeed 1.3.0 → 1.4.0
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/AGENTS.md +50 -211
- package/README.md +16 -0
- package/dist/_experiments/bitcask.cjs +243 -1
- package/dist/_experiments/bitcask.cjs.map +1 -1
- package/dist/_experiments/bitcask.mjs +230 -1
- package/dist/_experiments/bitcask.mjs.map +1 -1
- package/dist/bin-BAoS4qtm.mjs +593 -0
- package/dist/{bin-SPdenYkw.mjs.map → bin-BAoS4qtm.mjs.map} +1 -1
- package/dist/bin-Ddaz2lxM.cjs +862 -0
- package/dist/{bin-Ce3i6ABn.cjs.map → bin-Ddaz2lxM.cjs.map} +1 -1
- package/dist/browser/base64.cjs +14 -1
- package/dist/browser/base64.cjs.map +1 -1
- package/dist/browser/base64.mjs +12 -1
- package/dist/browser/base64.mjs.map +1 -1
- package/dist/browser/gravatar.cjs +186 -1
- package/dist/browser/gravatar.cjs.map +1 -1
- package/dist/browser/gravatar.mjs +184 -1
- package/dist/browser/gravatar.mjs.map +1 -1
- package/dist/browser/index.cjs +14 -1
- package/dist/browser/index.mjs +8 -1
- package/dist/browser/localstorage.cjs +46 -1
- package/dist/browser/localstorage.cjs.map +1 -1
- package/dist/browser/localstorage.mjs +45 -1
- package/dist/browser/localstorage.mjs.map +1 -1
- package/dist/browser/log/index.cjs +8 -1
- package/dist/browser/log/index.mjs +5 -1
- package/dist/browser/log/log-browser-factory.cjs +65 -1
- package/dist/browser/log/log-browser-factory.cjs.map +1 -1
- package/dist/browser/log/log-browser-factory.mjs +64 -1
- package/dist/browser/log/log-browser-factory.mjs.map +1 -1
- package/dist/browser/log/log-browser.cjs +72 -1
- package/dist/browser/log/log-browser.cjs.map +1 -1
- package/dist/browser/log/log-browser.mjs +71 -1
- package/dist/browser/log/log-browser.mjs.map +1 -1
- package/dist/browser/log/log-colors.cjs +11 -1
- package/dist/browser/log/log-colors.cjs.map +1 -1
- package/dist/browser/log/log-colors.mjs +9 -1
- package/dist/browser/log/log-colors.mjs.map +1 -1
- package/dist/browser/log/log-context-browser.cjs +25 -1
- package/dist/browser/log/log-context-browser.cjs.map +1 -1
- package/dist/browser/log/log-context-browser.mjs +23 -1
- package/dist/browser/log/log-context-browser.mjs.map +1 -1
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/chunk-uaV2rQ02.cjs +53 -0
- package/dist/common/assert.cjs +22 -1
- package/dist/common/assert.cjs.map +1 -1
- package/dist/common/assert.mjs +19 -1
- package/dist/common/assert.mjs.map +1 -1
- package/dist/common/bin/index.cjs +106 -1
- package/dist/common/bin/index.cjs.map +1 -1
- package/dist/common/bin/index.mjs +98 -1
- package/dist/common/bin/index.mjs.map +1 -1
- package/dist/common/bin/lib0/binary.cjs +146 -1
- package/dist/common/bin/lib0/binary.cjs.map +1 -1
- package/dist/common/bin/lib0/binary.mjs +80 -1
- package/dist/common/bin/lib0/binary.mjs.map +1 -1
- package/dist/common/bin/lib0/buffer.cjs +42 -1
- package/dist/common/bin/lib0/buffer.cjs.map +1 -1
- package/dist/common/bin/lib0/buffer.mjs +38 -1
- package/dist/common/bin/lib0/buffer.mjs.map +1 -1
- package/dist/common/bin/lib0/create.cjs +24 -1
- package/dist/common/bin/lib0/create.cjs.map +1 -1
- package/dist/common/bin/lib0/create.mjs +21 -1
- package/dist/common/bin/lib0/create.mjs.map +1 -1
- package/dist/common/bin/lib0/decoding.cjs +325 -1
- package/dist/common/bin/lib0/decoding.cjs.map +1 -1
- package/dist/common/bin/lib0/decoding.mjs +298 -1
- package/dist/common/bin/lib0/decoding.mjs.map +1 -1
- package/dist/common/bin/lib0/encoding.cjs +404 -1
- package/dist/common/bin/lib0/encoding.cjs.map +1 -1
- package/dist/common/bin/lib0/encoding.mjs +377 -1
- package/dist/common/bin/lib0/encoding.mjs.map +1 -1
- package/dist/common/bin/lib0/string.cjs +81 -1
- package/dist/common/bin/lib0/string.cjs.map +1 -1
- package/dist/common/bin/lib0/string.mjs +71 -1
- package/dist/common/bin/lib0/string.mjs.map +1 -1
- package/dist/common/crypto/aes-sealed.cjs +34 -1
- package/dist/common/crypto/aes-sealed.cjs.map +1 -1
- package/dist/common/crypto/aes-sealed.mjs +32 -1
- package/dist/common/crypto/aes-sealed.mjs.map +1 -1
- package/dist/common/crypto/crypto.cjs +91 -1
- package/dist/common/crypto/crypto.cjs.map +1 -1
- package/dist/common/crypto/crypto.mjs +80 -1
- package/dist/common/crypto/crypto.mjs.map +1 -1
- package/dist/common/crypto/index.cjs +23 -1
- package/dist/common/crypto/index.mjs +5 -1
- package/dist/common/crypto/xaes.cjs +128 -1
- package/dist/common/crypto/xaes.cjs.map +1 -1
- package/dist/common/crypto/xaes.mjs +123 -1
- package/dist/common/crypto/xaes.mjs.map +1 -1
- package/dist/common/csv.cjs +49 -4
- package/dist/common/csv.cjs.map +1 -1
- package/dist/common/csv.mjs +46 -4
- package/dist/common/csv.mjs.map +1 -1
- package/dist/common/data/array.cjs +299 -1
- package/dist/common/data/array.cjs.map +1 -1
- package/dist/common/data/array.mjs +274 -1
- package/dist/common/data/array.mjs.map +1 -1
- package/dist/common/data/basex-secure.cjs +30 -1
- package/dist/common/data/basex-secure.mjs +3 -1
- package/dist/common/data/basex.cjs +163 -1
- package/dist/common/data/basex.cjs.map +1 -1
- package/dist/common/data/basex.mjs +152 -1
- package/dist/common/data/basex.mjs.map +1 -1
- package/dist/common/data/bin-types.mjs +1 -1
- package/dist/common/data/bin.cjs +21 -1
- package/dist/common/data/bin.mjs +3 -1
- package/dist/common/data/camelcase.cjs +27 -1
- package/dist/common/data/camelcase.cjs.map +1 -1
- package/dist/common/data/camelcase.mjs +22 -1
- package/dist/common/data/camelcase.mjs.map +1 -1
- package/dist/common/data/convert.cjs +104 -1
- package/dist/common/data/convert.cjs.map +1 -1
- package/dist/common/data/convert.mjs +88 -1
- package/dist/common/data/convert.mjs.map +1 -1
- package/dist/common/data/datauri.cjs +32 -1
- package/dist/common/data/datauri.cjs.map +1 -1
- package/dist/common/data/datauri.mjs +27 -1
- package/dist/common/data/datauri.mjs.map +1 -1
- package/dist/common/data/day-legacy.cjs +148 -1
- package/dist/common/data/day-legacy.cjs.map +1 -1
- package/dist/common/data/day-legacy.mjs +143 -1
- package/dist/common/data/day-legacy.mjs.map +1 -1
- package/dist/common/data/day.cjs +335 -1
- package/dist/common/data/day.cjs.map +1 -1
- package/dist/common/data/day.mjs +305 -1
- package/dist/common/data/day.mjs.map +1 -1
- package/dist/common/data/decimal.cjs +28 -1
- package/dist/common/data/decimal.cjs.map +1 -1
- package/dist/common/data/decimal.mjs +23 -1
- package/dist/common/data/decimal.mjs.map +1 -1
- package/dist/common/data/deep.cjs +57 -1
- package/dist/common/data/deep.cjs.map +1 -1
- package/dist/common/data/deep.mjs +54 -1
- package/dist/common/data/deep.mjs.map +1 -1
- package/dist/common/data/diff.cjs +62 -1
- package/dist/common/data/diff.cjs.map +1 -1
- package/dist/common/data/diff.mjs +60 -1
- package/dist/common/data/diff.mjs.map +1 -1
- package/dist/common/data/distributed.cjs +24 -1
- package/dist/common/data/distributed.cjs.map +1 -1
- package/dist/common/data/distributed.mjs +22 -1
- package/dist/common/data/distributed.mjs.map +1 -1
- package/dist/common/data/format.cjs +63 -1
- package/dist/common/data/format.cjs.map +1 -1
- package/dist/common/data/format.mjs +59 -1
- package/dist/common/data/format.mjs.map +1 -1
- package/dist/common/data/html.cjs +13 -1
- package/dist/common/data/html.cjs.map +1 -1
- package/dist/common/data/html.mjs +10 -1
- package/dist/common/data/html.mjs.map +1 -1
- package/dist/common/data/index.cjs +296 -1
- package/dist/common/data/index.mjs +37 -1
- package/dist/common/data/is.cjs +106 -1
- package/dist/common/data/is.cjs.map +1 -1
- package/dist/common/data/is.mjs +85 -1
- package/dist/common/data/is.mjs.map +1 -1
- package/dist/common/data/json.cjs +70 -1
- package/dist/common/data/json.cjs.map +1 -1
- package/dist/common/data/json.mjs +65 -1
- package/dist/common/data/json.mjs.map +1 -1
- package/dist/common/data/list.cjs +32 -1
- package/dist/common/data/list.cjs.map +1 -1
- package/dist/common/data/list.mjs +27 -1
- package/dist/common/data/list.mjs.map +1 -1
- package/dist/common/data/lru.mjs +1 -1
- package/dist/common/data/math.cjs +79 -1
- package/dist/common/data/math.cjs.map +1 -1
- package/dist/common/data/math.mjs +65 -1
- package/dist/common/data/math.mjs.map +1 -1
- package/dist/common/data/message.cjs +30 -1
- package/dist/common/data/message.cjs.map +1 -1
- package/dist/common/data/message.mjs +28 -1
- package/dist/common/data/message.mjs.map +1 -1
- package/dist/common/data/object-changes.cjs +66 -1
- package/dist/common/data/object-changes.cjs.map +1 -1
- package/dist/common/data/object-changes.mjs +63 -1
- package/dist/common/data/object-changes.mjs.map +1 -1
- package/dist/common/data/object.cjs +112 -1
- package/dist/common/data/object.cjs.map +1 -1
- package/dist/common/data/object.mjs +104 -1
- package/dist/common/data/object.mjs.map +1 -1
- package/dist/common/data/orderby.cjs +42 -1
- package/dist/common/data/orderby.cjs.map +1 -1
- package/dist/common/data/orderby.mjs +37 -1
- package/dist/common/data/orderby.mjs.map +1 -1
- package/dist/common/data/path.cjs +26 -1
- package/dist/common/data/path.cjs.map +1 -1
- package/dist/common/data/path.mjs +25 -1
- package/dist/common/data/path.mjs.map +1 -1
- package/dist/common/data/regexp.cjs +12 -1
- package/dist/common/data/regexp.cjs.map +1 -1
- package/dist/common/data/regexp.mjs +10 -1
- package/dist/common/data/regexp.mjs.map +1 -1
- package/dist/common/data/rounding.cjs +107 -1
- package/dist/common/data/rounding.cjs.map +1 -1
- package/dist/common/data/rounding.mjs +95 -1
- package/dist/common/data/rounding.mjs.map +1 -1
- package/dist/common/data/signal.cjs +39 -1
- package/dist/common/data/signal.cjs.map +1 -1
- package/dist/common/data/signal.mjs +38 -1
- package/dist/common/data/signal.mjs.map +1 -1
- package/dist/common/data/sortable.cjs +35 -1
- package/dist/common/data/sortable.cjs.map +1 -1
- package/dist/common/data/sortable.mjs +31 -1
- package/dist/common/data/sortable.mjs.map +1 -1
- package/dist/common/data/sorted.cjs +54 -1
- package/dist/common/data/sorted.cjs.map +1 -1
- package/dist/common/data/sorted.mjs +53 -1
- package/dist/common/data/sorted.mjs.map +1 -1
- package/dist/common/data/string-deburr.cjs +240 -1
- package/dist/common/data/string-deburr.cjs.map +1 -1
- package/dist/common/data/string-deburr.mjs +238 -1
- package/dist/common/data/string-deburr.mjs.map +1 -1
- package/dist/common/data/string-hash-fnv.cjs +69 -1
- package/dist/common/data/string-hash-fnv.cjs.map +1 -1
- package/dist/common/data/string-hash-fnv.mjs +67 -1
- package/dist/common/data/string-hash-fnv.mjs.map +1 -1
- package/dist/common/data/string-hash-pool.cjs +28 -1
- package/dist/common/data/string-hash-pool.cjs.map +1 -1
- package/dist/common/data/string-hash-pool.mjs +27 -1
- package/dist/common/data/string-hash-pool.mjs.map +1 -1
- package/dist/common/data/url.cjs +98 -2
- package/dist/common/data/url.cjs.map +1 -1
- package/dist/common/data/url.mjs +91 -2
- package/dist/common/data/url.mjs.map +1 -1
- package/dist/common/data/utils.cjs +118 -1
- package/dist/common/data/utils.cjs.map +1 -1
- package/dist/common/data/utils.mjs +107 -1
- package/dist/common/data/utils.mjs.map +1 -1
- package/dist/common/data/wordlist.cjs +531 -1
- package/dist/common/data/wordlist.cjs.map +1 -1
- package/dist/common/data/wordlist.mjs +529 -1
- package/dist/common/data/wordlist.mjs.map +1 -1
- package/dist/common/data/xrx.cjs +96 -1
- package/dist/common/data/xrx.cjs.map +1 -1
- package/dist/common/data/xrx.mjs +92 -1
- package/dist/common/data/xrx.mjs.map +1 -1
- package/dist/common/dispose-defer.cjs +133 -1
- package/dist/common/dispose-defer.cjs.map +1 -1
- package/dist/common/dispose-defer.mjs +130 -1
- package/dist/common/dispose-defer.mjs.map +1 -1
- package/dist/common/dispose-types.mjs +1 -1
- package/dist/common/dispose-utils.cjs +113 -1
- package/dist/common/dispose-utils.cjs.map +1 -1
- package/dist/common/dispose-utils.mjs +106 -1
- package/dist/common/dispose-utils.mjs.map +1 -1
- package/dist/common/exec/index.cjs +24 -1
- package/dist/common/exec/index.d.cts +1 -1
- package/dist/common/exec/index.d.mts +1 -1
- package/dist/common/exec/index.mjs +8 -1
- package/dist/common/exec/mutex.cjs +44 -1
- package/dist/common/exec/mutex.cjs.map +1 -1
- package/dist/common/exec/mutex.mjs +42 -1
- package/dist/common/exec/mutex.mjs.map +1 -1
- package/dist/common/exec/pool.cjs +181 -1
- package/dist/common/exec/pool.cjs.map +1 -1
- package/dist/common/exec/pool.d.cts +1 -1
- package/dist/common/exec/pool.d.mts +1 -1
- package/dist/common/exec/pool.mjs +180 -1
- package/dist/common/exec/pool.mjs.map +1 -1
- package/dist/common/exec/progress.cjs +149 -1
- package/dist/common/exec/progress.cjs.map +1 -1
- package/dist/common/exec/progress.d.cts +1 -1
- package/dist/common/exec/progress.d.mts +1 -1
- package/dist/common/exec/progress.mjs +148 -1
- package/dist/common/exec/progress.mjs.map +1 -1
- package/dist/common/exec/promise.cjs +113 -1
- package/dist/common/exec/promise.cjs.map +1 -1
- package/dist/common/exec/promise.mjs +103 -1
- package/dist/common/exec/promise.mjs.map +1 -1
- package/dist/common/exec/queue.cjs +125 -1
- package/dist/common/exec/queue.cjs.map +1 -1
- package/dist/common/exec/queue.d.cts +1 -1
- package/dist/common/exec/queue.d.mts +1 -1
- package/dist/common/exec/queue.mjs +124 -1
- package/dist/common/exec/queue.mjs.map +1 -1
- package/dist/common/exec/throttle-debounce.cjs +114 -1
- package/dist/common/exec/throttle-debounce.cjs.map +1 -1
- package/dist/common/exec/throttle-debounce.mjs +112 -1
- package/dist/common/exec/throttle-debounce.mjs.map +1 -1
- package/dist/common/global.cjs +22 -1
- package/dist/common/global.cjs.map +1 -1
- package/dist/common/global.mjs +19 -1
- package/dist/common/global.mjs.map +1 -1
- package/dist/common/index.cjs +559 -1
- package/dist/common/index.d.cts +1 -1
- package/dist/common/index.d.mts +1 -1
- package/dist/common/index.mjs +89 -1
- package/dist/common/localhost.cjs +16 -1
- package/dist/common/localhost.cjs.map +1 -1
- package/dist/common/localhost.mjs +14 -1
- package/dist/common/localhost.mjs.map +1 -1
- package/dist/common/log/index.cjs +34 -1
- package/dist/common/log/index.mjs +11 -1
- package/dist/common/log/log-base.cjs +40 -1
- package/dist/common/log/log-base.cjs.map +1 -1
- package/dist/common/log/log-base.mjs +31 -1
- package/dist/common/log/log-base.mjs.map +1 -1
- package/dist/common/log/log-colors.cjs +92 -1
- package/dist/common/log/log-colors.cjs.map +1 -1
- package/dist/common/log/log-colors.mjs +90 -1
- package/dist/common/log/log-colors.mjs.map +1 -1
- package/dist/common/log/log-config.cjs +15 -1
- package/dist/common/log/log-config.cjs.map +1 -1
- package/dist/common/log/log-config.mjs +14 -1
- package/dist/common/log/log-config.mjs.map +1 -1
- package/dist/common/log/log-console-capture.cjs +33 -1
- package/dist/common/log/log-console-capture.cjs.map +1 -1
- package/dist/common/log/log-console-capture.mjs +32 -1
- package/dist/common/log/log-console-capture.mjs.map +1 -1
- package/dist/common/log/log-console-original.cjs +27 -1
- package/dist/common/log/log-console-original.cjs.map +1 -1
- package/dist/common/log/log-console-original.mjs +26 -1
- package/dist/common/log/log-console-original.mjs.map +1 -1
- package/dist/common/log/log-console.cjs +39 -1
- package/dist/common/log/log-console.cjs.map +1 -1
- package/dist/common/log/log-console.mjs +38 -1
- package/dist/common/log/log-console.mjs.map +1 -1
- package/dist/common/log/log-context.cjs +109 -1
- package/dist/common/log/log-context.cjs.map +1 -1
- package/dist/common/log/log-context.mjs +108 -1
- package/dist/common/log/log-context.mjs.map +1 -1
- package/dist/common/log/log-filter.cjs +80 -1
- package/dist/common/log/log-filter.cjs.map +1 -1
- package/dist/common/log/log-filter.mjs +75 -1
- package/dist/common/log/log-filter.mjs.map +1 -1
- package/dist/common/log/log-memory.cjs +45 -1
- package/dist/common/log/log-memory.cjs.map +1 -1
- package/dist/common/log/log-memory.mjs +43 -1
- package/dist/common/log/log-memory.mjs.map +1 -1
- package/dist/common/log/log-noop.cjs +17 -1
- package/dist/common/log/log-noop.cjs.map +1 -1
- package/dist/common/log/log-noop.mjs +15 -1
- package/dist/common/log/log-noop.mjs.map +1 -1
- package/dist/common/log/log.cjs +46 -1
- package/dist/common/log/log.cjs.map +1 -1
- package/dist/common/log/log.mjs +43 -1
- package/dist/common/log/log.mjs.map +1 -1
- package/dist/common/msg/channel-debug.cjs +17 -1
- package/dist/common/msg/channel-debug.cjs.map +1 -1
- package/dist/common/msg/channel-debug.d.cts +1 -1
- package/dist/common/msg/channel-debug.d.mts +1 -1
- package/dist/common/msg/channel-debug.mjs +16 -1
- package/dist/common/msg/channel-debug.mjs.map +1 -1
- package/dist/common/msg/channel-local.cjs +28 -1
- package/dist/common/msg/channel-local.cjs.map +1 -1
- package/dist/common/msg/channel-local.d.cts +1 -1
- package/dist/common/msg/channel-local.d.mts +1 -1
- package/dist/common/msg/channel-local.mjs +26 -1
- package/dist/common/msg/channel-local.mjs.map +1 -1
- package/dist/common/msg/channel-resilient.cjs +63 -1
- package/dist/common/msg/channel-resilient.cjs.map +1 -1
- package/dist/common/msg/channel-resilient.d.cts +1 -1
- package/dist/common/msg/channel-resilient.d.mts +1 -1
- package/dist/common/msg/channel-resilient.mjs +62 -1
- package/dist/common/msg/channel-resilient.mjs.map +1 -1
- package/dist/common/msg/channel-wkwebview.cjs +35 -1
- package/dist/common/msg/channel-wkwebview.cjs.map +1 -1
- package/dist/common/msg/channel-wkwebview.d.cts +2 -1
- package/dist/common/msg/channel-wkwebview.d.mts +2 -1
- package/dist/common/msg/channel-wkwebview.mjs +34 -1
- package/dist/common/msg/channel-wkwebview.mjs.map +1 -1
- package/dist/common/msg/channel.cjs +23 -1
- package/dist/common/msg/channel.cjs.map +1 -1
- package/dist/common/msg/channel.d.cts +1 -1
- package/dist/common/msg/channel.d.mts +1 -1
- package/dist/common/msg/channel.mjs +22 -1
- package/dist/common/msg/channel.mjs.map +1 -1
- package/dist/common/msg/emitter.cjs +141 -1
- package/dist/common/msg/emitter.cjs.map +1 -1
- package/dist/common/msg/emitter.d.cts +1 -1
- package/dist/common/msg/emitter.d.mts +1 -1
- package/dist/common/msg/emitter.mjs +139 -1
- package/dist/common/msg/emitter.mjs.map +1 -1
- package/dist/common/msg/encoder.cjs +38 -1
- package/dist/common/msg/encoder.cjs.map +1 -1
- package/dist/common/msg/encoder.mjs +35 -1
- package/dist/common/msg/encoder.mjs.map +1 -1
- package/dist/common/msg/index.cjs +28 -1
- package/dist/common/msg/index.d.cts +1 -1
- package/dist/common/msg/index.d.mts +1 -1
- package/dist/common/msg/index.mjs +11 -1
- package/dist/common/msg/messages.cjs +135 -1
- package/dist/common/msg/messages.cjs.map +1 -1
- package/dist/common/msg/messages.d.cts +1 -1
- package/dist/common/msg/messages.d.mts +1 -1
- package/dist/common/msg/messages.mjs +133 -1
- package/dist/common/msg/messages.mjs.map +1 -1
- package/dist/common/msg/pipe.mjs +1 -1
- package/dist/common/msg/pubsub.cjs +78 -1
- package/dist/common/msg/pubsub.cjs.map +1 -1
- package/dist/common/msg/pubsub.d.cts +1 -1
- package/dist/common/msg/pubsub.d.mts +1 -1
- package/dist/common/msg/pubsub.mjs +76 -1
- package/dist/common/msg/pubsub.mjs.map +1 -1
- package/dist/common/msg/rpc.cjs +142 -1
- package/dist/common/msg/rpc.cjs.map +1 -1
- package/dist/common/msg/rpc.mjs +139 -1
- package/dist/common/msg/rpc.mjs.map +1 -1
- package/dist/common/network.cjs +129 -1
- package/dist/common/network.cjs.map +1 -1
- package/dist/common/network.mjs +122 -1
- package/dist/common/network.mjs.map +1 -1
- package/dist/common/platform.cjs +92 -1
- package/dist/common/platform.cjs.map +1 -1
- package/dist/common/platform.mjs +84 -1
- package/dist/common/platform.mjs.map +1 -1
- package/dist/common/schema/_sandbox/sandbox-inherit.mjs +1 -1
- package/dist/common/schema/_sandbox/sandbox.mjs +1 -1
- package/dist/common/schema/_sandbox/sandbox.xspec.mjs +1 -1
- package/dist/common/schema/export-json-schema.cjs +54 -1
- package/dist/common/schema/export-json-schema.cjs.map +1 -1
- package/dist/common/schema/export-json-schema.mjs +52 -1
- package/dist/common/schema/export-json-schema.mjs.map +1 -1
- package/dist/common/schema/export-swift.cjs +30 -2
- package/dist/common/schema/export-swift.cjs.map +1 -1
- package/dist/common/schema/export-swift.mjs +29 -2
- package/dist/common/schema/export-swift.mjs.map +1 -1
- package/dist/common/schema/export-typescript.cjs +20 -2
- package/dist/common/schema/export-typescript.cjs.map +1 -1
- package/dist/common/schema/export-typescript.mjs +19 -2
- package/dist/common/schema/export-typescript.mjs.map +1 -1
- package/dist/common/schema/index.cjs +55 -1
- package/dist/common/schema/index.mjs +12 -1
- package/dist/common/schema/parse-args.cjs +62 -2
- package/dist/common/schema/parse-args.cjs.map +1 -1
- package/dist/common/schema/parse-args.mjs +60 -2
- package/dist/common/schema/parse-args.mjs.map +1 -1
- package/dist/common/schema/parse-env.cjs +48 -3
- package/dist/common/schema/parse-env.cjs.map +1 -1
- package/dist/common/schema/parse-env.mjs +46 -3
- package/dist/common/schema/parse-env.mjs.map +1 -1
- package/dist/common/schema/parse-object.cjs +122 -1
- package/dist/common/schema/parse-object.cjs.map +1 -1
- package/dist/common/schema/parse-object.mjs +119 -1
- package/dist/common/schema/parse-object.mjs.map +1 -1
- package/dist/common/schema/schema-standard.mjs +1 -1
- package/dist/common/schema/schema.cjs +423 -1
- package/dist/common/schema/schema.cjs.map +1 -1
- package/dist/common/schema/schema.mjs +404 -1
- package/dist/common/schema/schema.mjs.map +1 -1
- package/dist/common/schema/serialize.cjs +109 -1
- package/dist/common/schema/serialize.cjs.map +1 -1
- package/dist/common/schema/serialize.mjs +107 -1
- package/dist/common/schema/serialize.mjs.map +1 -1
- package/dist/common/schema/type-test.mjs +1 -1
- package/dist/common/schema/utils.cjs +25 -1
- package/dist/common/schema/utils.cjs.map +1 -1
- package/dist/common/schema/utils.mjs +19 -1
- package/dist/common/schema/utils.mjs.map +1 -1
- package/dist/common/schema/z-collection.cjs +51 -1
- package/dist/common/schema/z-collection.mjs +27 -1
- package/dist/common/schema/z.cjs +9 -1
- package/dist/common/schema/z.mjs +3 -1
- package/dist/common/storage/index.cjs +4 -1
- package/dist/common/storage/index.mjs +3 -1
- package/dist/common/storage/memstorage.cjs +26 -1
- package/dist/common/storage/memstorage.cjs.map +1 -1
- package/dist/common/storage/memstorage.mjs +25 -1
- package/dist/common/storage/memstorage.mjs.map +1 -1
- package/dist/common/test.cjs +14 -1
- package/dist/common/test.cjs.map +1 -1
- package/dist/common/test.mjs +13 -1
- package/dist/common/test.mjs.map +1 -1
- package/dist/common/time.cjs +220 -1
- package/dist/common/time.cjs.map +1 -1
- package/dist/common/time.mjs +194 -1
- package/dist/common/time.mjs.map +1 -1
- package/dist/common/timeout.cjs +27 -1
- package/dist/common/timeout.cjs.map +1 -1
- package/dist/common/timeout.mjs +25 -1
- package/dist/common/timeout.mjs.map +1 -1
- package/dist/common/types.mjs +1 -1
- package/dist/common/utils.cjs +7 -1
- package/dist/common/utils.cjs.map +1 -1
- package/dist/common/utils.mjs +5 -1
- package/dist/common/utils.mjs.map +1 -1
- package/dist/common/uuid.cjs +307 -1
- package/dist/common/uuid.cjs.map +1 -1
- package/dist/common/uuid.mjs +284 -1
- package/dist/common/uuid.mjs.map +1 -1
- package/dist/{index-DHXVOH8h.d.cts → index-CFkMqHvX.d.cts} +1 -2
- package/dist/{index-DMaPyx9O.d.mts → index-C_3Y_s6f.d.mts} +1 -2
- package/dist/index.all.cjs +641 -1
- package/dist/index.all.d.cts +1 -1
- package/dist/index.all.d.mts +1 -1
- package/dist/index.all.mjs +113 -1
- package/dist/index.browser.cjs +576 -1
- package/dist/index.browser.d.cts +1 -1
- package/dist/index.browser.d.mts +1 -1
- package/dist/index.browser.mjs +98 -1
- package/dist/index.jsr.cjs +57 -1
- package/dist/index.jsr.mjs +6 -1
- package/dist/index.node.cjs +628 -1
- package/dist/index.node.d.cts +1 -1
- package/dist/index.node.d.mts +1 -1
- package/dist/index.node.mjs +106 -1
- package/dist/node/args.cjs +56 -1
- package/dist/node/args.cjs.map +1 -1
- package/dist/node/args.mjs +53 -1
- package/dist/node/args.mjs.map +1 -1
- package/dist/node/clipboard.cjs +18 -1
- package/dist/node/clipboard.cjs.map +1 -1
- package/dist/node/clipboard.mjs +16 -1
- package/dist/node/clipboard.mjs.map +1 -1
- package/dist/node/crypto.cjs +28 -1
- package/dist/node/crypto.cjs.map +1 -1
- package/dist/node/crypto.mjs +24 -1
- package/dist/node/crypto.mjs.map +1 -1
- package/dist/node/env.cjs +100 -4
- package/dist/node/env.cjs.map +1 -1
- package/dist/node/env.mjs +90 -4
- package/dist/node/env.mjs.map +1 -1
- package/dist/node/files-async.cjs +66 -1
- package/dist/node/files-async.cjs.map +1 -1
- package/dist/node/files-async.mjs +60 -1
- package/dist/node/files-async.mjs.map +1 -1
- package/dist/node/files.cjs +52 -1
- package/dist/node/files.cjs.map +1 -1
- package/dist/node/files.mjs +46 -1
- package/dist/node/files.mjs.map +1 -1
- package/dist/node/filestorage.cjs +100 -1
- package/dist/node/filestorage.cjs.map +1 -1
- package/dist/node/filestorage.mjs +97 -1
- package/dist/node/filestorage.mjs.map +1 -1
- package/dist/node/fs.cjs +119 -1
- package/dist/node/fs.cjs.map +1 -1
- package/dist/node/fs.mjs +101 -1
- package/dist/node/fs.mjs.map +1 -1
- package/dist/node/glob.cjs +75 -1
- package/dist/node/glob.cjs.map +1 -1
- package/dist/node/glob.mjs +73 -1
- package/dist/node/glob.mjs.map +1 -1
- package/dist/node/index.cjs +66 -1
- package/dist/node/index.mjs +16 -1
- package/dist/node/log/index.cjs +20 -1
- package/dist/node/log/index.mjs +7 -1
- package/dist/node/log/log-context-node.cjs +39 -1
- package/dist/node/log/log-context-node.cjs.map +1 -1
- package/dist/node/log/log-context-node.mjs +35 -1
- package/dist/node/log/log-context-node.mjs.map +1 -1
- package/dist/node/log/log-file-rotation.cjs +71 -1
- package/dist/node/log/log-file-rotation.cjs.map +1 -1
- package/dist/node/log/log-file-rotation.mjs +68 -1
- package/dist/node/log/log-file-rotation.mjs.map +1 -1
- package/dist/node/log/log-file.cjs +57 -1
- package/dist/node/log/log-file.cjs.map +1 -1
- package/dist/node/log/log-file.mjs +54 -1
- package/dist/node/log/log-file.mjs.map +1 -1
- package/dist/node/log/log-node.cjs +162 -1
- package/dist/node/log/log-node.cjs.map +1 -1
- package/dist/node/log/log-node.mjs +155 -1
- package/dist/node/log/log-node.mjs.map +1 -1
- package/dist/node/log/log-rotation.cjs +543 -3
- package/dist/node/log/log-rotation.cjs.map +1 -1
- package/dist/node/log/log-rotation.mjs +538 -3
- package/dist/node/log/log-rotation.mjs.map +1 -1
- package/dist/node/log/log-util.cjs +69 -3
- package/dist/node/log/log-util.cjs.map +1 -1
- package/dist/node/log/log-util.mjs +63 -3
- package/dist/node/log/log-util.mjs.map +1 -1
- package/dist/node/open-browser.cjs +20 -1
- package/dist/node/open-browser.cjs.map +1 -1
- package/dist/node/open-browser.mjs +18 -1
- package/dist/node/open-browser.mjs.map +1 -1
- package/package.json +15 -15
- package/src/common/schema/README.md +247 -66
- package/src/eslint-defaults.js +4 -0
- package/src/index.spec.ts +6 -6
- package/dist/bin-Ce3i6ABn.cjs +0 -3
- package/dist/bin-SPdenYkw.mjs +0 -3
- package/dist/chunk-0Lt9GpW0.mjs +0 -1
- package/dist/chunk-D-qHiVGv.cjs +0 -1
- package/src/common/schema/README-SCHEMA.md +0 -0
|
@@ -1,2 +1,299 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { BIT7, BIT8, BITS6, BITS7 } from "./binary.mjs";
|
|
2
|
+
import { createUint8ArrayViewFromArrayBuffer } from "./create.mjs";
|
|
3
|
+
import { getUtf8TextDecoder } from "./string.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/common/bin/lib0/decoding.ts
|
|
6
|
+
/**
|
|
7
|
+
* Original at https://github.com/dmonad/lib0
|
|
8
|
+
*
|
|
9
|
+
* Efficient schema-less binary decoding with support for variable length encoding.
|
|
10
|
+
*
|
|
11
|
+
* Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.
|
|
12
|
+
*
|
|
13
|
+
* Encodes numbers in little-endian order (least to most significant byte order)
|
|
14
|
+
* and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)
|
|
15
|
+
* which is also used in Protocol Buffers.
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* // encoding step
|
|
19
|
+
* const encoder = new encoding.createEncoder()
|
|
20
|
+
* encoding.writeVarUint(encoder, 256)
|
|
21
|
+
* encoding.writeVarString(encoder, 'Hello world!')
|
|
22
|
+
* const buf = encoding.toUint8Array(encoder)
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ```js
|
|
26
|
+
* // decoding step
|
|
27
|
+
* const decoder = new decoding.createDecoder(buf)
|
|
28
|
+
* decoding.readVarUint(decoder) // => 256
|
|
29
|
+
* decoding.readVarString(decoder) // => 'Hello world!'
|
|
30
|
+
* decoding.hasContent(decoder) // => false - all data is read
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
const errorUnexpectedEndOfArray = "Unexpected end of array";
|
|
34
|
+
const errorIntegerOutOfRange = "Integer out of Range";
|
|
35
|
+
/**
|
|
36
|
+
* A BinDecoder handles the decoding of an Uint8Array.
|
|
37
|
+
*/
|
|
38
|
+
var BinDecoder = class {
|
|
39
|
+
/** Decoding target. */
|
|
40
|
+
arr;
|
|
41
|
+
/** Current decoding position. */
|
|
42
|
+
pos;
|
|
43
|
+
constructor(uint8Array) {
|
|
44
|
+
this.arr = uint8Array;
|
|
45
|
+
this.pos = 0;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function createDecoder(uint8Array) {
|
|
49
|
+
return new BinDecoder(uint8Array);
|
|
50
|
+
}
|
|
51
|
+
function hasContent(decoder) {
|
|
52
|
+
return decoder.pos !== decoder.arr.length;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Clone a decoder instance.
|
|
56
|
+
* Optionally set a new position parameter.
|
|
57
|
+
*/
|
|
58
|
+
function clone(decoder, newPos = decoder.pos) {
|
|
59
|
+
const _decoder = createDecoder(decoder.arr);
|
|
60
|
+
_decoder.pos = newPos;
|
|
61
|
+
return _decoder;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create an Uint8Array view of the next `len` bytes and advance the position by `len`.
|
|
65
|
+
*
|
|
66
|
+
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
|
67
|
+
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
|
68
|
+
*/
|
|
69
|
+
function readUint8Array(decoder, len) {
|
|
70
|
+
const view = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
71
|
+
decoder.pos += len;
|
|
72
|
+
return view;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Read unsigned integer (32bit) with variable length.
|
|
76
|
+
* 1/8th of the storage is used as encoding overhead.
|
|
77
|
+
* numbers < 2^7 is stored in one bytlength
|
|
78
|
+
* numbers < 2^14 is stored in two bylength
|
|
79
|
+
*/
|
|
80
|
+
function readVarUint(decoder) {
|
|
81
|
+
let num = 0;
|
|
82
|
+
let mult = 1;
|
|
83
|
+
const len = decoder.arr.length;
|
|
84
|
+
while (decoder.pos < len) {
|
|
85
|
+
const r = decoder.arr[decoder.pos++];
|
|
86
|
+
num = num + (r & 127) * mult;
|
|
87
|
+
mult *= 128;
|
|
88
|
+
if (r < 128) return num;
|
|
89
|
+
if (num > Number.MAX_SAFE_INTEGER) throw new Error(errorIntegerOutOfRange);
|
|
90
|
+
}
|
|
91
|
+
throw new Error(errorUnexpectedEndOfArray);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Read variable length Uint8Array.
|
|
95
|
+
*
|
|
96
|
+
* Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.
|
|
97
|
+
* Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
|
|
98
|
+
*/
|
|
99
|
+
function readVarUint8Array(decoder) {
|
|
100
|
+
return readUint8Array(decoder, readVarUint(decoder));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Read the rest of the content as an ArrayBuffer
|
|
104
|
+
*/
|
|
105
|
+
function readTailAsUint8Array(decoder) {
|
|
106
|
+
return readUint8Array(decoder, decoder.arr.length - decoder.pos);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Skip one byte, jump to the next position.
|
|
110
|
+
*/
|
|
111
|
+
function skip8(decoder) {
|
|
112
|
+
return decoder.pos++;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Read one byte as unsigned integer.
|
|
116
|
+
*/
|
|
117
|
+
function readUint8(decoder) {
|
|
118
|
+
return decoder.arr[decoder.pos++];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Read 2 bytes as unsigned integer.
|
|
122
|
+
*/
|
|
123
|
+
function readUint16(decoder) {
|
|
124
|
+
const uint = decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8);
|
|
125
|
+
decoder.pos += 2;
|
|
126
|
+
return uint;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Read 4 bytes as unsigned integer.
|
|
130
|
+
*/
|
|
131
|
+
function readUint32(decoder) {
|
|
132
|
+
const uint = decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8) + (decoder.arr[decoder.pos + 2] << 16) + (decoder.arr[decoder.pos + 3] << 24) >>> 0;
|
|
133
|
+
decoder.pos += 4;
|
|
134
|
+
return uint;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Read 4 bytes as unsigned integer in big endian order.
|
|
138
|
+
* (most significant byte first)
|
|
139
|
+
*/
|
|
140
|
+
function readUint32BigEndian(decoder) {
|
|
141
|
+
const uint = decoder.arr[decoder.pos + 3] + (decoder.arr[decoder.pos + 2] << 8) + (decoder.arr[decoder.pos + 1] << 16) + (decoder.arr[decoder.pos] << 24) >>> 0;
|
|
142
|
+
decoder.pos += 4;
|
|
143
|
+
return uint;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Look ahead without incrementing the position
|
|
147
|
+
* to the next byte and read it as unsigned integer.
|
|
148
|
+
*/
|
|
149
|
+
function peekUint8(decoder) {
|
|
150
|
+
return decoder.arr[decoder.pos];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Look ahead without incrementing the position
|
|
154
|
+
* to the next byte and read it as unsigned integer.
|
|
155
|
+
*/
|
|
156
|
+
function peekUint16(decoder) {
|
|
157
|
+
return decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Look ahead without incrementing the position
|
|
161
|
+
* to the next byte and read it as unsigned integer.
|
|
162
|
+
*/
|
|
163
|
+
function peekUint32(decoder) {
|
|
164
|
+
return decoder.arr[decoder.pos] + (decoder.arr[decoder.pos + 1] << 8) + (decoder.arr[decoder.pos + 2] << 16) + (decoder.arr[decoder.pos + 3] << 24) >>> 0;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Read signed integer (32bit) with variable length.
|
|
168
|
+
* 1/8th of the storage is used as encoding overhead.
|
|
169
|
+
* numbers < 2^7 is stored in one bytlength
|
|
170
|
+
* numbers < 2^14 is stored in two bylength
|
|
171
|
+
* @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.
|
|
172
|
+
*/
|
|
173
|
+
function readVarInt(decoder) {
|
|
174
|
+
let r = decoder.arr[decoder.pos++];
|
|
175
|
+
let num = r & 63;
|
|
176
|
+
let mult = 64;
|
|
177
|
+
const sign = (r & 64) > 0 ? -1 : 1;
|
|
178
|
+
if ((r & 128) === 0) return sign * num;
|
|
179
|
+
const len = decoder.arr.length;
|
|
180
|
+
while (decoder.pos < len) {
|
|
181
|
+
r = decoder.arr[decoder.pos++];
|
|
182
|
+
num = num + (r & 127) * mult;
|
|
183
|
+
mult *= 128;
|
|
184
|
+
if (r < 128) return sign * num;
|
|
185
|
+
if (num > Number.MAX_SAFE_INTEGER) throw new Error(errorIntegerOutOfRange);
|
|
186
|
+
}
|
|
187
|
+
throw new Error(errorUnexpectedEndOfArray);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Look ahead and read varUint without incrementing position
|
|
191
|
+
*/
|
|
192
|
+
function peekVarUint(decoder) {
|
|
193
|
+
const pos = decoder.pos;
|
|
194
|
+
const s = readVarUint(decoder);
|
|
195
|
+
decoder.pos = pos;
|
|
196
|
+
return s;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Look ahead and read varUint without incrementing position
|
|
200
|
+
*/
|
|
201
|
+
function peekVarInt(decoder) {
|
|
202
|
+
const pos = decoder.pos;
|
|
203
|
+
const s = readVarInt(decoder);
|
|
204
|
+
decoder.pos = pos;
|
|
205
|
+
return s;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* We don't test this function anymore as we use native decoding/encoding by default now.
|
|
209
|
+
* Better not modify this anymore..
|
|
210
|
+
*
|
|
211
|
+
* Transforming utf8 to a string is pretty expensive. The code performs 10x better
|
|
212
|
+
* when String.fromCodePoint is fed with all characters as arguments.
|
|
213
|
+
* But most environments have a maximum number of arguments per functions.
|
|
214
|
+
* For effiency reasons we apply a maximum of 10000 characters at once.
|
|
215
|
+
*/
|
|
216
|
+
function _readVarStringPolyfill(decoder) {
|
|
217
|
+
let remainingLen = readVarUint(decoder);
|
|
218
|
+
if (remainingLen === 0) return "";
|
|
219
|
+
else {
|
|
220
|
+
let encodedString = String.fromCodePoint(readUint8(decoder));
|
|
221
|
+
if (--remainingLen < 100) while (remainingLen--) encodedString += String.fromCodePoint(readUint8(decoder));
|
|
222
|
+
else while (remainingLen > 0) {
|
|
223
|
+
const nextLen = remainingLen < 1e4 ? remainingLen : 1e4;
|
|
224
|
+
const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen);
|
|
225
|
+
decoder.pos += nextLen;
|
|
226
|
+
encodedString += String.fromCodePoint(...bytes);
|
|
227
|
+
remainingLen -= nextLen;
|
|
228
|
+
}
|
|
229
|
+
return decodeURIComponent(escape(encodedString));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Read string of variable length
|
|
234
|
+
* varUint is used to store the length of the string
|
|
235
|
+
*/
|
|
236
|
+
function readVarString(decoder) {
|
|
237
|
+
const utf8TextDecoder = getUtf8TextDecoder();
|
|
238
|
+
return utf8TextDecoder ? utf8TextDecoder.decode(readVarUint8Array(decoder)) : _readVarStringPolyfill(decoder);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Look ahead and read varString without incrementing position
|
|
242
|
+
*/
|
|
243
|
+
function peekVarString(decoder) {
|
|
244
|
+
const pos = decoder.pos;
|
|
245
|
+
const s = readVarString(decoder);
|
|
246
|
+
decoder.pos = pos;
|
|
247
|
+
return s;
|
|
248
|
+
}
|
|
249
|
+
function readFromDataView(decoder, len) {
|
|
250
|
+
const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len);
|
|
251
|
+
decoder.pos += len;
|
|
252
|
+
return dv;
|
|
253
|
+
}
|
|
254
|
+
function readFloat32(decoder) {
|
|
255
|
+
return readFromDataView(decoder, 4).getFloat32(0, false);
|
|
256
|
+
}
|
|
257
|
+
function readFloat64(decoder) {
|
|
258
|
+
return readFromDataView(decoder, 8).getFloat64(0, false);
|
|
259
|
+
}
|
|
260
|
+
function readBigInt64(decoder) {
|
|
261
|
+
return readFromDataView(decoder, 8).getBigInt64(0, false);
|
|
262
|
+
}
|
|
263
|
+
function readBigUint64(decoder) {
|
|
264
|
+
return readFromDataView(decoder, 8).getBigUint64(0, false);
|
|
265
|
+
}
|
|
266
|
+
const readAnyLookupTable = [
|
|
267
|
+
(_) => void 0,
|
|
268
|
+
(_) => null,
|
|
269
|
+
readVarInt,
|
|
270
|
+
readFloat32,
|
|
271
|
+
readFloat64,
|
|
272
|
+
readBigInt64,
|
|
273
|
+
(_) => false,
|
|
274
|
+
(_) => true,
|
|
275
|
+
readVarString,
|
|
276
|
+
(decoder) => {
|
|
277
|
+
const len = readVarUint(decoder);
|
|
278
|
+
const obj = {};
|
|
279
|
+
for (let i = 0; i < len; i++) {
|
|
280
|
+
const key = readVarString(decoder);
|
|
281
|
+
obj[key] = readAny(decoder);
|
|
282
|
+
}
|
|
283
|
+
return obj;
|
|
284
|
+
},
|
|
285
|
+
(decoder) => {
|
|
286
|
+
const len = readVarUint(decoder);
|
|
287
|
+
const arr = [];
|
|
288
|
+
for (let i = 0; i < len; i++) arr.push(readAny(decoder));
|
|
289
|
+
return arr;
|
|
290
|
+
},
|
|
291
|
+
readVarUint8Array
|
|
292
|
+
];
|
|
293
|
+
function readAny(decoder) {
|
|
294
|
+
return readAnyLookupTable[127 - readUint8(decoder)](decoder);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
//#endregion
|
|
298
|
+
export { BinDecoder, clone, createDecoder, hasContent, peekUint16, peekUint32, peekUint8, peekVarInt, peekVarString, peekVarUint, readAny, readBigInt64, readBigUint64, readFloat32, readFloat64, readFromDataView, readTailAsUint8Array, readUint16, readUint32, readUint32BigEndian, readUint8, readUint8Array, readVarInt, readVarString, readVarUint, readVarUint8Array, skip8 };
|
|
2
299
|
//# sourceMappingURL=decoding.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoding.mjs","names":[],"sources":["../../../../src/common/bin/lib0/decoding.ts"],"sourcesContent":["/**\n * Original at https://github.com/dmonad/lib0\n *\n * Efficient schema-less binary decoding with support for variable length encoding.\n *\n * Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = new encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = new decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n */\n\nimport { BIT7, BIT8, BITS6, BITS7 } from './binary'\nimport { createUint8ArrayViewFromArrayBuffer } from './create'\nimport { getUtf8TextDecoder } from './string'\n\nconst errorUnexpectedEndOfArray = 'Unexpected end of array'\nconst errorIntegerOutOfRange = 'Integer out of Range'\n\n/**\n * A BinDecoder handles the decoding of an Uint8Array.\n */\nexport class BinDecoder {\n /** Decoding target. */\n arr: Uint8Array\n /** Current decoding position. */\n pos: number\n\n constructor(uint8Array: Uint8Array) {\n this.arr = uint8Array\n this.pos = 0\n }\n}\n\nexport function createDecoder(uint8Array: Uint8Array): BinDecoder {\n return new BinDecoder(uint8Array)\n}\n\nexport function hasContent(decoder: BinDecoder): boolean {\n return decoder.pos !== decoder.arr.length\n}\n\n/**\n * Clone a decoder instance.\n * Optionally set a new position parameter.\n */\nexport function clone(decoder: BinDecoder, newPos: number = decoder.pos): BinDecoder {\n const _decoder = createDecoder(decoder.arr)\n _decoder.pos = newPos\n return _decoder\n}\n\n/**\n * Create an Uint8Array view of the next `len` bytes and advance the position by `len`.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readUint8Array(decoder: BinDecoder, len: number): Uint8Array {\n const view = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)\n decoder.pos += len\n return view\n}\n\n/**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n */\nexport function readVarUint(decoder: BinDecoder): number {\n let num = 0\n let mult = 1\n const len = decoder.arr.length\n while (decoder.pos < len) {\n const r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult // shift $r << (7*#iterations) and add it to num\n mult *= 128 // next iteration, shift 7 \"more\" to the left\n if (r < BIT8)\n return num\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Read variable length Uint8Array.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readVarUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, readVarUint(decoder))\n}\n\n/**\n * Read the rest of the content as an ArrayBuffer\n */\nexport function readTailAsUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, decoder.arr.length - decoder.pos)\n}\n\n/**\n * Skip one byte, jump to the next position.\n */\nexport function skip8(decoder: BinDecoder): number {\n return decoder.pos++\n}\n\n/**\n * Read one byte as unsigned integer.\n */\nexport function readUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos++]\n}\n\n/**\n * Read 2 bytes as unsigned integer.\n */\nexport function readUint16(decoder: BinDecoder): number {\n const uint = decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n decoder.pos += 2\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer.\n */\nexport function readUint32(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer in big endian order.\n * (most significant byte first)\n */\nexport function readUint32BigEndian(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos + 3]\n + (decoder.arr[decoder.pos + 2] << 8)\n + (decoder.arr[decoder.pos + 1] << 16)\n + (decoder.arr[decoder.pos] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint16(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint32(decoder: BinDecoder): number {\n return (\n decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)\n ) >>> 0\n}\n\n/**\n * Read signed integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n * @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.\n */\nexport function readVarInt(decoder: BinDecoder): number {\n let r = decoder.arr[decoder.pos++]\n let num = r & BITS6\n let mult = 64\n const sign = (r & BIT7) > 0 ? -1 : 1 // use Math.sign(?) for performance?\n if ((r & BIT8) === 0) {\n // don't continue reading\n return sign * num\n }\n const len = decoder.arr.length\n while (decoder.pos < len) {\n r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult\n mult *= 128\n if (r < BIT8)\n return sign * num\n\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarUint(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarUint(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarInt(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarInt(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * We don't test this function anymore as we use native decoding/encoding by default now.\n * Better not modify this anymore..\n *\n * Transforming utf8 to a string is pretty expensive. The code performs 10x better\n * when String.fromCodePoint is fed with all characters as arguments.\n * But most environments have a maximum number of arguments per functions.\n * For effiency reasons we apply a maximum of 10000 characters at once.\n */\nfunction _readVarStringPolyfill(decoder: BinDecoder): string {\n let remainingLen = readVarUint(decoder)\n if (remainingLen === 0) {\n return ''\n }\n else {\n let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen\n if (--remainingLen < 100) { // do not create a Uint8Array for small strings\n while (remainingLen--)\n encodedString += String.fromCodePoint(readUint8(decoder))\n }\n else {\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n // this is dangerous, we create a fresh array view from the existing buffer\n const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)\n decoder.pos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint(...bytes as any)\n remainingLen -= nextLen\n }\n }\n return decodeURIComponent(escape(encodedString))\n }\n}\n\n/**\n * Read string of variable length\n * varUint is used to store the length of the string\n */\nexport function readVarString(decoder: BinDecoder): string {\n const utf8TextDecoder = getUtf8TextDecoder()\n return utf8TextDecoder\n ? utf8TextDecoder.decode(readVarUint8Array(decoder))\n : _readVarStringPolyfill(decoder)\n}\n\n/**\n * Look ahead and read varString without incrementing position\n */\nexport function peekVarString(decoder: BinDecoder): string {\n const pos = decoder.pos\n const s = readVarString(decoder)\n decoder.pos = pos\n return s\n}\n\nexport function readFromDataView(decoder: BinDecoder, len: number): DataView {\n const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)\n decoder.pos += len\n return dv\n}\n\nexport function readFloat32(decoder: BinDecoder) {\n return readFromDataView(decoder, 4).getFloat32(0, false)\n}\n\nexport function readFloat64(decoder: BinDecoder) {\n return readFromDataView(decoder, 8).getFloat64(0, false)\n}\n\nexport function readBigInt64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigInt64(0, false)\n}\n\nexport function readBigUint64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigUint64(0, false)\n}\n\nconst readAnyLookupTable: Array<((arg0: BinDecoder) => any)> = [\n _ => undefined, // CASE 127: undefined\n _ => null, // CASE 126: null\n readVarInt, // CASE 125: integer\n readFloat32, // CASE 124: float32\n readFloat64, // CASE 123: float64\n readBigInt64, // CASE 122: bigint\n _ => false, // CASE 121: boolean (false)\n _ => true, // CASE 120: boolean (true)\n readVarString, // CASE 119: string\n (decoder) => { // CASE 118: object<string,any>\n const len = readVarUint(decoder)\n const obj: { [s: string]: any } = {}\n for (let i = 0; i < len; i++) {\n const key = readVarString(decoder)\n obj[key] = readAny(decoder)\n }\n return obj\n },\n (decoder) => { // CASE 117: array<any>\n const len = readVarUint(decoder)\n const arr = []\n for (let i = 0; i < len; i++)\n\n arr.push(readAny(decoder))\n\n return arr\n },\n readVarUint8Array, // CASE 116: Uint8Array\n]\n\nexport function readAny(decoder: BinDecoder) {\n return readAnyLookupTable[127 - readUint8(decoder)](decoder)\n}\n"],"mappings":"0IAgCA,MAAM,EAA4B,0BAC5B,EAAyB,uBAK/B,IAAa,EAAb,KAAwB,CAEtB,IAEA,IAEA,YAAY,EAAwB,CAClC,KAAK,IAAM,EACX,KAAK,IAAM,IAIf,SAAgB,EAAc,EAAoC,CAChE,OAAO,IAAI,EAAW,EAAW,CAGnC,SAAgB,EAAW,EAA8B,CACvD,OAAO,EAAQ,MAAQ,EAAQ,IAAI,OAOrC,SAAgB,EAAM,EAAqB,EAAiB,EAAQ,IAAiB,CACnF,IAAM,EAAW,EAAc,EAAQ,IAA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,GAAO,EAAQ,EAAQ,CAE7B,OAAO,GAER,GAAY,CACX,IAAM,EAAM,EAAY,EAAQ,CAC1B,EAAM,EAAE,CACd,IAAK,IAAI,EAAI,EAAG,EAAI,EAAK,IAEvB,EAAI,KAAK,EAAQ,EAAQ,CAAC,CAE5B,OAAO,GAET,EACD,CAED,SAAgB,EAAQ,EAAqB,CAC3C,OAAO,EAAmB,IAAM,EAAU,EAAQ,EAAE,EAAQ"}
|
|
1
|
+
{"version":3,"file":"decoding.mjs","names":[],"sources":["../../../../src/common/bin/lib0/decoding.ts"],"sourcesContent":["/**\n * Original at https://github.com/dmonad/lib0\n *\n * Efficient schema-less binary decoding with support for variable length encoding.\n *\n * Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = new encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = new decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n */\n\nimport { BIT7, BIT8, BITS6, BITS7 } from './binary'\nimport { createUint8ArrayViewFromArrayBuffer } from './create'\nimport { getUtf8TextDecoder } from './string'\n\nconst errorUnexpectedEndOfArray = 'Unexpected end of array'\nconst errorIntegerOutOfRange = 'Integer out of Range'\n\n/**\n * A BinDecoder handles the decoding of an Uint8Array.\n */\nexport class BinDecoder {\n /** Decoding target. */\n arr: Uint8Array\n /** Current decoding position. */\n pos: number\n\n constructor(uint8Array: Uint8Array) {\n this.arr = uint8Array\n this.pos = 0\n }\n}\n\nexport function createDecoder(uint8Array: Uint8Array): BinDecoder {\n return new BinDecoder(uint8Array)\n}\n\nexport function hasContent(decoder: BinDecoder): boolean {\n return decoder.pos !== decoder.arr.length\n}\n\n/**\n * Clone a decoder instance.\n * Optionally set a new position parameter.\n */\nexport function clone(decoder: BinDecoder, newPos: number = decoder.pos): BinDecoder {\n const _decoder = createDecoder(decoder.arr)\n _decoder.pos = newPos\n return _decoder\n}\n\n/**\n * Create an Uint8Array view of the next `len` bytes and advance the position by `len`.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readUint8Array(decoder: BinDecoder, len: number): Uint8Array {\n const view = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)\n decoder.pos += len\n return view\n}\n\n/**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n */\nexport function readVarUint(decoder: BinDecoder): number {\n let num = 0\n let mult = 1\n const len = decoder.arr.length\n while (decoder.pos < len) {\n const r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult // shift $r << (7*#iterations) and add it to num\n mult *= 128 // next iteration, shift 7 \"more\" to the left\n if (r < BIT8)\n return num\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Read variable length Uint8Array.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n */\nexport function readVarUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, readVarUint(decoder))\n}\n\n/**\n * Read the rest of the content as an ArrayBuffer\n */\nexport function readTailAsUint8Array(decoder: BinDecoder): Uint8Array {\n return readUint8Array(decoder, decoder.arr.length - decoder.pos)\n}\n\n/**\n * Skip one byte, jump to the next position.\n */\nexport function skip8(decoder: BinDecoder): number {\n return decoder.pos++\n}\n\n/**\n * Read one byte as unsigned integer.\n */\nexport function readUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos++]\n}\n\n/**\n * Read 2 bytes as unsigned integer.\n */\nexport function readUint16(decoder: BinDecoder): number {\n const uint = decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n decoder.pos += 2\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer.\n */\nexport function readUint32(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer in big endian order.\n * (most significant byte first)\n */\nexport function readUint32BigEndian(decoder: BinDecoder): number {\n const uint = (decoder.arr[decoder.pos + 3]\n + (decoder.arr[decoder.pos + 2] << 8)\n + (decoder.arr[decoder.pos + 1] << 16)\n + (decoder.arr[decoder.pos] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint8(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint16(decoder: BinDecoder): number {\n return decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n */\nexport function peekUint32(decoder: BinDecoder): number {\n return (\n decoder.arr[decoder.pos]\n + (decoder.arr[decoder.pos + 1] << 8)\n + (decoder.arr[decoder.pos + 2] << 16)\n + (decoder.arr[decoder.pos + 3] << 24)\n ) >>> 0\n}\n\n/**\n * Read signed integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * numbers < 2^7 is stored in one bytlength\n * numbers < 2^14 is stored in two bylength\n * @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.\n */\nexport function readVarInt(decoder: BinDecoder): number {\n let r = decoder.arr[decoder.pos++]\n let num = r & BITS6\n let mult = 64\n const sign = (r & BIT7) > 0 ? -1 : 1 // use Math.sign(?) for performance?\n if ((r & BIT8) === 0) {\n // don't continue reading\n return sign * num\n }\n const len = decoder.arr.length\n while (decoder.pos < len) {\n r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & BITS7) * mult\n mult *= 128\n if (r < BIT8)\n return sign * num\n\n if (num > Number.MAX_SAFE_INTEGER)\n throw new Error(errorIntegerOutOfRange)\n }\n throw new Error(errorUnexpectedEndOfArray)\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarUint(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarUint(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n */\nexport function peekVarInt(decoder: BinDecoder): number {\n const pos = decoder.pos\n const s = readVarInt(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * We don't test this function anymore as we use native decoding/encoding by default now.\n * Better not modify this anymore..\n *\n * Transforming utf8 to a string is pretty expensive. The code performs 10x better\n * when String.fromCodePoint is fed with all characters as arguments.\n * But most environments have a maximum number of arguments per functions.\n * For effiency reasons we apply a maximum of 10000 characters at once.\n */\nfunction _readVarStringPolyfill(decoder: BinDecoder): string {\n let remainingLen = readVarUint(decoder)\n if (remainingLen === 0) {\n return ''\n }\n else {\n let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen\n if (--remainingLen < 100) { // do not create a Uint8Array for small strings\n while (remainingLen--)\n encodedString += String.fromCodePoint(readUint8(decoder))\n }\n else {\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n // this is dangerous, we create a fresh array view from the existing buffer\n const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)\n decoder.pos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint(...bytes as any)\n remainingLen -= nextLen\n }\n }\n return decodeURIComponent(escape(encodedString))\n }\n}\n\n/**\n * Read string of variable length\n * varUint is used to store the length of the string\n */\nexport function readVarString(decoder: BinDecoder): string {\n const utf8TextDecoder = getUtf8TextDecoder()\n return utf8TextDecoder\n ? utf8TextDecoder.decode(readVarUint8Array(decoder))\n : _readVarStringPolyfill(decoder)\n}\n\n/**\n * Look ahead and read varString without incrementing position\n */\nexport function peekVarString(decoder: BinDecoder): string {\n const pos = decoder.pos\n const s = readVarString(decoder)\n decoder.pos = pos\n return s\n}\n\nexport function readFromDataView(decoder: BinDecoder, len: number): DataView {\n const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)\n decoder.pos += len\n return dv\n}\n\nexport function readFloat32(decoder: BinDecoder) {\n return readFromDataView(decoder, 4).getFloat32(0, false)\n}\n\nexport function readFloat64(decoder: BinDecoder) {\n return readFromDataView(decoder, 8).getFloat64(0, false)\n}\n\nexport function readBigInt64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigInt64(0, false)\n}\n\nexport function readBigUint64(decoder: BinDecoder) {\n return (readFromDataView(decoder, 8)).getBigUint64(0, false)\n}\n\nconst readAnyLookupTable: Array<((arg0: BinDecoder) => any)> = [\n _ => undefined, // CASE 127: undefined\n _ => null, // CASE 126: null\n readVarInt, // CASE 125: integer\n readFloat32, // CASE 124: float32\n readFloat64, // CASE 123: float64\n readBigInt64, // CASE 122: bigint\n _ => false, // CASE 121: boolean (false)\n _ => true, // CASE 120: boolean (true)\n readVarString, // CASE 119: string\n (decoder) => { // CASE 118: object<string,any>\n const len = readVarUint(decoder)\n const obj: { [s: string]: any } = {}\n for (let i = 0; i < len; i++) {\n const key = readVarString(decoder)\n obj[key] = readAny(decoder)\n }\n return obj\n },\n (decoder) => { // CASE 117: array<any>\n const len = readVarUint(decoder)\n const arr = []\n for (let i = 0; i < len; i++)\n\n arr.push(readAny(decoder))\n\n return arr\n },\n readVarUint8Array, // CASE 116: Uint8Array\n]\n\nexport function readAny(decoder: BinDecoder) {\n return readAnyLookupTable[127 - readUint8(decoder)](decoder)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAM,4BAA4B;AAClC,MAAM,yBAAyB;;;;AAK/B,IAAa,aAAb,MAAwB;;CAEtB;;CAEA;CAEA,YAAY,YAAwB;AAClC,OAAK,MAAM;AACX,OAAK,MAAM;;;AAIf,SAAgB,cAAc,YAAoC;AAChE,QAAO,IAAI,WAAW,WAAW;;AAGnC,SAAgB,WAAW,SAA8B;AACvD,QAAO,QAAQ,QAAQ,QAAQ,IAAI;;;;;;AAOrC,SAAgB,MAAM,SAAqB,SAAiB,QAAQ,KAAiB;CACnF,MAAM,WAAW,cAAc,QAAQ,IAAI;AAC3C,UAAS,MAAM;AACf,QAAO;;;;;;;;AAST,SAAgB,eAAe,SAAqB,KAAyB;CAC3E,MAAM,OAAO,oCAAoC,QAAQ,IAAI,QAAQ,QAAQ,MAAM,QAAQ,IAAI,YAAY,IAAI;AAC/G,SAAQ,OAAO;AACf,QAAO;;;;;;;;AAST,SAAgB,YAAY,SAA6B;CACvD,IAAI,MAAM;CACV,IAAI,OAAO;CACX,MAAM,MAAM,QAAQ,IAAI;AACxB,QAAO,QAAQ,MAAM,KAAK;EACxB,MAAM,IAAI,QAAQ,IAAI,QAAQ;AAE9B,QAAM,OAAO,WAAa;AAC1B,UAAQ;AACR,MAAI,QACF,QAAO;AACT,MAAI,MAAM,OAAO,iBACf,OAAM,IAAI,MAAM,uBAAuB;;AAE3C,OAAM,IAAI,MAAM,0BAA0B;;;;;;;;AAS5C,SAAgB,kBAAkB,SAAiC;AACjE,QAAO,eAAe,SAAS,YAAY,QAAQ,CAAC;;;;;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