aboutsummaryrefslogtreecommitdiff
path: root/node_modules/buffer-alloc-unsafe
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
commitd25e11bee6ca5ca523884da132d18e1400e077b9 (patch)
tree8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/buffer-alloc-unsafe
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/buffer-alloc-unsafe')
-rw-r--r--node_modules/buffer-alloc-unsafe/index.js17
-rw-r--r--node_modules/buffer-alloc-unsafe/package.json24
-rw-r--r--node_modules/buffer-alloc-unsafe/readme.md46
3 files changed, 87 insertions, 0 deletions
diff --git a/node_modules/buffer-alloc-unsafe/index.js b/node_modules/buffer-alloc-unsafe/index.js
new file mode 100644
index 0000000..0bd335f
--- /dev/null
+++ b/node_modules/buffer-alloc-unsafe/index.js
@@ -0,0 +1,17 @@
+function allocUnsafe (size) {
+ if (typeof size !== 'number') {
+ throw new TypeError('"size" argument must be a number')
+ }
+
+ if (size < 0) {
+ throw new RangeError('"size" argument must not be negative')
+ }
+
+ if (Buffer.allocUnsafe) {
+ return Buffer.allocUnsafe(size)
+ } else {
+ return new Buffer(size)
+ }
+}
+
+module.exports = allocUnsafe
diff --git a/node_modules/buffer-alloc-unsafe/package.json b/node_modules/buffer-alloc-unsafe/package.json
new file mode 100644
index 0000000..c2ab904
--- /dev/null
+++ b/node_modules/buffer-alloc-unsafe/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "buffer-alloc-unsafe",
+ "version": "1.1.0",
+ "license": "MIT",
+ "repository": "LinusU/buffer-alloc-unsafe",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "standard && node test"
+ },
+ "devDependencies": {
+ "standard": "^7.1.2"
+ },
+ "keywords": [
+ "allocUnsafe",
+ "allocate",
+ "buffer allocUnsafe",
+ "buffer unsafe allocate",
+ "buffer",
+ "ponyfill",
+ "unsafe allocate"
+ ]
+}
diff --git a/node_modules/buffer-alloc-unsafe/readme.md b/node_modules/buffer-alloc-unsafe/readme.md
new file mode 100644
index 0000000..8725ecf
--- /dev/null
+++ b/node_modules/buffer-alloc-unsafe/readme.md
@@ -0,0 +1,46 @@
+# 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`