Skip to content

Commit

Permalink
docs: update README to include emitErrors option for Keyv (#1253)
Browse files Browse the repository at this point in the history
* docs: update README to include emitErrors option for Keyv

* docs: clarify error event handling in README for Keyv
  • Loading branch information
Sadzurami authored Dec 14, 2024
1 parent 5edb8c0 commit 676a7d2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/keyv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,15 @@ await cache.get('foo'); // 'cache'

# Events

Keyv is a custom `EventEmitter` and will emit an `'error'` event if there is an error. In addition it will emit a `clear` and `disconnect` event when the corresponding methods are called.
Keyv is a custom `EventEmitter` and will emit an `'error'` event if there is an error.
If there is no listener for the `'error'` event, an uncaught exception will be thrown.
To disable the `'error'` event, pass `emitErrors: false` in the constructor options.

```js
const keyv = new Keyv({ emitErrors: false });
```

In addition it will emit `clear` and `disconnect` events when the corresponding methods are called.

```js
const keyv = new Keyv();
Expand Down

0 comments on commit 676a7d2

Please sign in to comment.