LinusU/buffer-alloc-unsafe


A ponyfill for Buffer.allocUnsafe

Language: JavaScript


Buffer Alloc Unsafe

A ponyfill for Buffer.allocUnsafe.

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

Installation

npm install --save buffer-alloc-unsafe

Usage

const allocUnsafe = require('buffer-alloc-unsafe')

console.log(allocUnsafe(10))
//=> <Buffer 78 0c 80 03 01 00 00 00 05 00>

console.log(allocUnsafe(10))
//=> <Buffer 58 ed bf 5f ff 7f 00 00 01 00>

console.log(allocUnsafe(10))
//=> <Buffer 50 0c 80 03 01 00 00 00 0a 00>

allocUnsafe(-10)
//=> RangeError: "size" argument must not be negative

API

allocUnsafe(size)

  • size <Integer> The desired length of the new Buffer

Allocates a new non-zero-filled Buffer of size bytes. The size must be less than or equal to the value of buffer.kMaxLength and greater than or equal to zero. Otherwise, a RangeError is thrown.

See also

Project Statistics

Sourcerank 9
Repository Size 6.84 KB
Stars 13
Forks 2
Watchers 1
Open issues 0
Dependencies 1
Contributors 2
Tags 4
Created
Last updated
Last pushed

Top Contributors See all

Linus Unnebäck Sindre Sorhus

Packages Referencing this Repo

buffer-alloc-unsafe
A [ponyfill](https://ponyfill.com) for `Buffer.allocUnsafe`.
Latest release 1.1.0 - Updated - 13 stars

Recent Tags See all

v1.1.0 May 29, 2018
v1.0.0 October 31, 2016
v0.1.1 August 21, 2016
v0.1.0 August 18, 2016

Something wrong with this page? Make a suggestion

Last synced: 2018-05-29 23:34:15 UTC

Login to resync this repository