buffer-alloc
A [ponyfill](https://ponyfill.com) for `Buffer.alloc`.
Last updated 7 years ago by linusu .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install buffer-alloc 
SYNC missed versions from official npm registry.

Buffer Alloc

A ponyfill for Buffer.alloc.

Works as Node.js: v7.0.0
Works on Node.js: v0.10.0

Installation

npm install --save buffer-alloc

Usage

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>

API

alloc(size[, fill[, encoding]])

  • 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.

See also

Current Tags

  • 1.2.0                                ...           latest (7 years ago)

5 Versions

  • 1.2.0                                ...           7 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
  • 0.1.1                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |