Socket
Socket
Sign inDemoInstall

buffer-alloc-unsafe

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    buffer-alloc-unsafe

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


Version published
Weekly downloads
4.5M
increased by2.51%
Maintainers
1
Install size
3.01 kB
Created
Weekly downloads
 

Readme

Source

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

Keywords

FAQs

Last updated on 29 May 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc