Skip to content

rf00/buffeream

Repository files navigation

buffeream

npm version

Installation

npm install buffeream
var buffeream = require('buffeream')

Usage

buffeream(readableStream[, callback])

Returns buffer.

readableStream - stream

callback - callback when there is a callback

##Examples

var buffeream = require('buffeream');

var fs = require('fs');

var readableStream = fs.createReadStream('example.js');

buffeream(readableStream, function(err, buffer) {
	
	if (err) {
		
		console.log(err);
		
		return;
		
	}
	
	var data = buffer.toString();
	
	console.log(data);
	
});

Using Promise:

buffeream(readableStream).then(function(buffer) {
	
	var data = buffer.toString();
	
	console.log(data);
	
}).catch(function(err) {
	
	console.log(err);
	
});

Using Async/Await:

convertStreamToBuffer();

async function convertStreamToBuffer() {
	
	try {
		
		var buffer = await buffeream(readableStream);
		
		var data = buffer.toString();
		
		console.log(data);
		
	} catch (err) {
		
		console.log(err);
		
	}
	
}

About

Convert readable stream into buffer.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published