@helia/unixfs 1.4.2 → 2.0.0

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.
Files changed (35) hide show
  1. package/README.md +47 -12
  2. package/dist/index.min.js +1 -1
  3. package/dist/src/commands/cat.js.map +1 -1
  4. package/dist/src/commands/chmod.js.map +1 -1
  5. package/dist/src/commands/cp.js.map +1 -1
  6. package/dist/src/commands/ls.js.map +1 -1
  7. package/dist/src/commands/mkdir.js.map +1 -1
  8. package/dist/src/commands/rm.js.map +1 -1
  9. package/dist/src/commands/stat.js.map +1 -1
  10. package/dist/src/commands/touch.js.map +1 -1
  11. package/dist/src/commands/utils/add-link.js.map +1 -1
  12. package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
  13. package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
  14. package/dist/src/commands/utils/consumable-hash.js.map +1 -1
  15. package/dist/src/commands/utils/dir-sharded.js.map +1 -1
  16. package/dist/src/commands/utils/hamt-utils.js.map +1 -1
  17. package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
  18. package/dist/src/commands/utils/persist.js.map +1 -1
  19. package/dist/src/commands/utils/remove-link.js.map +1 -1
  20. package/dist/src/commands/utils/resolve.js.map +1 -1
  21. package/dist/src/index.d.ts +16 -16
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/index.js +3 -3
  24. package/dist/src/utils/glob-source.d.ts.map +1 -1
  25. package/dist/src/utils/glob-source.js +2 -1
  26. package/dist/src/utils/glob-source.js.map +1 -1
  27. package/dist/src/utils/to-mtime.d.ts +4 -0
  28. package/dist/src/utils/to-mtime.d.ts.map +1 -0
  29. package/dist/src/utils/to-mtime.js +42 -0
  30. package/dist/src/utils/to-mtime.js.map +1 -0
  31. package/dist/src/utils/url-source.js.map +1 -1
  32. package/package.json +15 -10
  33. package/src/index.ts +16 -16
  34. package/src/utils/glob-source.ts +2 -1
  35. package/src/utils/to-mtime.ts +57 -0
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  </a>
5
5
  </p>
6
6
 
7
- # @helia/unixfs <!-- omit in toc -->
7
+ # @helia/unixfs
8
8
 
9
9
  [![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech)
10
10
  [![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech)
@@ -13,21 +13,56 @@
13
13
 
14
14
  > A Helia-compatible wrapper for UnixFS
15
15
 
16
- ## Table of contents <!-- omit in toc -->
16
+ # About
17
17
 
18
- - [Install](#install)
19
- - [Browser `<script>` tag](#browser-script-tag)
20
- - [API Docs](#api-docs)
21
- - [License](#license)
22
- - [Contribute](#contribute)
18
+ `@helia/unixfs` is an implementation of a filesystem compatible with Helia.
23
19
 
24
- ## Install
20
+ See the interface for all available operations.
21
+
22
+ ## Example - Creating files and directories
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 - Recursively adding a directory
48
+
49
+ 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
+
59
+ # Install
25
60
 
26
61
  ```console
27
62
  $ npm i @helia/unixfs
28
63
  ```
29
64
 
30
- ### Browser `<script>` tag
65
+ ## Browser `<script>` tag
31
66
 
32
67
  Loading this module through a script tag will make it's exports available as `HeliaUnixfs` in the global namespace.
33
68
 
@@ -35,18 +70,18 @@ Loading this module through a script tag will make it's exports available as `He
35
70
  <script src="https://unpkg.com/@helia/unixfs/dist/index.min.js"></script>
36
71
  ```
37
72
 
38
- ## API Docs
73
+ # API Docs
39
74
 
40
75
  - <https://ipfs.github.io/helia-unixfs/modules/_helia_unixfs.html>
41
76
 
42
- ## License
77
+ # License
43
78
 
44
79
  Licensed under either of
45
80
 
46
81
  - Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
47
82
  - MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
48
83
 
49
- ## Contribute
84
+ # Contribute
50
85
 
51
86
  Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia-unixfs/issues).
52
87