File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 13
13
14
14
> A Helia-compatible wrapper for UnixFS
15
15
16
+ # About
17
+
18
+ ` @helia/unixfs ` is an implementation of a filesystem compatible with Helia.
19
+
20
+ See the interface for all available operations.
21
+
22
+ ## Example
23
+
24
+ ``` typescript
25
+ import { createHelia } from ' helia'
26
+ import { unixfs } from ' @helia/unixfs'
27
+
28
+ const helia = createHelia ({
29
+ // ... helia config
30
+ })
31
+ const fs = unixfs (helia )
32
+
33
+ // create an empty dir and a file, then add the file to the dir
34
+ const emptyDirCid = await fs .addDirectory ()
35
+ const fileCid = await fs .addBytes (Uint8Array .from ([0 , 1 , 2 , 3 ]))
36
+ const updateDirCid = await fs .cp (fileCid , emptyDirCid , ' foo.txt' )
37
+
38
+ // or doing the same thing as a stream
39
+ for await (const entry of fs .addAll ([{
40
+ path: ' foo.txt' ,
41
+ content: Uint8Array .from ([0 , 1 , 2 , 3 ])
42
+ }])) {
43
+ console .info (entry )
44
+ }
45
+ ```
46
+
47
+ ## Example
48
+
49
+ Recursively adding a directory (Node.js-compatibly environments only):
50
+
51
+ ``` typescript
52
+ import { globSource } from ' @helia/unixfs'
53
+
54
+ for await (const entry of fs .addAll (globSource (' path/to/containing/dir' , ' glob-pattern' ))) {
55
+ console .info (entry )
56
+ }
57
+ ```
58
+
16
59
## Table of contents <!-- omit in toc -->
17
60
18
61
- [ Install] ( #install )
You can’t perform that action at this time.
0 commit comments