@@ -6,66 +6,16 @@ const resolve = require('./resolvers')
66const last = require ( 'it-last' )
77
88/**
9- * @typedef {import('ipfs-unixfs') } UnixFS
9+ * @typedef {import('ipfs-unixfs').UnixFS } UnixFS
1010 * @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
6919 */
7020
7121const toPathComponents = ( path = '' ) => {
@@ -115,7 +65,7 @@ const cidAndRest = (path) => {
11565 * @param {IPLD } ipld
11666 * @param {ExporterOptions } [options]
11767 */
118- const walkPath = async function * ( path , ipld , options = { } ) {
68+ async function * walkPath ( path , ipld , options = { } ) {
11969 let {
12070 cid,
12171 toResolve
@@ -152,7 +102,7 @@ const walkPath = async function * (path, ipld, options = {}) {
152102 * @param {IPLD } ipld
153103 * @param {ExporterOptions } [options]
154104 */
155- const exporter = async ( path , ipld , options = { } ) => {
105+ async function exporter ( path , ipld , options = { } ) {
156106 const result = await last ( walkPath ( path , ipld , options ) )
157107
158108 if ( ! result ) {
@@ -167,7 +117,7 @@ const exporter = async (path, ipld, options = {}) => {
167117 * @param {IPLD } ipld
168118 * @param {ExporterOptions } [options]
169119 */
170- const recursive = async function * ( path , ipld , options = { } ) {
120+ async function * recursive ( path , ipld , options = { } ) {
171121 const node = await exporter ( path , ipld , options )
172122
173123 if ( ! node ) {
@@ -202,7 +152,8 @@ const recursive = async function * (path, ipld, options = {}) {
202152 }
203153}
204154
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