@fireproof/vendor 0.0.0-smoke → 0.0.2-dev-test

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.
Files changed (489) hide show
  1. package/merge-package.ts +207 -0
  2. package/p-limit/index.d.ts +81 -0
  3. package/p-limit/index.js +104 -0
  4. package/p-limit/index.test-d.ts +19 -0
  5. package/p-limit/license +9 -0
  6. package/p-limit/package.json +59 -0
  7. package/p-limit/readme.md +128 -0
  8. package/p-limit/test.js +241 -0
  9. package/package.json +12 -9
  10. package/to-esm-transform.ts +42 -0
  11. package/patched/@ipld/dag-json/.github/dependabot.yml +0 -11
  12. package/patched/@ipld/dag-json/.github/workflows/js-test-and-release.yml +0 -28
  13. package/patched/@ipld/dag-json/CHANGELOG.md +0 -202
  14. package/patched/@ipld/dag-json/LICENSE +0 -4
  15. package/patched/@ipld/dag-json/LICENSE-APACHE +0 -5
  16. package/patched/@ipld/dag-json/LICENSE-MIT +0 -19
  17. package/patched/@ipld/dag-json/README.md +0 -58
  18. package/patched/@ipld/dag-json/ipld-dag-json-10.2.3.tgz +0 -0
  19. package/patched/@ipld/dag-json/package.json +0 -173
  20. package/patched/@ipld/dag-json/src/index.js +0 -291
  21. package/patched/@ipld/dag-json/test/test-basics.spec.js +0 -290
  22. package/patched/@ipld/dag-json/test/ts-use/package.json +0 -11
  23. package/patched/@ipld/dag-json/test/ts-use/src/main.ts +0 -54
  24. package/patched/@ipld/dag-json/test/ts-use/tsconfig.json +0 -9
  25. package/patched/@ipld/dag-json/tsconfig.json +0 -14
  26. package/patched/cborg/.github/dependabot.yml +0 -16
  27. package/patched/cborg/.github/workflows/test-and-release.yml +0 -52
  28. package/patched/cborg/CHANGELOG.md +0 -513
  29. package/patched/cborg/LICENSE +0 -13
  30. package/patched/cborg/README.md +0 -515
  31. package/patched/cborg/bench/bench.js +0 -117
  32. package/patched/cborg/bench/json.js +0 -124
  33. package/patched/cborg/bench/package.json +0 -8
  34. package/patched/cborg/cborg-4.2.7.tgz +0 -0
  35. package/patched/cborg/cborg.js +0 -31
  36. package/patched/cborg/example-bytestrings.js +0 -180
  37. package/patched/cborg/example-json.js +0 -6
  38. package/patched/cborg/example.js +0 -5
  39. package/patched/cborg/interface.ts +0 -56
  40. package/patched/cborg/lib/0uint.js +0 -227
  41. package/patched/cborg/lib/1negint.js +0 -111
  42. package/patched/cborg/lib/2bytes.js +0 -133
  43. package/patched/cborg/lib/3string.js +0 -90
  44. package/patched/cborg/lib/4array.js +0 -113
  45. package/patched/cborg/lib/5map.js +0 -113
  46. package/patched/cborg/lib/6tag.js +0 -80
  47. package/patched/cborg/lib/7float.js +0 -308
  48. package/patched/cborg/lib/bin.js +0 -189
  49. package/patched/cborg/lib/bl.js +0 -124
  50. package/patched/cborg/lib/byte-utils.js +0 -417
  51. package/patched/cborg/lib/common.js +0 -27
  52. package/patched/cborg/lib/decode.js +0 -209
  53. package/patched/cborg/lib/diagnostic.js +0 -156
  54. package/patched/cborg/lib/diagnostic_test.js +0 -117
  55. package/patched/cborg/lib/encode.js +0 -464
  56. package/patched/cborg/lib/is.js +0 -106
  57. package/patched/cborg/lib/json/decode.js +0 -462
  58. package/patched/cborg/lib/json/encode.js +0 -299
  59. package/patched/cborg/lib/json/json.js +0 -4
  60. package/patched/cborg/lib/jump.js +0 -209
  61. package/patched/cborg/lib/length.js +0 -61
  62. package/patched/cborg/lib/token.js +0 -76
  63. package/patched/cborg/package.json +0 -169
  64. package/patched/cborg/pnpm-lock.yaml +0 -6096
  65. package/patched/cborg/taglib.js +0 -73
  66. package/patched/cborg/test/appendix_a.js +0 -647
  67. package/patched/cborg/test/common.js +0 -18
  68. package/patched/cborg/test/node-test-bin.js +0 -402
  69. package/patched/cborg/test/noop-bin-test.js +0 -3
  70. package/patched/cborg/test/test-0uint.js +0 -103
  71. package/patched/cborg/test/test-1negint.js +0 -96
  72. package/patched/cborg/test/test-2bytes.js +0 -198
  73. package/patched/cborg/test/test-3string.js +0 -136
  74. package/patched/cborg/test/test-4array.js +0 -93
  75. package/patched/cborg/test/test-5map.js +0 -284
  76. package/patched/cborg/test/test-6tag.js +0 -85
  77. package/patched/cborg/test/test-7float.js +0 -131
  78. package/patched/cborg/test/test-bl.js +0 -37
  79. package/patched/cborg/test/test-cbor-vectors.js +0 -107
  80. package/patched/cborg/test/test-decode-errors.js +0 -65
  81. package/patched/cborg/test/test-fuzz.js +0 -42
  82. package/patched/cborg/test/test-json.js +0 -219
  83. package/patched/cborg/test/test-length.js +0 -65
  84. package/patched/cborg/test/test-partial.js +0 -111
  85. package/patched/cborg/tsconfig.json +0 -45
  86. package/patched/cborg/types/cborg.d.ts +0 -28
  87. package/patched/cborg/types/cborg.d.ts.map +0 -1
  88. package/patched/cborg/types/example.d.ts +0 -2
  89. package/patched/cborg/types/example.d.ts.map +0 -1
  90. package/patched/cborg/types/interface.d.ts +0 -47
  91. package/patched/cborg/types/interface.d.ts.map +0 -1
  92. package/patched/cborg/types/lib/0uint.d.ts +0 -100
  93. package/patched/cborg/types/lib/0uint.d.ts.map +0 -1
  94. package/patched/cborg/types/lib/1negint.d.ts +0 -58
  95. package/patched/cborg/types/lib/1negint.d.ts.map +0 -1
  96. package/patched/cborg/types/lib/2bytes.d.ts +0 -68
  97. package/patched/cborg/types/lib/2bytes.d.ts.map +0 -1
  98. package/patched/cborg/types/lib/3string.d.ts +0 -46
  99. package/patched/cborg/types/lib/3string.d.ts.map +0 -1
  100. package/patched/cborg/types/lib/4array.d.ts +0 -65
  101. package/patched/cborg/types/lib/4array.d.ts.map +0 -1
  102. package/patched/cborg/types/lib/5map.d.ts +0 -65
  103. package/patched/cborg/types/lib/5map.d.ts.map +0 -1
  104. package/patched/cborg/types/lib/6tag.d.ts +0 -61
  105. package/patched/cborg/types/lib/6tag.d.ts.map +0 -1
  106. package/patched/cborg/types/lib/7float.d.ts +0 -60
  107. package/patched/cborg/types/lib/7float.d.ts.map +0 -1
  108. package/patched/cborg/types/lib/bin.d.ts +0 -4
  109. package/patched/cborg/types/lib/bin.d.ts.map +0 -1
  110. package/patched/cborg/types/lib/bl.d.ts +0 -26
  111. package/patched/cborg/types/lib/bl.d.ts.map +0 -1
  112. package/patched/cborg/types/lib/byte-utils.d.ts +0 -53
  113. package/patched/cborg/types/lib/byte-utils.d.ts.map +0 -1
  114. package/patched/cborg/types/lib/common.d.ts +0 -10
  115. package/patched/cborg/types/lib/common.d.ts.map +0 -1
  116. package/patched/cborg/types/lib/decode.d.ts +0 -41
  117. package/patched/cborg/types/lib/decode.d.ts.map +0 -1
  118. package/patched/cborg/types/lib/diagnostic.d.ts +0 -12
  119. package/patched/cborg/types/lib/diagnostic.d.ts.map +0 -1
  120. package/patched/cborg/types/lib/diagnostic_test.d.ts +0 -2
  121. package/patched/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
  122. package/patched/cborg/types/lib/encode.d.ts +0 -50
  123. package/patched/cborg/types/lib/encode.d.ts.map +0 -1
  124. package/patched/cborg/types/lib/is.d.ts +0 -6
  125. package/patched/cborg/types/lib/is.d.ts.map +0 -1
  126. package/patched/cborg/types/lib/json/decode.d.ts +0 -67
  127. package/patched/cborg/types/lib/json/decode.d.ts.map +0 -1
  128. package/patched/cborg/types/lib/json/encode.d.ts +0 -11
  129. package/patched/cborg/types/lib/json/encode.d.ts.map +0 -1
  130. package/patched/cborg/types/lib/json/forward-cborg.d.ts +0 -6
  131. package/patched/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
  132. package/patched/cborg/types/lib/json/json.d.ts +0 -6
  133. package/patched/cborg/types/lib/json/json.d.ts.map +0 -1
  134. package/patched/cborg/types/lib/jump.d.ts +0 -12
  135. package/patched/cborg/types/lib/jump.d.ts.map +0 -1
  136. package/patched/cborg/types/lib/length.d.ts +0 -27
  137. package/patched/cborg/types/lib/length.d.ts.map +0 -1
  138. package/patched/cborg/types/lib/token.d.ts +0 -59
  139. package/patched/cborg/types/lib/token.d.ts.map +0 -1
  140. package/patched/cborg/types/taglib.d.ts +0 -18
  141. package/patched/cborg/types/taglib.d.ts.map +0 -1
  142. package/patched/cborg/types/tsconfig.tsbuildinfo +0 -1
  143. package/src/@ipld/car/car/LICENSE +0 -4
  144. package/src/@ipld/car/car/README.md +0 -1078
  145. package/src/@ipld/car/car/dist/index.min.js +0 -5
  146. package/src/@ipld/car/car/dist/src/api.d.ts +0 -72
  147. package/src/@ipld/car/car/dist/src/api.d.ts.map +0 -1
  148. package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts +0 -67
  149. package/src/@ipld/car/car/dist/src/buffer-decoder.d.ts.map +0 -1
  150. package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts +0 -116
  151. package/src/@ipld/car/car/dist/src/buffer-reader-browser.d.ts.map +0 -1
  152. package/src/@ipld/car/car/dist/src/buffer-reader.d.ts +0 -31
  153. package/src/@ipld/car/car/dist/src/buffer-reader.d.ts.map +0 -1
  154. package/src/@ipld/car/car/dist/src/buffer-writer.d.ts +0 -86
  155. package/src/@ipld/car/car/dist/src/buffer-writer.d.ts.map +0 -1
  156. package/src/@ipld/car/car/dist/src/coding.d.ts +0 -49
  157. package/src/@ipld/car/car/dist/src/coding.d.ts.map +0 -1
  158. package/src/@ipld/car/car/dist/src/decoder-common.d.ts +0 -43
  159. package/src/@ipld/car/car/dist/src/decoder-common.d.ts.map +0 -1
  160. package/src/@ipld/car/car/dist/src/decoder.d.ts +0 -87
  161. package/src/@ipld/car/car/dist/src/decoder.d.ts.map +0 -1
  162. package/src/@ipld/car/car/dist/src/encoder.d.ts +0 -17
  163. package/src/@ipld/car/car/dist/src/encoder.d.ts.map +0 -1
  164. package/src/@ipld/car/car/dist/src/header-validator.d.ts +0 -5
  165. package/src/@ipld/car/car/dist/src/header-validator.d.ts.map +0 -1
  166. package/src/@ipld/car/car/dist/src/index-browser.d.ts +0 -10
  167. package/src/@ipld/car/car/dist/src/index-browser.d.ts.map +0 -1
  168. package/src/@ipld/car/car/dist/src/index.d.ts +0 -11
  169. package/src/@ipld/car/car/dist/src/index.d.ts.map +0 -1
  170. package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts +0 -5
  171. package/src/@ipld/car/car/dist/src/indexed-reader-browser.d.ts.map +0 -1
  172. package/src/@ipld/car/car/dist/src/indexed-reader.d.ts +0 -152
  173. package/src/@ipld/car/car/dist/src/indexed-reader.d.ts.map +0 -1
  174. package/src/@ipld/car/car/dist/src/indexer.d.ts +0 -95
  175. package/src/@ipld/car/car/dist/src/indexer.d.ts.map +0 -1
  176. package/src/@ipld/car/car/dist/src/iterator-channel.d.ts +0 -7
  177. package/src/@ipld/car/car/dist/src/iterator-channel.d.ts.map +0 -1
  178. package/src/@ipld/car/car/dist/src/iterator.d.ts +0 -174
  179. package/src/@ipld/car/car/dist/src/iterator.d.ts.map +0 -1
  180. package/src/@ipld/car/car/dist/src/reader-browser.d.ts +0 -151
  181. package/src/@ipld/car/car/dist/src/reader-browser.d.ts.map +0 -1
  182. package/src/@ipld/car/car/dist/src/reader.d.ts +0 -35
  183. package/src/@ipld/car/car/dist/src/reader.d.ts.map +0 -1
  184. package/src/@ipld/car/car/dist/src/writer-browser.d.ts +0 -155
  185. package/src/@ipld/car/car/dist/src/writer-browser.d.ts.map +0 -1
  186. package/src/@ipld/car/car/dist/src/writer.d.ts +0 -45
  187. package/src/@ipld/car/car/dist/src/writer.d.ts.map +0 -1
  188. package/src/@ipld/car/car/node_modules/.bin/cborg +0 -17
  189. package/src/@ipld/car/car/package.json +0 -235
  190. package/src/@ipld/car/car/src/api.ts +0 -90
  191. package/src/@ipld/car/car/src/buffer-decoder.js +0 -213
  192. package/src/@ipld/car/car/src/buffer-reader-browser.js +0 -144
  193. package/src/@ipld/car/car/src/buffer-reader.js +0 -51
  194. package/src/@ipld/car/car/src/buffer-writer.js +0 -286
  195. package/src/@ipld/car/car/src/coding.ts +0 -68
  196. package/src/@ipld/car/car/src/decoder-common.js +0 -82
  197. package/src/@ipld/car/car/src/decoder.js +0 -347
  198. package/src/@ipld/car/car/src/encoder.js +0 -76
  199. package/src/@ipld/car/car/src/header-validator.js +0 -214
  200. package/src/@ipld/car/car/src/header.ipldsch +0 -18
  201. package/src/@ipld/car/car/src/index-browser.js +0 -18
  202. package/src/@ipld/car/car/src/index.js +0 -21
  203. package/src/@ipld/car/car/src/indexed-reader-browser.js +0 -7
  204. package/src/@ipld/car/car/src/indexed-reader.js +0 -211
  205. package/src/@ipld/car/car/src/indexer.js +0 -130
  206. package/src/@ipld/car/car/src/iterator-channel.js +0 -91
  207. package/src/@ipld/car/car/src/iterator.js +0 -267
  208. package/src/@ipld/car/car/src/reader-browser.js +0 -194
  209. package/src/@ipld/car/car/src/reader.js +0 -56
  210. package/src/@ipld/car/car/src/writer-browser.js +0 -250
  211. package/src/@ipld/car/car/src/writer.js +0 -84
  212. package/src/@ipld/dag-cbor/dag-cbor/LICENSE +0 -4
  213. package/src/@ipld/dag-cbor/dag-cbor/README.md +0 -80
  214. package/src/@ipld/dag-cbor/dag-cbor/dist/index.min.js +0 -3
  215. package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts +0 -67
  216. package/src/@ipld/dag-cbor/dag-cbor/dist/src/index.d.ts.map +0 -1
  217. package/src/@ipld/dag-cbor/dag-cbor/node_modules/.bin/cborg +0 -17
  218. package/src/@ipld/dag-cbor/dag-cbor/package.json +0 -171
  219. package/src/@ipld/dag-cbor/dag-cbor/src/index.js +0 -147
  220. package/src/@ipld/dag-json/dag-json/LICENSE +0 -4
  221. package/src/@ipld/dag-json/dag-json/README.md +0 -58
  222. package/src/@ipld/dag-json/dag-json/dist/index.min.js +0 -3
  223. package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts +0 -12
  224. package/src/@ipld/dag-json/dag-json/dist/src/index.d.ts.map +0 -1
  225. package/src/@ipld/dag-json/dag-json/node_modules/.bin/cborg +0 -17
  226. package/src/@ipld/dag-json/dag-json/package.json +0 -173
  227. package/src/@ipld/dag-json/dag-json/src/index.js +0 -291
  228. package/src/@web3-storage/pail/pail/LICENSE.md +0 -232
  229. package/src/@web3-storage/pail/pail/README.md +0 -84
  230. package/src/@web3-storage/pail/pail/cli.js +0 -218
  231. package/src/@web3-storage/pail/pail/dist/src/api.d.ts +0 -59
  232. package/src/@web3-storage/pail/pail/dist/src/api.d.ts.map +0 -1
  233. package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts +0 -31
  234. package/src/@web3-storage/pail/pail/dist/src/batch/api.d.ts.map +0 -1
  235. package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts +0 -75
  236. package/src/@web3-storage/pail/pail/dist/src/batch/index.d.ts.map +0 -1
  237. package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts +0 -3
  238. package/src/@web3-storage/pail/pail/dist/src/batch/shard.d.ts.map +0 -1
  239. package/src/@web3-storage/pail/pail/dist/src/block.d.ts +0 -35
  240. package/src/@web3-storage/pail/pail/dist/src/block.d.ts.map +0 -1
  241. package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts +0 -10
  242. package/src/@web3-storage/pail/pail/dist/src/clock/api.d.ts.map +0 -1
  243. package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts +0 -48
  244. package/src/@web3-storage/pail/pail/dist/src/clock/index.d.ts.map +0 -1
  245. package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts +0 -26
  246. package/src/@web3-storage/pail/pail/dist/src/crdt/api.d.ts.map +0 -1
  247. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts +0 -11
  248. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/api.d.ts.map +0 -1
  249. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts +0 -5
  250. package/src/@web3-storage/pail/pail/dist/src/crdt/batch/index.d.ts.map +0 -1
  251. package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts +0 -9
  252. package/src/@web3-storage/pail/pail/dist/src/crdt/index.d.ts.map +0 -1
  253. package/src/@web3-storage/pail/pail/dist/src/diff.d.ts +0 -13
  254. package/src/@web3-storage/pail/pail/dist/src/diff.d.ts.map +0 -1
  255. package/src/@web3-storage/pail/pail/dist/src/index.d.ts +0 -10
  256. package/src/@web3-storage/pail/pail/dist/src/index.d.ts.map +0 -1
  257. package/src/@web3-storage/pail/pail/dist/src/merge.d.ts +0 -5
  258. package/src/@web3-storage/pail/pail/dist/src/merge.d.ts.map +0 -1
  259. package/src/@web3-storage/pail/pail/dist/src/shard.d.ts +0 -43
  260. package/src/@web3-storage/pail/pail/dist/src/shard.d.ts.map +0 -1
  261. package/src/@web3-storage/pail/pail/dist/tsconfig.tsbuildinfo +0 -1
  262. package/src/@web3-storage/pail/pail/node_modules/.bin/pail +0 -17
  263. package/src/@web3-storage/pail/pail/package.json +0 -173
  264. package/src/@web3-storage/pail/pail/src/api.js +0 -1
  265. package/src/@web3-storage/pail/pail/src/api.ts +0 -90
  266. package/src/@web3-storage/pail/pail/src/batch/api.js +0 -1
  267. package/src/@web3-storage/pail/pail/src/batch/api.ts +0 -59
  268. package/src/@web3-storage/pail/pail/src/batch/index.js +0 -258
  269. package/src/@web3-storage/pail/pail/src/batch/shard.js +0 -13
  270. package/src/@web3-storage/pail/pail/src/block.js +0 -75
  271. package/src/@web3-storage/pail/pail/src/clock/api.js +0 -1
  272. package/src/@web3-storage/pail/pail/src/clock/api.ts +0 -12
  273. package/src/@web3-storage/pail/pail/src/clock/index.js +0 -182
  274. package/src/@web3-storage/pail/pail/src/crdt/api.js +0 -1
  275. package/src/@web3-storage/pail/pail/src/crdt/api.ts +0 -33
  276. package/src/@web3-storage/pail/pail/src/crdt/batch/api.js +0 -1
  277. package/src/@web3-storage/pail/pail/src/crdt/batch/api.ts +0 -30
  278. package/src/@web3-storage/pail/pail/src/crdt/batch/index.js +0 -155
  279. package/src/@web3-storage/pail/pail/src/crdt/index.js +0 -354
  280. package/src/@web3-storage/pail/pail/src/diff.js +0 -151
  281. package/src/@web3-storage/pail/pail/src/index.js +0 -406
  282. package/src/@web3-storage/pail/pail/src/merge.js +0 -43
  283. package/src/@web3-storage/pail/pail/src/shard.js +0 -180
  284. package/src/cborg/cborg/.github/dependabot.yml +0 -16
  285. package/src/cborg/cborg/.github/workflows/test-and-release.yml +0 -52
  286. package/src/cborg/cborg/CHANGELOG.md +0 -513
  287. package/src/cborg/cborg/LICENSE +0 -13
  288. package/src/cborg/cborg/README.md +0 -515
  289. package/src/cborg/cborg/bench/bench.js +0 -117
  290. package/src/cborg/cborg/bench/json.js +0 -124
  291. package/src/cborg/cborg/bench/package.json +0 -8
  292. package/src/cborg/cborg/cborg.js +0 -31
  293. package/src/cborg/cborg/example-bytestrings.js +0 -180
  294. package/src/cborg/cborg/example-json.js +0 -6
  295. package/src/cborg/cborg/example.js +0 -5
  296. package/src/cborg/cborg/interface.ts +0 -56
  297. package/src/cborg/cborg/lib/0uint.js +0 -227
  298. package/src/cborg/cborg/lib/1negint.js +0 -111
  299. package/src/cborg/cborg/lib/2bytes.js +0 -133
  300. package/src/cborg/cborg/lib/3string.js +0 -90
  301. package/src/cborg/cborg/lib/4array.js +0 -113
  302. package/src/cborg/cborg/lib/5map.js +0 -113
  303. package/src/cborg/cborg/lib/6tag.js +0 -80
  304. package/src/cborg/cborg/lib/7float.js +0 -308
  305. package/src/cborg/cborg/lib/bin.js +0 -189
  306. package/src/cborg/cborg/lib/bl.js +0 -124
  307. package/src/cborg/cborg/lib/byte-utils.js +0 -417
  308. package/src/cborg/cborg/lib/common.js +0 -27
  309. package/src/cborg/cborg/lib/decode.js +0 -209
  310. package/src/cborg/cborg/lib/diagnostic.js +0 -156
  311. package/src/cborg/cborg/lib/diagnostic_test.js +0 -117
  312. package/src/cborg/cborg/lib/encode.js +0 -464
  313. package/src/cborg/cborg/lib/is.js +0 -106
  314. package/src/cborg/cborg/lib/json/decode.js +0 -462
  315. package/src/cborg/cborg/lib/json/encode.js +0 -299
  316. package/src/cborg/cborg/lib/json/json.js +0 -4
  317. package/src/cborg/cborg/lib/jump.js +0 -209
  318. package/src/cborg/cborg/lib/length.js +0 -61
  319. package/src/cborg/cborg/lib/token.js +0 -76
  320. package/src/cborg/cborg/node_modules/.bin/cborg +0 -17
  321. package/src/cborg/cborg/package.json +0 -168
  322. package/src/cborg/cborg/taglib.js +0 -73
  323. package/src/cborg/cborg/test/appendix_a.js +0 -647
  324. package/src/cborg/cborg/test/common.js +0 -18
  325. package/src/cborg/cborg/test/node-test-bin.js +0 -402
  326. package/src/cborg/cborg/test/noop-bin-test.js +0 -3
  327. package/src/cborg/cborg/test/test-0uint.js +0 -103
  328. package/src/cborg/cborg/test/test-1negint.js +0 -96
  329. package/src/cborg/cborg/test/test-2bytes.js +0 -198
  330. package/src/cborg/cborg/test/test-3string.js +0 -136
  331. package/src/cborg/cborg/test/test-4array.js +0 -93
  332. package/src/cborg/cborg/test/test-5map.js +0 -284
  333. package/src/cborg/cborg/test/test-6tag.js +0 -85
  334. package/src/cborg/cborg/test/test-7float.js +0 -131
  335. package/src/cborg/cborg/test/test-bl.js +0 -37
  336. package/src/cborg/cborg/test/test-cbor-vectors.js +0 -107
  337. package/src/cborg/cborg/test/test-decode-errors.js +0 -65
  338. package/src/cborg/cborg/test/test-fuzz.js +0 -42
  339. package/src/cborg/cborg/test/test-json.js +0 -219
  340. package/src/cborg/cborg/test/test-length.js +0 -65
  341. package/src/cborg/cborg/test/test-partial.js +0 -111
  342. package/src/cborg/cborg/tsconfig.json +0 -45
  343. package/src/cborg/cborg/types/cborg.d.ts +0 -28
  344. package/src/cborg/cborg/types/cborg.d.ts.map +0 -1
  345. package/src/cborg/cborg/types/example.d.ts +0 -2
  346. package/src/cborg/cborg/types/example.d.ts.map +0 -1
  347. package/src/cborg/cborg/types/interface.d.ts +0 -47
  348. package/src/cborg/cborg/types/interface.d.ts.map +0 -1
  349. package/src/cborg/cborg/types/lib/0uint.d.ts +0 -100
  350. package/src/cborg/cborg/types/lib/0uint.d.ts.map +0 -1
  351. package/src/cborg/cborg/types/lib/1negint.d.ts +0 -58
  352. package/src/cborg/cborg/types/lib/1negint.d.ts.map +0 -1
  353. package/src/cborg/cborg/types/lib/2bytes.d.ts +0 -68
  354. package/src/cborg/cborg/types/lib/2bytes.d.ts.map +0 -1
  355. package/src/cborg/cborg/types/lib/3string.d.ts +0 -46
  356. package/src/cborg/cborg/types/lib/3string.d.ts.map +0 -1
  357. package/src/cborg/cborg/types/lib/4array.d.ts +0 -65
  358. package/src/cborg/cborg/types/lib/4array.d.ts.map +0 -1
  359. package/src/cborg/cborg/types/lib/5map.d.ts +0 -65
  360. package/src/cborg/cborg/types/lib/5map.d.ts.map +0 -1
  361. package/src/cborg/cborg/types/lib/6tag.d.ts +0 -61
  362. package/src/cborg/cborg/types/lib/6tag.d.ts.map +0 -1
  363. package/src/cborg/cborg/types/lib/7float.d.ts +0 -60
  364. package/src/cborg/cborg/types/lib/7float.d.ts.map +0 -1
  365. package/src/cborg/cborg/types/lib/bin.d.ts +0 -4
  366. package/src/cborg/cborg/types/lib/bin.d.ts.map +0 -1
  367. package/src/cborg/cborg/types/lib/bl.d.ts +0 -26
  368. package/src/cborg/cborg/types/lib/bl.d.ts.map +0 -1
  369. package/src/cborg/cborg/types/lib/byte-utils.d.ts +0 -53
  370. package/src/cborg/cborg/types/lib/byte-utils.d.ts.map +0 -1
  371. package/src/cborg/cborg/types/lib/common.d.ts +0 -10
  372. package/src/cborg/cborg/types/lib/common.d.ts.map +0 -1
  373. package/src/cborg/cborg/types/lib/decode.d.ts +0 -41
  374. package/src/cborg/cborg/types/lib/decode.d.ts.map +0 -1
  375. package/src/cborg/cborg/types/lib/diagnostic.d.ts +0 -12
  376. package/src/cborg/cborg/types/lib/diagnostic.d.ts.map +0 -1
  377. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts +0 -2
  378. package/src/cborg/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
  379. package/src/cborg/cborg/types/lib/encode.d.ts +0 -50
  380. package/src/cborg/cborg/types/lib/encode.d.ts.map +0 -1
  381. package/src/cborg/cborg/types/lib/is.d.ts +0 -6
  382. package/src/cborg/cborg/types/lib/is.d.ts.map +0 -1
  383. package/src/cborg/cborg/types/lib/json/decode.d.ts +0 -67
  384. package/src/cborg/cborg/types/lib/json/decode.d.ts.map +0 -1
  385. package/src/cborg/cborg/types/lib/json/encode.d.ts +0 -11
  386. package/src/cborg/cborg/types/lib/json/encode.d.ts.map +0 -1
  387. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts +0 -6
  388. package/src/cborg/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
  389. package/src/cborg/cborg/types/lib/json/json.d.ts +0 -6
  390. package/src/cborg/cborg/types/lib/json/json.d.ts.map +0 -1
  391. package/src/cborg/cborg/types/lib/jump.d.ts +0 -12
  392. package/src/cborg/cborg/types/lib/jump.d.ts.map +0 -1
  393. package/src/cborg/cborg/types/lib/length.d.ts +0 -27
  394. package/src/cborg/cborg/types/lib/length.d.ts.map +0 -1
  395. package/src/cborg/cborg/types/lib/token.d.ts +0 -59
  396. package/src/cborg/cborg/types/lib/token.d.ts.map +0 -1
  397. package/src/cborg/cborg/types/taglib.d.ts +0 -18
  398. package/src/cborg/cborg/types/taglib.d.ts.map +0 -1
  399. package/src/cborg/cborg/types/tsconfig.tsbuildinfo +0 -1
  400. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/LICENSE +0 -4
  401. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/README.md +0 -105
  402. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/index.min.js +0 -3
  403. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts +0 -57
  404. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.d.ts.map +0 -1
  405. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js +0 -73
  406. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/errors.js.map +0 -1
  407. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts +0 -355
  408. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.d.ts.map +0 -1
  409. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js +0 -197
  410. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/index.js.map +0 -1
  411. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts +0 -4
  412. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.d.ts.map +0 -1
  413. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js +0 -9
  414. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-cbor.js.map +0 -1
  415. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts +0 -4
  416. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.d.ts.map +0 -1
  417. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js +0 -9
  418. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/dag-json.js.map +0 -1
  419. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts +0 -4
  420. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.d.ts.map +0 -1
  421. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js +0 -38
  422. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/identity.js.map +0 -1
  423. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts +0 -4
  424. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.d.ts.map +0 -1
  425. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js +0 -30
  426. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/index.js.map +0 -1
  427. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts +0 -4
  428. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.d.ts.map +0 -1
  429. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js +0 -9
  430. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/json.js.map +0 -1
  431. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts +0 -4
  432. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.d.ts.map +0 -1
  433. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js +0 -37
  434. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/raw.js.map +0 -1
  435. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts +0 -4
  436. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.d.ts.map +0 -1
  437. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js +0 -29
  438. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/directory.js.map +0 -1
  439. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts +0 -4
  440. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.d.ts.map +0 -1
  441. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js +0 -153
  442. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/file.js.map +0 -1
  443. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts +0 -4
  444. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.d.ts.map +0 -1
  445. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js +0 -59
  446. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/hamt-sharded-directory.js.map +0 -1
  447. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts +0 -4
  448. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.d.ts.map +0 -1
  449. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js +0 -25
  450. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/content/raw.js.map +0 -1
  451. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts +0 -4
  452. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.d.ts.map +0 -1
  453. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js +0 -104
  454. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/resolvers/unixfs-v1/index.js.map +0 -1
  455. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts +0 -3
  456. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.d.ts.map +0 -1
  457. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js +0 -20
  458. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/extract-data-from-block.js.map +0 -1
  459. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts +0 -6
  460. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.d.ts.map +0 -1
  461. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js +0 -116
  462. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/find-cid-in-shard.js.map +0 -1
  463. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts +0 -4
  464. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.d.ts.map +0 -1
  465. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js +0 -57
  466. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/resolve-object-path.js.map +0 -1
  467. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts +0 -6
  468. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.d.ts.map +0 -1
  469. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js +0 -30
  470. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/src/utils/validate-offset-and-length.js.map +0 -1
  471. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/dist/typedoc-urls.json +0 -58
  472. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/package.json +0 -180
  473. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/errors.ts +0 -87
  474. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/index.ts +0 -498
  475. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-cbor.ts +0 -12
  476. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/dag-json.ts +0 -12
  477. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/identity.ts +0 -49
  478. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/index.ts +0 -35
  479. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/json.ts +0 -12
  480. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/raw.ts +0 -49
  481. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/directory.ts +0 -39
  482. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.ts +0 -198
  483. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts +0 -76
  484. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/raw.ts +0 -37
  485. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/index.ts +0 -121
  486. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/extract-data-from-block.ts +0 -24
  487. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/find-cid-in-shard.ts +0 -149
  488. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/resolve-object-path.ts +0 -62
  489. package/src/ipfs-unixfs-exporter/ipfs-unixfs-exporter/src/utils/validate-offset-and-length.ts +0 -38
@@ -1,124 +0,0 @@
1
- // can be run in a browser with `polendina --runner=bare-sync --timeout 6000 --cleanup bench.js`
2
- // with additional dependencies for cborg installed here
3
-
4
- import assert from 'assert'
5
- import { garbage } from 'ipld-garbage'
6
- import { decode, encode } from '../lib/json/json.js'
7
-
8
- let writebuf = ''
9
- const write = process.stdout
10
- ? process.stdout.write.bind(process.stdout)
11
- : (str) => {
12
- writebuf += str
13
- if (str.endsWith('\n')) {
14
- console.log(writebuf.replace(/\n$/, ''))
15
- writebuf = ''
16
- }
17
- }
18
-
19
- const textEncoder = new TextEncoder()
20
- const textDecoder = new TextDecoder()
21
-
22
- function jencode (obj) {
23
- return textEncoder.encode(JSON.stringify(obj))
24
- }
25
-
26
- function jdecode (buf) {
27
- return JSON.parse(textDecoder.decode(buf))
28
- }
29
-
30
- function runWith (description, count, targetTime, size, options) {
31
- const fixtures = []
32
-
33
- console.log(`${description} @ ${count.toLocaleString()}`)
34
- for (let i = 0; i < count; i++) {
35
- const obj = garbage(size, options)
36
- const cbyts = encode(obj)
37
- /*
38
- const jbyts = jencode(obj)
39
- if (Buffer.compare(Buffer.from(cbyts), jbyts) !== 0) {
40
- console.log(`mismatch for obj: ${JSON.stringify(obj)}`)
41
- console.log('\tc> ', Buffer.from(cbyts).toString('utf8'))
42
- console.log('\tj> ', Buffer.from(jbyts).toString('utf8'))
43
- }
44
- */
45
- if (cbyts.length <= size * 2) {
46
- fixtures.push([obj, cbyts])
47
- }
48
- }
49
- const avgSize = Math.round(fixtures.reduce((p, c) => p + c[1].length, 0) / fixtures.length)
50
-
51
- const enc = (encoder) => {
52
- for (const [obj, byts] of fixtures) {
53
- const ebyts = encoder(obj)
54
- if (byts.length !== ebyts.length) {
55
- throw new Error('bork')
56
- }
57
- }
58
- return fixtures.length
59
- }
60
-
61
- const bench = (bfn) => {
62
- const start = Date.now()
63
- let opcount = 0
64
- do {
65
- opcount += bfn()
66
- } while (Date.now() - start < targetTime)
67
- const ops = Math.round(opcount / ((Date.now() - start) / 1000))
68
- return ops
69
- }
70
-
71
- const dec = (decoder) => {
72
- for (const [obj, byts] of fixtures) {
73
- let cobj
74
- try {
75
- cobj = decoder(byts)
76
- } catch (e) {
77
- console.log('Failed to decode:', Buffer.from(byts).toString('utf8'))
78
- throw e
79
- }
80
- if (obj != null && typeof obj === 'object') {
81
- assert.deepStrictEqual(Object.keys(cobj).length, Object.keys(obj).length)
82
- } else {
83
- assert.deepStrictEqual(obj, cobj)
84
- }
85
- }
86
- return fixtures.length
87
- }
88
-
89
- const cmp = (desc, cbfn, bofn) => {
90
- write(`\t${desc} (avg ${avgSize.toLocaleString()} b):`)
91
- const cborgOps = bench(cbfn)
92
- write(` cborg @ ${cborgOps.toLocaleString()} op/s`)
93
- const jOps = bench(bofn)
94
- write(` / JSON @ ${jOps.toLocaleString()} op/s`)
95
- const percent = Math.round((cborgOps / jOps) * 1000) / 10
96
- write(` = ${(percent).toLocaleString()} %\n`)
97
- return percent
98
- }
99
-
100
- return [
101
- cmp('encode', () => enc(encode), () => enc(jencode)),
102
- cmp('decode', () => dec(decode), () => dec(jdecode))
103
- ]
104
- }
105
-
106
- const targetTime = 1000
107
- const accum = []
108
- accum.push(runWith('rnd-100', 1000, targetTime, 100, { weights: { CID: 0, bytes: 0 } }))
109
- accum.push(runWith('rnd-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0 } }))
110
- accum.push(runWith('rnd-nomap-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, map: 0 } }))
111
- accum.push(runWith('rnd-nolist-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, list: 0 } }))
112
- accum.push(runWith('rnd-nofloat-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, float: 0 } }))
113
- accum.push(runWith('rnd-nomaj7-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, float: 0, null: 0, boolean: 0 } }))
114
- accum.push(runWith('rnd-nostr-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, string: 0 } }))
115
- accum.push(runWith('rnd-nostrbyts-300', 1000, targetTime, 300, { weights: { CID: 0, bytes: 0, string: 0 } }))
116
- accum.push(runWith('rnd-1000', 1000, targetTime, 1000, { weights: { CID: 0, bytes: 0 } }))
117
- accum.push(runWith('rnd-2000', 1000, targetTime, 2000, { weights: { CID: 0, bytes: 0 } }))
118
- accum.push(runWith('rnd-fil-100', 1000, targetTime, 100, { weights: { float: 0, map: 0, CID: 0, bytes: 0 } }))
119
- accum.push(runWith('rnd-fil-300', 1000, targetTime, 300, { weights: { float: 0, map: 0, CID: 0, bytes: 0 } }))
120
- accum.push(runWith('rnd-fil-500', 1000, targetTime, 500, { weights: { float: 0, map: 0, CID: 0, bytes: 0 } }))
121
- accum.push(runWith('rnd-fil-1000', 1000, targetTime, 1000, { weights: { float: 0, map: 0, CID: 0, bytes: 0 } }))
122
- accum.push(runWith('rnd-fil-2000', 1000, targetTime, 2000, { weights: { float: 0, map: 0, CID: 0, bytes: 0 } }))
123
- console.log(`Avg encode: ${Math.round(accum.reduce((p, c) => p + c[0], 0) / accum.length).toLocaleString()} %`)
124
- console.log(`Avg decode: ${Math.round(accum.reduce((p, c) => p + c[1], 0) / accum.length).toLocaleString()} %`)
@@ -1,8 +0,0 @@
1
- {
2
- "name": "cborg-bench",
3
- "type": "module",
4
- "dependencies": {
5
- "borc": "^2.1.2",
6
- "ipld-garbage": "^3.0.3"
7
- }
8
- }
Binary file
@@ -1,31 +0,0 @@
1
- import { encode } from './lib/encode.js'
2
- import { decode, decodeFirst, Tokeniser, tokensToObject } from './lib/decode.js'
3
- import { Token, Type } from './lib/token.js'
4
-
5
- // is this needed for the json module and other independ encoders
6
- export { encodeCustom } from './lib/encode.js'
7
- export { encodeErrPrefix, decodeErrPrefix } from './lib/common.js'
8
- export { asU8A, fromString, decodeCodePointsArray } from './lib/byte-utils.js'
9
-
10
- /**
11
- * Export the types that were present in the original manual cborg.d.ts
12
- * @typedef {import('./interface').TagDecoder} TagDecoder
13
- * There was originally just `TypeEncoder` so don't break types by renaming or not exporting
14
- * @typedef {import('./interface').OptionalTypeEncoder} TypeEncoder
15
- * @typedef {import('./interface').DecodeOptions} DecodeOptions
16
- * @typedef {import('./interface').EncodeOptions} EncodeOptions
17
- */
18
-
19
- export {
20
- // this is needed to prevent the bundleing trouble which happens
21
- // due to the fact that token.js is used in lib/json and so in
22
- // cborg/json which ends up on bundling to have two copies of token.js
23
- // which will fail stmts like token.type === Type.array
24
- decode,
25
- decodeFirst,
26
- Tokeniser as Tokenizer,
27
- tokensToObject,
28
- encode,
29
- Token,
30
- Type
31
- }
@@ -1,180 +0,0 @@
1
- /*
2
- RFC 8746 defines a set of tags to use for typed arrays. Out of the box, cborg doesn't care about
3
- tags and just squashes all concerns around byte arrays to Uint8Array with major type 2. This is
4
- fine for most use cases, but it is lossy, you can't round-trip and retain your original type.
5
-
6
- This example shows how to use cborg to round-trip a typed array with tags.
7
-
8
- https://www.rfc-editor.org/rfc/rfc8746.html
9
- */
10
-
11
- import { encode, decode, Token, Tokenizer, Type } from 'cborg.js'
12
-
13
- const tagUint8Array = 64
14
- const tagUint64Array = 71
15
- // etc... see https://www.rfc-editor.org/rfc/rfc8746.html#name-iana-considerations
16
-
17
- /* ENCODERS */
18
-
19
- /**
20
- * @param {any} obj
21
- * @returns {[Token]}
22
- */
23
- function uint8ArrayEncoder (obj) {
24
- if (!(obj instanceof Uint8Array)) {
25
- throw new Error('expected Uint8Array')
26
- }
27
- return [
28
- new Token(Type.tag, tagUint8Array),
29
- new Token(Type.bytes, obj)
30
- ]
31
- }
32
-
33
- /**
34
- * @param {any} obj
35
- * @returns {[Token]}
36
- */
37
- function uint64ArrayEncoder (obj) {
38
- if (!(obj instanceof BigUint64Array)) {
39
- throw new Error('expected BigUint64Array')
40
- }
41
- return [
42
- new Token(Type.tag, tagUint64Array),
43
- // BigUint64Array to a Uint8Array, but we have to pay attention to the possibility of it being
44
- // a view of a larger ArrayBuffer.
45
- new Token(Type.bytes, new Uint8Array(obj.buffer, obj.byteOffset, obj.byteLength))
46
- ]
47
- }
48
-
49
- // etc...
50
-
51
- const typeEncoders = {
52
- Uint8Array: uint8ArrayEncoder,
53
- BigUint64Array: uint64ArrayEncoder
54
- }
55
-
56
- /* DECODERS */
57
-
58
- /**
59
- * @param {ArrayBuffer} bytes
60
- * @returns {any}
61
- */
62
- function uint8ArrayDecoder (bytes) {
63
- if (!(bytes instanceof ArrayBuffer)) {
64
- throw new Error('expected ArrayBuffer')
65
- }
66
- return new Uint8Array(bytes)
67
- }
68
-
69
- /**
70
- * @param {ArrayBuffer} bytes
71
- * @returns {any}
72
- */
73
- function uint64ArrayDecoder (bytes) {
74
- if (!(bytes instanceof ArrayBuffer)) {
75
- throw new Error('expected ArrayBuffer')
76
- }
77
- return new BigUint64Array(bytes)
78
- }
79
-
80
- // etc...
81
-
82
- const tags = []
83
- tags[tagUint8Array] = uint8ArrayDecoder
84
- tags[tagUint64Array] = uint64ArrayDecoder
85
-
86
- /* TOKENIZER */
87
-
88
- // We have to deal with the fact that cborg talks in Uint8Arrays but we now want it to treat major 2
89
- // as ArrayBuffers, so we have to transform the token stream to replace the Uint8Array with an
90
- // ArrayBuffer.
91
-
92
- class ArrayBufferTransformingTokeniser extends Tokenizer {
93
- next () {
94
- const nextToken = super.next()
95
- if (nextToken.type.equals(Type.bytes)) {
96
- // Transform the (assumed) Uint8Array value to an ArrayBuffer of the same bytes, note though
97
- // that all tags we care about are going to be <tag><bytes>, so we're also transforming those
98
- // into ArrayBuffers, so our tag decoders need to also assume they are getting ArrayBuffers
99
- // now. An alternative would be to watch the token stream for <tag> and not transform the next
100
- // token if it's <bytes>, but that's a bit more complicated for demo purposes.
101
- nextToken.value = nextToken.value.buffer
102
- }
103
- return nextToken
104
- }
105
- }
106
-
107
- // Optional: a new decode() wrapper, mainly so we don't have to deal with the complications of\
108
- // instantiating a Tokenizer which needs both data and the options.
109
- function byteStringDecoder (data, options) {
110
- options = Object.assign({}, options, {
111
- tags,
112
- tokenizer: new ArrayBufferTransformingTokeniser(data, options)
113
- })
114
- return decode(data, options)
115
- }
116
-
117
- /* ROUND-TRIP */
118
-
119
- const original = {
120
- u8: new Uint8Array([1, 2, 3, 4, 5]),
121
- u64: new BigUint64Array([10000000000000000n, 20000000000000000n, 30000000000000000n, 40000000000000000n, 50000000000000000n]),
122
- ab: new Uint8Array([6, 7, 8, 9, 10]).buffer
123
- }
124
-
125
- const encoded = encode(original, { typeEncoders })
126
-
127
- const decoded = byteStringDecoder(encoded)
128
-
129
- console.log('Original:', original)
130
- console.log('Encoded:', Buffer.from(encoded).toString('hex')) // excuse the Buffer, sorry browser peeps
131
- console.log('Decoded:', decoded)
132
-
133
- /* Output:
134
-
135
- Original: {
136
- u8: Uint8Array(5) [ 1, 2, 3, 4, 5 ],
137
- u64: BigUint64Array(5) [
138
- 10000000000000000n,
139
- 20000000000000000n,
140
- 30000000000000000n,
141
- 40000000000000000n,
142
- 50000000000000000n
143
- ],
144
- ab: ArrayBuffer { [Uint8Contents]: <06 07 08 09 0a>, byteLength: 5 }
145
- }
146
- Encoded: a362616245060708090a627538d84045010203040563753634d84758280000c16ff2862300000082dfe40d47000000434fd7946a00000004bfc91b8e000000c52ebca2b100
147
- Decoded: {
148
- ab: ArrayBuffer { [Uint8Contents]: <06 07 08 09 0a>, byteLength: 5 },
149
- u8: Uint8Array(5) [ 1, 2, 3, 4, 5 ],
150
- u64: BigUint64Array(5) [
151
- 10000000000000000n,
152
- 20000000000000000n,
153
- 30000000000000000n,
154
- 40000000000000000n,
155
- 50000000000000000n
156
- ]
157
- }
158
-
159
- */
160
-
161
- /* Diagnostic:
162
-
163
- $ cborg hex2diag a362616245060708090a627538d84045010203040563753634d84758280000c16ff2862300000082dfe40d47000000434fd7946a00000004bfc91b8e000000c52ebca2b100
164
- a3 # map(3)
165
- 62 # string(2)
166
- 6162 # "ab"
167
- 45 # bytes(5)
168
- 060708090a # "\x06\x07\x08\x09\x0a"
169
- 62 # string(2)
170
- 7538 # "u8"
171
- d8 40 # tag(64)
172
- 45 # bytes(5)
173
- 0102030405 # "\x01\x02\x03\x04\x05"
174
- 63 # string(3)
175
- 753634 # "u64"
176
- d8 47 # tag(71)
177
- 58 28 # bytes(40)
178
- 0000c16ff2862300000082dfe40d47000000434fd7 # "\x00\x00Áoò\x86#\x00\x00\x00\x82ßä\x0dG\x00\x00\x00CO×"
179
- 946a00000004bfc91b8e000000c52ebca2b100 # "\x94j\x00\x00\x00\x04¿É\x1b\x8e\x00\x00\x00Å.¼¢±\x00
180
- */
@@ -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())
@@ -1,5 +0,0 @@
1
- import { encode, decode } from 'cborg'
2
-
3
- const decoded = decode(Buffer.from('a16474686973a26269736543424f522163796179f5', 'hex'))
4
- console.log('decoded:', decoded)
5
- console.log('encoded:', encode(decoded))
@@ -1,56 +0,0 @@
1
- import { Token } from './lib/token'
2
- import { Bl } from './lib/bl'
3
-
4
- export type TokenOrNestedTokens = Token | Token[] | TokenOrNestedTokens[]
5
-
6
- export interface Reference {
7
- parent: Reference | undefined
8
- obj: object | any[]
9
- includes(obj: object | any[]): boolean
10
- }
11
-
12
- export type OptionalTypeEncoder = (data: any, typ: string, options: EncodeOptions, refStack?: Reference) => TokenOrNestedTokens | null
13
-
14
- export type StrictTypeEncoder = (data: any, typ: string, options: EncodeOptions, refStack?: Reference) => TokenOrNestedTokens
15
-
16
- export type TokenTypeEncoder = {
17
- (buf: Bl, token: Token, options?: EncodeOptions): void;
18
- compareTokens(t1: Token, t2: Token): number;
19
- // TODO: make this non-optional as a breaking change and remove the throw in length.js
20
- encodedSize?(token: Token, options?: EncodeOptions): number;
21
- }
22
-
23
- export type MapSorter = (e1: (Token | Token[])[], e2: (Token | Token[])[]) => number
24
-
25
- export type QuickEncodeToken = (token: Token) => Uint8Array | undefined
26
-
27
- export interface DecodeTokenizer {
28
- done(): boolean,
29
- next(): Token,
30
- pos(): number,
31
- }
32
-
33
- export type TagDecoder = (inner: any) => any
34
-
35
- export interface DecodeOptions {
36
- allowIndefinite?: boolean
37
- allowUndefined?: boolean
38
- coerceUndefinedToNull?: boolean
39
- allowInfinity?: boolean
40
- allowNaN?: boolean
41
- allowBigInt?: boolean
42
- strict?: boolean
43
- useMaps?: boolean
44
- rejectDuplicateMapKeys?: boolean
45
- retainStringBytes?: boolean
46
- tags?: TagDecoder[],
47
- tokenizer?: DecodeTokenizer
48
- }
49
-
50
- export interface EncodeOptions {
51
- float64?: boolean,
52
- addBreakTokens?: boolean,
53
- mapSorter?: MapSorter,
54
- quickEncodeToken?: QuickEncodeToken,
55
- typeEncoders?: { [typeName: string]: OptionalTypeEncoder }
56
- }
@@ -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
- }