@fireproof/vendor 0.0.0-smoke → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +155 -8
- package/src/@ipld/car/{car/README.md → README.md} +229 -175
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -0
- package/src/@ipld/car/{car/src → src}/reader.js +19 -2
- package/src/cborg/cborg/{lib/bin.js → bin.js} +2 -2
- package/src/cborg/cborg/common.js +28 -0
- package/{patched/cborg/lib → src/cborg/cborg}/decode.js +24 -22
- package/src/cborg/cborg/{lib/diagnostic.js → diagnostic.js} +6 -4
- package/{patched/cborg/lib → src/cborg/cborg}/diagnostic_test.js +1 -1
- package/src/cborg/cborg/{lib/encode.js → encode.js} +23 -21
- package/{patched/cborg/cborg.js → src/cborg/cborg/index.js} +12 -10
- package/src/cborg/cborg/{lib/length.js → length.js} +3 -2
- package/{patched → src}/cborg/interface.ts +7 -4
- package/src/cborg/{cborg/lib/json → json}/decode.js +25 -25
- package/src/cborg/{cborg/lib/json → json}/encode.js +19 -16
- package/src/cborg/{cborg/package.json → package.json} +15 -11
- package/src/cborg/{cborg/taglib.js → taglib.js} +3 -1
- package/src/cborg/{cborg/test → test}/common.js +1 -1
- package/{patched → src}/cborg/test/noop-bin-test.js +1 -1
- package/{patched → src}/cborg/test/test-0uint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-1negint.js +2 -2
- package/src/cborg/{cborg/test → test}/test-2bytes.js +2 -2
- package/src/cborg/{cborg/test → test}/test-3string.js +2 -2
- package/{patched → src}/cborg/test/test-4array.js +2 -2
- package/{patched → src}/cborg/test/test-5map.js +2 -2
- package/src/cborg/{cborg/test → test}/test-6tag.js +2 -3
- package/{patched → src}/cborg/test/test-7float.js +2 -2
- package/{patched → src}/cborg/test/test-bl.js +1 -1
- package/src/cborg/{cborg/test → test}/test-cbor-vectors.js +2 -2
- package/src/cborg/{cborg/test → test}/test-decode-errors.js +2 -2
- package/{patched → src}/cborg/test/test-fuzz.js +1 -1
- package/src/cborg/{cborg/test → test}/test-json.js +25 -25
- package/{patched → src}/cborg/test/test-length.js +3 -3
- package/src/cborg/{cborg/test → test}/test-partial.js +2 -2
- package/src/cborg/{cborg/tsconfig.json → tsconfig.json} +5 -2
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/decode.d.ts +5 -3
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/cborg}/encode.d.ts +4 -3
- 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.map +1 -0
- package/src/cborg/{cborg/types → types}/interface.d.ts +6 -4
- package/src/cborg/types/interface.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types}/json/decode.d.ts +7 -7
- 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.map +1 -0
- package/{patched → src}/cborg/types/taglib.d.ts +1 -1
- package/{patched → src}/cborg/types/taglib.d.ts.map +1 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/0uint.d.ts +6 -4
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/1negint.d.ts +4 -3
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/2bytes.d.ts +5 -4
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/3string.d.ts +1 -1
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/4array.d.ts +3 -2
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/5map.d.ts +3 -2
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/{patched/cborg/types/lib → src/cborg/types/utils}/6tag.d.ts +4 -3
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/{cborg/types/lib → types/utils}/7float.d.ts +2 -2
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -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.map +1 -0
- package/src/cborg/{cborg/lib → utils}/0uint.js +16 -14
- package/src/cborg/{cborg/lib → utils}/1negint.js +5 -5
- package/src/cborg/{cborg/lib → utils}/2bytes.js +16 -14
- package/src/cborg/{cborg/lib → utils}/3string.js +4 -4
- package/src/cborg/{cborg/lib → utils}/4array.js +7 -6
- package/{patched/cborg/lib → src/cborg/utils}/5map.js +6 -6
- package/{patched/cborg/lib → src/cborg/utils}/6tag.js +4 -3
- package/src/cborg/{cborg/lib → utils}/7float.js +23 -21
- package/{patched/cborg/lib → src/cborg/utils}/bl.js +1 -1
- 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/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
- package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
- package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
- package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
- package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
- package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
- package/patched/@ipld/dag-json/src/index.js +0 -291
- package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
- package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
- package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
- package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
- package/patched/@ipld/dag-json/tsconfig.json +0 -14
- package/patched/cborg/cborg-4.2.7.tgz +0 -0
- package/patched/cborg/example-json.js +0 -6
- package/patched/cborg/example.js +0 -5
- package/patched/cborg/lib/0uint.js +0 -227
- package/patched/cborg/lib/1negint.js +0 -111
- package/patched/cborg/lib/2bytes.js +0 -133
- package/patched/cborg/lib/3string.js +0 -90
- package/patched/cborg/lib/4array.js +0 -113
- package/patched/cborg/lib/7float.js +0 -308
- package/patched/cborg/lib/bin.js +0 -189
- package/patched/cborg/lib/common.js +0 -27
- package/patched/cborg/lib/diagnostic.js +0 -156
- package/patched/cborg/lib/encode.js +0 -464
- package/patched/cborg/lib/json/decode.js +0 -462
- package/patched/cborg/lib/json/encode.js +0 -299
- package/patched/cborg/lib/jump.js +0 -209
- package/patched/cborg/lib/length.js +0 -61
- package/patched/cborg/package.json +0 -169
- package/patched/cborg/pnpm-lock.yaml +0 -6096
- package/patched/cborg/taglib.js +0 -73
- package/patched/cborg/test/common.js +0 -18
- package/patched/cborg/test/test-1negint.js +0 -96
- package/patched/cborg/test/test-2bytes.js +0 -198
- package/patched/cborg/test/test-3string.js +0 -136
- package/patched/cborg/test/test-6tag.js +0 -85
- package/patched/cborg/test/test-cbor-vectors.js +0 -107
- package/patched/cborg/test/test-decode-errors.js +0 -65
- package/patched/cborg/test/test-json.js +0 -219
- package/patched/cborg/test/test-partial.js +0 -111
- package/patched/cborg/tsconfig.json +0 -45
- package/patched/cborg/types/cborg.d.ts +0 -28
- package/patched/cborg/types/cborg.d.ts.map +0 -1
- package/patched/cborg/types/interface.d.ts +0 -47
- package/patched/cborg/types/interface.d.ts.map +0 -1
- package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
- package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
- package/patched/cborg/types/lib/2bytes.d.ts +0 -68
- package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/patched/cborg/types/lib/3string.d.ts +0 -46
- package/patched/cborg/types/lib/3string.d.ts.map +0 -1
- package/patched/cborg/types/lib/4array.d.ts.map +0 -1
- package/patched/cborg/types/lib/5map.d.ts +0 -65
- package/patched/cborg/types/lib/5map.d.ts.map +0 -1
- package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
- package/patched/cborg/types/lib/7float.d.ts +0 -60
- package/patched/cborg/types/lib/7float.d.ts.map +0 -1
- package/patched/cborg/types/lib/bin.d.ts +0 -4
- package/patched/cborg/types/lib/bin.d.ts.map +0 -1
- package/patched/cborg/types/lib/bl.d.ts.map +0 -1
- package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/patched/cborg/types/lib/common.d.ts +0 -10
- package/patched/cborg/types/lib/common.d.ts.map +0 -1
- package/patched/cborg/types/lib/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
- package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/patched/cborg/types/lib/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/is.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/encode.d.ts +0 -11
- package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
- package/patched/cborg/types/lib/jump.d.ts +0 -12
- package/patched/cborg/types/lib/jump.d.ts.map +0 -1
- package/patched/cborg/types/lib/length.d.ts +0 -27
- package/patched/cborg/types/lib/length.d.ts.map +0 -1
- package/patched/cborg/types/lib/token.d.ts.map +0 -1
- package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
- package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/README.md +0 -58
- package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
- package/src/@ipld/dag-json/dag-json/package.json +0 -173
- package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
- package/src/cborg/cborg/.github/dependabot.yml +0 -16
- package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
- package/src/cborg/cborg/CHANGELOG.md +0 -513
- package/src/cborg/cborg/LICENSE +0 -13
- package/src/cborg/cborg/README.md +0 -515
- package/src/cborg/cborg/bench/bench.js +0 -117
- package/src/cborg/cborg/bench/json.js +0 -124
- package/src/cborg/cborg/bench/package.json +0 -8
- package/src/cborg/cborg/cborg.js +0 -31
- package/src/cborg/cborg/example-bytestrings.js +0 -180
- package/src/cborg/cborg/interface.ts +0 -56
- package/src/cborg/cborg/lib/5map.js +0 -113
- package/src/cborg/cborg/lib/6tag.js +0 -80
- package/src/cborg/cborg/lib/bl.js +0 -124
- package/src/cborg/cborg/lib/byte-utils.js +0 -417
- package/src/cborg/cborg/lib/common.js +0 -27
- package/src/cborg/cborg/lib/decode.js +0 -209
- package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
- package/src/cborg/cborg/lib/is.js +0 -106
- package/src/cborg/cborg/lib/json/json.js +0 -4
- package/src/cborg/cborg/lib/jump.js +0 -209
- package/src/cborg/cborg/lib/token.js +0 -76
- package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
- package/src/cborg/cborg/test/appendix_a.js +0 -647
- package/src/cborg/cborg/test/node-test-bin.js +0 -402
- package/src/cborg/cborg/test/noop-bin-test.js +0 -3
- package/src/cborg/cborg/test/test-0uint.js +0 -103
- package/src/cborg/cborg/test/test-4array.js +0 -93
- package/src/cborg/cborg/test/test-5map.js +0 -284
- package/src/cborg/cborg/test/test-7float.js +0 -131
- package/src/cborg/cborg/test/test-bl.js +0 -37
- package/src/cborg/cborg/test/test-fuzz.js +0 -42
- package/src/cborg/cborg/test/test-length.js +0 -65
- package/src/cborg/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/example.d.ts +0 -2
- package/src/cborg/cborg/types/example.d.ts.map +0 -1
- package/src/cborg/cborg/types/interface.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
- package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
- package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
- package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
- package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
- package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
- package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
- package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
- package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/is.d.ts +0 -6
- package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
- package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
- package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/cborg/types/lib/token.d.ts +0 -59
- package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
- package/src/cborg/cborg/types/taglib.d.ts +0 -18
- package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
- package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
- package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
- /package/{patched/@ipld/dag-json → src/@ipld/car}/LICENSE +0 -0
- /package/src/@ipld/car/{car/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/buffer-writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/coding.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder-common.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/decoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/encoder.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/header-validator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexed-reader.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/indexer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator-channel.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/iterator.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/reader.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer-browser.d.ts.map +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts +0 -0
- /package/src/@ipld/car/{car/dist → dist}/src/writer.d.ts.map +0 -0
- /package/src/@ipld/car/{car/package.json → package.json} +0 -0
- /package/src/@ipld/car/{car/src → src}/api.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/buffer-writer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/coding.ts +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder-common.js +0 -0
- /package/src/@ipld/car/{car/src → src}/decoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/encoder.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header-validator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/header.ipldsch +0 -0
- /package/src/@ipld/car/{car/src → src}/index-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/index.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexed-reader.js +0 -0
- /package/src/@ipld/car/{car/src → src}/indexer.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator-channel.js +0 -0
- /package/src/@ipld/car/{car/src → src}/iterator.js +0 -0
- /package/src/@ipld/car/{car/src → src}/reader-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer-browser.js +0 -0
- /package/src/@ipld/car/{car/src → src}/writer.js +0 -0
- /package/src/@ipld/{car/car → dag-cbor}/LICENSE +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/README.md → README.md} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/package.json → package.json} +0 -0
- /package/src/@ipld/dag-cbor/{dag-cbor/src → src}/index.js +0 -0
- /package/src/@ipld/{dag-cbor/dag-cbor → dag-json}/LICENSE +0 -0
- /package/{patched → src}/@ipld/dag-json/README.md +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/index.min.js +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts +0 -0
- /package/src/@ipld/dag-json/{dag-json/dist → dist}/src/index.d.ts.map +0 -0
- /package/{patched → src}/@ipld/dag-json/package.json +0 -0
- /package/src/@ipld/dag-json/{dag-json/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/LICENSE.md → LICENSE.md} +0 -0
- /package/src/@web3-storage/pail/{pail/README.md → README.md} +0 -0
- /package/src/@web3-storage/pail/{pail/cli.js → cli.js} +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/batch/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/block.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/clock/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/api.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/batch/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/crdt/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/diff.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/merge.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/src/shard.d.ts.map +0 -0
- /package/src/@web3-storage/pail/{pail/dist → dist}/tsconfig.tsbuildinfo +0 -0
- /package/src/@web3-storage/pail/{pail/package.json → package.json} +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/batch/shard.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/block.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/clock/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/api.ts +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/batch/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/crdt/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/diff.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/index.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/merge.js +0 -0
- /package/src/@web3-storage/pail/{pail/src → src}/shard.js +0 -0
- /package/{patched → src}/cborg/.github/dependabot.yml +0 -0
- /package/{patched → src}/cborg/.github/workflows/test-and-release.yml +0 -0
- /package/{patched → src}/cborg/CHANGELOG.md +0 -0
- /package/{patched → src}/cborg/LICENSE +0 -0
- /package/{patched → src}/cborg/README.md +0 -0
- /package/{patched → src}/cborg/bench/bench.js +0 -0
- /package/{patched → src}/cborg/bench/json.js +0 -0
- /package/{patched → src}/cborg/bench/package.json +0 -0
- /package/{patched/cborg/lib → src/cborg/cborg}/is.js +0 -0
- /package/{patched → src}/cborg/example-bytestrings.js +0 -0
- /package/src/cborg/{cborg/example-json.js → example-json.js} +0 -0
- /package/src/cborg/{cborg/example.js → example.js} +0 -0
- /package/{patched/cborg/lib → src/cborg}/json/json.js +0 -0
- /package/{patched → src}/cborg/test/appendix_a.js +0 -0
- /package/{patched → src}/cborg/test/node-test-bin.js +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/cborg}/is.d.ts +0 -0
- /package/{patched → src}/cborg/types/example.d.ts +0 -0
- /package/{patched → src}/cborg/types/example.d.ts.map +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types}/json/json.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/bl.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/byte-utils.d.ts +0 -0
- /package/{patched/cborg/types/lib → src/cborg/types/utils}/token.d.ts +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/byte-utils.js +0 -0
- /package/{patched/cborg/lib → src/cborg/utils}/token.js +0 -0
- /package/src/{@ipld/dag-json/dag-json → ipfs-unixfs-exporter}/LICENSE +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/README.md → README.md} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/index.min.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/errors.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-cbor.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/dag-json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/identity.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/json.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/file.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/content/raw.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/resolvers/unixfs-v1/index.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/extract-data-from-block.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/find-cid-in-shard.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/resolve-object-path.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.d.ts.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/src/utils/validate-offset-and-length.js.map +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/dist → dist}/typedoc-urls.json +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/package.json → package.json} +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/errors.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-cbor.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/dag-json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/identity.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/json.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/file.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/content/raw.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/resolvers/unixfs-v1/index.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/extract-data-from-block.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/find-cid-in-shard.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/resolve-object-path.ts +0 -0
- /package/src/ipfs-unixfs-exporter/{ipfs-unixfs-exporter/src → src}/utils/validate-offset-and-length.ts +0 -0
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { garbage } from '@ipld/garbage'
|
|
3
|
-
import { assert } from 'aegir/chai'
|
|
4
|
-
import { bytes, CID } from 'multiformats'
|
|
5
|
-
import { base64 } from 'multiformats/bases/base64'
|
|
6
|
-
import { encode, decode, stringify, parse } from '../src/index.js'
|
|
7
|
-
|
|
8
|
-
const same = assert.deepStrictEqual
|
|
9
|
-
|
|
10
|
-
const recode = (/** @type {Uint8Array} */ byts) => encode(decode(byts))
|
|
11
|
-
|
|
12
|
-
const link = CID.parse('bafyreifepiu23okq5zuyvyhsoiazv2icw2van3s7ko6d3ixl5jx2yj2yhu')
|
|
13
|
-
|
|
14
|
-
describe('basic dag-json', () => {
|
|
15
|
-
it('encode decode', () => {
|
|
16
|
-
const byts = encode({ hello: 'world' })
|
|
17
|
-
same(JSON.parse(bytes.toString(recode(byts))), { hello: 'world' })
|
|
18
|
-
const o = { link, byts: bytes.fromString('asdf'), n: null, o: {} }
|
|
19
|
-
const byts2 = encode(o)
|
|
20
|
-
same(decode(byts2), o)
|
|
21
|
-
same(bytes.isBinary(decode(byts2).byts), true)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('encode decode 2', () => {
|
|
25
|
-
// mirrors a go-ipld-prime test, but with sorted keys
|
|
26
|
-
const obj = { plain: 'olde string', bytes: utf8Encode('deadbeef') }
|
|
27
|
-
const expected = '{"bytes":{"/":{"bytes":"ZGVhZGJlZWY"}},"plain":"olde string"}'
|
|
28
|
-
const byts = encode(obj)
|
|
29
|
-
same(JSON.parse(bytes.toString(recode(byts))), JSON.parse(expected))
|
|
30
|
-
same(bytes.toString(recode(byts)), expected)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it('encode decode with ArrayBuffer', () => {
|
|
34
|
-
const byts = encode({ hello: 'world' })
|
|
35
|
-
same(JSON.parse(bytes.toString(recode(byts))), { hello: 'world' })
|
|
36
|
-
const o = { link, byts: bytes.fromString('asdf'), n: null, o: {} }
|
|
37
|
-
const byts2 = encode(o)
|
|
38
|
-
same(decode(byts2), o)
|
|
39
|
-
same(bytes.isBinary(decode(byts2).byts.buffer), true)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
describe('reserved space', () => {
|
|
43
|
-
it('allow alternative types', () => {
|
|
44
|
-
// wrong types
|
|
45
|
-
for (const obj of [true, false, null, 1, -1, 1.1, { blip: 'bop' }, ['foo']]) {
|
|
46
|
-
same(decode(encode({ '/': obj })), { '/': obj })
|
|
47
|
-
same(decode(encode({ '/': { bytes: obj } })), { '/': { bytes: obj } })
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('allow specials within reserved space', () => {
|
|
52
|
-
// can we put slash-objects within slashes?
|
|
53
|
-
same(decode(encode({ '/': bytes.fromString('asdf') })), { '/': bytes.fromString('asdf') })
|
|
54
|
-
same(new TextDecoder().decode(encode({ '/': bytes.fromString('asdf') })), '{"/":{"/":{"bytes":"YXNkZg"}}}')
|
|
55
|
-
same(decode(encode({ '/': link })), { '/': link })
|
|
56
|
-
same(new TextDecoder().decode(encode({ '/': link })), '{"/":{"/":"bafyreifepiu23okq5zuyvyhsoiazv2icw2van3s7ko6d3ixl5jx2yj2yhu"}}')
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it('disallow extraneous tokens', () => {
|
|
60
|
-
// encode() shouldn't allow this but it currently does
|
|
61
|
-
// https://github.com/ipld/js-dag-json/issues/91 should change this test
|
|
62
|
-
// into two parts, encode and decode
|
|
63
|
-
assert.throws(() => decode(encode({ '/': link.toString(), x: 'bip' })))
|
|
64
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA', x: 'bip' } })))
|
|
65
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA' }, x: 'bip' })))
|
|
66
|
-
assert.throws(() => decode(encode({ '/': { bytes: 'mS7ldeA', x: 'bip' }, bop: 'bip' })))
|
|
67
|
-
})
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
it('native types', () => {
|
|
71
|
-
const flip = (/** @type {any} */ obj) => decode(encode(obj))
|
|
72
|
-
same(flip('test'), 'test')
|
|
73
|
-
same(flip(null), null)
|
|
74
|
-
same(flip(12), 12)
|
|
75
|
-
same(flip(-1), -1)
|
|
76
|
-
same(flip(1.2), 1.2)
|
|
77
|
-
same(flip(true), true)
|
|
78
|
-
same(flip(false), false)
|
|
79
|
-
same(flip([]), [])
|
|
80
|
-
same(flip(['asdf']), ['asdf'])
|
|
81
|
-
same(decode(utf8Encode('10.0')), 10)
|
|
82
|
-
same(decode(utf8Encode('[-10.0, 1.0, 0.0, 100.0]')), [-10, 1, 0, 100])
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
it('stable map key sorting', () => {
|
|
86
|
-
const s1 = bytes.toString(encode({ a: 1, b: 2, bb: 2.2, c: 3, c_: 3.3 }))
|
|
87
|
-
const s2 = bytes.toString(encode({ c_: 3.3, bb: 2.2, b: 2, c: 3, a: 1 }))
|
|
88
|
-
same('{"a":1,"b":2,"bb":2.2,"c":3,"c_":3.3}', s1)
|
|
89
|
-
same('{"a":1,"b":2,"bb":2.2,"c":3,"c_":3.3}', s2)
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
it('bigints', () => {
|
|
93
|
-
const verify = (/** @type {number | bigint} **/ inp) => {
|
|
94
|
-
assert.strictEqual(decode(utf8Encode(String(inp))), inp)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// plain Number objects
|
|
98
|
-
verify(0)
|
|
99
|
-
verify(1)
|
|
100
|
-
verify(-1)
|
|
101
|
-
verify(Math.pow(2, 50))
|
|
102
|
-
verify(-Math.pow(2, 50))
|
|
103
|
-
verify(Number.MAX_SAFE_INTEGER)
|
|
104
|
-
verify(-Number.MAX_SAFE_INTEGER)
|
|
105
|
-
// should round-trip as BigInts
|
|
106
|
-
verify(BigInt('9007199254740992')) // Number.MAX_SAFE_INTEGER+1
|
|
107
|
-
verify(BigInt('9007199254740993'))
|
|
108
|
-
verify(BigInt('11959030306112471731'))
|
|
109
|
-
verify(BigInt('18446744073709551615')) // max uint64
|
|
110
|
-
verify(BigInt('9223372036854775807')) // max int64
|
|
111
|
-
verify(BigInt('-9007199254740992'))
|
|
112
|
-
verify(BigInt('-9007199254740993'))
|
|
113
|
-
verify(BigInt('-9223372036854776000')) // min int64
|
|
114
|
-
verify(BigInt('-11959030306112471732'))
|
|
115
|
-
verify(BigInt('-18446744073709551616')) // min -uint64
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
it('error on circular references', () => {
|
|
119
|
-
const circularObj = {}
|
|
120
|
-
circularObj.a = circularObj
|
|
121
|
-
assert.throws(() => encode(circularObj), /object contains circular references/)
|
|
122
|
-
const circularArr = [circularObj]
|
|
123
|
-
circularObj.a = circularArr
|
|
124
|
-
assert.throws(() => encode(circularArr), /object contains circular references/)
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
it('error on encoding undefined', () => {
|
|
128
|
-
assert.throws(() => encode(undefined), /\Wundefined\W.*not supported/)
|
|
129
|
-
const objWithUndefined = { a: 'a', b: undefined }
|
|
130
|
-
assert.throws(() => encode(objWithUndefined), /\Wundefined\W.*not supported/)
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('error on encoding IEEE 754 specials', () => {
|
|
134
|
-
for (const special of [NaN, Infinity, -Infinity]) {
|
|
135
|
-
assert.throws(() => encode(special), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
136
|
-
const objWithSpecial = { a: 'a', b: special }
|
|
137
|
-
assert.throws(() => encode(objWithSpecial), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
138
|
-
const arrWithSpecial = [1, 1.1, -1, -1.1, Number.MAX_SAFE_INTEGER, special, Number.MIN_SAFE_INTEGER]
|
|
139
|
-
assert.throws(() => encode(arrWithSpecial), new RegExp(`\\W${String(special)}\\W.*not supported`))
|
|
140
|
-
}
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it('fuzz serialize and deserialize with garbage', function () {
|
|
144
|
-
// filter out fuzz garbage for objects that are disqualified by DAG-JSON rules
|
|
145
|
-
/** @type {(obj: any) => boolean} */
|
|
146
|
-
const checkObj = (obj) => {
|
|
147
|
-
if (Array.isArray(obj)) {
|
|
148
|
-
return obj.every(checkObj)
|
|
149
|
-
}
|
|
150
|
-
if (obj && typeof obj === 'object') {
|
|
151
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
152
|
-
if (key === '/') {
|
|
153
|
-
if (typeof value === 'string') {
|
|
154
|
-
return false
|
|
155
|
-
}
|
|
156
|
-
if (value && typeof value === 'object' && value.bytes !== undefined) {
|
|
157
|
-
return false
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
if (!checkObj(value)) {
|
|
161
|
-
return false
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return true
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
this.timeout(5000)
|
|
169
|
-
for (let ii = 0; ii < 1000; ii++) {
|
|
170
|
-
const original = garbage(300)
|
|
171
|
-
if (!checkObj(original)) {
|
|
172
|
-
continue
|
|
173
|
-
}
|
|
174
|
-
const encoded = encode(original)
|
|
175
|
-
const decoded = decode(encoded)
|
|
176
|
-
same(decoded, original)
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
it('serialize', () => {
|
|
181
|
-
same(stringify({ hello: 'world' }), JSON.stringify({ hello: 'world' }))
|
|
182
|
-
|
|
183
|
-
const input = { link, bytes: bytes.fromString('asdf'), n: null, o: {} }
|
|
184
|
-
same(stringify(input), JSON.stringify({
|
|
185
|
-
bytes: { '/': { bytes: base64.baseEncode(input.bytes) } },
|
|
186
|
-
link: { '/': link.toString() },
|
|
187
|
-
n: null,
|
|
188
|
-
o: {}
|
|
189
|
-
}))
|
|
190
|
-
|
|
191
|
-
const output = parse(stringify(input))
|
|
192
|
-
same(input, output)
|
|
193
|
-
same(bytes.isBinary(output.bytes), true)
|
|
194
|
-
same(CID.asCID(output.link), output.link)
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
describe('typed arrays', () => {
|
|
198
|
-
// This mirrors what ships by default in dag-cbor: https://github.com/rvagg/cborg/blob/968fdac4af22c9b22fe5b40c2a6f9bb855780a4a/test/test-2bytes.js#L121
|
|
199
|
-
// It's an open question whether this should slip by without error or not,
|
|
200
|
-
// for now we silently convert them to plain bytes and they all round trip
|
|
201
|
-
// as Uint8Arrays.
|
|
202
|
-
const cases = /** @type {{obj: ArrayBufferView, expected: string}[]} */([
|
|
203
|
-
{
|
|
204
|
-
obj: Uint8Array.from([1, 2, 3]),
|
|
205
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
obj: Uint8ClampedArray.from([1, 2, 3]),
|
|
209
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
obj: Uint16Array.from([1, 2, 3]),
|
|
213
|
-
expected: '{"/":{"bytes":"AQACAAMA"}}'
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
obj: Uint32Array.from([1, 2, 3]),
|
|
217
|
-
expected: '{"/":{"bytes":"AQAAAAIAAAADAAAA"}}'
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
obj: Int8Array.from([1, 2, -3]),
|
|
221
|
-
expected: '{"/":{"bytes":"AQL9"}}'
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
obj: Int16Array.from([1, 2, -3]),
|
|
225
|
-
expected: '{"/":{"bytes":"AQACAP3/"}}'
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
obj: Int32Array.from([1, 2, -3]),
|
|
229
|
-
expected: '{"/":{"bytes":"AQAAAAIAAAD9////"}}'
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
obj: Float32Array.from([1, 2, -3]),
|
|
233
|
-
expected: '{"/":{"bytes":"AACAPwAAAEAAAEDA"}}'
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
obj: Float64Array.from([1, 2, -3]),
|
|
237
|
-
expected: '{"/":{"bytes":"AAAAAAAA8D8AAAAAAAAAQAAAAAAAAAjA"}}'
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
obj: BigUint64Array.from([BigInt(1), BigInt(2), BigInt(3)]),
|
|
241
|
-
expected: '{"/":{"bytes":"AQAAAAAAAAACAAAAAAAAAAMAAAAAAAAA"}}'
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
obj: BigInt64Array.from([BigInt(1), BigInt(2), BigInt(-3)]),
|
|
245
|
-
expected: '{"/":{"bytes":"AQAAAAAAAAACAAAAAAAAAP3/////////"}}'
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
obj: new DataView(Uint8Array.from([1, 2, 3]).buffer),
|
|
249
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
obj: Uint8Array.from([1, 2, 3]).buffer,
|
|
253
|
-
expected: '{"/":{"bytes":"AQID"}}'
|
|
254
|
-
}
|
|
255
|
-
])
|
|
256
|
-
|
|
257
|
-
for (const testCase of cases) {
|
|
258
|
-
it(testCase.obj.constructor.name, () => {
|
|
259
|
-
same(utf8Decode(encode(testCase.obj)), testCase.expected)
|
|
260
|
-
const decoded = decode(utf8Encode(testCase.expected))
|
|
261
|
-
assert.instanceOf(decoded, Uint8Array)
|
|
262
|
-
if (testCase.obj instanceof ArrayBuffer) {
|
|
263
|
-
same(decoded, new Uint8Array(testCase.obj))
|
|
264
|
-
} else {
|
|
265
|
-
same(decoded, new Uint8Array(testCase.obj.buffer, testCase.obj.byteOffset, testCase.obj.byteLength))
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
}
|
|
269
|
-
})
|
|
270
|
-
|
|
271
|
-
it('reject duplicate map keys', () => {
|
|
272
|
-
assert.throws(() => decode(utf8Encode('{"foo":1,"foo":2,"bar":3}')), /found repeat map key "foo"/)
|
|
273
|
-
})
|
|
274
|
-
})
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* @param {string} s
|
|
278
|
-
* @returns {Uint8Array}
|
|
279
|
-
*/
|
|
280
|
-
function utf8Encode (s) {
|
|
281
|
-
return new TextEncoder().encode(s)
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
* @param {Uint8Array} b
|
|
286
|
-
* @returns {string}
|
|
287
|
-
*/
|
|
288
|
-
function utf8Decode (b) {
|
|
289
|
-
return new TextDecoder().decode(b)
|
|
290
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { deepStrictEqual } from 'assert'
|
|
2
|
-
|
|
3
|
-
import { BlockEncoder, BlockDecoder, BlockCodec } from 'multiformats/codecs/interface'
|
|
4
|
-
import * as dagJson from '@ipld/dag-json'
|
|
5
|
-
|
|
6
|
-
const main = () => {
|
|
7
|
-
// make sure we have a full CodecFeature
|
|
8
|
-
useCodecFeature(dagJson)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function useCodecFeature (codec: BlockCodec<297, any>) {
|
|
12
|
-
// use only as a BlockEncoder
|
|
13
|
-
useEncoder(codec)
|
|
14
|
-
|
|
15
|
-
// use only as a BlockDecoder
|
|
16
|
-
useDecoder(codec)
|
|
17
|
-
|
|
18
|
-
// use with ArrayBuffer input type
|
|
19
|
-
useDecoderWithArrayBuffer(codec)
|
|
20
|
-
|
|
21
|
-
// use as a full BlockCodec which does both BlockEncoder & BlockDecoder
|
|
22
|
-
useBlockCodec(codec)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function useEncoder<Codec extends number> (encoder: BlockEncoder<Codec, string>) {
|
|
26
|
-
deepStrictEqual(encoder.code, 297)
|
|
27
|
-
deepStrictEqual(encoder.name, 'dag-json')
|
|
28
|
-
deepStrictEqual(Array.from(encoder.encode('blip')), [34, 98, 108, 105, 112, 34])
|
|
29
|
-
console.log('[TS] ✓ { encoder: BlockEncoder }')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function useDecoder<Codec extends number> (decoder: BlockDecoder<Codec, Uint8Array>) {
|
|
33
|
-
deepStrictEqual(decoder.code, 297)
|
|
34
|
-
deepStrictEqual(decoder.decode(Uint8Array.from([34, 98, 108, 105, 112, 34 ])), 'blip')
|
|
35
|
-
console.log('[TS] ✓ { decoder: BlockDecoder }')
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function useDecoderWithArrayBuffer<Codec extends number> (decoder: BlockDecoder<Codec, Uint8Array>) {
|
|
39
|
-
deepStrictEqual(decoder.code, 297)
|
|
40
|
-
deepStrictEqual(decoder.decode(Uint8Array.from([34, 98, 108, 105, 112, 34 ]).buffer), 'blip')
|
|
41
|
-
console.log('[TS] ✓ { decoder: BlockDecoder }')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function useBlockCodec<Codec extends number> (blockCodec: BlockCodec<Codec, string>) {
|
|
45
|
-
deepStrictEqual(blockCodec.code, 297)
|
|
46
|
-
deepStrictEqual(blockCodec.name, 'dag-json')
|
|
47
|
-
deepStrictEqual(Array.from(blockCodec.encode('blip')), [34, 98, 108, 105, 112, 34])
|
|
48
|
-
deepStrictEqual(blockCodec.decode(Uint8Array.from([34, 98, 108, 105, 112, 34])), 'blip')
|
|
49
|
-
console.log('[TS] ✓ {}:BlockCodec')
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
main()
|
|
53
|
-
|
|
54
|
-
export default main
|
|
Binary file
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { encode, decode } from 'cborg/json'
|
|
2
|
-
|
|
3
|
-
const decoded = decode(Buffer.from('7b2274686973223a7b226973223a224a534f4e21222c22796179223a747275657d7d', 'hex'))
|
|
4
|
-
console.log('decoded:', decoded)
|
|
5
|
-
console.log('encoded:', encode(decoded))
|
|
6
|
-
console.log('encoded (string):', Buffer.from(encode(decoded)).toString())
|
package/patched/cborg/example.js
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/* globals BigInt */
|
|
2
|
-
|
|
3
|
-
import { Token, Type } from './token.js'
|
|
4
|
-
import { decodeErrPrefix, 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').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)
|
|
21
|
-
const value = data[offset]
|
|
22
|
-
if (options.strict === true && value < uintBoundaries[0]) {
|
|
23
|
-
throw new Error(`${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)
|
|
36
|
-
const value = (data[offset] << 8) | data[offset + 1]
|
|
37
|
-
if (options.strict === true && value < uintBoundaries[1]) {
|
|
38
|
-
throw new Error(`${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)
|
|
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(`${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)
|
|
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(`${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(`${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
|
-
*/
|
|
137
|
-
export function encodeUint (buf, token) {
|
|
138
|
-
return encodeUintValue(buf, 0, token.value)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* @param {Bl} buf
|
|
143
|
-
* @param {number} major
|
|
144
|
-
* @param {number|bigint} uint
|
|
145
|
-
*/
|
|
146
|
-
export function encodeUintValue (buf, major, uint) {
|
|
147
|
-
if (uint < uintBoundaries[0]) {
|
|
148
|
-
const nuint = Number(uint)
|
|
149
|
-
// pack into one byte, minor=0, additional=value
|
|
150
|
-
buf.push([major | nuint])
|
|
151
|
-
} else if (uint < uintBoundaries[1]) {
|
|
152
|
-
const nuint = Number(uint)
|
|
153
|
-
// pack into two byte, minor=0, additional=24
|
|
154
|
-
buf.push([major | 24, nuint])
|
|
155
|
-
} else if (uint < uintBoundaries[2]) {
|
|
156
|
-
const nuint = Number(uint)
|
|
157
|
-
// pack into three byte, minor=0, additional=25
|
|
158
|
-
buf.push([major | 25, nuint >>> 8, nuint & 0xff])
|
|
159
|
-
} else if (uint < uintBoundaries[3]) {
|
|
160
|
-
const nuint = Number(uint)
|
|
161
|
-
// pack into five byte, minor=0, additional=26
|
|
162
|
-
buf.push([major | 26, (nuint >>> 24) & 0xff, (nuint >>> 16) & 0xff, (nuint >>> 8) & 0xff, nuint & 0xff])
|
|
163
|
-
} else {
|
|
164
|
-
const buint = BigInt(uint)
|
|
165
|
-
if (buint < uintBoundaries[4]) {
|
|
166
|
-
// pack into nine byte, minor=0, additional=27
|
|
167
|
-
const set = [major | 27, 0, 0, 0, 0, 0, 0, 0]
|
|
168
|
-
// simulate bitwise above 32 bits
|
|
169
|
-
let lo = Number(buint & BigInt(0xffffffff))
|
|
170
|
-
let hi = Number(buint >> BigInt(32) & BigInt(0xffffffff))
|
|
171
|
-
set[8] = lo & 0xff
|
|
172
|
-
lo = lo >> 8
|
|
173
|
-
set[7] = lo & 0xff
|
|
174
|
-
lo = lo >> 8
|
|
175
|
-
set[6] = lo & 0xff
|
|
176
|
-
lo = lo >> 8
|
|
177
|
-
set[5] = lo & 0xff
|
|
178
|
-
set[4] = hi & 0xff
|
|
179
|
-
hi = hi >> 8
|
|
180
|
-
set[3] = hi & 0xff
|
|
181
|
-
hi = hi >> 8
|
|
182
|
-
set[2] = hi & 0xff
|
|
183
|
-
hi = hi >> 8
|
|
184
|
-
set[1] = hi & 0xff
|
|
185
|
-
buf.push(set)
|
|
186
|
-
} else {
|
|
187
|
-
throw new Error(`${decodeErrPrefix} encountered BigInt larger than allowable range`)
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @param {Token} token
|
|
194
|
-
* @returns {number}
|
|
195
|
-
*/
|
|
196
|
-
encodeUint.encodedSize = function encodedSize (token) {
|
|
197
|
-
return encodeUintValue.encodedSize(token.value)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param {number} uint
|
|
202
|
-
* @returns {number}
|
|
203
|
-
*/
|
|
204
|
-
encodeUintValue.encodedSize = function encodedSize (uint) {
|
|
205
|
-
if (uint < uintBoundaries[0]) {
|
|
206
|
-
return 1
|
|
207
|
-
}
|
|
208
|
-
if (uint < uintBoundaries[1]) {
|
|
209
|
-
return 2
|
|
210
|
-
}
|
|
211
|
-
if (uint < uintBoundaries[2]) {
|
|
212
|
-
return 3
|
|
213
|
-
}
|
|
214
|
-
if (uint < uintBoundaries[3]) {
|
|
215
|
-
return 5
|
|
216
|
-
}
|
|
217
|
-
return 9
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @param {Token} tok1
|
|
222
|
-
* @param {Token} tok2
|
|
223
|
-
* @returns {number}
|
|
224
|
-
*/
|
|
225
|
-
encodeUint.compareTokens = function compareTokens (tok1, tok2) {
|
|
226
|
-
return tok1.value < tok2.value ? -1 : tok1.value > tok2.value ? 1 : /* c8 ignore next */ 0
|
|
227
|
-
}
|