Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

promisebuffer

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

promisebuffer

Utilities for Buffering streamed content into a Promise value.

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

Promise Stream Buffer

Utilities for Buffering streamed content into a Promise value.

API

buffer(stream)

Given a stream returns a Promise that will resolve with the Buffered contents of to the Stream once it has been fully written (end event emitted).

Example:

var buffer = require('promisebuffer');

buffer(require('fs').createReadStream('myfile')).then(function(buffer) {
	console.log(buffer.toString());
}).catch(function(error) {
	console.error(error.message);
});

bufferStreamError(stream)

Given a stream buffer the first error that occurs until an event listener is registered. This allows you to attach event listeners in a different event loop run.

Example:

var bufferError = require('promisebuffer').bufferError;

var stream = bufferError(require('fs').createReadStream('myfile'));

// Allows you to attach error handlers inside async sections without an error
// throwing an uncaught exception
var x = new Promise(function(resolve, reject) {
	stream.on('error', reject);
	/ * ... */
});

License

MIT

FAQs

Package last updated on 08 Jun 2015

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