@fireproof/vendor 1.0.3 → 1.1.0-dev
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 +4 -97
- package/src/@web3-storage/pail/dist/src/batch/index.d.ts +1 -53
- 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/@ipld/car/LICENSE +0 -4
- package/src/@ipld/car/README.md +0 -1132
- package/src/@ipld/car/dist/index.min.js +0 -5
- package/src/@ipld/car/dist/src/api.d.ts +0 -72
- package/src/@ipld/car/dist/src/api.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts +0 -67
- package/src/@ipld/car/dist/src/buffer-decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts +0 -116
- package/src/@ipld/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-reader.d.ts +0 -31
- package/src/@ipld/car/dist/src/buffer-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/buffer-writer.d.ts +0 -86
- package/src/@ipld/car/dist/src/buffer-writer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/coding.d.ts +0 -49
- package/src/@ipld/car/dist/src/coding.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder-common.d.ts +0 -43
- package/src/@ipld/car/dist/src/decoder-common.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/decoder.d.ts +0 -87
- package/src/@ipld/car/dist/src/decoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/encoder.d.ts +0 -17
- package/src/@ipld/car/dist/src/encoder.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/header-validator.d.ts +0 -5
- package/src/@ipld/car/dist/src/header-validator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index-browser.d.ts +0 -10
- package/src/@ipld/car/dist/src/index-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/index.d.ts +0 -11
- package/src/@ipld/car/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts +0 -5
- package/src/@ipld/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexed-reader.d.ts +0 -152
- package/src/@ipld/car/dist/src/indexed-reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/indexer.d.ts +0 -95
- package/src/@ipld/car/dist/src/indexer.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator-channel.d.ts +0 -7
- package/src/@ipld/car/dist/src/iterator-channel.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/iterator.d.ts +0 -174
- package/src/@ipld/car/dist/src/iterator.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader-browser.d.ts +0 -151
- package/src/@ipld/car/dist/src/reader-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/reader.d.ts +0 -35
- package/src/@ipld/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer-browser.d.ts +0 -155
- package/src/@ipld/car/dist/src/writer-browser.d.ts.map +0 -1
- package/src/@ipld/car/dist/src/writer.d.ts +0 -45
- package/src/@ipld/car/dist/src/writer.d.ts.map +0 -1
- package/src/@ipld/car/src/api.ts +0 -90
- package/src/@ipld/car/src/buffer-decoder.js +0 -213
- package/src/@ipld/car/src/buffer-reader-browser.js +0 -144
- package/src/@ipld/car/src/buffer-reader.js +0 -51
- package/src/@ipld/car/src/buffer-writer.js +0 -286
- package/src/@ipld/car/src/coding.ts +0 -68
- package/src/@ipld/car/src/decoder-common.js +0 -82
- package/src/@ipld/car/src/decoder.js +0 -347
- package/src/@ipld/car/src/encoder.js +0 -76
- package/src/@ipld/car/src/header-validator.js +0 -214
- package/src/@ipld/car/src/header.ipldsch +0 -18
- package/src/@ipld/car/src/index-browser.js +0 -18
- package/src/@ipld/car/src/index.js +0 -21
- package/src/@ipld/car/src/indexed-reader-browser.js +0 -7
- package/src/@ipld/car/src/indexed-reader.js +0 -211
- package/src/@ipld/car/src/indexer.js +0 -130
- package/src/@ipld/car/src/iterator-channel.js +0 -91
- package/src/@ipld/car/src/iterator.js +0 -267
- package/src/@ipld/car/src/reader-browser.js +0 -194
- package/src/@ipld/car/src/reader.js +0 -73
- package/src/@ipld/car/src/writer-browser.js +0 -250
- package/src/@ipld/car/src/writer.js +0 -84
- package/src/@ipld/dag-cbor/LICENSE +0 -4
- package/src/@ipld/dag-cbor/README.md +0 -80
- package/src/@ipld/dag-cbor/dist/index.min.js +0 -3
- package/src/@ipld/dag-cbor/dist/src/index.d.ts +0 -67
- package/src/@ipld/dag-cbor/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-cbor/src/index.js +0 -147
- package/src/@ipld/dag-json/LICENSE +0 -4
- package/src/@ipld/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dist/index.min.js +0 -3
- package/src/@ipld/dag-json/dist/src/index.d.ts +0 -12
- package/src/@ipld/dag-json/dist/src/index.d.ts.map +0 -1
- package/src/@ipld/dag-json/src/index.js +0 -291
- package/src/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/CHANGELOG.md +0 -513
- package/src/cborg/LICENSE +0 -13
- package/src/cborg/README.md +0 -515
- package/src/cborg/bench/bench.js +0 -117
- package/src/cborg/bench/json.js +0 -124
- package/src/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/bin.js +0 -189
- package/src/cborg/cborg/common.js +0 -28
- package/src/cborg/cborg/decode.js +0 -211
- package/src/cborg/cborg/diagnostic.js +0 -158
- package/src/cborg/cborg/diagnostic_test.js +0 -117
- package/src/cborg/cborg/encode.js +0 -466
- package/src/cborg/cborg/index.js +0 -33
- package/src/cborg/cborg/is.js +0 -106
- package/src/cborg/cborg/length.js +0 -62
- package/src/cborg/example-bytestrings.js +0 -180
- package/src/cborg/example-json.js +0 -6
- package/src/cborg/example.js +0 -5
- package/src/cborg/interface.ts +0 -59
- package/src/cborg/json/decode.js +0 -462
- package/src/cborg/json/encode.js +0 -302
- package/src/cborg/json/json.js +0 -4
- package/src/cborg/taglib.js +0 -75
- package/src/cborg/test/appendix_a.js +0 -647
- package/src/cborg/test/common.js +0 -18
- package/src/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/test/test-0uint.js +0 -103
- package/src/cborg/test/test-1negint.js +0 -96
- package/src/cborg/test/test-2bytes.js +0 -198
- package/src/cborg/test/test-3string.js +0 -136
- package/src/cborg/test/test-4array.js +0 -93
- package/src/cborg/test/test-5map.js +0 -284
- package/src/cborg/test/test-6tag.js +0 -84
- package/src/cborg/test/test-7float.js +0 -131
- package/src/cborg/test/test-bl.js +0 -37
- package/src/cborg/test/test-cbor-vectors.js +0 -107
- package/src/cborg/test/test-decode-errors.js +0 -65
- package/src/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/test/test-json.js +0 -219
- package/src/cborg/test/test-length.js +0 -65
- package/src/cborg/test/test-partial.js +0 -111
- package/src/cborg/tsconfig.json +0 -48
- package/src/cborg/types/cborg/decode.d.ts +0 -43
- package/src/cborg/types/cborg/decode.d.ts.map +0 -1
- package/src/cborg/types/cborg/encode.d.ts +0 -51
- package/src/cborg/types/cborg/encode.d.ts.map +0 -1
- package/src/cborg/types/cborg/index.d.ts +0 -26
- package/src/cborg/types/cborg/index.d.ts.map +0 -1
- package/src/cborg/types/cborg/is.d.ts +0 -6
- package/src/cborg/types/cborg/is.d.ts.map +0 -1
- package/src/cborg/types/example.d.ts +0 -2
- package/src/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/types/interface.d.ts +0 -49
- package/src/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/types/json/decode.d.ts +0 -67
- package/src/cborg/types/json/decode.d.ts.map +0 -1
- package/src/cborg/types/json/encode.d.ts +0 -11
- package/src/cborg/types/json/encode.d.ts.map +0 -1
- package/src/cborg/types/json/json.d.ts +0 -6
- package/src/cborg/types/json/json.d.ts.map +0 -1
- package/src/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/cborg/types/utils/0uint.d.ts +0 -102
- package/src/cborg/types/utils/0uint.d.ts.map +0 -1
- package/src/cborg/types/utils/1negint.d.ts +0 -59
- package/src/cborg/types/utils/1negint.d.ts.map +0 -1
- package/src/cborg/types/utils/2bytes.d.ts +0 -69
- package/src/cborg/types/utils/2bytes.d.ts.map +0 -1
- package/src/cborg/types/utils/3string.d.ts +0 -46
- package/src/cborg/types/utils/3string.d.ts.map +0 -1
- package/src/cborg/types/utils/4array.d.ts +0 -66
- package/src/cborg/types/utils/4array.d.ts.map +0 -1
- package/src/cborg/types/utils/5map.d.ts +0 -66
- package/src/cborg/types/utils/5map.d.ts.map +0 -1
- package/src/cborg/types/utils/6tag.d.ts +0 -62
- package/src/cborg/types/utils/6tag.d.ts.map +0 -1
- package/src/cborg/types/utils/7float.d.ts +0 -60
- package/src/cborg/types/utils/7float.d.ts.map +0 -1
- package/src/cborg/types/utils/bl.d.ts +0 -26
- package/src/cborg/types/utils/bl.d.ts.map +0 -1
- package/src/cborg/types/utils/byte-utils.d.ts +0 -53
- package/src/cborg/types/utils/byte-utils.d.ts.map +0 -1
- package/src/cborg/types/utils/common.d.ts +0 -8
- package/src/cborg/types/utils/common.d.ts.map +0 -1
- package/src/cborg/types/utils/index.d.ts +0 -13
- package/src/cborg/types/utils/index.d.ts.map +0 -1
- package/src/cborg/types/utils/jump.d.ts +0 -16
- package/src/cborg/types/utils/jump.d.ts.map +0 -1
- package/src/cborg/types/utils/token.d.ts +0 -59
- package/src/cborg/types/utils/token.d.ts.map +0 -1
- package/src/cborg/utils/0uint.js +0 -229
- package/src/cborg/utils/1negint.js +0 -111
- package/src/cborg/utils/2bytes.js +0 -135
- package/src/cborg/utils/3string.js +0 -90
- package/src/cborg/utils/4array.js +0 -114
- package/src/cborg/utils/5map.js +0 -113
- package/src/cborg/utils/6tag.js +0 -81
- package/src/cborg/utils/7float.js +0 -310
- package/src/cborg/utils/bl.js +0 -124
- package/src/cborg/utils/byte-utils.js +0 -417
- package/src/cborg/utils/common.js +0 -11
- package/src/cborg/utils/index.js +0 -12
- package/src/cborg/utils/jump.js +0 -222
- package/src/cborg/utils/token.js +0 -76
- package/src/ipfs-unixfs-exporter/LICENSE +0 -4
- package/src/ipfs-unixfs-exporter/README.md +0 -105
- package/src/ipfs-unixfs-exporter/dist/index.min.js +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
- package/src/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
- package/src/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/index.js +0 -197
- package/src/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
- package/src/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
- package/src/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
- package/src/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
- package/src/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
- package/src/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
- package/src/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
- package/src/ipfs-unixfs-exporter/src/errors.ts +0 -87
- package/src/ipfs-unixfs-exporter/src/index.ts +0 -498
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
- package/src/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
- package/src/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
- package/src/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
- package/src/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
- package/src/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
- package/src/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
- package/src/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import { assertEnoughData } from './common.js'
|
|
3
|
-
import * as uint from './0uint.js'
|
|
4
|
-
import { compare, fromString, slice } from './byte-utils.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} prefix
|
|
15
|
-
* @param {number} length
|
|
16
|
-
* @param {string} decodeErrPrefix
|
|
17
|
-
* @returns {Token}
|
|
18
|
-
*/
|
|
19
|
-
function toToken (data, pos, prefix, length, decodeErrPrefix) {
|
|
20
|
-
assertEnoughData(data, pos, prefix + length, decodeErrPrefix)
|
|
21
|
-
const buf = slice(data, pos + prefix, pos + prefix + length)
|
|
22
|
-
return new Token(Type.bytes, buf, prefix + length)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* @param {Uint8Array} data
|
|
27
|
-
* @param {number} pos
|
|
28
|
-
* @param {number} minor
|
|
29
|
-
* @param {DecodeOptions} options
|
|
30
|
-
* @returns {Token}
|
|
31
|
-
*/
|
|
32
|
-
export function decodeBytesCompact (data, pos, minor, options) {
|
|
33
|
-
return toToken(data, pos, 1, minor, options.decodeErrPrefix)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {Uint8Array} data
|
|
38
|
-
* @param {number} pos
|
|
39
|
-
* @param {number} _minor
|
|
40
|
-
* @param {DecodeOptions} options
|
|
41
|
-
* @returns {Token}
|
|
42
|
-
*/
|
|
43
|
-
export function decodeBytes8 (data, pos, _minor, options) {
|
|
44
|
-
return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options), options.decodeErrPrefix)
|
|
45
|
-
}
|
|
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 decodeBytes16 (data, pos, _minor, options) {
|
|
55
|
-
return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options), options.decodeErrPrefix)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @param {Uint8Array} data
|
|
60
|
-
* @param {number} pos
|
|
61
|
-
* @param {number} _minor
|
|
62
|
-
* @param {DecodeOptions} options
|
|
63
|
-
* @returns {Token}
|
|
64
|
-
*/
|
|
65
|
-
export function decodeBytes32 (data, pos, _minor, options) {
|
|
66
|
-
return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options), options.decodeErrPrefix)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// TODO: maybe we shouldn't support this ..
|
|
70
|
-
/**
|
|
71
|
-
* @param {Uint8Array} data
|
|
72
|
-
* @param {number} pos
|
|
73
|
-
* @param {number} _minor
|
|
74
|
-
* @param {DecodeOptions} options
|
|
75
|
-
* @returns {Token}
|
|
76
|
-
*/
|
|
77
|
-
export function decodeBytes64 (data, pos, _minor, options) {
|
|
78
|
-
const l = uint.readUint64(data, pos + 1, options)
|
|
79
|
-
if (typeof l === 'bigint') {
|
|
80
|
-
throw new Error(`${options.decodeErrPrefix} 64-bit integer bytes lengths not supported`)
|
|
81
|
-
}
|
|
82
|
-
return toToken(data, pos, 9, l, options.decodeErrPrefix)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* `encodedBytes` allows for caching when we do a byte version of a string
|
|
87
|
-
* for key sorting purposes
|
|
88
|
-
* @param {Token} token
|
|
89
|
-
* @returns {Uint8Array}
|
|
90
|
-
*/
|
|
91
|
-
function tokenBytes (token) {
|
|
92
|
-
if (token.encodedBytes === undefined) {
|
|
93
|
-
token.encodedBytes = token.type.equals(Type.string) ? fromString(token.value) : token.value
|
|
94
|
-
}
|
|
95
|
-
// @ts-ignore c'mon
|
|
96
|
-
return token.encodedBytes
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* @param {Bl} buf
|
|
101
|
-
* @param {Token} token
|
|
102
|
-
* @param {import('../interface.js').EncodeOptions} options
|
|
103
|
-
*/
|
|
104
|
-
export function encodeBytes (buf, token, { encodeErrPrefix }) {
|
|
105
|
-
const bytes = tokenBytes(token)
|
|
106
|
-
uint.encodeUintValue(buf, token.type.majorEncoded, bytes.length, encodeErrPrefix)
|
|
107
|
-
buf.push(bytes)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* @param {Token} token
|
|
112
|
-
* @returns {number}
|
|
113
|
-
*/
|
|
114
|
-
encodeBytes.encodedSize = function encodedSize (token) {
|
|
115
|
-
const bytes = tokenBytes(token)
|
|
116
|
-
return uint.encodeUintValue.encodedSize(bytes.length) + bytes.length
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @param {Token} tok1
|
|
121
|
-
* @param {Token} tok2
|
|
122
|
-
* @returns {number}
|
|
123
|
-
*/
|
|
124
|
-
encodeBytes.compareTokens = function compareTokens (tok1, tok2) {
|
|
125
|
-
return compareBytes(tokenBytes(tok1), tokenBytes(tok2))
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param {Uint8Array} b1
|
|
130
|
-
* @param {Uint8Array} b2
|
|
131
|
-
* @returns {number}
|
|
132
|
-
*/
|
|
133
|
-
export function compareBytes (b1, b2) {
|
|
134
|
-
return b1.length < b2.length ? -1 : b1.length > b2.length ? 1 : compare(b1, b2)
|
|
135
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import { assertEnoughData } from './common.js'
|
|
3
|
-
import * as uint from './0uint.js'
|
|
4
|
-
import { encodeBytes } from './2bytes.js'
|
|
5
|
-
import { toString, slice } from './byte-utils.js'
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @typedef {import('./bl.js').Bl} Bl
|
|
9
|
-
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @param {Uint8Array} data
|
|
14
|
-
* @param {number} pos
|
|
15
|
-
* @param {number} prefix
|
|
16
|
-
* @param {number} length
|
|
17
|
-
* @param {DecodeOptions} options
|
|
18
|
-
* @returns {Token}
|
|
19
|
-
*/
|
|
20
|
-
function toToken (data, pos, prefix, length, options) {
|
|
21
|
-
const totLength = prefix + length
|
|
22
|
-
assertEnoughData(data, pos, totLength, options.decodeErrPrefix)
|
|
23
|
-
const tok = new Token(Type.string, toString(data, pos + prefix, pos + totLength), totLength)
|
|
24
|
-
if (options.retainStringBytes === true) {
|
|
25
|
-
tok.byteValue = slice(data, pos + prefix, pos + totLength)
|
|
26
|
-
}
|
|
27
|
-
return tok
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @param {Uint8Array} data
|
|
32
|
-
* @param {number} pos
|
|
33
|
-
* @param {number} minor
|
|
34
|
-
* @param {DecodeOptions} options
|
|
35
|
-
* @returns {Token}
|
|
36
|
-
*/
|
|
37
|
-
export function decodeStringCompact (data, pos, minor, options) {
|
|
38
|
-
return toToken(data, pos, 1, minor, options)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {Uint8Array} data
|
|
43
|
-
* @param {number} pos
|
|
44
|
-
* @param {number} _minor
|
|
45
|
-
* @param {DecodeOptions} options
|
|
46
|
-
* @returns {Token}
|
|
47
|
-
*/
|
|
48
|
-
export function decodeString8 (data, pos, _minor, options) {
|
|
49
|
-
return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options), options)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* @param {Uint8Array} data
|
|
54
|
-
* @param {number} pos
|
|
55
|
-
* @param {number} _minor
|
|
56
|
-
* @param {DecodeOptions} options
|
|
57
|
-
* @returns {Token}
|
|
58
|
-
*/
|
|
59
|
-
export function decodeString16 (data, pos, _minor, options) {
|
|
60
|
-
return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options), options)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @param {Uint8Array} data
|
|
65
|
-
* @param {number} pos
|
|
66
|
-
* @param {number} _minor
|
|
67
|
-
* @param {DecodeOptions} options
|
|
68
|
-
* @returns {Token}
|
|
69
|
-
*/
|
|
70
|
-
export function decodeString32 (data, pos, _minor, options) {
|
|
71
|
-
return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options), options)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// TODO: maybe we shouldn't support this ..
|
|
75
|
-
/**
|
|
76
|
-
* @param {Uint8Array} data
|
|
77
|
-
* @param {number} pos
|
|
78
|
-
* @param {number} _minor
|
|
79
|
-
* @param {DecodeOptions} options
|
|
80
|
-
* @returns {Token}
|
|
81
|
-
*/
|
|
82
|
-
export function decodeString64 (data, pos, _minor, options) {
|
|
83
|
-
const l = uint.readUint64(data, pos + 1, options)
|
|
84
|
-
if (typeof l === 'bigint') {
|
|
85
|
-
throw new Error(`${options.decodeErrPrefix} 64-bit integer string lengths not supported`)
|
|
86
|
-
}
|
|
87
|
-
return toToken(data, pos, 9, l, options)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export const encodeString = encodeBytes
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import * as uint from './0uint.js'
|
|
3
|
-
// import { decodeErrPrefix } from '../lib/common.js'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {import('./bl.js').Bl} Bl
|
|
7
|
-
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @param {Uint8Array} _data
|
|
12
|
-
* @param {number} _pos
|
|
13
|
-
* @param {number} prefix
|
|
14
|
-
* @param {number} length
|
|
15
|
-
* @returns {Token}
|
|
16
|
-
*/
|
|
17
|
-
function toToken (_data, _pos, prefix, length) {
|
|
18
|
-
return new Token(Type.array, length, prefix)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* @param {Uint8Array} data
|
|
23
|
-
* @param {number} pos
|
|
24
|
-
* @param {number} minor
|
|
25
|
-
* @param {DecodeOptions} _options
|
|
26
|
-
* @returns {Token}
|
|
27
|
-
*/
|
|
28
|
-
export function decodeArrayCompact (data, pos, minor, _options) {
|
|
29
|
-
return toToken(data, pos, 1, minor)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {Uint8Array} data
|
|
34
|
-
* @param {number} pos
|
|
35
|
-
* @param {number} _minor
|
|
36
|
-
* @param {DecodeOptions} options
|
|
37
|
-
* @returns {Token}
|
|
38
|
-
*/
|
|
39
|
-
export function decodeArray8 (data, pos, _minor, options) {
|
|
40
|
-
return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @param {Uint8Array} data
|
|
45
|
-
* @param {number} pos
|
|
46
|
-
* @param {number} _minor
|
|
47
|
-
* @param {DecodeOptions} options
|
|
48
|
-
* @returns {Token}
|
|
49
|
-
*/
|
|
50
|
-
export function decodeArray16 (data, pos, _minor, options) {
|
|
51
|
-
return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @param {Uint8Array} data
|
|
56
|
-
* @param {number} pos
|
|
57
|
-
* @param {number} _minor
|
|
58
|
-
* @param {DecodeOptions} options
|
|
59
|
-
* @returns {Token}
|
|
60
|
-
*/
|
|
61
|
-
export function decodeArray32 (data, pos, _minor, options) {
|
|
62
|
-
return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// TODO: maybe we shouldn't support this ..
|
|
66
|
-
/**
|
|
67
|
-
* @param {Uint8Array} data
|
|
68
|
-
* @param {number} pos
|
|
69
|
-
* @param {number} _minor
|
|
70
|
-
* @param {DecodeOptions} options
|
|
71
|
-
* @returns {Token}
|
|
72
|
-
*/
|
|
73
|
-
export function decodeArray64 (data, pos, _minor, options) {
|
|
74
|
-
const l = uint.readUint64(data, pos + 1, options)
|
|
75
|
-
if (typeof l === 'bigint') {
|
|
76
|
-
throw new Error(`${options.decodeErrPrefix} 64-bit integer array lengths not supported`)
|
|
77
|
-
}
|
|
78
|
-
return toToken(data, pos, 9, l)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* @param {Uint8Array} data
|
|
83
|
-
* @param {number} pos
|
|
84
|
-
* @param {number} _minor
|
|
85
|
-
* @param {DecodeOptions} options
|
|
86
|
-
* @returns {Token}
|
|
87
|
-
*/
|
|
88
|
-
export function decodeArrayIndefinite (data, pos, _minor, options) {
|
|
89
|
-
if (options.allowIndefinite === false) {
|
|
90
|
-
throw new Error(`${options.decodeErrPrefix} indefinite length items not allowed`)
|
|
91
|
-
}
|
|
92
|
-
return toToken(data, pos, 1, Infinity)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @param {Bl} buf
|
|
97
|
-
* @param {Token} token
|
|
98
|
-
* @param {import('../interface.js').EncodeOptions} options
|
|
99
|
-
*/
|
|
100
|
-
export function encodeArray (buf, token, { encodeErrPrefix }) {
|
|
101
|
-
uint.encodeUintValue(buf, Type.array.majorEncoded, token.value, encodeErrPrefix)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// using an array as a map key, are you sure about this? we can only sort
|
|
105
|
-
// by map length here, it's up to the encoder to decide to look deeper
|
|
106
|
-
encodeArray.compareTokens = uint.encodeUint.compareTokens
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @param {Token} token
|
|
110
|
-
* @returns {number}
|
|
111
|
-
*/
|
|
112
|
-
encodeArray.encodedSize = function encodedSize (token) {
|
|
113
|
-
return uint.encodeUintValue.encodedSize(token.value)
|
|
114
|
-
}
|
package/src/cborg/utils/5map.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import * as uint from './0uint.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {import('./bl.js').Bl} Bl
|
|
6
|
-
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {Uint8Array} _data
|
|
11
|
-
* @param {number} _pos
|
|
12
|
-
* @param {number} prefix
|
|
13
|
-
* @param {number} length
|
|
14
|
-
* @returns {Token}
|
|
15
|
-
*/
|
|
16
|
-
function toToken (_data, _pos, prefix, length) {
|
|
17
|
-
return new Token(Type.map, length, prefix)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @param {Uint8Array} data
|
|
22
|
-
* @param {number} pos
|
|
23
|
-
* @param {number} minor
|
|
24
|
-
* @param {DecodeOptions} _options
|
|
25
|
-
* @returns {Token}
|
|
26
|
-
*/
|
|
27
|
-
export function decodeMapCompact (data, pos, minor, _options) {
|
|
28
|
-
return toToken(data, pos, 1, minor)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {Uint8Array} data
|
|
33
|
-
* @param {number} pos
|
|
34
|
-
* @param {number} _minor
|
|
35
|
-
* @param {DecodeOptions} options
|
|
36
|
-
* @returns {Token}
|
|
37
|
-
*/
|
|
38
|
-
export function decodeMap8 (data, pos, _minor, options) {
|
|
39
|
-
return toToken(data, pos, 2, uint.readUint8(data, pos + 1, options))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {Uint8Array} data
|
|
44
|
-
* @param {number} pos
|
|
45
|
-
* @param {number} _minor
|
|
46
|
-
* @param {DecodeOptions} options
|
|
47
|
-
* @returns {Token}
|
|
48
|
-
*/
|
|
49
|
-
export function decodeMap16 (data, pos, _minor, options) {
|
|
50
|
-
return toToken(data, pos, 3, uint.readUint16(data, pos + 1, options))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param {Uint8Array} data
|
|
55
|
-
* @param {number} pos
|
|
56
|
-
* @param {number} _minor
|
|
57
|
-
* @param {DecodeOptions} options
|
|
58
|
-
* @returns {Token}
|
|
59
|
-
*/
|
|
60
|
-
export function decodeMap32 (data, pos, _minor, options) {
|
|
61
|
-
return toToken(data, pos, 5, uint.readUint32(data, pos + 1, options))
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// TODO: maybe we shouldn't support this ..
|
|
65
|
-
/**
|
|
66
|
-
* @param {Uint8Array} data
|
|
67
|
-
* @param {number} pos
|
|
68
|
-
* @param {number} _minor
|
|
69
|
-
* @param {DecodeOptions} options
|
|
70
|
-
* @returns {Token}
|
|
71
|
-
*/
|
|
72
|
-
export function decodeMap64 (data, pos, _minor, options) {
|
|
73
|
-
const l = uint.readUint64(data, pos + 1, options)
|
|
74
|
-
if (typeof l === 'bigint') {
|
|
75
|
-
throw new Error(`${options.decodeErrPrefix} 64-bit integer map lengths not supported`)
|
|
76
|
-
}
|
|
77
|
-
return toToken(data, pos, 9, l)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* @param {Uint8Array} data
|
|
82
|
-
* @param {number} pos
|
|
83
|
-
* @param {number} _minor
|
|
84
|
-
* @param {DecodeOptions} options
|
|
85
|
-
* @returns {Token}
|
|
86
|
-
*/
|
|
87
|
-
export function decodeMapIndefinite (data, pos, _minor, options) {
|
|
88
|
-
if (options.allowIndefinite === false) {
|
|
89
|
-
throw new Error(`${options.decodeErrPrefix} indefinite length items not allowed`)
|
|
90
|
-
}
|
|
91
|
-
return toToken(data, pos, 1, Infinity)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {Bl} buf
|
|
96
|
-
* @param {Token} token
|
|
97
|
-
* @param {import('../interface.js').EncodeOptions} options
|
|
98
|
-
*/
|
|
99
|
-
export function encodeMap (buf, token, { encodeErrPrefix }) {
|
|
100
|
-
uint.encodeUintValue(buf, Type.map.majorEncoded, token.value, encodeErrPrefix)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// using a map as a map key, are you sure about this? we can only sort
|
|
104
|
-
// by map length here, it's up to the encoder to decide to look deeper
|
|
105
|
-
encodeMap.compareTokens = uint.encodeUint.compareTokens
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* @param {Token} token
|
|
109
|
-
* @returns {number}
|
|
110
|
-
*/
|
|
111
|
-
encodeMap.encodedSize = function encodedSize (token) {
|
|
112
|
-
return uint.encodeUintValue.encodedSize(token.value)
|
|
113
|
-
}
|
package/src/cborg/utils/6tag.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import * as uint from './0uint.js'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @typedef {import('./bl.js').Bl} Bl
|
|
6
|
-
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @param {Uint8Array} _data
|
|
11
|
-
* @param {number} _pos
|
|
12
|
-
* @param {number} minor
|
|
13
|
-
* @param {DecodeOptions} _options
|
|
14
|
-
* @returns {Token}
|
|
15
|
-
*/
|
|
16
|
-
export function decodeTagCompact (_data, _pos, minor, _options) {
|
|
17
|
-
return new Token(Type.tag, minor, 1)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @param {Uint8Array} data
|
|
22
|
-
* @param {number} pos
|
|
23
|
-
* @param {number} _minor
|
|
24
|
-
* @param {DecodeOptions} options
|
|
25
|
-
* @returns {Token}
|
|
26
|
-
*/
|
|
27
|
-
export function decodeTag8 (data, pos, _minor, options) {
|
|
28
|
-
return new Token(Type.tag, uint.readUint8(data, pos + 1, options), 2)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* @param {Uint8Array} data
|
|
33
|
-
* @param {number} pos
|
|
34
|
-
* @param {number} _minor
|
|
35
|
-
* @param {DecodeOptions} options
|
|
36
|
-
* @returns {Token}
|
|
37
|
-
*/
|
|
38
|
-
export function decodeTag16 (data, pos, _minor, options) {
|
|
39
|
-
return new Token(Type.tag, uint.readUint16(data, pos + 1, options), 3)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* @param {Uint8Array} data
|
|
44
|
-
* @param {number} pos
|
|
45
|
-
* @param {number} _minor
|
|
46
|
-
* @param {DecodeOptions} options
|
|
47
|
-
* @returns {Token}
|
|
48
|
-
*/
|
|
49
|
-
export function decodeTag32 (data, pos, _minor, options) {
|
|
50
|
-
return new Token(Type.tag, uint.readUint32(data, pos + 1, options), 5)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* @param {Uint8Array} data
|
|
55
|
-
* @param {number} pos
|
|
56
|
-
* @param {number} _minor
|
|
57
|
-
* @param {DecodeOptions} options
|
|
58
|
-
* @returns {Token}
|
|
59
|
-
*/
|
|
60
|
-
export function decodeTag64 (data, pos, _minor, options) {
|
|
61
|
-
return new Token(Type.tag, uint.readUint64(data, pos + 1, options), 9)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @param {Bl} buf
|
|
66
|
-
* @param {Token} token
|
|
67
|
-
* @param {import('../interface.js').EncodeOptions} options
|
|
68
|
-
*/
|
|
69
|
-
export function encodeTag (buf, token, { encodeErrPrefix }) {
|
|
70
|
-
uint.encodeUintValue(buf, Type.tag.majorEncoded, token.value, encodeErrPrefix)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
encodeTag.compareTokens = uint.encodeUint.compareTokens
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param {Token} token
|
|
77
|
-
* @returns {number}
|
|
78
|
-
*/
|
|
79
|
-
encodeTag.encodedSize = function encodedSize (token) {
|
|
80
|
-
return uint.encodeUintValue.encodedSize(token.value)
|
|
81
|
-
}
|