# buffer-fill

> A [ponyfill](https://ponyfill.com) for `Buffer.fill`.

Latest version **1.0.0** (published 2018-05-29) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-29 |
| First published | 2016-08-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Maintainers | linusu |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2018-05-29
- 0.1.1 — 2018-03-26
- 0.1.0 — 2016-08-21

## README

# Buffer Fill

A [ponyfill](https://ponyfill.com) for `Buffer.fill`.

Works as Node.js: `v6.4.0` <br>
Works on Node.js: `v0.10.0`

## Installation

```sh
npm install --save buffer-fill
```

## Usage

```js
const fill = require('buffer-fill')
const buf = Buffer.allocUnsafe(5)

console.log(buf.fill(8))
//=> <Buffer 08 08 08 08 08>

console.log(buf.fill(9, 2, 4))
//=> <Buffer 08 08 09 09 08>

console.log(buf.fill('linus', 'latin1'))
//=> <Buffer 6c 69 6e 75 73>

console.log(buf.fill('\u0222'))
//=> <Buffer c8 a2 c8 a2 c8>
```

## API

### fill(buf, value[, offset[, end]][, encoding])

- `value` &lt;String&gt; | &lt;Buffer&gt; | &lt;Integer&gt; The value to fill `buf` with
- `offset` &lt;Integer&gt; Where to start filling `buf`. **Default:** `0`
- `end` &lt;Integer&gt; Where to stop filling `buf` (not inclusive). **Default:** `buf.length`
- `encoding` &lt;String&gt; If `value` is a string, this is its encoding. **Default:** `'utf8'`
- Return: &lt;Buffer&gt; A reference to `buf`

Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
the entire `buf` will be filled. This is meant to be a small simplification to
allow the creation and filling of a `Buffer` to be done on a single line.

If the final write of a `fill()` operation falls on a multi-byte character, then
only the first bytes of that character that fit into `buf` are written.

## See also

- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`
- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
- [buffer-from](https://github.com/LinusU/buffer-from) A ponyfill for `Buffer.from`

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