Skip to content

Commit 1b0b2ef

Browse files
author
aegir[bot]
committed
chore: update sibling dependencies
1 parent ffe7629 commit 1b0b2ef

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

packages/unixfs/README.md

+43
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,49 @@
1313

1414
> A Helia-compatible wrapper for UnixFS
1515
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+
1659
## Table of contents <!-- omit in toc -->
1760

1861
- [Install](#install)

0 commit comments

Comments
 (0)