1.6.0 • Published 2 years ago

get-buffer v1.6.0

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

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.

1.6.0

2 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.2.10

6 years ago

1.3.0

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago