convert-stream

Convert stream in node.js to buffer or array

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
convert-stream
101.0.28 years ago8 years agoMinified + gzip package size for convert-stream in KB

Readme

convert-stream
Converts any stream to buffer or an array. Saves you from the trouble of saveing the streams to files.

Features

  • Fast
  • Promises implementation

Requirements

Before using gifme, please install:

Installation

For local
npm install convert-stream --save

Usage

For converting to Buffer
const cs = require('convert-stream');
const fs = require('fs');
const path = require('path');

let input = path.join(__dirname, 'yourexamplefile');

let yourStream = fs.createReadStream(input);
cs.toBuffer(yourStream)
    .then((returnedBuffer) => { /*doSomething*/ })
    .catch(err, function doSomthingWithError(error) { /*do something*/ });
For converting to array
cs.toArray(yourStream)
    .then((returnedArray) => { /*doSomething*/ })
    .catch(err, function doSomthingWithError(error) { /*do something*/ });