Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

callback-to-async-iterator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-to-async-iterator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc