@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.
Files changed (54) hide show
  1. package/README.md +43 -0
  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.d.ts +1 -1
  12. package/dist/src/commands/utils/add-link.d.ts.map +1 -1
  13. package/dist/src/commands/utils/add-link.js.map +1 -1
  14. package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
  15. package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
  16. package/dist/src/commands/utils/constants.d.ts.map +1 -1
  17. package/dist/src/commands/utils/constants.js.map +1 -1
  18. package/dist/src/commands/utils/consumable-hash.js.map +1 -1
  19. package/dist/src/commands/utils/dir-sharded.js.map +1 -1
  20. package/dist/src/commands/utils/hamt-utils.d.ts +1 -1
  21. package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
  22. package/dist/src/commands/utils/hamt-utils.js.map +1 -1
  23. package/dist/src/commands/utils/is-over-shard-threshold.d.ts +1 -1
  24. package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
  25. package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
  26. package/dist/src/commands/utils/persist.js.map +1 -1
  27. package/dist/src/commands/utils/remove-link.d.ts +1 -1
  28. package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
  29. package/dist/src/commands/utils/remove-link.js.map +1 -1
  30. package/dist/src/commands/utils/resolve.d.ts +1 -1
  31. package/dist/src/commands/utils/resolve.d.ts.map +1 -1
  32. package/dist/src/commands/utils/resolve.js.map +1 -1
  33. package/dist/src/index.d.ts +15 -15
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/utils/glob-source.d.ts.map +1 -1
  36. package/dist/src/utils/glob-source.js +5 -4
  37. package/dist/src/utils/glob-source.js.map +1 -1
  38. package/dist/src/utils/to-mtime.d.ts +4 -0
  39. package/dist/src/utils/to-mtime.d.ts.map +1 -0
  40. package/dist/src/utils/to-mtime.js +42 -0
  41. package/dist/src/utils/to-mtime.js.map +1 -0
  42. package/dist/src/utils/url-source.js.map +1 -1
  43. package/dist/typedoc-urls.json +25 -1
  44. package/package.json +10 -14
  45. package/src/commands/stat.ts +1 -1
  46. package/src/commands/utils/add-link.ts +1 -1
  47. package/src/commands/utils/constants.ts +0 -1
  48. package/src/commands/utils/hamt-utils.ts +1 -1
  49. package/src/commands/utils/is-over-shard-threshold.ts +1 -1
  50. package/src/commands/utils/remove-link.ts +1 -2
  51. package/src/commands/utils/resolve.ts +1 -1
  52. package/src/index.ts +15 -15
  53. package/src/utils/glob-source.ts +5 -4
  54. 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)