Browse Source

update README

ameba23 2 years ago
parent
commit
735287ea8b
1 changed files with 27 additions and 11 deletions
  1. 27
    11
      README.md

+ 27
- 11
README.md View File

@@ -1,19 +1,35 @@
1 1
 # kappa-drive-mount
2 2
 
3
-mount a `kappa-drive` with `hyperdrive-fuse`.
3
+Mount a `kappa-drive` with [`hyperdrive-fuse`](https://github.com/andrewosh/hyperdrive-fuse/).
4 4
 
5
-## API
6
-```
7
-const MountDrive = require('kappa-drive-mount')
8
-const mountDrive = MountDrive() 
9
-```
5
+## Example
6
+
7
+This will mount a kappa-drive for 3 seconds, and then unmount it.
8
+
9
+```js
10
+const KappaDrive = require('kappa-drive')
11
+const mount = require('./')
10 12
 
11
-### `const destroy = mountDrive.mount(drive, destination, options)`
13
+const mountdir = './mnt'
14
+const storage = './drive'
15
+const drive = KappaDrive(storage)
12 16
 
13
-mount a kappa-drive, `drive` at path `destination`. `options` will be passed to `hyperdrive-fuse`
17
+mount(drive, mountdir, (err, unmount) => {
18
+  if (err) return console.error(err)
19
+
20
+  setTimeout(() => {
21
+    unmount()
22
+  }, 3000)
23
+})
24
+```
25
+
26
+## API
27
+```js
28
+const mount = require('kappa-drive-mount')
29
+mount(drive, destination, [options,] callback)
30
+```
14 31
 
15
-Returns a promise which passes a destroy function.
32
+mount a kappa-drive, `drive` at path `destination`. `options`, if given, will be passed to `hyperdrive-fuse`.
16 33
 
17
-### `const cleanedUp = destroy.then((destroy) => { mountDrive.cleanup(destroy, desination)})`  
34
+`callback` will be given arguments `(err, unmount)`.  `unmount` is a function which can be used to unmount the drive.  The drive can also be unmounted by sending the `'SIGINT'` event (pressing Ctrl + C).
18 35
 
19
-unmount and remove the mounted drive.  Returns a promise