mirror of
				https://github.com/musix-org/musix-oss
				synced 2025-11-04 09:49:32 +00:00 
			
		
		
		
	fix
This commit is contained in:
		
							
								
								
									
										113
									
								
								node_modules/buffer-fill/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										113
									
								
								node_modules/buffer-fill/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,113 @@
 | 
			
		||||
/* 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
 | 
			
		||||
							
								
								
									
										49
									
								
								node_modules/buffer-fill/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								node_modules/buffer-fill/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,49 @@
 | 
			
		||||
{
 | 
			
		||||
  "_from": "buffer-fill@^1.0.0",
 | 
			
		||||
  "_id": "buffer-fill@1.0.0",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=",
 | 
			
		||||
  "_location": "/buffer-fill",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "buffer-fill@^1.0.0",
 | 
			
		||||
    "name": "buffer-fill",
 | 
			
		||||
    "escapedName": "buffer-fill",
 | 
			
		||||
    "rawSpec": "^1.0.0",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^1.0.0"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/buffer-alloc"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz",
 | 
			
		||||
  "_shasum": "f8f78b76789888ef39f205cd637f68e702122b2c",
 | 
			
		||||
  "_spec": "buffer-fill@^1.0.0",
 | 
			
		||||
  "_where": "C:\\Users\\matia\\Musix\\node_modules\\buffer-alloc",
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/LinusU/buffer-fill/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "A [ponyfill](https://ponyfill.com) for `Buffer.fill`.",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "buffer-alloc-unsafe": "^1.1.0",
 | 
			
		||||
    "standard": "^7.1.2"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "index.js"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://github.com/LinusU/buffer-fill#readme",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "name": "buffer-fill",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/LinusU/buffer-fill.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "test": "standard && node test"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "1.0.0"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										54
									
								
								node_modules/buffer-fill/readme.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								node_modules/buffer-fill/readme.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
# 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` <String> | <Buffer> | <Integer> The value to fill `buf` with
 | 
			
		||||
- `offset` <Integer> Where to start filling `buf`. **Default:** `0`
 | 
			
		||||
- `end` <Integer> Where to stop filling `buf` (not inclusive). **Default:** `buf.length`
 | 
			
		||||
- `encoding` <String> If `value` is a string, this is its encoding. **Default:** `'utf8'`
 | 
			
		||||
- Return: <Buffer> 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`
 | 
			
		||||
		Reference in New Issue
	
	Block a user