@fireproof/vendor 1.1.0 → 1.2.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/package.json +97 -4
- package/src/@ipld/car/LICENSE +4 -0
- package/src/@ipld/car/README.md +1132 -0
- package/src/@ipld/car/dist/index.min.js +5 -0
- package/src/@ipld/car/dist/src/api.d.ts +72 -0
- package/src/@ipld/car/dist/src/api.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts +67 -0
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +116 -0
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/buffer-reader.d.ts +31 -0
- package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/buffer-writer.d.ts +86 -0
- package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/coding.d.ts +49 -0
- package/src/@ipld/car/dist/src/coding.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/decoder-common.d.ts +43 -0
- package/src/@ipld/car/dist/src/decoder-common.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/decoder.d.ts +87 -0
- package/src/@ipld/car/dist/src/decoder.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/encoder.d.ts +17 -0
- package/src/@ipld/car/dist/src/encoder.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/header-validator.d.ts +5 -0
- package/src/@ipld/car/dist/src/header-validator.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/index-browser.d.ts +10 -0
- package/src/@ipld/car/dist/src/index-browser.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/index.d.ts +11 -0
- package/src/@ipld/car/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +5 -0
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/indexed-reader.d.ts +152 -0
- package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/indexer.d.ts +95 -0
- package/src/@ipld/car/dist/src/indexer.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/iterator-channel.d.ts +7 -0
- package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/iterator.d.ts +174 -0
- package/src/@ipld/car/dist/src/iterator.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts +28 -0
- package/src/@ipld/car/dist/src/promise-fs-opts.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/reader-browser.d.ts +151 -0
- package/src/@ipld/car/dist/src/reader-browser.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/reader.d.ts +40 -0
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/writer-browser.d.ts +155 -0
- package/src/@ipld/car/dist/src/writer-browser.d.ts.map +1 -0
- package/src/@ipld/car/dist/src/writer.d.ts +45 -0
- package/src/@ipld/car/dist/src/writer.d.ts.map +1 -0
- package/src/@ipld/car/src/api.ts +90 -0
- package/src/@ipld/car/src/buffer-decoder.js +213 -0
- package/src/@ipld/car/src/buffer-reader-browser.js +144 -0
- package/src/@ipld/car/src/buffer-reader.js +51 -0
- package/src/@ipld/car/src/buffer-writer.js +286 -0
- package/src/@ipld/car/src/coding.ts +68 -0
- package/src/@ipld/car/src/decoder-common.js +82 -0
- package/src/@ipld/car/src/decoder.js +347 -0
- package/src/@ipld/car/src/encoder.js +76 -0
- package/src/@ipld/car/src/header-validator.js +214 -0
- package/src/@ipld/car/src/header.ipldsch +18 -0
- package/src/@ipld/car/src/index-browser.js +18 -0
- package/src/@ipld/car/src/index.js +21 -0
- package/src/@ipld/car/src/indexed-reader-browser.js +7 -0
- package/src/@ipld/car/src/indexed-reader.js +211 -0
- package/src/@ipld/car/src/indexer.js +130 -0
- package/src/@ipld/car/src/iterator-channel.js +91 -0
- package/src/@ipld/car/src/iterator.js +267 -0
- package/src/@ipld/car/src/promise-fs-opts.js +46 -0
- package/src/@ipld/car/src/reader-browser.js +194 -0
- package/src/@ipld/car/src/reader.js +54 -0
- package/src/@ipld/car/src/writer-browser.js +250 -0
- package/src/@ipld/car/src/writer.js +81 -0
- package/src/@ipld/dag-cbor/LICENSE +4 -0
- package/src/@ipld/dag-cbor/README.md +80 -0
- package/src/@ipld/dag-cbor/dist/index.min.js +3 -0
- package/src/@ipld/dag-cbor/dist/src/index.d.ts +67 -0
- package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/dag-cbor/src/index.js +147 -0
- package/src/@ipld/dag-json/LICENSE +4 -0
- package/src/@ipld/dag-json/README.md +58 -0
- package/src/@ipld/dag-json/dist/index.min.js +3 -0
- package/src/@ipld/dag-json/dist/src/index.d.ts +12 -0
- package/src/@ipld/dag-json/dist/src/index.d.ts.map +1 -0
- package/src/@ipld/dag-json/src/index.js +291 -0
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts +53 -1
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/batch/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/block.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/block.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/clock/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/batch/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts +2 -2
- package/src/@web3-storage/pail/dist/src/crdt/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/diff.d.ts +3 -3
- package/src/@web3-storage/pail/dist/src/diff.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts +1 -1
- package/src/@web3-storage/pail/dist/src/index.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/merge.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/src/shard.d.ts +4 -4
- package/src/@web3-storage/pail/dist/src/shard.d.ts.map +1 -1
- package/src/@web3-storage/pail/dist/tsconfig.tsbuildinfo +1 -1
- package/src/@web3-storage/pail/src/api.ts +1 -1
- package/src/@web3-storage/pail/src/clock/index.js +1 -1
- package/src/@web3-storage/pail/src/shard.js +1 -1
- package/src/cborg/.github/dependabot.yml +16 -0
- package/src/cborg/.github/workflows/test-and-release.yml +52 -0
- package/src/cborg/CHANGELOG.md +513 -0
- package/src/cborg/LICENSE +13 -0
- package/src/cborg/README.md +515 -0
- package/src/cborg/bench/bench.js +117 -0
- package/src/cborg/bench/json.js +124 -0
- package/src/cborg/bench/package.json +8 -0
- package/src/cborg/cborg/bin.js +189 -0
- package/src/cborg/cborg/common.js +28 -0
- package/src/cborg/cborg/decode.js +211 -0
- package/src/cborg/cborg/diagnostic.js +158 -0
- package/src/cborg/cborg/diagnostic_test.js +117 -0
- package/src/cborg/cborg/encode.js +466 -0
- package/src/cborg/cborg/index.js +33 -0
- package/src/cborg/cborg/is.js +106 -0
- package/src/cborg/cborg/length.js +62 -0
- package/src/cborg/example-bytestrings.js +180 -0
- package/src/cborg/example-json.js +6 -0
- package/src/cborg/example.js +5 -0
- package/src/cborg/interface.ts +59 -0
- package/src/cborg/json/decode.js +462 -0
- package/src/cborg/json/encode.js +302 -0
- package/src/cborg/json/json.js +4 -0
- package/src/cborg/taglib.js +75 -0
- package/src/cborg/test/appendix_a.js +647 -0
- package/src/cborg/test/common.js +18 -0
- package/src/cborg/test/node-test-bin.js +402 -0
- package/src/cborg/test/noop-bin-test.js +3 -0
- package/src/cborg/test/test-0uint.js +103 -0
- package/src/cborg/test/test-1negint.js +96 -0
- package/src/cborg/test/test-2bytes.js +198 -0
- package/src/cborg/test/test-3string.js +136 -0
- package/src/cborg/test/test-4array.js +93 -0
- package/src/cborg/test/test-5map.js +284 -0
- package/src/cborg/test/test-6tag.js +84 -0
- package/src/cborg/test/test-7float.js +131 -0
- package/src/cborg/test/test-bl.js +37 -0
- package/src/cborg/test/test-cbor-vectors.js +107 -0
- package/src/cborg/test/test-decode-errors.js +65 -0
- package/src/cborg/test/test-fuzz.js +42 -0
- package/src/cborg/test/test-json.js +219 -0
- package/src/cborg/test/test-length.js +65 -0
- package/src/cborg/test/test-partial.js +111 -0
- package/src/cborg/tsconfig.json +48 -0
- package/src/cborg/types/cborg/decode.d.ts +43 -0
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/src/cborg/types/cborg/encode.d.ts +51 -0
- package/src/cborg/types/cborg/encode.d.ts.map +1 -0
- package/src/cborg/types/cborg/index.d.ts +26 -0
- package/src/cborg/types/cborg/index.d.ts.map +1 -0
- package/src/cborg/types/cborg/is.d.ts +6 -0
- package/src/cborg/types/cborg/is.d.ts.map +1 -0
- package/src/cborg/types/example.d.ts +2 -0
- package/src/cborg/types/example.d.ts.map +1 -0
- package/src/cborg/types/interface.d.ts +49 -0
- package/src/cborg/types/interface.d.ts.map +1 -0
- package/src/cborg/types/json/decode.d.ts +67 -0
- package/src/cborg/types/json/decode.d.ts.map +1 -0
- package/src/cborg/types/json/encode.d.ts +11 -0
- package/src/cborg/types/json/encode.d.ts.map +1 -0
- package/src/cborg/types/json/json.d.ts +6 -0
- package/src/cborg/types/json/json.d.ts.map +1 -0
- package/src/cborg/types/taglib.d.ts +18 -0
- package/src/cborg/types/taglib.d.ts.map +1 -0
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/src/cborg/types/utils/0uint.d.ts +102 -0
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/src/cborg/types/utils/1negint.d.ts +59 -0
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/types/utils/2bytes.d.ts +69 -0
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/types/utils/3string.d.ts +46 -0
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/src/cborg/types/utils/4array.d.ts +66 -0
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/types/utils/5map.d.ts +66 -0
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/src/cborg/types/utils/6tag.d.ts +62 -0
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/types/utils/7float.d.ts +60 -0
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts +26 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -0
- package/src/cborg/types/utils/byte-utils.d.ts +53 -0
- package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
- package/src/cborg/types/utils/common.d.ts +8 -0
- package/src/cborg/types/utils/common.d.ts.map +1 -0
- package/src/cborg/types/utils/index.d.ts +13 -0
- package/src/cborg/types/utils/index.d.ts.map +1 -0
- package/src/cborg/types/utils/jump.d.ts +16 -0
- package/src/cborg/types/utils/jump.d.ts.map +1 -0
- package/src/cborg/types/utils/token.d.ts +59 -0
- package/src/cborg/types/utils/token.d.ts.map +1 -0
- package/src/cborg/utils/0uint.js +229 -0
- package/src/cborg/utils/1negint.js +111 -0
- package/src/cborg/utils/2bytes.js +135 -0
- package/src/cborg/utils/3string.js +90 -0
- package/src/cborg/utils/4array.js +114 -0
- package/src/cborg/utils/5map.js +113 -0
- package/src/cborg/utils/6tag.js +81 -0
- package/src/cborg/utils/7float.js +310 -0
- package/src/cborg/utils/bl.js +124 -0
- package/src/cborg/utils/byte-utils.js +417 -0
- package/src/cborg/utils/common.js +11 -0
- package/src/cborg/utils/index.js +12 -0
- package/src/cborg/utils/jump.js +222 -0
- package/src/cborg/utils/token.js +76 -0
- package/src/ipfs-unixfs-exporter/LICENSE +4 -0
- package/src/ipfs-unixfs-exporter/README.md +105 -0
- package/src/ipfs-unixfs-exporter/dist/index.min.js +3 -0
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +57 -0
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/errors.js +73 -0
- package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +355 -0
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/index.js +197 -0
- package/src/ipfs-unixfs-exporter/dist/src/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +9 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +9 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +38 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +30 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +9 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +37 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +29 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +153 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +59 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +25 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +104 -0
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +3 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +20 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +6 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +116 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +4 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +57 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +6 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +30 -0
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +1 -0
- package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +58 -0
- package/src/ipfs-unixfs-exporter/src/errors.ts +87 -0
- package/src/ipfs-unixfs-exporter/src/index.ts +498 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +12 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +12 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +49 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +35 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +12 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +49 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +39 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +198 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +76 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +37 -0
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +121 -0
- package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +24 -0
- package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +149 -0
- package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +62 -0
- package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"5map.d.ts","sourceRoot":"","sources":["../../utils/5map.js"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,uCANW,UAAU,OACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,iCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAGD;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAQjB;AAED;;;;;;GAMG;AACH,0CANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAOjB;AAED;;;;GAIG;AACH,+BAJW,EAAE,SACF,KAAK,uBACL,OAAO,iBAAiB,EAAE,aAAa,QAIjD;;;IAMD;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;;iBA5GY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,iBAAiB,EAAE,aAAa;sBALxB,YAAY"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('./bl.js').Bl} Bl
|
|
3
|
+
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @param {Uint8Array} _data
|
|
7
|
+
* @param {number} _pos
|
|
8
|
+
* @param {number} minor
|
|
9
|
+
* @param {DecodeOptions} _options
|
|
10
|
+
* @returns {Token}
|
|
11
|
+
*/
|
|
12
|
+
export function decodeTagCompact(_data: Uint8Array, _pos: number, minor: number, _options: DecodeOptions): Token;
|
|
13
|
+
/**
|
|
14
|
+
* @param {Uint8Array} data
|
|
15
|
+
* @param {number} pos
|
|
16
|
+
* @param {number} _minor
|
|
17
|
+
* @param {DecodeOptions} options
|
|
18
|
+
* @returns {Token}
|
|
19
|
+
*/
|
|
20
|
+
export function decodeTag8(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
21
|
+
/**
|
|
22
|
+
* @param {Uint8Array} data
|
|
23
|
+
* @param {number} pos
|
|
24
|
+
* @param {number} _minor
|
|
25
|
+
* @param {DecodeOptions} options
|
|
26
|
+
* @returns {Token}
|
|
27
|
+
*/
|
|
28
|
+
export function decodeTag16(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
29
|
+
/**
|
|
30
|
+
* @param {Uint8Array} data
|
|
31
|
+
* @param {number} pos
|
|
32
|
+
* @param {number} _minor
|
|
33
|
+
* @param {DecodeOptions} options
|
|
34
|
+
* @returns {Token}
|
|
35
|
+
*/
|
|
36
|
+
export function decodeTag32(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
37
|
+
/**
|
|
38
|
+
* @param {Uint8Array} data
|
|
39
|
+
* @param {number} pos
|
|
40
|
+
* @param {number} _minor
|
|
41
|
+
* @param {DecodeOptions} options
|
|
42
|
+
* @returns {Token}
|
|
43
|
+
*/
|
|
44
|
+
export function decodeTag64(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
45
|
+
/**
|
|
46
|
+
* @param {Bl} buf
|
|
47
|
+
* @param {Token} token
|
|
48
|
+
* @param {import('../interface.js').EncodeOptions} options
|
|
49
|
+
*/
|
|
50
|
+
export function encodeTag(buf: Bl, token: Token, { encodeErrPrefix }: import("../interface.js").EncodeOptions): void;
|
|
51
|
+
export namespace encodeTag {
|
|
52
|
+
let compareTokens: (tok1: Token, tok2: Token) => number;
|
|
53
|
+
/**
|
|
54
|
+
* @param {Token} token
|
|
55
|
+
* @returns {number}
|
|
56
|
+
*/
|
|
57
|
+
function encodedSize(token: Token): number;
|
|
58
|
+
}
|
|
59
|
+
export type Bl = import("./bl.js").Bl;
|
|
60
|
+
export type DecodeOptions = import("../interface.js").DecodeOptions;
|
|
61
|
+
import { Token } from './token.js';
|
|
62
|
+
//# sourceMappingURL=6tag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"6tag.d.ts","sourceRoot":"","sources":["../../utils/6tag.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;;;;;;GAMG;AACH,wCANW,UAAU,QACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,iCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;GAIG;AACH,+BAJW,EAAE,SACF,KAAK,uBACL,OAAO,iBAAiB,EAAE,aAAa,QAIjD;;;IAID;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;;iBA5EY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,iBAAiB,EAAE,aAAa;sBALxB,YAAY"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} _data
|
|
3
|
+
* @param {number} _pos
|
|
4
|
+
* @param {number} _minor
|
|
5
|
+
* @param {DecodeOptions} options
|
|
6
|
+
* @returns {Token}
|
|
7
|
+
*/
|
|
8
|
+
export function decodeUndefined(_data: Uint8Array, _pos: number, _minor: number, options: DecodeOptions): Token;
|
|
9
|
+
/**
|
|
10
|
+
* @param {Uint8Array} _data
|
|
11
|
+
* @param {number} _pos
|
|
12
|
+
* @param {number} _minor
|
|
13
|
+
* @param {DecodeOptions} options
|
|
14
|
+
* @returns {Token}
|
|
15
|
+
*/
|
|
16
|
+
export function decodeBreak(_data: Uint8Array, _pos: number, _minor: number, options: DecodeOptions): Token;
|
|
17
|
+
/**
|
|
18
|
+
* @param {Uint8Array} data
|
|
19
|
+
* @param {number} pos
|
|
20
|
+
* @param {number} _minor
|
|
21
|
+
* @param {DecodeOptions} options
|
|
22
|
+
* @returns {Token}
|
|
23
|
+
*/
|
|
24
|
+
export function decodeFloat16(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
25
|
+
/**
|
|
26
|
+
* @param {Uint8Array} data
|
|
27
|
+
* @param {number} pos
|
|
28
|
+
* @param {number} _minor
|
|
29
|
+
* @param {DecodeOptions} options
|
|
30
|
+
* @returns {Token}
|
|
31
|
+
*/
|
|
32
|
+
export function decodeFloat32(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
33
|
+
/**
|
|
34
|
+
* @param {Uint8Array} data
|
|
35
|
+
* @param {number} pos
|
|
36
|
+
* @param {number} _minor
|
|
37
|
+
* @param {DecodeOptions} options
|
|
38
|
+
* @returns {Token}
|
|
39
|
+
*/
|
|
40
|
+
export function decodeFloat64(data: Uint8Array, pos: number, _minor: number, options: DecodeOptions): Token;
|
|
41
|
+
/**
|
|
42
|
+
* @param {Bl} buf
|
|
43
|
+
* @param {Token} token
|
|
44
|
+
* @param {EncodeOptions} options
|
|
45
|
+
*/
|
|
46
|
+
export function encodeFloat(buf: Bl, token: Token, options: EncodeOptions): void;
|
|
47
|
+
export namespace encodeFloat {
|
|
48
|
+
/**
|
|
49
|
+
* @param {Token} token
|
|
50
|
+
* @param {EncodeOptions} options
|
|
51
|
+
* @returns {number}
|
|
52
|
+
*/
|
|
53
|
+
function encodedSize(token: Token, options: EncodeOptions): number;
|
|
54
|
+
let compareTokens: (tok1: Token, tok2: Token) => number;
|
|
55
|
+
}
|
|
56
|
+
export type Bl = import("./bl.js").Bl;
|
|
57
|
+
export type DecodeOptions = import("../interface.js").DecodeOptions;
|
|
58
|
+
export type EncodeOptions = import("../interface.js").EncodeOptions;
|
|
59
|
+
import { Token } from './token.js';
|
|
60
|
+
//# sourceMappingURL=7float.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"7float.d.ts","sourceRoot":"","sources":["../../utils/7float.js"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,uCANW,UAAU,QACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CASjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,QACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAOjB;AAoBD;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;GAIG;AACH,iCAJW,EAAE,SACF,KAAK,WACL,aAAa,QAwCvB;;IAED;;;;OAIG;IACH,4BAJW,KAAK,WACL,aAAa,GACX,MAAM,CAsBlB;;;iBAjKY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,iBAAiB,EAAE,aAAa;4BACvC,OAAO,iBAAiB,EAAE,aAAa;sBANxB,YAAY"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class Bl {
|
|
2
|
+
/**
|
|
3
|
+
* @param {number} [chunkSize]
|
|
4
|
+
*/
|
|
5
|
+
constructor(chunkSize?: number);
|
|
6
|
+
chunkSize: number;
|
|
7
|
+
/** @type {number} */
|
|
8
|
+
cursor: number;
|
|
9
|
+
/** @type {number} */
|
|
10
|
+
maxCursor: number;
|
|
11
|
+
/** @type {(Uint8Array|number[])[]} */
|
|
12
|
+
chunks: (Uint8Array | number[])[];
|
|
13
|
+
/** @type {Uint8Array|number[]|null} */
|
|
14
|
+
_initReuseChunk: Uint8Array | number[] | null;
|
|
15
|
+
reset(): void;
|
|
16
|
+
/**
|
|
17
|
+
* @param {Uint8Array|number[]} bytes
|
|
18
|
+
*/
|
|
19
|
+
push(bytes: Uint8Array | number[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* @param {boolean} [reset]
|
|
22
|
+
* @returns {Uint8Array}
|
|
23
|
+
*/
|
|
24
|
+
toBytes(reset?: boolean): Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=bl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bl.d.ts","sourceRoot":"","sources":["../../utils/bl.js"],"names":[],"mappings":"AA0BA;IACE;;OAEG;IACH,wBAFW,MAAM,EAahB;IAVC,kBAA0B;IAC1B,qBAAqB;IACrB,QADW,MAAM,CACF;IACf,qBAAqB;IACrB,WADW,MAAM,CACE;IACnB,sCAAsC;IACtC,QADW,CAAC,UAAU,GAAC,MAAM,EAAE,CAAC,EAAE,CAClB;IAEhB,uCAAuC;IACvC,iBADW,UAAU,GAAC,MAAM,EAAE,GAAC,IAAI,CACR;IAG7B,cAUC;IAED;;OAEG;IACH,YAFW,UAAU,GAAC,MAAM,EAAE,QAsC7B;IAED;;;OAGG;IACH,gBAHW,OAAO,GACL,UAAU,CAwBtB;CACF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array|number[]} buf
|
|
3
|
+
* @returns {Uint8Array}
|
|
4
|
+
*/
|
|
5
|
+
export function asU8A(buf: Uint8Array | number[]): Uint8Array;
|
|
6
|
+
/**
|
|
7
|
+
* @param {Uint8Array} b1
|
|
8
|
+
* @param {Uint8Array} b2
|
|
9
|
+
* @returns {number}
|
|
10
|
+
*/
|
|
11
|
+
export function compare(b1: Uint8Array, b2: Uint8Array): number;
|
|
12
|
+
/**
|
|
13
|
+
* @param {number[]} codePoints
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function decodeCodePointsArray(codePoints: number[]): string;
|
|
17
|
+
export const useBuffer: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @param {Uint8Array} bytes
|
|
20
|
+
* @param {number} start
|
|
21
|
+
* @param {number} end
|
|
22
|
+
*/
|
|
23
|
+
export function toString(bytes: Uint8Array, start: number, end: number): string;
|
|
24
|
+
export const fromString: ((string: string) => number[] | Buffer<ArrayBuffer>) | ((string: string) => Uint8Array<ArrayBufferLike> | number[]);
|
|
25
|
+
export function fromArray(arr: number[]): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* @param {Uint8Array} bytes
|
|
28
|
+
* @param {number} start
|
|
29
|
+
* @param {number} end
|
|
30
|
+
*/
|
|
31
|
+
export function slice(bytes: Uint8Array, start: number, end: number): Uint8Array<ArrayBuffer>;
|
|
32
|
+
/**
|
|
33
|
+
* @param {Uint8Array[]} chunks
|
|
34
|
+
* @param {number} length
|
|
35
|
+
* @returns {Uint8Array}
|
|
36
|
+
*/
|
|
37
|
+
export function concat(chunks: Uint8Array[], length: number): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* @param {number} size
|
|
40
|
+
* @returns {Uint8Array}
|
|
41
|
+
*/
|
|
42
|
+
export function alloc(size: number): Uint8Array;
|
|
43
|
+
/**
|
|
44
|
+
* @param {Uint8Array} d
|
|
45
|
+
* @returns {string}
|
|
46
|
+
*/
|
|
47
|
+
export function toHex(d: Uint8Array): string;
|
|
48
|
+
/**
|
|
49
|
+
* @param {string|Uint8Array} hex
|
|
50
|
+
* @returns {Uint8Array}
|
|
51
|
+
*/
|
|
52
|
+
export function fromHex(hex: string | Uint8Array): Uint8Array;
|
|
53
|
+
//# sourceMappingURL=byte-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byte-utils.d.ts","sourceRoot":"","sources":["../../utils/byte-utils.js"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,2BAHW,UAAU,GAAC,MAAM,EAAE,GACjB,UAAU,CAQtB;AA8ND;;;;GAIG;AACH,4BAJW,UAAU,MACV,UAAU,GACR,MAAM,CAgBlB;AAyHD;;;GAGG;AACH,kDAHW,MAAM,EAAE,GACN,MAAM,CAkBlB;AA5ZD,gCAMkD;AA4B9C;;;;GAIG;AACH,gCAJW,UAAU,SACV,MAAM,OACN,MAAM,UAQhB;AAcL,mCAGe,MAAM,iDAYN,MAAM,6CAIhB;AAOE,+BAHI,MAAM,EAAE,GACN,UAAU,CAItB;AAIG;;;;GAIG;AACH,6BAJW,UAAU,SACV,MAAM,OACN,MAAM,2BAOhB;AAcD;;;;GAIG;AACH,+BAJW,UAAU,EAAE,UACZ,MAAM,GACJ,UAAU,CActB;AAwBD;;;GAGG;AACH,4BAHW,MAAM,GACJ,UAAU,CAMtB;AAaD;;;GAGG;AACH,yBAHW,UAAU,GACR,MAAM,CAQlB;AAiBH;;;GAGG;AACD,6BAHS,MAAM,GAAC,UAAU,GACf,UAAU,CAQpB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {Uint8Array} data
|
|
3
|
+
* @param {number} pos
|
|
4
|
+
* @param {number} need
|
|
5
|
+
* @param {string} decodeErrPrefix
|
|
6
|
+
*/
|
|
7
|
+
export function assertEnoughData(data: Uint8Array, pos: number, need: number, decodeErrPrefix: string): void;
|
|
8
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../utils/common.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,uCALW,UAAU,OACV,MAAM,QACN,MAAM,mBACN,MAAM,QAMhB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./byte-utils.js";
|
|
2
|
+
export * from "./jump.js";
|
|
3
|
+
export { encodeNegint } from "./1negint.js";
|
|
4
|
+
export { encodeBytes } from "./2bytes.js";
|
|
5
|
+
export { encodeString } from "./3string.js";
|
|
6
|
+
export { encodeArray } from "./4array.js";
|
|
7
|
+
export { encodeMap } from "./5map.js";
|
|
8
|
+
export { encodeTag } from "./6tag.js";
|
|
9
|
+
export { encodeFloat } from "./7float.js";
|
|
10
|
+
export { Bl } from "./bl.js";
|
|
11
|
+
export { encodeUint, uintBoundaries } from "./0uint.js";
|
|
12
|
+
export { Token, Type } from "./token.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../utils/index.js"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {string} decodeErrPrefix
|
|
3
|
+
* @return {DecodeFunction[]}
|
|
4
|
+
*/
|
|
5
|
+
export function jump(decodeErrPrefix: string): DecodeFunction[];
|
|
6
|
+
/**
|
|
7
|
+
* @param {Token} token
|
|
8
|
+
* @returns {Uint8Array|undefined}
|
|
9
|
+
*/
|
|
10
|
+
export function quickEncodeToken(token: Token): Uint8Array | undefined;
|
|
11
|
+
/** @type {Token[]} */
|
|
12
|
+
export const quick: Token[];
|
|
13
|
+
export type DecodeOptions = import("../interface.js").DecodeOptions;
|
|
14
|
+
export type DecodeFunction = import("../interface.js").DecodeFunction;
|
|
15
|
+
import { Token } from './token.js';
|
|
16
|
+
//# sourceMappingURL=jump.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../utils/jump.js"],"names":[],"mappings":"AAwCA;;;GAGG;AACH,sCAHW,MAAM,GACL,cAAc,EAAE,CA0G3B;AA2BD;;;GAGG;AACH,wCAHW,KAAK,GACH,UAAU,GAAC,SAAS,CA4ChC;AAvED,sBAAsB;AACtB,oBADW,KAAK,EAAE,CACK;4BA3IV,OAAO,iBAAiB,EAAE,aAAa;6BACvC,OAAO,iBAAiB,EAAE,cAAc;sBAbzB,YAAY"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export class Type {
|
|
2
|
+
/**
|
|
3
|
+
* @param {number} major
|
|
4
|
+
* @param {string} name
|
|
5
|
+
* @param {boolean} terminal
|
|
6
|
+
*/
|
|
7
|
+
constructor(major: number, name: string, terminal: boolean);
|
|
8
|
+
major: number;
|
|
9
|
+
majorEncoded: number;
|
|
10
|
+
name: string;
|
|
11
|
+
terminal: boolean;
|
|
12
|
+
toString(): string;
|
|
13
|
+
/**
|
|
14
|
+
* @param {Type} typ
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
equals(typ: Type): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @param {Type} typ
|
|
20
|
+
* @returns {number}
|
|
21
|
+
*/
|
|
22
|
+
compare(typ: Type): number;
|
|
23
|
+
}
|
|
24
|
+
export namespace Type {
|
|
25
|
+
export let uint: Type;
|
|
26
|
+
export let negint: Type;
|
|
27
|
+
export let bytes: Type;
|
|
28
|
+
export let string: Type;
|
|
29
|
+
export let array: Type;
|
|
30
|
+
export let map: Type;
|
|
31
|
+
export let tag: Type;
|
|
32
|
+
export let float: Type;
|
|
33
|
+
let _false: Type;
|
|
34
|
+
export { _false as false };
|
|
35
|
+
let _true: Type;
|
|
36
|
+
export { _true as true };
|
|
37
|
+
let _null: Type;
|
|
38
|
+
export { _null as null };
|
|
39
|
+
export let undefined: Type;
|
|
40
|
+
let _break: Type;
|
|
41
|
+
export { _break as break };
|
|
42
|
+
}
|
|
43
|
+
export class Token {
|
|
44
|
+
/**
|
|
45
|
+
* @param {Type} type
|
|
46
|
+
* @param {any} [value]
|
|
47
|
+
* @param {number} [encodedLength]
|
|
48
|
+
*/
|
|
49
|
+
constructor(type: Type, value?: any, encodedLength?: number);
|
|
50
|
+
type: Type;
|
|
51
|
+
value: any;
|
|
52
|
+
encodedLength: number | undefined;
|
|
53
|
+
/** @type {Uint8Array|undefined} */
|
|
54
|
+
encodedBytes: Uint8Array | undefined;
|
|
55
|
+
/** @type {Uint8Array|undefined} */
|
|
56
|
+
byteValue: Uint8Array | undefined;
|
|
57
|
+
toString(): string;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=token.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../utils/token.js"],"names":[],"mappings":"AAAA;IACE;;;;OAIG;IACH,mBAJW,MAAM,QACN,MAAM,YACN,OAAO,EAOjB;IAJC,cAAkB;IAClB,qBAA8B;IAC9B,aAAgB;IAChB,kBAAwB;IAI1B,mBAEC;IAED;;;OAGG;IACH,YAHW,IAAI,GACF,OAAO,CAInB;IAED;;;OAGG;IACH,aAHW,IAAI,GACF,MAAM,CAKlB;CACF;;;;;;;;;;;;;;;;;;;;AAmBD;IACE;;;;OAIG;IACH,kBAJW,IAAI,UACJ,GAAG,kBACH,MAAM,EAUhB;IAPC,WAAgB;IAChB,WAAkB;IAClB,kCAAkC;IAClC,mCAAmC;IACnC,cADW,UAAU,GAAC,SAAS,CACF;IAC7B,mCAAmC;IACnC,WADW,UAAU,GAAC,SAAS,CACL;IAI5B,mBAEC;CACF"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/* globals BigInt */
|
|
2
|
+
|
|
3
|
+
import { Token, Type } from './token.js'
|
|
4
|
+
import { assertEnoughData } from './common.js'
|
|
5
|
+
|
|
6
|
+
export const uintBoundaries = [24, 256, 65536, 4294967296, BigInt('18446744073709551616')]
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {import('./bl.js').Bl} Bl
|
|
10
|
+
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {Uint8Array} data
|
|
15
|
+
* @param {number} offset
|
|
16
|
+
* @param {DecodeOptions} options
|
|
17
|
+
* @returns {number}
|
|
18
|
+
*/
|
|
19
|
+
export function readUint8 (data, offset, options) {
|
|
20
|
+
assertEnoughData(data, offset, 1, options.decodeErrPrefix)
|
|
21
|
+
const value = data[offset]
|
|
22
|
+
if (options.strict === true && value < uintBoundaries[0]) {
|
|
23
|
+
throw new Error(`${options.decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)
|
|
24
|
+
}
|
|
25
|
+
return value
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {Uint8Array} data
|
|
30
|
+
* @param {number} offset
|
|
31
|
+
* @param {DecodeOptions} options
|
|
32
|
+
* @returns {number}
|
|
33
|
+
*/
|
|
34
|
+
export function readUint16 (data, offset, options) {
|
|
35
|
+
assertEnoughData(data, offset, 2, options.decodeErrPrefix)
|
|
36
|
+
const value = (data[offset] << 8) | data[offset + 1]
|
|
37
|
+
if (options.strict === true && value < uintBoundaries[1]) {
|
|
38
|
+
throw new Error(`${options.decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)
|
|
39
|
+
}
|
|
40
|
+
return value
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {Uint8Array} data
|
|
45
|
+
* @param {number} offset
|
|
46
|
+
* @param {DecodeOptions} options
|
|
47
|
+
* @returns {number}
|
|
48
|
+
*/
|
|
49
|
+
export function readUint32 (data, offset, options) {
|
|
50
|
+
assertEnoughData(data, offset, 4, options.decodeErrPrefix)
|
|
51
|
+
const value = ((data[offset] * 16777216) /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]
|
|
52
|
+
if (options.strict === true && value < uintBoundaries[2]) {
|
|
53
|
+
throw new Error(`${options.decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)
|
|
54
|
+
}
|
|
55
|
+
return value
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {Uint8Array} data
|
|
60
|
+
* @param {number} offset
|
|
61
|
+
* @param {DecodeOptions} options
|
|
62
|
+
* @returns {number|bigint}
|
|
63
|
+
*/
|
|
64
|
+
export function readUint64 (data, offset, options) {
|
|
65
|
+
// assume BigInt, convert back to Number if within safe range
|
|
66
|
+
assertEnoughData(data, offset, 8, options.decodeErrPrefix)
|
|
67
|
+
const hi = ((data[offset] * 16777216) /* 2 ** 24 */) + (data[offset + 1] << 16) + (data[offset + 2] << 8) + data[offset + 3]
|
|
68
|
+
const lo = ((data[offset + 4] * 16777216) /* 2 ** 24 */) + (data[offset + 5] << 16) + (data[offset + 6] << 8) + data[offset + 7]
|
|
69
|
+
const value = (BigInt(hi) << BigInt(32)) + BigInt(lo)
|
|
70
|
+
if (options.strict === true && value < uintBoundaries[3]) {
|
|
71
|
+
throw new Error(`${options.decodeErrPrefix} integer encoded in more bytes than necessary (strict decode)`)
|
|
72
|
+
}
|
|
73
|
+
if (value <= Number.MAX_SAFE_INTEGER) {
|
|
74
|
+
return Number(value)
|
|
75
|
+
}
|
|
76
|
+
if (options.allowBigInt === true) {
|
|
77
|
+
return value
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`${options.decodeErrPrefix} integers outside of the safe integer range are not supported`)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* not required thanks to quick[] list
|
|
83
|
+
const oneByteTokens = new Array(24).fill(0).map((v, i) => new Token(Type.uint, i, 1))
|
|
84
|
+
export function decodeUintCompact (data, pos, minor, options) {
|
|
85
|
+
return oneByteTokens[minor]
|
|
86
|
+
}
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @param {Uint8Array} data
|
|
91
|
+
* @param {number} pos
|
|
92
|
+
* @param {number} _minor
|
|
93
|
+
* @param {DecodeOptions} options
|
|
94
|
+
* @returns {Token}
|
|
95
|
+
*/
|
|
96
|
+
export function decodeUint8 (data, pos, _minor, options) {
|
|
97
|
+
return new Token(Type.uint, readUint8(data, pos + 1, options), 2)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @param {Uint8Array} data
|
|
102
|
+
* @param {number} pos
|
|
103
|
+
* @param {number} _minor
|
|
104
|
+
* @param {DecodeOptions} options
|
|
105
|
+
* @returns {Token}
|
|
106
|
+
*/
|
|
107
|
+
export function decodeUint16 (data, pos, _minor, options) {
|
|
108
|
+
return new Token(Type.uint, readUint16(data, pos + 1, options), 3)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @param {Uint8Array} data
|
|
113
|
+
* @param {number} pos
|
|
114
|
+
* @param {number} _minor
|
|
115
|
+
* @param {DecodeOptions} options
|
|
116
|
+
* @returns {Token}
|
|
117
|
+
*/
|
|
118
|
+
export function decodeUint32 (data, pos, _minor, options) {
|
|
119
|
+
return new Token(Type.uint, readUint32(data, pos + 1, options), 5)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {Uint8Array} data
|
|
124
|
+
* @param {number} pos
|
|
125
|
+
* @param {number} _minor
|
|
126
|
+
* @param {DecodeOptions} options
|
|
127
|
+
* @returns {Token}
|
|
128
|
+
*/
|
|
129
|
+
export function decodeUint64 (data, pos, _minor, options) {
|
|
130
|
+
return new Token(Type.uint, readUint64(data, pos + 1, options), 9)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @param {Bl} buf
|
|
135
|
+
* @param {Token} token
|
|
136
|
+
* @param {import('../interface.js').EncodeOptions} options
|
|
137
|
+
*/
|
|
138
|
+
export function encodeUint (buf, token, { encodeErrPrefix }) {
|
|
139
|
+
return encodeUintValue(buf, 0, token.value, encodeErrPrefix)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* @param {Bl} buf
|
|
144
|
+
* @param {number} major
|
|
145
|
+
* @param {number|bigint} uint
|
|
146
|
+
* @param {string} decodeErrPrefix
|
|
147
|
+
*/
|
|
148
|
+
export function encodeUintValue (buf, major, uint, decodeErrPrefix) {
|
|
149
|
+
if (uint < uintBoundaries[0]) {
|
|
150
|
+
const nuint = Number(uint)
|
|
151
|
+
// pack into one byte, minor=0, additional=value
|
|
152
|
+
buf.push([major | nuint])
|
|
153
|
+
} else if (uint < uintBoundaries[1]) {
|
|
154
|
+
const nuint = Number(uint)
|
|
155
|
+
// pack into two byte, minor=0, additional=24
|
|
156
|
+
buf.push([major | 24, nuint])
|
|
157
|
+
} else if (uint < uintBoundaries[2]) {
|
|
158
|
+
const nuint = Number(uint)
|
|
159
|
+
// pack into three byte, minor=0, additional=25
|
|
160
|
+
buf.push([major | 25, nuint >>> 8, nuint & 0xff])
|
|
161
|
+
} else if (uint < uintBoundaries[3]) {
|
|
162
|
+
const nuint = Number(uint)
|
|
163
|
+
// pack into five byte, minor=0, additional=26
|
|
164
|
+
buf.push([major | 26, (nuint >>> 24) & 0xff, (nuint >>> 16) & 0xff, (nuint >>> 8) & 0xff, nuint & 0xff])
|
|
165
|
+
} else {
|
|
166
|
+
const buint = BigInt(uint)
|
|
167
|
+
if (buint < uintBoundaries[4]) {
|
|
168
|
+
// pack into nine byte, minor=0, additional=27
|
|
169
|
+
const set = [major | 27, 0, 0, 0, 0, 0, 0, 0]
|
|
170
|
+
// simulate bitwise above 32 bits
|
|
171
|
+
let lo = Number(buint & BigInt(0xffffffff))
|
|
172
|
+
let hi = Number(buint >> BigInt(32) & BigInt(0xffffffff))
|
|
173
|
+
set[8] = lo & 0xff
|
|
174
|
+
lo = lo >> 8
|
|
175
|
+
set[7] = lo & 0xff
|
|
176
|
+
lo = lo >> 8
|
|
177
|
+
set[6] = lo & 0xff
|
|
178
|
+
lo = lo >> 8
|
|
179
|
+
set[5] = lo & 0xff
|
|
180
|
+
set[4] = hi & 0xff
|
|
181
|
+
hi = hi >> 8
|
|
182
|
+
set[3] = hi & 0xff
|
|
183
|
+
hi = hi >> 8
|
|
184
|
+
set[2] = hi & 0xff
|
|
185
|
+
hi = hi >> 8
|
|
186
|
+
set[1] = hi & 0xff
|
|
187
|
+
buf.push(set)
|
|
188
|
+
} else {
|
|
189
|
+
throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* @param {Token} token
|
|
196
|
+
* @returns {number}
|
|
197
|
+
*/
|
|
198
|
+
encodeUint.encodedSize = function encodedSize (token) {
|
|
199
|
+
return encodeUintValue.encodedSize(token.value)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @param {number} uint
|
|
204
|
+
* @returns {number}
|
|
205
|
+
*/
|
|
206
|
+
encodeUintValue.encodedSize = function encodedSize (uint) {
|
|
207
|
+
if (uint < uintBoundaries[0]) {
|
|
208
|
+
return 1
|
|
209
|
+
}
|
|
210
|
+
if (uint < uintBoundaries[1]) {
|
|
211
|
+
return 2
|
|
212
|
+
}
|
|
213
|
+
if (uint < uintBoundaries[2]) {
|
|
214
|
+
return 3
|
|
215
|
+
}
|
|
216
|
+
if (uint < uintBoundaries[3]) {
|
|
217
|
+
return 5
|
|
218
|
+
}
|
|
219
|
+
return 9
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @param {Token} tok1
|
|
224
|
+
* @param {Token} tok2
|
|
225
|
+
* @returns {number}
|
|
226
|
+
*/
|
|
227
|
+
encodeUint.compareTokens = function compareTokens (tok1, tok2) {
|
|
228
|
+
return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : /* c8 ignore next */ 0
|
|
229
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* eslint-env es2020 */
|
|
2
|
+
|
|
3
|
+
import { Token, Type } from './token.js'
|
|
4
|
+
import * as uint from './0uint.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import('./bl.js').Bl} Bl
|
|
8
|
+
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Uint8Array} data
|
|
13
|
+
* @param {number} pos
|
|
14
|
+
* @param {number} _minor
|
|
15
|
+
* @param {DecodeOptions} options
|
|
16
|
+
* @returns {Token}
|
|
17
|
+
*/
|
|
18
|
+
export function decodeNegint8 (data, pos, _minor, options) {
|
|
19
|
+
return new Token(Type.negint, -1 - uint.readUint8(data, pos + 1, options), 2)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param {Uint8Array} data
|
|
24
|
+
* @param {number} pos
|
|
25
|
+
* @param {number} _minor
|
|
26
|
+
* @param {DecodeOptions} options
|
|
27
|
+
* @returns {Token}
|
|
28
|
+
*/
|
|
29
|
+
export function decodeNegint16 (data, pos, _minor, options) {
|
|
30
|
+
return new Token(Type.negint, -1 - uint.readUint16(data, pos + 1, options), 3)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {Uint8Array} data
|
|
35
|
+
* @param {number} pos
|
|
36
|
+
* @param {number} _minor
|
|
37
|
+
* @param {DecodeOptions} options
|
|
38
|
+
* @returns {Token}
|
|
39
|
+
*/
|
|
40
|
+
export function decodeNegint32 (data, pos, _minor, options) {
|
|
41
|
+
return new Token(Type.negint, -1 - uint.readUint32(data, pos + 1, options), 5)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const neg1b = BigInt(-1)
|
|
45
|
+
const pos1b = BigInt(1)
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {Uint8Array} data
|
|
49
|
+
* @param {number} pos
|
|
50
|
+
* @param {number} _minor
|
|
51
|
+
* @param {DecodeOptions} options
|
|
52
|
+
* @returns {Token}
|
|
53
|
+
*/
|
|
54
|
+
export function decodeNegint64 (data, pos, _minor, options) {
|
|
55
|
+
const int = uint.readUint64(data, pos + 1, options)
|
|
56
|
+
if (typeof int !== 'bigint') {
|
|
57
|
+
const value = -1 - int
|
|
58
|
+
if (value >= Number.MIN_SAFE_INTEGER) {
|
|
59
|
+
return new Token(Type.negint, value, 9)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (options.allowBigInt !== true) {
|
|
63
|
+
throw new Error(`${options.decodeErrPrefix} integers outside of the safe integer range are not supported`)
|
|
64
|
+
}
|
|
65
|
+
return new Token(Type.negint, neg1b - BigInt(int), 9)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @param {Bl} buf
|
|
70
|
+
* @param {Token} token
|
|
71
|
+
* @param {import('../interface.js').EncodeOptions} options
|
|
72
|
+
*/
|
|
73
|
+
export function encodeNegint (buf, token, { encodeErrPrefix }) {
|
|
74
|
+
const negint = token.value
|
|
75
|
+
const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))
|
|
76
|
+
uint.encodeUintValue(buf, token.type.majorEncoded, unsigned, encodeErrPrefix)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @param {Token} token
|
|
81
|
+
* @returns {number}
|
|
82
|
+
*/
|
|
83
|
+
encodeNegint.encodedSize = function encodedSize (token) {
|
|
84
|
+
const negint = token.value
|
|
85
|
+
const unsigned = (typeof negint === 'bigint' ? (negint * neg1b - pos1b) : (negint * -1 - 1))
|
|
86
|
+
/* c8 ignore next 4 */
|
|
87
|
+
// handled by quickEncode, we shouldn't get here but it's included for completeness
|
|
88
|
+
if (unsigned < uint.uintBoundaries[0]) {
|
|
89
|
+
return 1
|
|
90
|
+
}
|
|
91
|
+
if (unsigned < uint.uintBoundaries[1]) {
|
|
92
|
+
return 2
|
|
93
|
+
}
|
|
94
|
+
if (unsigned < uint.uintBoundaries[2]) {
|
|
95
|
+
return 3
|
|
96
|
+
}
|
|
97
|
+
if (unsigned < uint.uintBoundaries[3]) {
|
|
98
|
+
return 5
|
|
99
|
+
}
|
|
100
|
+
return 9
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @param {Token} tok1
|
|
105
|
+
* @param {Token} tok2
|
|
106
|
+
* @returns {number}
|
|
107
|
+
*/
|
|
108
|
+
encodeNegint.compareTokens = function compareTokens (tok1, tok2) {
|
|
109
|
+
// opposite of the uint comparison since we store the uint version in bytes
|
|
110
|
+
return tok1.value < tok2.value ? 1 : tok1.value > tok2.value ? -1 : /* c8 ignore next */ 0
|
|
111
|
+
}
|