@@ -6,66 +6,16 @@ const resolve = require('./resolvers')
6
6
const last = require ( 'it-last' )
7
7
8
8
/**
9
- * @typedef {import('ipfs-unixfs') } UnixFS
9
+ * @typedef {import('ipfs-unixfs').UnixFS } UnixFS
10
10
* @typedef {import('ipld-dag-pb').DAGNode } DAGNode
11
- * @typedef {import('ipfs-core-types/src/ipld').IPLD } IPLD
12
- *
13
- * @typedef {object } UnixFSFile
14
- * @property {'file' } type
15
- * @property {string } name
16
- * @property {string } path
17
- * @property {CID } cid
18
- * @property {number } depth
19
- * @property {UnixFS } unixfs
20
- * @property {DAGNode } node
21
- * @property {(options?: ExporterOptions) => AsyncIterable<Uint8Array> } content
22
- *
23
- * @typedef {object } UnixFSDirectory
24
- * @property {'directory' } type
25
- * @property {string } name
26
- * @property {string } path
27
- * @property {CID } cid
28
- * @property {number } depth
29
- * @property {UnixFS } unixfs
30
- * @property {DAGNode } node
31
- * @property {(options?: ExporterOptions) => AsyncIterable<UnixFSEntry> } content
32
- *
33
- * @typedef {object } ObjectNode
34
- * @property {'object' } type
35
- * @property {string } name
36
- * @property {string } path
37
- * @property {CID } cid
38
- * @property {number } depth
39
- * @property {Uint8Array } node
40
- * @property {(options?: ExporterOptions) => AsyncIterable<any> } content
41
- *
42
- * @typedef {object } RawNode
43
- * @property {'raw' } type
44
- * @property {string } name
45
- * @property {string } path
46
- * @property {CID } cid
47
- * @property {number } depth
48
- * @property {Uint8Array } node
49
- * @property {(options?: ExporterOptions) => AsyncIterable<Uint8Array> } content
50
- *
51
- * @typedef {object } IdentityNode
52
- * @property {'identity' } type
53
- * @property {string } name
54
- * @property {string } path
55
- * @property {CID } cid
56
- * @property {number } depth
57
- * @property {Uint8Array } node
58
- * @property {(options?: ExporterOptions) => AsyncIterable<Uint8Array> } content
59
- *
60
- * @typedef {UnixFSFile | UnixFSDirectory | ObjectNode | RawNode | IdentityNode } UnixFSEntry
61
- */
62
-
63
- /**
64
- * @typedef {object } ExporterOptions
65
- * @property {number } [offset=0]
66
- * @property {number } [length]
67
- * @property {AbortSignal } [signal]
68
- * @property {number } [timeout]
11
+ * @typedef {import('ipld') } IPLD
12
+ * @typedef {import('./types').ExporterOptions } ExporterOptions
13
+ * @typedef {import('./types').UnixFSFile } UnixFSFile
14
+ * @typedef {import('./types').UnixFSDirectory } UnixFSDirectory
15
+ * @typedef {import('./types').ObjectNode } ObjectNode
16
+ * @typedef {import('./types').RawNode } RawNode
17
+ * @typedef {import('./types').IdentityNode } IdentityNode
18
+ * @typedef {import('./types').UnixFSEntry } UnixFSEntry
69
19
*/
70
20
71
21
const toPathComponents = ( path = '' ) => {
@@ -115,7 +65,7 @@ const cidAndRest = (path) => {
115
65
* @param {IPLD } ipld
116
66
* @param {ExporterOptions } [options]
117
67
*/
118
- const walkPath = async function * ( path , ipld , options = { } ) {
68
+ async function * walkPath ( path , ipld , options = { } ) {
119
69
let {
120
70
cid,
121
71
toResolve
@@ -152,7 +102,7 @@ const walkPath = async function * (path, ipld, options = {}) {
152
102
* @param {IPLD } ipld
153
103
* @param {ExporterOptions } [options]
154
104
*/
155
- const exporter = async ( path , ipld , options = { } ) => {
105
+ async function exporter ( path , ipld , options = { } ) {
156
106
const result = await last ( walkPath ( path , ipld , options ) )
157
107
158
108
if ( ! result ) {
@@ -167,7 +117,7 @@ const exporter = async (path, ipld, options = {}) => {
167
117
* @param {IPLD } ipld
168
118
* @param {ExporterOptions } [options]
169
119
*/
170
- const recursive = async function * ( path , ipld , options = { } ) {
120
+ async function * recursive ( path , ipld , options = { } ) {
171
121
const node = await exporter ( path , ipld , options )
172
122
173
123
if ( ! node ) {
@@ -202,7 +152,8 @@ const recursive = async function * (path, ipld, options = {}) {
202
152
}
203
153
}
204
154
205
- exporter . path = walkPath
206
- exporter . recursive = recursive
207
-
208
- module . exports = exporter
155
+ module . exports = {
156
+ exporter,
157
+ walkPath,
158
+ recursive
159
+ }
0 commit comments