get-buffer
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

get-buffer

Build Status JavaScript Style Guide

Install

§ npm install get-buffer

Usage

const getBuffer = require('get-buffer');
const fs = require('fs');
const stream = fs.createReadStream('./test.png');

getBuffer.fromStream(stream, 4100)
.then(buffer => console.log(buffer))
.catch(err => console.error(err))

try{
    const buffer = getBuffer.fromPath('./test.png', 4100);
    console.log(buffer)
}catch(err){
    console.error(err);
}

API

fromStream(stream: Readable, callback: function)
fromStream(stream: Readable, bufferSize: int, callback: function)

Reads a Buffer from a Readable, bufferSize could be provided to limit the Buffer into a maximum size. Returns either a Promise or a function(callback).

fromPath(filePath: string)
fromPath(filePath: string, bufferSize: int)

Reads a Buffer from a path, bufferSize could be provided to limit the Buffer into a maximum size. Returns synchronously.

fromArrayBuffer(arrayBuffer: ArrayBuffer)
fromArrayBuffer(arrayBuffer: ArrayBuffer, bufferSize: int)

Reads a Buffer from a ArrayBuffer, bufferSize could be provided to limit the Buffer into a maximum size. Returns synchronously.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.6.0112latest

Version History

VersionDownloads (Last 7 Days)Published
1.6.0112
1.5.50
1.5.40
1.5.30
1.5.20
1.5.10
1.5.00
1.4.21
1.4.10
1.4.01
1.2.101
1.3.00
1.2.90
1.2.82
1.2.70
1.2.61
1.2.50
1.2.41
1.2.30
1.2.20
1.2.10
1.2.00
1.1.30
1.1.20
1.1.10
1.1.00
1.0.21
1.0.10
1.0.00

Package Sidebar

Install

npm i get-buffer

Weekly Downloads

118

Version

1.6.0

License

MIT

Unpacked Size

9.35 kB

Total Files

5

Last publish

Collaborators

  • emilsivervik