Socket
Socket
Sign inDemoInstall

event-emitter-promisify

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-emitter-promisify

Utility to resolve EventEmitters as a promise


Version published
Weekly downloads
2.7K
increased by13.52%
Maintainers
1
Weekly downloads
 
Created
Source

event-emitter-promisify

Utility to resolve EventEmitters as a promise

GitHub license npm version build Dependabot semantic-release

Usage

By default promisifyEventEmitter returns a promise which resolves to undefined if the end event is called, and rejects if the error event is called.

import { promisifyEventEmitter } from 'event-emitter-promisify'

const stream = new Readable();
stream.push(null);
await promisifyEventEmitter(stream.on('data', () => {}));

The return value on end can also be customized. For instance:

export default function arrayifyStream<T = any>(stream: EventEmitter): Promise<T[]> {
  const array: T[] = [];
  return promisifyEventEmitter(stream.on('data', data => array.push(data)), array);
}

License

©2022–present Jesse Wright, MIT License.

Keywords

FAQs

Package last updated on 17 Feb 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc