# buffer-alloc-unsafe

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

Latest version **1.1.0** (published 2018-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install buffer-alloc-unsafe
pnpm add buffer-alloc-unsafe
yarn add buffer-alloc-unsafe
bun add buffer-alloc-unsafe
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-05-29 |
| First published | 2016-08-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Maintainers | linusu |
| Keywords | allocUnsafe, allocate, buffer allocUnsafe, buffer unsafe allocate, buffer, ponyfill, unsafe allocate |

## Links

- npm: https://www.npmjs.com/package/buffer-alloc-unsafe
- Repository: https://github.com/LinusU/buffer-alloc-unsafe
- Homepage: https://github.com/LinusU/buffer-alloc-unsafe#readme
- Issues: https://github.com/LinusU/buffer-alloc-unsafe/issues
- npm.io page: https://npm.io/package/buffer-alloc-unsafe

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2018-05-29
- 1.0.0 — 2016-10-31
- 0.1.1 — 2016-08-21
- 0.1.0 — 2016-08-18

## README

# Buffer Alloc Unsafe

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

Works as Node.js: `v7.0.0` <br>
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))
//=> <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` &lt;Integer&gt; 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`

---
_Source: https://npm.io/package/buffer-alloc-unsafe · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
