3 A [ponyfill](https://ponyfill.com) for `Buffer.fill`.
5 Works as Node.js: `v6.4.0` <br>
6 Works on Node.js: `v0.10.0`
11 npm install --save buffer-fill
17 const fill = require('buffer-fill')
18 const buf = Buffer.allocUnsafe(5)
20 console.log(buf.fill(8))
21 //=> <Buffer 08 08 08 08 08>
23 console.log(buf.fill(9, 2, 4))
24 //=> <Buffer 08 08 09 09 08>
26 console.log(buf.fill('linus', 'latin1'))
27 //=> <Buffer 6c 69 6e 75 73>
29 console.log(buf.fill('\u0222'))
30 //=> <Buffer c8 a2 c8 a2 c8>
35 ### fill(buf, value[, offset[, end]][, encoding])
37 - `value` <String> | <Buffer> | <Integer> The value to fill `buf` with
38 - `offset` <Integer> Where to start filling `buf`. **Default:** `0`
39 - `end` <Integer> Where to stop filling `buf` (not inclusive). **Default:** `buf.length`
40 - `encoding` <String> If `value` is a string, this is its encoding. **Default:** `'utf8'`
41 - Return: <Buffer> A reference to `buf`
43 Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
44 the entire `buf` will be filled. This is meant to be a small simplification to
45 allow the creation and filling of a `Buffer` to be done on a single line.
47 If the final write of a `fill()` operation falls on a multi-byte character, then
48 only the first bytes of that character that fit into `buf` are written.
52 - [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`
53 - [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
54 - [buffer-from](https://github.com/LinusU/buffer-from) A ponyfill for `Buffer.from`