# get-buffer

> Package for getting Buffers from Streams and Files with maximum size input.

Latest version **1.6.0** (published 2023-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install get-buffer
pnpm add get-buffer
yarn add get-buffer
bun add get-buffer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2023-02-21 |
| First published | 2018-11-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=0.9.4 |
| Dependencies | 2 |
| Unpacked size | 9.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Emil Sivervik |
| Maintainers | emilsivervik |
| Keywords | get, buffer, stream, filesystem, readstream, path, read buffer, buffer limit |

## Links

- npm: https://www.npmjs.com/package/get-buffer
- Repository: https://github.com/emilsivervik/get-buffer
- Homepage: https://github.com/emilsivervik/get-buffer#readme
- Issues: https://github.com/emilsivervik/get-buffer/issues
- npm.io page: https://npm.io/package/get-buffer

## Dependencies (2)

- [read-chunk](https://npm.io/package/read-chunk.md) ^3.2.0
- [is-array-buffer](https://npm.io/package/is-array-buffer.md) ^3.0.1

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.6.0 (latest) — 2023-02-21
- 1.5.5 — 2019-05-08
- 1.5.4 — 2019-05-08
- 1.5.3 — 2019-03-05
- 1.5.2 — 2019-02-26
- 1.5.1 — 2019-02-26
- 1.5.0 — 2019-02-25
- 1.4.2 — 2019-02-22
- 1.4.1 — 2019-02-22
- 1.4.0 — 2019-02-20
- 1.2.10 — 2019-02-20
- 1.3.0 — 2019-01-29
- 1.2.9 — 2019-01-21
- 1.2.8 — 2019-01-21
- 1.2.7 — 2019-01-21
- … 14 more at https://npm.io/package/get-buffer/versions

## README

# get-buffer

[![Build Status](https://travis-ci.org/emilsivervik/get-buffer.svg?branch=master)](https://travis-ci.org/emilsivervik/get-buffer) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
## Install
```
§ npm install get-buffer
```

## Usage

``` js
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.

---
_Source: https://npm.io/package/get-buffer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
