Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit a9d303c

Browse files
docs(exporter): describe directory exporter
1 parent 43503d4 commit a9d303c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/exporters/dir.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ const switchType = require('../util').switchType
99

1010
// Logic to export a unixfs directory.
1111
module.exports = (node, name, dagService) => {
12+
// The algorithm below is as follows
13+
//
14+
// 1. Take all links from a given directory node
15+
// 2. Map each link to their full name (parent + link name) + hash
16+
// 3. Parallel map to
17+
// 3.1. Resolve the hash against the dagService
18+
// 3.2. Switch on the node type
19+
// - `directory`: return node
20+
// - `file`: use the fileExporter to load and return the file
21+
// 4. Flatten
1222
return pull(
1323
pull.values(node.links),
1424
pull.map((link) => ({

0 commit comments

Comments
 (0)