@ipld/car 4.1.6 → 5.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.
Files changed (226) hide show
  1. package/LICENSE +4 -0
  2. package/README.md +12 -4
  3. package/dist/index.min.js +5 -0
  4. package/{types → dist/src}/api.d.ts +19 -19
  5. package/dist/src/api.d.ts.map +1 -0
  6. package/{types/lib → dist/src}/buffer-writer.d.ts +10 -10
  7. package/{types/lib → dist/src}/buffer-writer.d.ts.map +1 -1
  8. package/dist/src/coding.d.ts +41 -0
  9. package/dist/src/coding.d.ts.map +1 -0
  10. package/{types/lib → dist/src}/decoder.d.ts +3 -3
  11. package/{types/lib → dist/src}/decoder.d.ts.map +1 -1
  12. package/{types/lib → dist/src}/encoder.d.ts +2 -2
  13. package/{types/lib → dist/src}/encoder.d.ts.map +1 -1
  14. package/{types/lib → dist/src}/header-validator.d.ts +0 -0
  15. package/dist/src/header-validator.d.ts.map +1 -0
  16. package/dist/src/index-browser.d.ts +8 -0
  17. package/dist/src/index-browser.d.ts.map +1 -0
  18. package/dist/src/index.d.ts +9 -0
  19. package/dist/src/index.d.ts.map +1 -0
  20. package/{types/lib → dist/src}/indexed-reader-browser.d.ts +0 -0
  21. package/dist/src/indexed-reader-browser.d.ts.map +1 -0
  22. package/{types/lib → dist/src}/indexed-reader.d.ts +13 -13
  23. package/dist/src/indexed-reader.d.ts.map +1 -0
  24. package/{types/lib → dist/src}/indexer.d.ts +9 -9
  25. package/{types/lib → dist/src}/indexer.d.ts.map +1 -1
  26. package/{types/lib → dist/src}/iterator-channel.d.ts +0 -0
  27. package/{types/lib → dist/src}/iterator-channel.d.ts.map +1 -1
  28. package/{types/lib → dist/src}/iterator.d.ts +8 -8
  29. package/{types/lib → dist/src}/iterator.d.ts.map +1 -1
  30. package/{types/lib → dist/src}/reader-browser.d.ts +10 -10
  31. package/{types/lib → dist/src}/reader-browser.d.ts.map +1 -1
  32. package/{types/lib → dist/src}/reader.d.ts +5 -5
  33. package/{types/lib → dist/src}/reader.d.ts.map +1 -1
  34. package/{types/lib → dist/src}/writer-browser.d.ts +10 -10
  35. package/{types/lib → dist/src}/writer-browser.d.ts.map +1 -1
  36. package/{types/lib → dist/src}/writer.d.ts +4 -4
  37. package/{types/lib → dist/src}/writer.d.ts.map +1 -1
  38. package/package.json +102 -209
  39. package/{api.ts → src/api.ts} +14 -14
  40. package/{lib → src}/buffer-writer.js +5 -5
  41. package/src/coding.ts +56 -0
  42. package/{lib → src}/decoder.js +7 -7
  43. package/{lib → src}/encoder.js +1 -1
  44. package/src/header-validator.js +74 -0
  45. package/{lib → src}/header.ipldsch +0 -0
  46. package/src/index-browser.js +14 -0
  47. package/src/index.js +16 -0
  48. package/{lib → src}/indexed-reader-browser.js +0 -0
  49. package/{lib → src}/indexed-reader.js +9 -9
  50. package/{lib → src}/indexer.js +4 -4
  51. package/{lib → src}/iterator-channel.js +0 -0
  52. package/{lib → src}/iterator.js +4 -4
  53. package/{lib → src}/reader-browser.js +7 -7
  54. package/{lib → src}/reader.js +5 -5
  55. package/{lib → src}/writer-browser.js +7 -7
  56. package/{lib → src}/writer.js +3 -3
  57. package/LICENSE-APACHE +0 -13
  58. package/LICENSE-MIT +0 -7
  59. package/buffer-writer +0 -1
  60. package/car-browser.js +0 -14
  61. package/car.js +0 -16
  62. package/cjs/browser-test/common.js +0 -301
  63. package/cjs/browser-test/node-test-file-streams.js +0 -71
  64. package/cjs/browser-test/node-test-indexed-reader.js +0 -51
  65. package/cjs/browser-test/node-test-large.js +0 -135
  66. package/cjs/browser-test/node-test-raw.js +0 -68
  67. package/cjs/browser-test/node-test-updateroots.js +0 -78
  68. package/cjs/browser-test/test-buffer-writer.js +0 -330
  69. package/cjs/browser-test/test-errors.js +0 -90
  70. package/cjs/browser-test/test-indexer.js +0 -80
  71. package/cjs/browser-test/test-interface.js +0 -21
  72. package/cjs/browser-test/test-iterator.js +0 -83
  73. package/cjs/browser-test/test-reader.js +0 -278
  74. package/cjs/browser-test/test-writer.js +0 -286
  75. package/cjs/browser-test/verify-store-reader.js +0 -142
  76. package/cjs/car-browser.js +0 -18
  77. package/cjs/car.js +0 -20
  78. package/cjs/lib/buffer-writer.js +0 -164
  79. package/cjs/lib/decoder.js +0 -301
  80. package/cjs/lib/encoder.js +0 -44
  81. package/cjs/lib/header-validator.js +0 -29
  82. package/cjs/lib/indexed-reader-browser.js +0 -13
  83. package/cjs/lib/indexed-reader.js +0 -90
  84. package/cjs/lib/indexer.js +0 -41
  85. package/cjs/lib/iterator-channel.js +0 -77
  86. package/cjs/lib/iterator.js +0 -97
  87. package/cjs/lib/reader-browser.js +0 -62
  88. package/cjs/lib/reader.js +0 -38
  89. package/cjs/lib/writer-browser.js +0 -118
  90. package/cjs/lib/writer.js +0 -51
  91. package/cjs/node-test/common.js +0 -301
  92. package/cjs/node-test/node-test-file-streams.js +0 -71
  93. package/cjs/node-test/node-test-indexed-reader.js +0 -51
  94. package/cjs/node-test/node-test-large.js +0 -135
  95. package/cjs/node-test/node-test-raw.js +0 -68
  96. package/cjs/node-test/node-test-updateroots.js +0 -78
  97. package/cjs/node-test/test-buffer-writer.js +0 -330
  98. package/cjs/node-test/test-errors.js +0 -90
  99. package/cjs/node-test/test-indexer.js +0 -80
  100. package/cjs/node-test/test-interface.js +0 -21
  101. package/cjs/node-test/test-iterator.js +0 -83
  102. package/cjs/node-test/test-reader.js +0 -278
  103. package/cjs/node-test/test-writer.js +0 -286
  104. package/cjs/node-test/verify-store-reader.js +0 -142
  105. package/decoder +0 -1
  106. package/esm/browser-test/common.js +0 -274
  107. package/esm/browser-test/node-test-file-streams.js +0 -76
  108. package/esm/browser-test/node-test-indexed-reader.js +0 -53
  109. package/esm/browser-test/node-test-large.js +0 -109
  110. package/esm/browser-test/node-test-raw.js +0 -63
  111. package/esm/browser-test/node-test-updateroots.js +0 -76
  112. package/esm/browser-test/test-buffer-writer.js +0 -311
  113. package/esm/browser-test/test-errors.js +0 -91
  114. package/esm/browser-test/test-indexer.js +0 -85
  115. package/esm/browser-test/test-interface.js +0 -24
  116. package/esm/browser-test/test-iterator.js +0 -91
  117. package/esm/browser-test/test-reader.js +0 -270
  118. package/esm/browser-test/test-writer.js +0 -297
  119. package/esm/browser-test/verify-store-reader.js +0 -122
  120. package/esm/car-browser.js +0 -16
  121. package/esm/car.js +0 -18
  122. package/esm/lib/buffer-writer.js +0 -129
  123. package/esm/lib/decoder.js +0 -265
  124. package/esm/lib/encoder.js +0 -35
  125. package/esm/lib/header-validator.js +0 -23
  126. package/esm/lib/indexed-reader-browser.js +0 -6
  127. package/esm/lib/indexed-reader.js +0 -78
  128. package/esm/lib/indexer.js +0 -38
  129. package/esm/lib/iterator-channel.js +0 -71
  130. package/esm/lib/iterator.js +0 -92
  131. package/esm/lib/reader-browser.js +0 -57
  132. package/esm/lib/reader.js +0 -26
  133. package/esm/lib/writer-browser.js +0 -115
  134. package/esm/lib/writer.js +0 -42
  135. package/esm/node-test/common.js +0 -274
  136. package/esm/node-test/node-test-file-streams.js +0 -76
  137. package/esm/node-test/node-test-indexed-reader.js +0 -53
  138. package/esm/node-test/node-test-large.js +0 -109
  139. package/esm/node-test/node-test-raw.js +0 -63
  140. package/esm/node-test/node-test-updateroots.js +0 -76
  141. package/esm/node-test/test-buffer-writer.js +0 -311
  142. package/esm/node-test/test-errors.js +0 -91
  143. package/esm/node-test/test-indexer.js +0 -85
  144. package/esm/node-test/test-interface.js +0 -24
  145. package/esm/node-test/test-iterator.js +0 -91
  146. package/esm/node-test/test-reader.js +0 -270
  147. package/esm/node-test/test-writer.js +0 -297
  148. package/esm/node-test/verify-store-reader.js +0 -122
  149. package/esm/package.json +0 -9
  150. package/examples/car-to-fixture.js +0 -66
  151. package/examples/dump-car.js +0 -58
  152. package/examples/dump-index.js +0 -24
  153. package/examples/package.json +0 -27
  154. package/examples/round-trip.js +0 -45
  155. package/examples/test-examples.js +0 -115
  156. package/examples/verify-car.js +0 -87
  157. package/index.js +0 -1
  158. package/indexed-reader +0 -1
  159. package/indexer +0 -1
  160. package/iterator +0 -1
  161. package/lib/coding.ts +0 -56
  162. package/lib/header-validator.js +0 -33
  163. package/reader +0 -1
  164. package/test/_fixtures_to_js.mjs +0 -24
  165. package/test/common.js +0 -210
  166. package/test/go.car +0 -0
  167. package/test/go.carv2 +0 -0
  168. package/test/node-test-file-streams.js +0 -84
  169. package/test/node-test-indexed-reader.js +0 -45
  170. package/test/node-test-large.js +0 -112
  171. package/test/node-test-raw.js +0 -83
  172. package/test/node-test-updateroots.js +0 -89
  173. package/test/test-buffer-writer.js +0 -256
  174. package/test/test-errors.js +0 -98
  175. package/test/test-indexer.js +0 -87
  176. package/test/test-interface.js +0 -24
  177. package/test/test-iterator.js +0 -74
  178. package/test/test-reader.js +0 -245
  179. package/test/test-writer.js +0 -336
  180. package/test/verify-store-reader.js +0 -191
  181. package/tsconfig.json +0 -48
  182. package/types/api.d.ts.map +0 -1
  183. package/types/car-browser.d.ts +0 -8
  184. package/types/car-browser.d.ts.map +0 -1
  185. package/types/car.d.ts +0 -9
  186. package/types/car.d.ts.map +0 -1
  187. package/types/lib/coding.d.ts +0 -41
  188. package/types/lib/coding.d.ts.map +0 -1
  189. package/types/lib/header-validator.d.ts.map +0 -1
  190. package/types/lib/indexed-reader-browser.d.ts.map +0 -1
  191. package/types/lib/indexed-reader.d.ts.map +0 -1
  192. package/types/test/_fixtures_to_js.d.mts +0 -3
  193. package/types/test/_fixtures_to_js.d.mts.map +0 -1
  194. package/types/test/common.d.ts +0 -73
  195. package/types/test/common.d.ts.map +0 -1
  196. package/types/test/fixtures-expectations.d.ts +0 -63
  197. package/types/test/fixtures-expectations.d.ts.map +0 -1
  198. package/types/test/fixtures.d.ts +0 -3
  199. package/types/test/fixtures.d.ts.map +0 -1
  200. package/types/test/node-test-file-streams.d.ts +0 -3
  201. package/types/test/node-test-file-streams.d.ts.map +0 -1
  202. package/types/test/node-test-indexed-reader.d.ts +0 -2
  203. package/types/test/node-test-indexed-reader.d.ts.map +0 -1
  204. package/types/test/node-test-large.d.ts +0 -2
  205. package/types/test/node-test-large.d.ts.map +0 -1
  206. package/types/test/node-test-raw.d.ts +0 -2
  207. package/types/test/node-test-raw.d.ts.map +0 -1
  208. package/types/test/node-test-updateroots.d.ts +0 -2
  209. package/types/test/node-test-updateroots.d.ts.map +0 -1
  210. package/types/test/test-buffer-writer.d.ts +0 -2
  211. package/types/test/test-buffer-writer.d.ts.map +0 -1
  212. package/types/test/test-errors.d.ts +0 -2
  213. package/types/test/test-errors.d.ts.map +0 -1
  214. package/types/test/test-indexer.d.ts +0 -2
  215. package/types/test/test-indexer.d.ts.map +0 -1
  216. package/types/test/test-interface.d.ts +0 -2
  217. package/types/test/test-interface.d.ts.map +0 -1
  218. package/types/test/test-iterator.d.ts +0 -2
  219. package/types/test/test-iterator.d.ts.map +0 -1
  220. package/types/test/test-reader.d.ts +0 -2
  221. package/types/test/test-reader.d.ts.map +0 -1
  222. package/types/test/test-writer.d.ts +0 -2
  223. package/types/test/test-writer.d.ts.map +0 -1
  224. package/types/test/verify-store-reader.d.ts +0 -29
  225. package/types/test/verify-store-reader.d.ts.map +0 -1
  226. package/writer +0 -1
@@ -4,10 +4,10 @@ import { tokensToLength } from 'cborg/length'
4
4
  import * as CBOR from '@ipld/dag-cbor'
5
5
 
6
6
  /**
7
- * @typedef {import('../api').CID} CID
8
- * @typedef {import('../api').Block} Block
9
- * @typedef {import('../api').CarBufferWriter} Writer
10
- * @typedef {import('../api').CarBufferWriterOptions} Options
7
+ * @typedef {import('./api').CID} CID
8
+ * @typedef {import('./api').Block} Block
9
+ * @typedef {import('./api').CarBufferWriter} Writer
10
+ * @typedef {import('./api').CarBufferWriterOptions} Options
11
11
  * @typedef {import('./coding').CarEncoder} CarEncoder
12
12
  */
13
13
 
@@ -53,7 +53,7 @@ class CarBufferWriter {
53
53
  * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
54
54
  * Throws if there is not enough capacity.
55
55
  *
56
- * @param {Block} block A `{ cid:CID, bytes:Uint8Array }` pair.
56
+ * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
57
57
  * @returns {CarBufferWriter}
58
58
  */
59
59
  write (block) {
package/src/coding.ts ADDED
@@ -0,0 +1,56 @@
1
+ import type { CID } from 'multiformats/cid'
2
+ import type { Block, BlockIndex } from './api.js'
3
+
4
+ export interface CarEncoder {
5
+ setRoots: (roots: CID[]) => Promise<void>
6
+
7
+ writeBlock: (block: Block) => Promise<void>
8
+
9
+ close: () => Promise<void>
10
+ }
11
+
12
+ export interface IteratorChannel_Writer<T> {
13
+ write: (chunk: T) => Promise<void>
14
+ end: () => Promise<void>
15
+ }
16
+
17
+ export interface IteratorChannel<T> {
18
+ writer: IteratorChannel_Writer<T>
19
+
20
+ iterator: AsyncIterator<T>
21
+ }
22
+
23
+ export interface CarHeader {
24
+ version: 1
25
+ roots: CID[]
26
+ }
27
+
28
+ export interface CarV2FixedHeader {
29
+ characteristics: [bigint, bigint]
30
+ dataOffset: number
31
+ dataSize: number
32
+ indexOffset: number
33
+ }
34
+
35
+ export interface CarV2Header extends CarV2FixedHeader {
36
+ version: 2
37
+ roots: CID[]
38
+ }
39
+
40
+ export interface CarDecoder {
41
+ header: () => Promise<CarHeader|CarV2Header>
42
+
43
+ blocks: () => AsyncGenerator<Block>
44
+
45
+ blocksIndex: () => AsyncGenerator<BlockIndex>
46
+ }
47
+
48
+ export interface BytesReader {
49
+ upTo: (length: number) => Promise<Uint8Array>
50
+
51
+ exactly: (length: number) => Promise<Uint8Array>
52
+
53
+ seek: (length: number) => void
54
+
55
+ pos: number
56
+ }
@@ -5,9 +5,9 @@ import { decode as decodeDagCbor } from '@ipld/dag-cbor'
5
5
  import { CarHeader as headerValidator } from './header-validator.js'
6
6
 
7
7
  /**
8
- * @typedef {import('../api').Block} Block
9
- * @typedef {import('../api').BlockHeader} BlockHeader
10
- * @typedef {import('../api').BlockIndex} BlockIndex
8
+ * @typedef {import('./api').Block} Block
9
+ * @typedef {import('./api').BlockHeader} BlockHeader
10
+ * @typedef {import('./api').BlockIndex} BlockIndex
11
11
  * @typedef {import('./coding').BytesReader} BytesReader
12
12
  * @typedef {import('./coding').CarHeader} CarHeader
13
13
  * @typedef {import('./coding').CarV2Header} CarV2Header
@@ -33,7 +33,7 @@ async function readVarint (reader) {
33
33
  throw new Error('Unexpected end of data')
34
34
  }
35
35
  const i = varint.decode(bytes)
36
- reader.seek(varint.decode.bytes)
36
+ reader.seek(/** @type {number} */(varint.decode.bytes))
37
37
  return i
38
38
  /* c8 ignore next 2 */
39
39
  // Node.js 12 c8 bug
@@ -117,9 +117,9 @@ async function readMultihash (reader) {
117
117
 
118
118
  const bytes = await reader.upTo(8)
119
119
  varint.decode(bytes) // code
120
- const codeLength = varint.decode.bytes
120
+ const codeLength = /** @type {number} */(varint.decode.bytes)
121
121
  const length = varint.decode(bytes.subarray(varint.decode.bytes))
122
- const lengthLength = varint.decode.bytes
122
+ const lengthLength = /** @type {number} */(varint.decode.bytes)
123
123
  const mhLength = codeLength + lengthLength + length
124
124
  const multihash = await reader.exactly(mhLength)
125
125
  reader.seek(mhLength)
@@ -183,7 +183,7 @@ export async function readBlockHead (reader) {
183
183
 
184
184
  /**
185
185
  * @param {BytesReader} reader
186
- * @return {Promise<Block>}
186
+ * @returns {Promise<Block>}
187
187
  */
188
188
  async function readBlock (reader) {
189
189
  const { cid, blockLength } = await readBlockHead(reader)
@@ -3,7 +3,7 @@ import { encode as dagCborEncode } from '@ipld/dag-cbor'
3
3
 
4
4
  /**
5
5
  * @typedef {import('multiformats').CID} CID
6
- * @typedef {import('../api').Block} Block
6
+ * @typedef {import('./api').Block} Block
7
7
  * @typedef {import('./coding').CarEncoder} CarEncoder
8
8
  * @typedef {import('./coding').IteratorChannel_Writer<Uint8Array>} IteratorChannel_Writer
9
9
  */
@@ -0,0 +1,74 @@
1
+ /* eslint-disable jsdoc/check-indentation */
2
+
3
+ /** Auto-generated with ipld-schema-validator@0.0.0-dev at Thu Jun 17 2021 from IPLD Schema:
4
+ *
5
+ * type CarHeader struct {
6
+ * version Int
7
+ * roots optional [&Any]
8
+ * # roots is _not_ optional for CarV1 but we defer that check within code to
9
+ * # gracefully handle the >V1 case where it's just {version:X}
10
+ * }
11
+ *
12
+ */
13
+
14
+ const Kinds = {
15
+ Null: /**
16
+ * @param {any} obj
17
+ * @returns {boolean}
18
+ */ (/** @type {any} */ obj) => obj === null,
19
+ Int: /**
20
+ * @param {any} obj
21
+ * @returns {boolean}
22
+ */ (/** @type {any} */ obj) => Number.isInteger(obj),
23
+ Float: /**
24
+ * @param {any} obj
25
+ * @returns {boolean}
26
+ */ (/** @type {any} */ obj) => typeof obj === 'number' && Number.isFinite(obj),
27
+ String: /**
28
+ * @param {any} obj
29
+ * @returns {boolean}
30
+ */ (/** @type {any} */ obj) => typeof obj === 'string',
31
+ Bool: /**
32
+ * @param {any} obj
33
+ * @returns {boolean}
34
+ */ (/** @type {any} */ obj) => typeof obj === 'boolean',
35
+ Bytes: /**
36
+ * @param {any} obj
37
+ * @returns {boolean}
38
+ */ (/** @type {any} */ obj) => obj instanceof Uint8Array,
39
+ Link: /**
40
+ * @param {any} obj
41
+ * @returns {boolean}
42
+ */ (/** @type {any} */ obj) => !Kinds.Null(obj) && typeof obj === 'object' && obj.asCID === obj,
43
+ List: /**
44
+ * @param {any} obj
45
+ * @returns {boolean}
46
+ */ (/** @type {any} */ obj) => Array.isArray(obj),
47
+ Map: /**
48
+ * @param {any} obj
49
+ * @returns {boolean}
50
+ */ (/** @type {any} */ obj) => !Kinds.Null(obj) && typeof obj === 'object' && obj.asCID !== obj && !Kinds.List(obj) && !Kinds.Bytes(obj)
51
+ }
52
+ /** @type {{ [k in string]: (obj:any)=>boolean}} */
53
+ const Types = {
54
+ Int: Kinds.Int,
55
+ 'CarHeader > version': /**
56
+ * @param {any} obj
57
+ * @returns {boolean}
58
+ */ (/** @type {any} */ obj) => Types.Int(obj),
59
+ 'CarHeader > roots (anon) > valueType (anon)': Kinds.Link,
60
+ 'CarHeader > roots (anon)': /**
61
+ * @param {any} obj
62
+ * @returns {boolean}
63
+ */ (/** @type {any} */ obj) => Kinds.List(obj) && Array.prototype.every.call(obj, Types['CarHeader > roots (anon) > valueType (anon)']),
64
+ 'CarHeader > roots': /**
65
+ * @param {any} obj
66
+ * @returns {boolean}
67
+ */ (/** @type {any} */ obj) => Types['CarHeader > roots (anon)'](obj),
68
+ CarHeader: /**
69
+ * @param {any} obj
70
+ * @returns {boolean}
71
+ */ (/** @type {any} */ obj) => { const keys = obj && Object.keys(obj); return Kinds.Map(obj) && ['version'].every((k) => keys.includes(k)) && Object.entries(obj).every(([name, value]) => Types['CarHeader > ' + name] && Types['CarHeader > ' + name](value)) }
72
+ }
73
+
74
+ export const CarHeader = Types.CarHeader
File without changes
@@ -0,0 +1,14 @@
1
+ import { CarReader } from './reader-browser.js'
2
+ import { CarIndexer } from './indexer.js'
3
+ import { CarBlockIterator, CarCIDIterator } from './iterator.js'
4
+ import { CarWriter } from './writer-browser.js'
5
+ import { CarIndexedReader } from './indexed-reader-browser.js'
6
+
7
+ export {
8
+ CarReader,
9
+ CarIndexer,
10
+ CarBlockIterator,
11
+ CarCIDIterator,
12
+ CarWriter,
13
+ CarIndexedReader
14
+ }
package/src/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import { CarReader } from './reader.js'
2
+ import { CarIndexer } from './indexer.js'
3
+ import { CarBlockIterator, CarCIDIterator } from './iterator.js'
4
+ import { CarWriter } from './writer.js'
5
+ import { CarIndexedReader } from './indexed-reader.js'
6
+ import * as CarBufferWriter from './buffer-writer.js'
7
+
8
+ export {
9
+ CarReader,
10
+ CarIndexer,
11
+ CarBlockIterator,
12
+ CarCIDIterator,
13
+ CarWriter,
14
+ CarIndexedReader,
15
+ CarBufferWriter
16
+ }
File without changes
@@ -6,9 +6,9 @@ import { CarReader as NodeCarReader } from './reader.js'
6
6
 
7
7
  /**
8
8
  * @typedef {import('fs').promises.FileHandle} FileHandle
9
- * @typedef {import('../api').Block} Block
10
- * @typedef {import('../api').BlockIndex} BlockIndex
11
- * @typedef {import('../api').CarReader} CarReaderIface
9
+ * @typedef {import('./api').Block} Block
10
+ * @typedef {import('./api').BlockIndex} BlockIndex
11
+ * @typedef {import('./api').CarReader} CarReaderIface
12
12
  * @typedef {import('./reader-browser').CarReader} CarReader
13
13
  * @typedef {{ blockLength:number, blockOffset:number }} RawLocation
14
14
  */
@@ -68,7 +68,7 @@ export class CarIndexedReader {
68
68
  /**
69
69
  * See {@link CarReader#getRoots}
70
70
  *
71
- * @method
71
+ * @function
72
72
  * @memberof CarIndexedReader
73
73
  * @instance
74
74
  * @async
@@ -83,7 +83,7 @@ export class CarIndexedReader {
83
83
  /**
84
84
  * See {@link CarReader#has}
85
85
  *
86
- * @method
86
+ * @function
87
87
  * @memberof CarIndexedReader
88
88
  * @instance
89
89
  * @async
@@ -99,7 +99,7 @@ export class CarIndexedReader {
99
99
  /**
100
100
  * See {@link CarReader#get}
101
101
  *
102
- * @method
102
+ * @function
103
103
  * @memberof CarIndexedReader
104
104
  * @instance
105
105
  * @async
@@ -129,7 +129,7 @@ export class CarIndexedReader {
129
129
  /**
130
130
  * See {@link CarReader#blocks}
131
131
  *
132
- * @method
132
+ * @function
133
133
  * @memberof CarIndexedReader
134
134
  * @instance
135
135
  * @async
@@ -150,7 +150,7 @@ export class CarIndexedReader {
150
150
  /**
151
151
  * See {@link CarReader#cids}
152
152
  *
153
- * @method
153
+ * @function
154
154
  * @memberof CarIndexedReader
155
155
  * @instance
156
156
  * @async
@@ -167,7 +167,7 @@ export class CarIndexedReader {
167
167
  * Close the underlying file descriptor maintained by this `CarIndexedReader`.
168
168
  * This must be called for proper resource clean-up to occur.
169
169
  *
170
- * @method
170
+ * @function
171
171
  * @memberof CarIndexedReader
172
172
  * @instance
173
173
  * @async
@@ -6,9 +6,9 @@ import {
6
6
 
7
7
  /**
8
8
  * @typedef {import('multiformats').CID} CID
9
- * @typedef {import('../api').Block} Block
10
- * @typedef {import('../api').RootsReader} RootsReader
11
- * @typedef {import('../api').BlockIndex} BlockIndex
9
+ * @typedef {import('./api').Block} Block
10
+ * @typedef {import('./api').RootsReader} RootsReader
11
+ * @typedef {import('./api').BlockIndex} BlockIndex
12
12
  * @typedef {import('./coding').BytesReader} BytesReader
13
13
  */
14
14
 
@@ -62,7 +62,7 @@ export class CarIndexer {
62
62
  * Get the list of roots defined by the CAR referenced by this indexer. May be
63
63
  * zero or more `CID`s.
64
64
  *
65
- * @method
65
+ * @function
66
66
  * @memberof CarIndexer
67
67
  * @instance
68
68
  * @async
File without changes
@@ -6,8 +6,8 @@ import {
6
6
 
7
7
  /**
8
8
  * @typedef {import('multiformats').CID} CID
9
- * @typedef {import('../api').Block} Block
10
- * @typedef {import('../api').RootsReader} RootsReader
9
+ * @typedef {import('./api').Block} Block
10
+ * @typedef {import('./api').RootsReader} RootsReader
11
11
  * @typedef {import('./coding').BytesReader} BytesReader
12
12
  */
13
13
 
@@ -77,7 +77,7 @@ export class CarBlockIterator extends CarIteratorBase {
77
77
  * Get the list of roots defined by the CAR referenced by this iterator. May be
78
78
  * zero or more `CID`s.
79
79
  *
80
- * @method getRoots
80
+ * @function getRoots
81
81
  * @memberof CarBlockIterator
82
82
  * @instance
83
83
  * @async
@@ -172,7 +172,7 @@ export class CarCIDIterator extends CarIteratorBase {
172
172
  * Get the list of roots defined by the CAR referenced by this iterator. May be
173
173
  * zero or more `CID`s.
174
174
  *
175
- * @method getRoots
175
+ * @function getRoots
176
176
  * @memberof CarCIDIterator
177
177
  * @instance
178
178
  * @async
@@ -2,8 +2,8 @@ import { asyncIterableReader, bytesReader, createDecoder } from './decoder.js'
2
2
 
3
3
  /**
4
4
  * @typedef {import('multiformats').CID} CID
5
- * @typedef {import('../api').Block} Block
6
- * @typedef {import('../api').CarReader} CarReaderIface
5
+ * @typedef {import('./api').Block} Block
6
+ * @typedef {import('./api').CarReader} CarReaderIface
7
7
  * @typedef {import('./coding').BytesReader} BytesReader
8
8
  * @typedef {import('./coding').CarHeader} CarHeader
9
9
  * @typedef {import('./coding').CarV2Header} CarV2Header
@@ -55,7 +55,7 @@ export class CarReader {
55
55
  * Get the list of roots defined by the CAR referenced by this reader. May be
56
56
  * zero or more `CID`s.
57
57
  *
58
- * @method
58
+ * @function
59
59
  * @memberof CarReader
60
60
  * @instance
61
61
  * @async
@@ -71,7 +71,7 @@ export class CarReader {
71
71
  * Check whether a given `CID` exists within the CAR referenced by this
72
72
  * reader.
73
73
  *
74
- * @method
74
+ * @function
75
75
  * @memberof CarReader
76
76
  * @instance
77
77
  * @async
@@ -90,7 +90,7 @@ export class CarReader {
90
90
  * the provided `CID` doesn't exist within the CAR, `undefined` will be
91
91
  * returned.
92
92
  *
93
- * @method
93
+ * @function
94
94
  * @memberof CarReader
95
95
  * @instance
96
96
  * @async
@@ -109,7 +109,7 @@ export class CarReader {
109
109
  * of the `Block`s (`{ cid:CID, bytes:Uint8Array }` pairs) contained within
110
110
  * the CAR referenced by this reader.
111
111
  *
112
- * @method
112
+ * @function
113
113
  * @memberof CarReader
114
114
  * @instance
115
115
  * @async
@@ -126,7 +126,7 @@ export class CarReader {
126
126
  * Returns a `CIDIterator` (`AsyncIterable<CID>`) that iterates over all of
127
127
  * the `CID`s contained within the CAR referenced by this reader.
128
128
  *
129
- * @method
129
+ * @function
130
130
  * @memberof CarReader
131
131
  * @instance
132
132
  * @async
@@ -3,9 +3,9 @@ import { promisify } from 'util'
3
3
  import { CarReader as BrowserCarReader } from './reader-browser.js'
4
4
 
5
5
  /**
6
- * @typedef {import('../api').Block} Block
7
- * @typedef {import('../api').BlockIndex} BlockIndex
8
- * @typedef {import('../api').CarReader} CarReaderIface
6
+ * @typedef {import('./api').Block} Block
7
+ * @typedef {import('./api').BlockIndex} BlockIndex
8
+ * @typedef {import('./api').CarReader} CarReaderIface
9
9
  */
10
10
 
11
11
  const fsread = promisify(fs.read)
@@ -27,10 +27,10 @@ export class CarReader extends BrowserCarReader {
27
27
  * @async
28
28
  * @static
29
29
  * @memberof CarReader
30
- * @param {fs.promises.FileHandle | number} fd A file descriptor from the
30
+ * @param {fs.promises.FileHandle | number} fd - A file descriptor from the
31
31
  * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
32
32
  * from `fs.promises.open()`.
33
- * @param {BlockIndex} blockIndex An index pointing to the location of the
33
+ * @param {BlockIndex} blockIndex - An index pointing to the location of the
34
34
  * Block required. This `BlockIndex` should take the form:
35
35
  * `{cid:CID, blockLength:number, blockOffset:number}`.
36
36
  * @returns {Promise<Block>} A `{ cid:CID, bytes:Uint8Array }` pair.
@@ -4,9 +4,9 @@ import { create as iteratorChannel } from './iterator-channel.js'
4
4
  import { bytesReader, readHeader } from './decoder.js'
5
5
 
6
6
  /**
7
- * @typedef {import('../api').Block} Block
8
- * @typedef {import('../api').BlockWriter} BlockWriter
9
- * @typedef {import('../api').WriterChannel} WriterChannel
7
+ * @typedef {import('./api').Block} Block
8
+ * @typedef {import('./api').BlockWriter} BlockWriter
9
+ * @typedef {import('./api').WriterChannel} WriterChannel
10
10
  * @typedef {import('./coding').CarEncoder} CarEncoder
11
11
  * @typedef {import('./coding').IteratorChannel<Uint8Array>} IteratorChannel
12
12
  */
@@ -62,11 +62,11 @@ export class CarWriter {
62
62
  /**
63
63
  * Write a `Block` (a `{ cid:CID, bytes:Uint8Array }` pair) to the archive.
64
64
  *
65
- * @method
65
+ * @function
66
66
  * @memberof CarWriter
67
67
  * @instance
68
68
  * @async
69
- * @param {Block} block A `{ cid:CID, bytes:Uint8Array }` pair.
69
+ * @param {Block} block - A `{ cid:CID, bytes:Uint8Array }` pair.
70
70
  * @returns {Promise<void>} The returned promise will only resolve once the
71
71
  * bytes this block generates are written to the `out` iterable.
72
72
  */
@@ -91,7 +91,7 @@ export class CarWriter {
91
91
  * Finalise the CAR archive and signal that the `out` iterable should end once
92
92
  * any remaining bytes are written.
93
93
  *
94
- * @method
94
+ * @function
95
95
  * @memberof CarWriter
96
96
  * @instance
97
97
  * @async
@@ -166,7 +166,7 @@ export class CarWriter {
166
166
  * @static
167
167
  * @memberof CarWriter
168
168
  * @param {Uint8Array} bytes
169
- * @param {CID[]} roots A new list of roots to replace the existing list in
169
+ * @param {CID[]} roots - A new list of roots to replace the existing list in
170
170
  * the CAR header. The new header must take up the same number of bytes as the
171
171
  * existing header, so the roots should collectively be the same byte length
172
172
  * as the existing roots.
@@ -9,7 +9,7 @@ const fswrite = promisify(fs.write)
9
9
 
10
10
  /**
11
11
  * @typedef {import('multiformats/cid').CID} CID
12
- * @typedef {import('../api').BlockWriter} BlockWriter
12
+ * @typedef {import('./api').BlockWriter} BlockWriter
13
13
  */
14
14
 
15
15
  /**
@@ -35,10 +35,10 @@ export class CarWriter extends BrowserCarWriter {
35
35
  * @async
36
36
  * @static
37
37
  * @memberof CarWriter
38
- * @param {fs.promises.FileHandle | number} fd A file descriptor from the
38
+ * @param {fs.promises.FileHandle | number} fd - A file descriptor from the
39
39
  * Node.js `fs` module. Either an integer, from `fs.open()` or a `FileHandle`
40
40
  * from `fs.promises.open()`.
41
- * @param {CID[]} roots A new list of roots to replace the existing list in
41
+ * @param {CID[]} roots - A new list of roots to replace the existing list in
42
42
  * the CAR header. The new header must take up the same number of bytes as the
43
43
  * existing header, so the roots should collectively be the same byte length
44
44
  * as the existing roots.
package/LICENSE-APACHE DELETED
@@ -1,13 +0,0 @@
1
- Copyright 2020 Protocol Labs
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
package/LICENSE-MIT DELETED
@@ -1,7 +0,0 @@
1
- Copyright 2020 Protocol Labs
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/buffer-writer DELETED
@@ -1 +0,0 @@
1
- module.exports = require('./cjs/lib/buffer-writer.js')
package/car-browser.js DELETED
@@ -1,14 +0,0 @@
1
- import { CarReader } from './lib/reader-browser.js'
2
- import { CarIndexer } from './lib/indexer.js'
3
- import { CarBlockIterator, CarCIDIterator } from './lib/iterator.js'
4
- import { CarWriter } from './lib/writer-browser.js'
5
- import { CarIndexedReader } from './lib/indexed-reader-browser.js'
6
-
7
- export {
8
- CarReader,
9
- CarIndexer,
10
- CarBlockIterator,
11
- CarCIDIterator,
12
- CarWriter,
13
- CarIndexedReader
14
- }
package/car.js DELETED
@@ -1,16 +0,0 @@
1
- import { CarReader } from './lib/reader.js'
2
- import { CarIndexer } from './lib/indexer.js'
3
- import { CarBlockIterator, CarCIDIterator } from './lib/iterator.js'
4
- import { CarWriter } from './lib/writer.js'
5
- import { CarIndexedReader } from './lib/indexed-reader.js'
6
- import * as CarBufferWriter from './lib/buffer-writer.js'
7
-
8
- export {
9
- CarReader,
10
- CarIndexer,
11
- CarBlockIterator,
12
- CarCIDIterator,
13
- CarWriter,
14
- CarIndexedReader,
15
- CarBufferWriter
16
- }