Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/linusu/buffer-alloc-unsafe
A ponyfill for Buffer.allocUnsafe
https://github.com/linusu/buffer-alloc-unsafe
Last synced: 12 days ago
JSON representation
A ponyfill for Buffer.allocUnsafe
- Host: GitHub
- URL: https://github.com/linusu/buffer-alloc-unsafe
- Owner: LinusU
- License: mit
- Created: 2016-08-18T19:18:16.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-20T13:24:54.000Z (almost 6 years ago)
- Last Synced: 2024-10-25T17:05:08.981Z (18 days ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 14
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Buffer Alloc Unsafe
A [ponyfill](https://ponyfill.com) for `Buffer.allocUnsafe`.
Works as Node.js: `v7.0.0`
Works on Node.js: `v0.10.0`## Installation
```sh
npm install --save buffer-alloc-unsafe
```## Usage
```js
const allocUnsafe = require('buffer-alloc-unsafe')console.log(allocUnsafe(10))
//=>console.log(allocUnsafe(10))
//=>console.log(allocUnsafe(10))
//=>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
- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
- [buffer-fill](https://github.com/LinusU/buffer-fill) A ponyfill for `Buffer.fill`
- [buffer-from](https://github.com/LinusU/buffer-from) A ponyfill for `Buffer.from`