lhl 8884f64fe1 10-8 | 3 سال پیش | |
---|---|---|
.. | ||
index.js | 3 سال پیش | |
package.json | 3 سال پیش | |
readme.md | 3 سال پیش |
A ponyfill for Buffer.alloc
.
Works as Node.js: v7.0.0
Works on Node.js: v0.10.0
npm install --save buffer-alloc
const alloc = require('buffer-alloc')
console.log(alloc(4))
//=> <Buffer 00 00 00 00>
console.log(alloc(6, 0x41))
//=> <Buffer 41 41 41 41 41 41>
console.log(alloc(10, 'linus', 'utf8'))
//=> <Buffer 6c 69 6e 75 73 6c 69 6e 75 73>
size
<Integer> The desired length of the new Buffer
fill
<String> | <Buffer> | <Integer> A value to pre-fill the new Buffer
with. Default: 0
encoding
<String> If fill
is a string, this is its encoding. Default: 'utf8'
Allocates a new Buffer
of size
bytes. If fill
is undefined
, the Buffer
will be zero-filled.
Buffer.allocUnsafe
Buffer.fill
Buffer.from