Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Latest commit

 

History

History
23 lines (15 loc) · 500 Bytes

README.md

File metadata and controls

23 lines (15 loc) · 500 Bytes

stream-to-buf

Collect a readable stream's data into buffer. Support max size limit.

Install

npm i stream-to-buf

Usage

const streamTobuffer = require('stream-to-buf');

const stream = fs.createReadStream(path.join(__dirname, 'fixtures/file'));
streamToBuffer(stream, { maxSize: '10kb' }).then(onBuffer, onError);

Options

  • maxSize: If stream's emitted buffer exceed maxSize, it will throw an error.(but it will still consume the stream before resolve).