Needlessly Promiscuous, Modularize!
Need private packages and team management tools?Check out npm Teams »

promising-a-stream

1.0.0 • Public • Published

stream-to-promise

listen the error and success event to resolve and reject promise

API

streamToPromise(StreamInstance, successString) -> PromiseInstance

Receive a stream and listen the success and error event to resolve and reject the promise returned.

Example

const assert = require('assert');
const EventEmitter = require('events');
const streamToPromise = require('stream-to-promise');
 
const emitter = new EventEmitter();
setTimeout(() => emitter.emit('successString', 'res'), 1000);
const res = await streamToPromise(emitter, 'successString');
assert(res == 'res');
 

Install

npm i promising-a-stream

DownloadsWeekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

2.97 kB

Total Files

5

Last publish

Collaborators

  • avatar