@helia/unixfs 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/dist/index.min.js +1 -1
- package/dist/src/commands/cat.js.map +1 -1
- package/dist/src/commands/chmod.js.map +1 -1
- package/dist/src/commands/cp.js.map +1 -1
- package/dist/src/commands/ls.js.map +1 -1
- package/dist/src/commands/mkdir.js.map +1 -1
- package/dist/src/commands/rm.js.map +1 -1
- package/dist/src/commands/stat.js.map +1 -1
- package/dist/src/commands/touch.js.map +1 -1
- package/dist/src/commands/utils/add-link.d.ts +1 -1
- package/dist/src/commands/utils/add-link.d.ts.map +1 -1
- package/dist/src/commands/utils/add-link.js.map +1 -1
- package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
- package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
- package/dist/src/commands/utils/constants.d.ts.map +1 -1
- package/dist/src/commands/utils/constants.js.map +1 -1
- package/dist/src/commands/utils/consumable-hash.js.map +1 -1
- package/dist/src/commands/utils/dir-sharded.js.map +1 -1
- package/dist/src/commands/utils/hamt-utils.d.ts +1 -1
- package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
- package/dist/src/commands/utils/hamt-utils.js.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
- package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
- package/dist/src/commands/utils/persist.js.map +1 -1
- package/dist/src/commands/utils/remove-link.d.ts +1 -1
- package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
- package/dist/src/commands/utils/remove-link.js.map +1 -1
- package/dist/src/commands/utils/resolve.d.ts +1 -1
- package/dist/src/commands/utils/resolve.d.ts.map +1 -1
- package/dist/src/commands/utils/resolve.js.map +1 -1
- package/dist/src/index.d.ts +15 -15
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/utils/glob-source.d.ts.map +1 -1
- package/dist/src/utils/glob-source.js +5 -4
- package/dist/src/utils/glob-source.js.map +1 -1
- package/dist/src/utils/to-mtime.d.ts +4 -0
- package/dist/src/utils/to-mtime.d.ts.map +1 -0
- package/dist/src/utils/to-mtime.js +42 -0
- package/dist/src/utils/to-mtime.js.map +1 -0
- package/dist/src/utils/url-source.js.map +1 -1
- package/dist/typedoc-urls.json +25 -1
- package/package.json +10 -14
- package/src/commands/stat.ts +1 -1
- package/src/commands/utils/add-link.ts +1 -1
- package/src/commands/utils/constants.ts +0 -1
- package/src/commands/utils/hamt-utils.ts +1 -1
- package/src/commands/utils/is-over-shard-threshold.ts +1 -1
- package/src/commands/utils/remove-link.ts +1 -2
- package/src/commands/utils/resolve.ts +1 -1
- package/src/index.ts +15 -15
- package/src/utils/glob-source.ts +5 -4
- package/src/utils/to-mtime.ts +57 -0
package/README.md
CHANGED
|
@@ -13,6 +13,49 @@
|
|
|
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)
|