Socket
Socket
Sign inDemoInstall

await-event-or-error

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    await-event-or-error

Returns a Promise that resolves on an event or rejects on an error


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Install size
16.1 kB
Created
Weekly downloads
 

Changelog

Source

1.0.1 (2021-02-24)

Bug Fixes

  • update readme with examples (1b3ac31)

Features

Readme

Source

Actions Status

await-event-or-error

Returns a Promise that resolves on an event or rejects on an error.

Examples

Pass an EventEmitter and an event to be watched.

await awaitEventOrError(emitter, "connected");

The function can be added to an EventEmitter to allow only passing the event.

emitter.eventOrError = awaitEventOrError;
await emitter.eventOrError("connected");

The promise will reject on an "error" event by default, but you can specify a different error event.

await emitter.eventOrError("connected", "responseError");

If the event emits values they will be returned in an array.

const values = await emitter.eventOrError("connected");
...
emitter.emit("connected", 1, 2);
...
// values === [1, 2]

Keywords

FAQs

Last updated on 24 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc