aboutsummaryrefslogtreecommitdiff
path: root/node_modules/buffer-alloc
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
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/buffer-alloc')
-rw-r--r--node_modules/buffer-alloc/index.js32
-rw-r--r--node_modules/buffer-alloc/package.json26
-rw-r--r--node_modules/buffer-alloc/readme.md43
3 files changed, 101 insertions, 0 deletions
diff --git a/node_modules/buffer-alloc/index.js b/node_modules/buffer-alloc/index.js
new file mode 100644
index 0000000..fe65860
--- /dev/null
+++ b/node_modules/buffer-alloc/index.js
@@ -0,0 +1,32 @@
+var bufferFill = require('buffer-fill')
+var allocUnsafe = require('buffer-alloc-unsafe')
+
+module.exports = function alloc (size, fill, encoding) {
+ 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.alloc) {
+ return Buffer.alloc(size, fill, encoding)
+ }
+
+ var buffer = allocUnsafe(size)
+
+ if (size === 0) {
+ return buffer
+ }
+
+ if (fill === undefined) {
+ return bufferFill(buffer, 0)
+ }
+
+ if (typeof encoding !== 'string') {
+ encoding = undefined
+ }
+
+ return bufferFill(buffer, fill, encoding)
+}
diff --git a/node_modules/buffer-alloc/package.json b/node_modules/buffer-alloc/package.json
new file mode 100644
index 0000000..a8a3c3a
--- /dev/null
+++ b/node_modules/buffer-alloc/package.json
@@ -0,0 +1,26 @@
+{
+ "name": "buffer-alloc",
+ "version": "1.2.0",
+ "license": "MIT",
+ "repository": "LinusU/buffer-alloc",
+ "files": [
+ "index.js"
+ ],
+ "scripts": {
+ "test": "standard && node test"
+ },
+ "dependencies": {
+ "buffer-alloc-unsafe": "^1.1.0",
+ "buffer-fill": "^1.0.0"
+ },
+ "devDependencies": {
+ "standard": "^7.1.2"
+ },
+ "keywords": [
+ "alloc",
+ "allocate",
+ "buffer alloc",
+ "buffer allocate",
+ "buffer"
+ ]
+}
diff --git a/node_modules/buffer-alloc/readme.md b/node_modules/buffer-alloc/readme.md
new file mode 100644
index 0000000..80c7d7b
--- /dev/null
+++ b/node_modules/buffer-alloc/readme.md
@@ -0,0 +1,43 @@
+# Buffer Alloc
+
+A [ponyfill](https://ponyfill.com) for `Buffer.alloc`.
+
+Works as Node.js: `v7.0.0` <br>
+Works on Node.js: `v0.10.0`
+
+## Installation
+
+```sh
+npm install --save buffer-alloc
+```
+
+## Usage
+
+```js
+const alloc = require('buffer-alloc')
+
+console.log(alloc(4))
+//=> <Buffer 00 00 00 00>
+
+console.log(alloc(6, 0x41))
+//=> <Buffer 41 41 41 41 41 41>
+
+console.log(alloc(10, 'linus', 'utf8'))
+//=> <Buffer 6c 69 6e 75 73 6c 69 6e 75 73>
+```
+
+## API
+
+### alloc(size[, fill[, encoding]])
+
+- `size` &lt;Integer&gt; The desired length of the new `Buffer`
+- `fill` &lt;String&gt; | &lt;Buffer&gt; | &lt;Integer&gt; A value to pre-fill the new `Buffer` with. **Default:** `0`
+- `encoding` &lt;String&gt; If `fill` is a string, this is its encoding. **Default:** `'utf8'`
+
+Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the `Buffer` will be zero-filled.
+
+## See also
+
+- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`
+- [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`