callback-to-async-iterator
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "callback-to-async-iterator", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Turn any callback-based listener into an async iterator.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -44,2 +44,19 @@ # `callback-to-async-iterator` | ||
### Options | ||
- `onClose`: A function that's called with whatever you resolve from the listener after the async iterator is done, perfect to do cleanup | ||
- `onError`: A function that's called with any error that happens in the listener or async iterator | ||
```js | ||
asyncify(listenToNewMessages, { | ||
// Close the database connection when the async iterator is done | ||
// NOTE: This is passed whatever the listener resolves the returned promise with, in this case listenToNewMessages resolves with the database connection but it could be whatever you desire | ||
onClose: (connection) => { connection.close(); }, | ||
// Log errors to your error tracking system | ||
onError: (err) => { | ||
errorTracking.capture(err); | ||
} | ||
}) | ||
``` | ||
## Credits | ||
@@ -46,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
369960
68