Skip to content

Commit

Permalink
Add events feature
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Oct 9, 2021
1 parent d1b6d89 commit 22a3837
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -284,6 +284,16 @@ await db.put('key', 'value')

</details>

### `events` (boolean or object)

Is db an event emitter, as indicated by a truthy value? And does it support specific events as indicated by nested properties?

```js
if (db.supports.events && db.supports.events.open) {
db.once('open', () => { /* .. */})
}
```

### `streams` (boolean)

Does db have the methods `createReadStream`, `createKeyStream` and `createValueStream`, following the API currently documented in `levelup`?
Expand Down
5 changes: 5 additions & 0 deletions index.js
Expand Up @@ -29,8 +29,13 @@ module.exports = function supports (...manifests) {
promises: manifest.promises || false,
streams: manifest.streams || false,
encodings: manifest.encodings || false,
events: maybeObject(manifest.events),

// Methods that are not part of abstract-leveldown or levelup
additionalMethods: Object.assign({}, manifest.additionalMethods)
})
}

function maybeObject (value) {
return !value ? false : Object.assign({}, value)
}

0 comments on commit 22a3837

Please sign in to comment.