Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ Efficiently mirror this drive into another. Returns a [`MirrorDrive`](https://gi

Call `await mirror.done()` to wait for the mirroring to finish.

#### `const watcher = db.watch([folder])`
#### `const watcher = db.watch([file|folder])`

Returns an iterator that listens on `folder` to yield changes, by default on `/`.
Returns an iterator that listens on a `file` or `folder` to yield changes, by default on `/`.

Usage example:
```js
Expand Down
17 changes: 17 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,23 @@ test('watch(folder) should normalize folder', async function (t) {
onchange = null
})

test('watch(file) basic', async function (t) {
t.plan(1)
t.timeout(1000)

const { drive } = await testenv(t.teardown)
const buf = b4a.from('hi')

await drive.put('/a.txt', buf)

const watcher = drive.watch('/a.txt')
watcher.next().then(data => {
t.ok(data)
})

await drive.put('/a.txt', buf)
})

test('drive.diff(length)', async (t) => {
const { drive, paths: { root, tmp } } = await testenv(t.teardown)
const paths = []
Expand Down