summaryrefslogtreecommitdiff
path: root/node_modules/buffer-fill
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/buffer-fill')
-rw-r--r--node_modules/buffer-fill/index.js113
-rw-r--r--node_modules/buffer-fill/package.json16
-rw-r--r--node_modules/buffer-fill/readme.md54
3 files changed, 0 insertions, 183 deletions
diff --git a/node_modules/buffer-fill/index.js b/node_modules/buffer-fill/index.js
deleted file mode 100644
index 428a9e1..0000000
--- a/node_modules/buffer-fill/index.js
+++ /dev/null
@@ -1,113 +0,0 @@
-/* Node.js 6.4.0 and up has full support */
-var hasFullSupport = (function () {
- try {
- if (!Buffer.isEncoding('latin1')) {
- return false
- }
-
- var buf = Buffer.alloc ? Buffer.alloc(4) : new Buffer(4)
-
- buf.fill('ab', 'ucs2')
-
- return (buf.toString('hex') === '61006200')
- } catch (_) {
- return false
- }
-}())
-
-function isSingleByte (val) {
- return (val.length === 1 && val.charCodeAt(0) < 256)
-}
-
-function fillWithNumber (buffer, val, start, end) {
- if (start < 0 || end > buffer.length) {
- throw new RangeError('Out of range index')
- }
-
- start = start >>> 0
- end = end === undefined ? buffer.length : end >>> 0
-
- if (end > start) {
- buffer.fill(val, start, end)
- }
-
- return buffer
-}
-
-function fillWithBuffer (buffer, val, start, end) {
- if (start < 0 || end > buffer.length) {
- throw new RangeError('Out of range index')
- }
-
- if (end <= start) {
- return buffer
- }
-
- start = start >>> 0
- end = end === undefined ? buffer.length : end >>> 0
-
- var pos = start
- var len = val.length
- while (pos <= (end - len)) {
- val.copy(buffer, pos)
- pos += len
- }
-
- if (pos !== end) {
- val.copy(buffer, pos, 0, end - pos)
- }
-
- return buffer
-}
-
-function fill (buffer, val, start, end, encoding) {
- if (hasFullSupport) {
- return buffer.fill(val, start, end, encoding)
- }
-
- if (typeof val === 'number') {
- return fillWithNumber(buffer, val, start, end)
- }
-
- if (typeof val === 'string') {
- if (typeof start === 'string') {
- encoding = start
- start = 0
- end = buffer.length
- } else if (typeof end === 'string') {
- encoding = end
- end = buffer.length
- }
-
- if (encoding !== undefined && typeof encoding !== 'string') {
- throw new TypeError('encoding must be a string')
- }
-
- if (encoding === 'latin1') {
- encoding = 'binary'
- }
-
- if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
- throw new TypeError('Unknown encoding: ' + encoding)
- }
-
- if (val === '') {
- return fillWithNumber(buffer, 0, start, end)
- }
-
- if (isSingleByte(val)) {
- return fillWithNumber(buffer, val.charCodeAt(0), start, end)
- }
-
- val = new Buffer(val, encoding)
- }
-
- if (Buffer.isBuffer(val)) {
- return fillWithBuffer(buffer, val, start, end)
- }
-
- // Other values (e.g. undefined, boolean, object) results in zero-fill
- return fillWithNumber(buffer, 0, start, end)
-}
-
-module.exports = fill
diff --git a/node_modules/buffer-fill/package.json b/node_modules/buffer-fill/package.json
deleted file mode 100644
index b8f67c5..0000000
--- a/node_modules/buffer-fill/package.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "name": "buffer-fill",
- "version": "1.0.0",
- "license": "MIT",
- "repository": "LinusU/buffer-fill",
- "files": [
- "index.js"
- ],
- "scripts": {
- "test": "standard && node test"
- },
- "devDependencies": {
- "buffer-alloc-unsafe": "^1.1.0",
- "standard": "^7.1.2"
- }
-}
diff --git a/node_modules/buffer-fill/readme.md b/node_modules/buffer-fill/readme.md
deleted file mode 100644
index ac30738..0000000
--- a/node_modules/buffer-fill/readme.md
+++ /dev/null
@@ -1,54 +0,0 @@
-# Buffer Fill
-
-A [ponyfill](https://ponyfill.com) for `Buffer.fill`.
-
-Works as Node.js: `v6.4.0` <br>
-Works on Node.js: `v0.10.0`
-
-## Installation
-
-```sh
-npm install --save buffer-fill
-```
-
-## Usage
-
-```js
-const fill = require('buffer-fill')
-const buf = Buffer.allocUnsafe(5)
-
-console.log(buf.fill(8))
-//=> <Buffer 08 08 08 08 08>
-
-console.log(buf.fill(9, 2, 4))
-//=> <Buffer 08 08 09 09 08>
-
-console.log(buf.fill('linus', 'latin1'))
-//=> <Buffer 6c 69 6e 75 73>
-
-console.log(buf.fill('\u0222'))
-//=> <Buffer c8 a2 c8 a2 c8>
-```
-
-## API
-
-### fill(buf, value[, offset[, end]][, encoding])
-
-- `value` &lt;String&gt; | &lt;Buffer&gt; | &lt;Integer&gt; The value to fill `buf` with
-- `offset` &lt;Integer&gt; Where to start filling `buf`. **Default:** `0`
-- `end` &lt;Integer&gt; Where to stop filling `buf` (not inclusive). **Default:** `buf.length`
-- `encoding` &lt;String&gt; If `value` is a string, this is its encoding. **Default:** `'utf8'`
-- Return: &lt;Buffer&gt; A reference to `buf`
-
-Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
-the entire `buf` will be filled. This is meant to be a small simplification to
-allow the creation and filling of a `Buffer` to be done on a single line.
-
-If the final write of a `fill()` operation falls on a multi-byte character, then
-only the first bytes of that character that fit into `buf` are written.
-
-## See also
-
-- [buffer-alloc-unsafe](https://github.com/LinusU/buffer-alloc-unsafe) A ponyfill for `Buffer.allocUnsafe`
-- [buffer-alloc](https://github.com/LinusU/buffer-alloc) A ponyfill for `Buffer.alloc`
-- [buffer-from](https://github.com/LinusU/buffer-from) A ponyfill for `Buffer.from`