1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 03:33:17 +00:00
This commit is contained in:
MatteZ02 2019-05-30 12:10:19 +03:00
parent 5eb0264906
commit c525181752
1544 changed files with 0 additions and 205295 deletions

15
node_modules/.bin/lzmajs generated vendored
View File

@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../lzma-native/bin/lzmajs" "$@"
ret=$?
else
node "$basedir/../lzma-native/bin/lzmajs" "$@"
ret=$?
fi
exit $ret

7
node_modules/.bin/lzmajs.cmd generated vendored
View File

@ -1,7 +0,0 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\lzma-native\bin\lzmajs" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\lzma-native\bin\lzmajs" %*
)

15
node_modules/.bin/seek-bunzip generated vendored
View File

@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../seek-bzip/bin/seek-bunzip" "$@"
ret=$?
else
node "$basedir/../seek-bzip/bin/seek-bunzip" "$@"
ret=$?
fi
exit $ret

7
node_modules/.bin/seek-bunzip.cmd generated vendored
View File

@ -1,7 +0,0 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\seek-bzip\bin\seek-bunzip" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\seek-bzip\bin\seek-bunzip" %*
)

15
node_modules/.bin/seek-table generated vendored
View File

@ -1,15 +0,0 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../seek-bzip/bin/seek-bzip-table" "$@"
ret=$?
else
node "$basedir/../seek-bzip/bin/seek-bzip-table" "$@"
ret=$?
fi
exit $ret

7
node_modules/.bin/seek-table.cmd generated vendored
View File

@ -1,7 +0,0 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\seek-bzip\bin\seek-bzip-table" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\seek-bzip\bin\seek-bzip-table" %*
)

21
node_modules/base64-js/LICENSE generated vendored
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

34
node_modules/base64-js/README.md generated vendored
View File

@ -1,34 +0,0 @@
base64-js
=========
`base64-js` does basic base64 encoding/decoding in pure JS.
[![build status](https://secure.travis-ci.org/beatgammit/base64-js.png)](http://travis-ci.org/beatgammit/base64-js)
[![testling badge](https://ci.testling.com/beatgammit/base64-js.png)](https://ci.testling.com/beatgammit/base64-js)
Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.
Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
## install
With [npm](https://npmjs.org) do:
`npm install base64-js` and `var base64js = require('base64-js')`
For use in web browsers do:
`<script src="base64js.min.js"></script>`
## methods
`base64js` has three exposed functions, `byteLength`, `toByteArray` and `fromByteArray`, which both take a single argument.
* `byteLength` - Takes a base64 string and returns length of byte array
* `toByteArray` - Takes a base64 string and returns a byte array
* `fromByteArray` - Takes a byte array and returns a base64 string
## license
MIT

View File

@ -1 +0,0 @@
(function(r){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=r()}else if(typeof define==="function"&&define.amd){define([],r)}else{var e;if(typeof window!=="undefined"){e=window}else if(typeof global!=="undefined"){e=global}else if(typeof self!=="undefined"){e=self}else{e=this}e.base64js=r()}})(function(){var r,e,n;return function(){function r(e,n,t){function o(f,i){if(!n[f]){if(!e[f]){var u="function"==typeof require&&require;if(!i&&u)return u(f,!0);if(a)return a(f,!0);var v=new Error("Cannot find module '"+f+"'");throw v.code="MODULE_NOT_FOUND",v}var d=n[f]={exports:{}};e[f][0].call(d.exports,function(r){var n=e[f][1][r];return o(n||r)},d,d.exports,r,e,n,t)}return n[f].exports}for(var a="function"==typeof require&&require,f=0;f<t.length;f++)o(t[f]);return o}return r}()({"/":[function(r,e,n){"use strict";n.byteLength=d;n.toByteArray=h;n.fromByteArray=p;var t=[];var o=[];var a=typeof Uint8Array!=="undefined"?Uint8Array:Array;var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var i=0,u=f.length;i<u;++i){t[i]=f[i];o[f.charCodeAt(i)]=i}o["-".charCodeAt(0)]=62;o["_".charCodeAt(0)]=63;function v(r){var e=r.length;if(e%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var n=r.indexOf("=");if(n===-1)n=e;var t=n===e?0:4-n%4;return[n,t]}function d(r){var e=v(r);var n=e[0];var t=e[1];return(n+t)*3/4-t}function c(r,e,n){return(e+n)*3/4-n}function h(r){var e;var n=v(r);var t=n[0];var f=n[1];var i=new a(c(r,t,f));var u=0;var d=f>0?t-4:t;for(var h=0;h<d;h+=4){e=o[r.charCodeAt(h)]<<18|o[r.charCodeAt(h+1)]<<12|o[r.charCodeAt(h+2)]<<6|o[r.charCodeAt(h+3)];i[u++]=e>>16&255;i[u++]=e>>8&255;i[u++]=e&255}if(f===2){e=o[r.charCodeAt(h)]<<2|o[r.charCodeAt(h+1)]>>4;i[u++]=e&255}if(f===1){e=o[r.charCodeAt(h)]<<10|o[r.charCodeAt(h+1)]<<4|o[r.charCodeAt(h+2)]>>2;i[u++]=e>>8&255;i[u++]=e&255}return i}function s(r){return t[r>>18&63]+t[r>>12&63]+t[r>>6&63]+t[r&63]}function l(r,e,n){var t;var o=[];for(var a=e;a<n;a+=3){t=(r[a]<<16&16711680)+(r[a+1]<<8&65280)+(r[a+2]&255);o.push(s(t))}return o.join("")}function p(r){var e;var n=r.length;var o=n%3;var a=[];var f=16383;for(var i=0,u=n-o;i<u;i+=f){a.push(l(r,i,i+f>u?u:i+f))}if(o===1){e=r[n-1];a.push(t[e>>2]+t[e<<4&63]+"==")}else if(o===2){e=(r[n-2]<<8)+r[n-1];a.push(t[e>>10]+t[e>>4&63]+t[e<<2&63]+"=")}return a.join("")}},{}]},{},[])("/")});

151
node_modules/base64-js/index.js generated vendored
View File

@ -1,151 +0,0 @@
'use strict'
exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]
revLookup[code.charCodeAt(i)] = i
}
// Support decoding URL-safe base64 strings, as Node.js does.
// See: https://en.wikipedia.org/wiki/Base64#URL_applications
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63
function getLens (b64) {
var len = b64.length
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen = b64.indexOf('=')
if (validLen === -1) validLen = len
var placeHoldersLen = validLen === len
? 0
: 4 - (validLen % 4)
return [validLen, placeHoldersLen]
}
// base64 is 4/3 + up to two characters of the original data
function byteLength (b64) {
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function _byteLength (b64, validLen, placeHoldersLen) {
return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
}
function toByteArray (b64) {
var tmp
var lens = getLens(b64)
var validLen = lens[0]
var placeHoldersLen = lens[1]
var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
var curByte = 0
// if there are placeholders, only get up to the last complete 4 chars
var len = placeHoldersLen > 0
? validLen - 4
: validLen
for (var i = 0; i < len; i += 4) {
tmp =
(revLookup[b64.charCodeAt(i)] << 18) |
(revLookup[b64.charCodeAt(i + 1)] << 12) |
(revLookup[b64.charCodeAt(i + 2)] << 6) |
revLookup[b64.charCodeAt(i + 3)]
arr[curByte++] = (tmp >> 16) & 0xFF
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 2) {
tmp =
(revLookup[b64.charCodeAt(i)] << 2) |
(revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[curByte++] = tmp & 0xFF
}
if (placeHoldersLen === 1) {
tmp =
(revLookup[b64.charCodeAt(i)] << 10) |
(revLookup[b64.charCodeAt(i + 1)] << 4) |
(revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[curByte++] = (tmp >> 8) & 0xFF
arr[curByte++] = tmp & 0xFF
}
return arr
}
function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] +
lookup[num >> 12 & 0x3F] +
lookup[num >> 6 & 0x3F] +
lookup[num & 0x3F]
}
function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp =
((uint8[i] << 16) & 0xFF0000) +
((uint8[i + 1] << 8) & 0xFF00) +
(uint8[i + 2] & 0xFF)
output.push(tripletToBase64(tmp))
}
return output.join('')
}
function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(
uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
parts.push(
lookup[tmp >> 2] +
lookup[(tmp << 4) & 0x3F] +
'=='
)
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + uint8[len - 1]
parts.push(
lookup[tmp >> 10] +
lookup[(tmp >> 4) & 0x3F] +
lookup[(tmp << 2) & 0x3F] +
'='
)
}
return parts.join('')
}

65
node_modules/base64-js/package.json generated vendored
View File

@ -1,65 +0,0 @@
{
"_from": "base64-js@^1.0.2",
"_id": "base64-js@1.3.0",
"_inBundle": false,
"_integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
"_location": "/base64-js",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "base64-js@^1.0.2",
"name": "base64-js",
"escapedName": "base64-js",
"rawSpec": "^1.0.2",
"saveSpec": null,
"fetchSpec": "^1.0.2"
},
"_requiredBy": [
"/buffer"
],
"_resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
"_shasum": "cab1e6118f051095e58b5281aea8c1cd22bfc0e3",
"_spec": "base64-js@^1.0.2",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\buffer",
"author": {
"name": "T. Jameson Little",
"email": "t.jameson.little@gmail.com"
},
"bugs": {
"url": "https://github.com/beatgammit/base64-js/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Base64 encoding/decoding in pure JS",
"devDependencies": {
"benchmark": "^2.1.4",
"browserify": "^14.0.0",
"standard": "*",
"tape": "4.x",
"uglify-js": "^2.8.29"
},
"files": [
"test",
"index.js",
"base64js.min.js"
],
"homepage": "https://github.com/beatgammit/base64-js",
"keywords": [
"base64"
],
"license": "MIT",
"main": "index.js",
"name": "base64-js",
"repository": {
"type": "git",
"url": "git://github.com/beatgammit/base64-js.git"
},
"scripts": {
"build": "browserify -s base64js -r ./ | uglifyjs -m > base64js.min.js",
"lint": "standard",
"test": "npm run lint && npm run unit",
"unit": "tape test/*.js"
},
"version": "1.3.0"
}

View File

@ -1,25 +0,0 @@
var test = require('tape')
var b64 = require('../')
test('convert big data to base64', function (t) {
var b64str, arr, i, length
var big = new Uint8Array(64 * 1024 * 1024)
for (i = 0, length = big.length; i < length; ++i) {
big[i] = i % 256
}
b64str = b64.fromByteArray(big)
arr = b64.toByteArray(b64str)
t.ok(equal(arr, big))
t.equal(b64.byteLength(b64str), arr.length)
t.end()
})
function equal (a, b) {
var i
var length = a.length
if (length !== b.length) return false
for (i = 0; i < length; ++i) {
if (a[i] !== b[i]) return false
}
return true
}

View File

@ -1,88 +0,0 @@
var test = require('tape')
var b64 = require('../')
var checks = [
'a',
'aa',
'aaa',
'hi',
'hi!',
'hi!!',
'sup',
'sup?',
'sup?!'
]
test('convert to base64 and back', function (t) {
t.plan(checks.length * 2)
for (var i = 0; i < checks.length; i++) {
var check = checks[i]
var b64Str, arr, str
b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0) }))
arr = b64.toByteArray(b64Str)
str = map(arr, function (byte) { return String.fromCharCode(byte) }).join('')
t.equal(check, str, 'Checked ' + check)
t.equal(b64.byteLength(b64Str), arr.length, 'Checked length for ' + check)
}
})
var data = [
[[0, 0, 0], 'AAAA'],
[[0, 0, 1], 'AAAB'],
[[0, 1, -1], 'AAH/'],
[[1, 1, 1], 'AQEB'],
[[0, -73, 23], 'ALcX']
]
test('convert known data to string', function (t) {
for (var i = 0; i < data.length; i++) {
var bytes = data[i][0]
var expected = data[i][1]
var actual = b64.fromByteArray(bytes)
t.equal(actual, expected, 'Ensure that ' + bytes + ' serialise to ' + expected)
}
t.end()
})
test('convert known data from string', function (t) {
for (var i = 0; i < data.length; i++) {
var expected = data[i][0]
var string = data[i][1]
var actual = b64.toByteArray(string)
t.ok(equal(actual, expected), 'Ensure that ' + string + ' deserialise to ' + expected)
var length = b64.byteLength(string)
t.equal(length, expected.length, 'Ensure that ' + string + ' has byte lentgh of ' + expected.length)
}
t.end()
})
function equal (a, b) {
var i
var length = a.length
if (length !== b.length) return false
for (i = 0; i < length; ++i) {
if ((a[i] & 0xFF) !== (b[i] & 0xFF)) return false
}
return true
}
function map (arr, callback) {
var res = []
var kValue, mappedValue
for (var k = 0, len = arr.length; k < len; k++) {
if ((typeof arr === 'string' && !!arr.charAt(k))) {
kValue = arr.charAt(k)
mappedValue = callback(kValue, k, arr)
res[k] = mappedValue
} else if (typeof arr !== 'string' && k in arr) {
kValue = arr[k]
mappedValue = callback(kValue, k, arr)
res[k] = mappedValue
}
}
return res
}

View File

@ -1,10 +0,0 @@
var test = require('tape')
var b64 = require('../')
test('padding bytes found inside base64 string', function (t) {
// See https://github.com/beatgammit/base64-js/issues/42
var str = 'SQ==QU0='
t.deepEqual(b64.toByteArray(str), new Uint8Array([73]))
t.equal(b64.byteLength(str), 1)
t.end()
})

View File

@ -1,24 +0,0 @@
var test = require('tape')
var b64 = require('../')
test('decode url-safe style base64 strings', function (t) {
var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff]
var str = '//++/++/++//'
var actual = b64.toByteArray(str)
for (var i = 0; i < actual.length; i++) {
t.equal(actual[i], expected[i])
}
t.equal(b64.byteLength(str), actual.length)
str = '__--_--_--__'
actual = b64.toByteArray(str)
for (i = 0; i < actual.length; i++) {
t.equal(actual[i], expected[i])
}
t.equal(b64.byteLength(str), actual.length)
t.end()
})

59
node_modules/bl/.jshintrc generated vendored
View File

@ -1,59 +0,0 @@
{
"predef": [ ]
, "bitwise": false
, "camelcase": false
, "curly": false
, "eqeqeq": false
, "forin": false
, "immed": false
, "latedef": false
, "noarg": true
, "noempty": true
, "nonew": true
, "plusplus": false
, "quotmark": true
, "regexp": false
, "undef": true
, "unused": true
, "strict": false
, "trailing": true
, "maxlen": 120
, "asi": true
, "boss": true
, "debug": true
, "eqnull": true
, "esnext": true
, "evil": true
, "expr": true
, "funcscope": false
, "globalstrict": false
, "iterator": false
, "lastsemic": true
, "laxbreak": true
, "laxcomma": true
, "loopfunc": true
, "multistr": false
, "onecase": false
, "proto": false
, "regexdash": false
, "scripturl": true
, "smarttabs": false
, "shadow": false
, "sub": true
, "supernew": false
, "validthis": true
, "browser": true
, "couch": false
, "devel": false
, "dojo": false
, "mootools": false
, "node": true
, "nonstandard": true
, "prototypejs": false
, "rhino": false
, "worker": true
, "wsh": false
, "nomen": false
, "onevar": false
, "passfail": false
}

16
node_modules/bl/.travis.yml generated vendored
View File

@ -1,16 +0,0 @@
sudo: false
language: node_js
node_js:
- '0.10'
- '0.12'
- '4'
- '6'
- '8'
- '9'
branches:
only:
- master
notifications:
email:
- rod@vagg.org
- matteo.collina@gmail.com

13
node_modules/bl/LICENSE.md generated vendored
View File

@ -1,13 +0,0 @@
The MIT License (MIT)
=====================
Copyright (c) 2013-2016 bl contributors
----------------------------------
*bl contributors listed at <https://github.com/rvagg/bl#contributors>*
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

208
node_modules/bl/README.md generated vendored
View File

@ -1,208 +0,0 @@
# bl *(BufferList)*
[![Build Status](https://travis-ci.org/rvagg/bl.svg?branch=master)](https://travis-ci.org/rvagg/bl)
**A Node.js Buffer list collector, reader and streamer thingy.**
[![NPM](https://nodei.co/npm/bl.png?downloads=true&downloadRank=true)](https://nodei.co/npm/bl/)
[![NPM](https://nodei.co/npm-dl/bl.png?months=6&height=3)](https://nodei.co/npm/bl/)
**bl** is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.
```js
const BufferList = require('bl')
var bl = new BufferList()
bl.append(new Buffer('abcd'))
bl.append(new Buffer('efg'))
bl.append('hi') // bl will also accept & convert Strings
bl.append(new Buffer('j'))
bl.append(new Buffer([ 0x3, 0x4 ]))
console.log(bl.length) // 12
console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij'
console.log(bl.slice(3, 10).toString('ascii')) // 'defghij'
console.log(bl.slice(3, 6).toString('ascii')) // 'def'
console.log(bl.slice(3, 8).toString('ascii')) // 'defgh'
console.log(bl.slice(5, 10).toString('ascii')) // 'fghij'
// or just use toString!
console.log(bl.toString()) // 'abcdefghij\u0003\u0004'
console.log(bl.toString('ascii', 3, 8)) // 'defgh'
console.log(bl.toString('ascii', 5, 10)) // 'fghij'
// other standard Buffer readables
console.log(bl.readUInt16BE(10)) // 0x0304
console.log(bl.readUInt16LE(10)) // 0x0403
```
Give it a callback in the constructor and use it just like **[concat-stream](https://github.com/maxogden/node-concat-stream)**:
```js
const bl = require('bl')
, fs = require('fs')
fs.createReadStream('README.md')
.pipe(bl(function (err, data) { // note 'new' isn't strictly required
// `data` is a complete Buffer object containing the full data
console.log(data.toString())
}))
```
Note that when you use the *callback* method like this, the resulting `data` parameter is a concatenation of all `Buffer` objects in the list. If you want to avoid the overhead of this concatenation (in cases of extreme performance consciousness), then avoid the *callback* method and just listen to `'end'` instead, like a standard Stream.
Or to fetch a URL using [hyperquest](https://github.com/substack/hyperquest) (should work with [request](http://github.com/mikeal/request) and even plain Node http too!):
```js
const hyperquest = require('hyperquest')
, bl = require('bl')
, url = 'https://raw.github.com/rvagg/bl/master/README.md'
hyperquest(url).pipe(bl(function (err, data) {
console.log(data.toString())
}))
```
Or, use it as a readable stream to recompose a list of Buffers to an output source:
```js
const BufferList = require('bl')
, fs = require('fs')
var bl = new BufferList()
bl.append(new Buffer('abcd'))
bl.append(new Buffer('efg'))
bl.append(new Buffer('hi'))
bl.append(new Buffer('j'))
bl.pipe(fs.createWriteStream('gibberish.txt'))
```
## API
* <a href="#ctor"><code><b>new BufferList([ callback ])</b></code></a>
* <a href="#length"><code>bl.<b>length</b></code></a>
* <a href="#append"><code>bl.<b>append(buffer)</b></code></a>
* <a href="#get"><code>bl.<b>get(index)</b></code></a>
* <a href="#slice"><code>bl.<b>slice([ start[, end ] ])</b></code></a>
* <a href="#shallowSlice"><code>bl.<b>shallowSlice([ start[, end ] ])</b></code></a>
* <a href="#copy"><code>bl.<b>copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])</b></code></a>
* <a href="#duplicate"><code>bl.<b>duplicate()</b></code></a>
* <a href="#consume"><code>bl.<b>consume(bytes)</b></code></a>
* <a href="#toString"><code>bl.<b>toString([encoding, [ start, [ end ]]])</b></code></a>
* <a href="#readXX"><code>bl.<b>readDoubleBE()</b></code>, <code>bl.<b>readDoubleLE()</b></code>, <code>bl.<b>readFloatBE()</b></code>, <code>bl.<b>readFloatLE()</b></code>, <code>bl.<b>readInt32BE()</b></code>, <code>bl.<b>readInt32LE()</b></code>, <code>bl.<b>readUInt32BE()</b></code>, <code>bl.<b>readUInt32LE()</b></code>, <code>bl.<b>readInt16BE()</b></code>, <code>bl.<b>readInt16LE()</b></code>, <code>bl.<b>readUInt16BE()</b></code>, <code>bl.<b>readUInt16LE()</b></code>, <code>bl.<b>readInt8()</b></code>, <code>bl.<b>readUInt8()</b></code></a>
* <a href="#streams">Streams</a>
--------------------------------------------------------
<a name="ctor"></a>
### new BufferList([ callback | Buffer | Buffer array | BufferList | BufferList array | String ])
The constructor takes an optional callback, if supplied, the callback will be called with an error argument followed by a reference to the **bl** instance, when `bl.end()` is called (i.e. from a piped stream). This is a convenient method of collecting the entire contents of a stream, particularly when the stream is *chunky*, such as a network stream.
Normally, no arguments are required for the constructor, but you can initialise the list by passing in a single `Buffer` object or an array of `Buffer` object.
`new` is not strictly required, if you don't instantiate a new object, it will be done automatically for you so you can create a new instance simply with:
```js
var bl = require('bl')
var myinstance = bl()
// equivalent to:
var BufferList = require('bl')
var myinstance = new BufferList()
```
--------------------------------------------------------
<a name="length"></a>
### bl.length
Get the length of the list in bytes. This is the sum of the lengths of all of the buffers contained in the list, minus any initial offset for a semi-consumed buffer at the beginning. Should accurately represent the total number of bytes that can be read from the list.
--------------------------------------------------------
<a name="append"></a>
### bl.append(Buffer | Buffer array | BufferList | BufferList array | String)
`append(buffer)` adds an additional buffer or BufferList to the internal list. `this` is returned so it can be chained.
--------------------------------------------------------
<a name="get"></a>
### bl.get(index)
`get()` will return the byte at the specified index.
--------------------------------------------------------
<a name="slice"></a>
### bl.slice([ start, [ end ] ])
`slice()` returns a new `Buffer` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
If the requested range spans a single internal buffer then a slice of that buffer will be returned which shares the original memory range of that Buffer. If the range spans multiple buffers then copy operations will likely occur to give you a uniform Buffer.
--------------------------------------------------------
<a name="shallowSlice"></a>
### bl.shallowSlice([ start, [ end ] ])
`shallowSlice()` returns a new `BufferList` object containing the bytes within the range specified. Both `start` and `end` are optional and will default to the beginning and end of the list respectively.
No copies will be performed. All buffers in the result share memory with the original list.
--------------------------------------------------------
<a name="copy"></a>
### bl.copy(dest, [ destStart, [ srcStart [, srcEnd ] ] ])
`copy()` copies the content of the list in the `dest` buffer, starting from `destStart` and containing the bytes within the range specified with `srcStart` to `srcEnd`. `destStart`, `start` and `end` are optional and will default to the beginning of the `dest` buffer, and the beginning and end of the list respectively.
--------------------------------------------------------
<a name="duplicate"></a>
### bl.duplicate()
`duplicate()` performs a **shallow-copy** of the list. The internal Buffers remains the same, so if you change the underlying Buffers, the change will be reflected in both the original and the duplicate. This method is needed if you want to call `consume()` or `pipe()` and still keep the original list.Example:
```js
var bl = new BufferList()
bl.append('hello')
bl.append(' world')
bl.append('\n')
bl.duplicate().pipe(process.stdout, { end: false })
console.log(bl.toString())
```
--------------------------------------------------------
<a name="consume"></a>
### bl.consume(bytes)
`consume()` will shift bytes *off the start of the list*. The number of bytes consumed don't need to line up with the sizes of the internal Buffers&mdash;initial offsets will be calculated accordingly in order to give you a consistent view of the data.
--------------------------------------------------------
<a name="toString"></a>
### bl.toString([encoding, [ start, [ end ]]])
`toString()` will return a string representation of the buffer. The optional `start` and `end` arguments are passed on to `slice()`, while the `encoding` is passed on to `toString()` of the resulting Buffer. See the [Buffer#toString()](http://nodejs.org/docs/latest/api/buffer.html#buffer_buf_tostring_encoding_start_end) documentation for more information.
--------------------------------------------------------
<a name="readXX"></a>
### bl.readDoubleBE(), bl.readDoubleLE(), bl.readFloatBE(), bl.readFloatLE(), bl.readInt32BE(), bl.readInt32LE(), bl.readUInt32BE(), bl.readUInt32LE(), bl.readInt16BE(), bl.readInt16LE(), bl.readUInt16BE(), bl.readUInt16LE(), bl.readInt8(), bl.readUInt8()
All of the standard byte-reading methods of the `Buffer` interface are implemented and will operate across internal Buffer boundaries transparently.
See the <b><code>[Buffer](http://nodejs.org/docs/latest/api/buffer.html)</code></b> documentation for how these work.
--------------------------------------------------------
<a name="streams"></a>
### Streams
**bl** is a Node **[Duplex Stream](http://nodejs.org/docs/latest/api/stream.html#stream_class_stream_duplex)**, so it can be read from and written to like a standard Node stream. You can also `pipe()` to and from a **bl** instance.
--------------------------------------------------------
## Contributors
**bl** is brought to you by the following hackers:
* [Rod Vagg](https://github.com/rvagg)
* [Matteo Collina](https://github.com/mcollina)
* [Jarett Cruger](https://github.com/jcrugzz)
=======
<a name="license"></a>
## License &amp; copyright
Copyright (c) 2013-2016 bl contributors (listed above).
bl is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

281
node_modules/bl/bl.js generated vendored
View File

@ -1,281 +0,0 @@
var DuplexStream = require('readable-stream/duplex')
, util = require('util')
, Buffer = require('safe-buffer').Buffer
function BufferList (callback) {
if (!(this instanceof BufferList))
return new BufferList(callback)
this._bufs = []
this.length = 0
if (typeof callback == 'function') {
this._callback = callback
var piper = function piper (err) {
if (this._callback) {
this._callback(err)
this._callback = null
}
}.bind(this)
this.on('pipe', function onPipe (src) {
src.on('error', piper)
})
this.on('unpipe', function onUnpipe (src) {
src.removeListener('error', piper)
})
} else {
this.append(callback)
}
DuplexStream.call(this)
}
util.inherits(BufferList, DuplexStream)
BufferList.prototype._offset = function _offset (offset) {
var tot = 0, i = 0, _t
if (offset === 0) return [ 0, 0 ]
for (; i < this._bufs.length; i++) {
_t = tot + this._bufs[i].length
if (offset < _t || i == this._bufs.length - 1)
return [ i, offset - tot ]
tot = _t
}
}
BufferList.prototype.append = function append (buf) {
var i = 0
if (Buffer.isBuffer(buf)) {
this._appendBuffer(buf);
} else if (Array.isArray(buf)) {
for (; i < buf.length; i++)
this.append(buf[i])
} else if (buf instanceof BufferList) {
// unwrap argument into individual BufferLists
for (; i < buf._bufs.length; i++)
this.append(buf._bufs[i])
} else if (buf != null) {
// coerce number arguments to strings, since Buffer(number) does
// uninitialized memory allocation
if (typeof buf == 'number')
buf = buf.toString()
this._appendBuffer(Buffer.from(buf));
}
return this
}
BufferList.prototype._appendBuffer = function appendBuffer (buf) {
this._bufs.push(buf)
this.length += buf.length
}
BufferList.prototype._write = function _write (buf, encoding, callback) {
this._appendBuffer(buf)
if (typeof callback == 'function')
callback()
}
BufferList.prototype._read = function _read (size) {
if (!this.length)
return this.push(null)
size = Math.min(size, this.length)
this.push(this.slice(0, size))
this.consume(size)
}
BufferList.prototype.end = function end (chunk) {
DuplexStream.prototype.end.call(this, chunk)
if (this._callback) {
this._callback(null, this.slice())
this._callback = null
}
}
BufferList.prototype.get = function get (index) {
return this.slice(index, index + 1)[0]
}
BufferList.prototype.slice = function slice (start, end) {
if (typeof start == 'number' && start < 0)
start += this.length
if (typeof end == 'number' && end < 0)
end += this.length
return this.copy(null, 0, start, end)
}
BufferList.prototype.copy = function copy (dst, dstStart, srcStart, srcEnd) {
if (typeof srcStart != 'number' || srcStart < 0)
srcStart = 0
if (typeof srcEnd != 'number' || srcEnd > this.length)
srcEnd = this.length
if (srcStart >= this.length)
return dst || Buffer.alloc(0)
if (srcEnd <= 0)
return dst || Buffer.alloc(0)
var copy = !!dst
, off = this._offset(srcStart)
, len = srcEnd - srcStart
, bytes = len
, bufoff = (copy && dstStart) || 0
, start = off[1]
, l
, i
// copy/slice everything
if (srcStart === 0 && srcEnd == this.length) {
if (!copy) { // slice, but full concat if multiple buffers
return this._bufs.length === 1
? this._bufs[0]
: Buffer.concat(this._bufs, this.length)
}
// copy, need to copy individual buffers
for (i = 0; i < this._bufs.length; i++) {
this._bufs[i].copy(dst, bufoff)
bufoff += this._bufs[i].length
}
return dst
}
// easy, cheap case where it's a subset of one of the buffers
if (bytes <= this._bufs[off[0]].length - start) {
return copy
? this._bufs[off[0]].copy(dst, dstStart, start, start + bytes)
: this._bufs[off[0]].slice(start, start + bytes)
}
if (!copy) // a slice, we need something to copy in to
dst = Buffer.allocUnsafe(len)
for (i = off[0]; i < this._bufs.length; i++) {
l = this._bufs[i].length - start
if (bytes > l) {
this._bufs[i].copy(dst, bufoff, start)
} else {
this._bufs[i].copy(dst, bufoff, start, start + bytes)
break
}
bufoff += l
bytes -= l
if (start)
start = 0
}
return dst
}
BufferList.prototype.shallowSlice = function shallowSlice (start, end) {
start = start || 0
end = end || this.length
if (start < 0)
start += this.length
if (end < 0)
end += this.length
var startOffset = this._offset(start)
, endOffset = this._offset(end)
, buffers = this._bufs.slice(startOffset[0], endOffset[0] + 1)
if (endOffset[1] == 0)
buffers.pop()
else
buffers[buffers.length-1] = buffers[buffers.length-1].slice(0, endOffset[1])
if (startOffset[1] != 0)
buffers[0] = buffers[0].slice(startOffset[1])
return new BufferList(buffers)
}
BufferList.prototype.toString = function toString (encoding, start, end) {
return this.slice(start, end).toString(encoding)
}
BufferList.prototype.consume = function consume (bytes) {
while (this._bufs.length) {
if (bytes >= this._bufs[0].length) {
bytes -= this._bufs[0].length
this.length -= this._bufs[0].length
this._bufs.shift()
} else {
this._bufs[0] = this._bufs[0].slice(bytes)
this.length -= bytes
break
}
}
return this
}
BufferList.prototype.duplicate = function duplicate () {
var i = 0
, copy = new BufferList()
for (; i < this._bufs.length; i++)
copy.append(this._bufs[i])
return copy
}
BufferList.prototype.destroy = function destroy () {
this._bufs.length = 0
this.length = 0
this.push(null)
}
;(function () {
var methods = {
'readDoubleBE' : 8
, 'readDoubleLE' : 8
, 'readFloatBE' : 4
, 'readFloatLE' : 4
, 'readInt32BE' : 4
, 'readInt32LE' : 4
, 'readUInt32BE' : 4
, 'readUInt32LE' : 4
, 'readInt16BE' : 2
, 'readInt16LE' : 2
, 'readUInt16BE' : 2
, 'readUInt16LE' : 2
, 'readInt8' : 1
, 'readUInt8' : 1
}
for (var m in methods) {
(function (m) {
BufferList.prototype[m] = function (offset) {
return this.slice(offset, offset + methods[m])[m](0)
}
}(m))
}
}())
module.exports = BufferList

63
node_modules/bl/package.json generated vendored
View File

@ -1,63 +0,0 @@
{
"_from": "bl@^1.0.0",
"_id": "bl@1.2.2",
"_inBundle": false,
"_integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==",
"_location": "/bl",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "bl@^1.0.0",
"name": "bl",
"escapedName": "bl",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/tar-stream"
],
"_resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz",
"_shasum": "a160911717103c07410cef63ef51b397c025af9c",
"_spec": "bl@^1.0.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\tar-stream",
"authors": [
"Rod Vagg <rod@vagg.org> (https://github.com/rvagg)",
"Matteo Collina <matteo.collina@gmail.com> (https://github.com/mcollina)",
"Jarett Cruger <jcrugzz@gmail.com> (https://github.com/jcrugzz)"
],
"bugs": {
"url": "https://github.com/rvagg/bl/issues"
},
"bundleDependencies": false,
"dependencies": {
"readable-stream": "^2.3.5",
"safe-buffer": "^5.1.1"
},
"deprecated": false,
"description": "Buffer List: collect buffers and access with a standard readable Buffer interface, streamable too!",
"devDependencies": {
"faucet": "0.0.1",
"hash_file": "~0.1.1",
"tape": "~4.9.0"
},
"homepage": "https://github.com/rvagg/bl",
"keywords": [
"buffer",
"buffers",
"stream",
"awesomesauce"
],
"license": "MIT",
"main": "bl.js",
"name": "bl",
"repository": {
"type": "git",
"url": "git+https://github.com/rvagg/bl.git"
},
"scripts": {
"test": "node test/test.js | faucet"
},
"version": "1.2.2"
}

702
node_modules/bl/test/test.js generated vendored
View File

@ -1,702 +0,0 @@
var tape = require('tape')
, crypto = require('crypto')
, fs = require('fs')
, hash = require('hash_file')
, BufferList = require('../')
, Buffer = require('safe-buffer').Buffer
, encodings =
('hex utf8 utf-8 ascii binary base64'
+ (process.browser ? '' : ' ucs2 ucs-2 utf16le utf-16le')).split(' ')
tape('single bytes from single buffer', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
t.equal(bl.length, 4)
t.equal(bl.get(0), 97)
t.equal(bl.get(1), 98)
t.equal(bl.get(2), 99)
t.equal(bl.get(3), 100)
t.end()
})
tape('single bytes from multiple buffers', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append(Buffer.from('hi'))
bl.append(Buffer.from('j'))
t.equal(bl.length, 10)
t.equal(bl.get(0), 97)
t.equal(bl.get(1), 98)
t.equal(bl.get(2), 99)
t.equal(bl.get(3), 100)
t.equal(bl.get(4), 101)
t.equal(bl.get(5), 102)
t.equal(bl.get(6), 103)
t.equal(bl.get(7), 104)
t.equal(bl.get(8), 105)
t.equal(bl.get(9), 106)
t.end()
})
tape('multi bytes from single buffer', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
t.equal(bl.length, 4)
t.equal(bl.slice(0, 4).toString('ascii'), 'abcd')
t.equal(bl.slice(0, 3).toString('ascii'), 'abc')
t.equal(bl.slice(1, 4).toString('ascii'), 'bcd')
t.equal(bl.slice(-4, -1).toString('ascii'), 'abc')
t.end()
})
tape('multi bytes from single buffer (negative indexes)', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('buffer'))
t.equal(bl.length, 6)
t.equal(bl.slice(-6, -1).toString('ascii'), 'buffe')
t.equal(bl.slice(-6, -2).toString('ascii'), 'buff')
t.equal(bl.slice(-5, -2).toString('ascii'), 'uff')
t.end()
})
tape('multiple bytes from multiple buffers', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append(Buffer.from('hi'))
bl.append(Buffer.from('j'))
t.equal(bl.length, 10)
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
t.equal(bl.slice(-7, -4).toString('ascii'), 'def')
t.end()
})
tape('multiple bytes from multiple buffer lists', function (t) {
var bl = new BufferList()
bl.append(new BufferList([ Buffer.from('abcd'), Buffer.from('efg') ]))
bl.append(new BufferList([ Buffer.from('hi'), Buffer.from('j') ]))
t.equal(bl.length, 10)
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
t.end()
})
// same data as previous test, just using nested constructors
tape('multiple bytes from crazy nested buffer lists', function (t) {
var bl = new BufferList()
bl.append(new BufferList([
new BufferList([
new BufferList(Buffer.from('abc'))
, Buffer.from('d')
, new BufferList(Buffer.from('efg'))
])
, new BufferList([ Buffer.from('hi') ])
, new BufferList(Buffer.from('j'))
]))
t.equal(bl.length, 10)
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
t.equal(bl.slice(3, 10).toString('ascii'), 'defghij')
t.equal(bl.slice(3, 6).toString('ascii'), 'def')
t.equal(bl.slice(3, 8).toString('ascii'), 'defgh')
t.equal(bl.slice(5, 10).toString('ascii'), 'fghij')
t.end()
})
tape('append accepts arrays of Buffers', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abc'))
bl.append([ Buffer.from('def') ])
bl.append([ Buffer.from('ghi'), Buffer.from('jkl') ])
bl.append([ Buffer.from('mnop'), Buffer.from('qrstu'), Buffer.from('vwxyz') ])
t.equal(bl.length, 26)
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
t.end()
})
tape('append accepts arrays of BufferLists', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abc'))
bl.append([ new BufferList('def') ])
bl.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
bl.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
t.equal(bl.length, 26)
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
t.end()
})
tape('append chainable', function (t) {
var bl = new BufferList()
t.ok(bl.append(Buffer.from('abcd')) === bl)
t.ok(bl.append([ Buffer.from('abcd') ]) === bl)
t.ok(bl.append(new BufferList(Buffer.from('abcd'))) === bl)
t.ok(bl.append([ new BufferList(Buffer.from('abcd')) ]) === bl)
t.end()
})
tape('append chainable (test results)', function (t) {
var bl = new BufferList('abc')
.append([ new BufferList('def') ])
.append(new BufferList([ Buffer.from('ghi'), new BufferList('jkl') ]))
.append([ Buffer.from('mnop'), new BufferList([ Buffer.from('qrstu'), Buffer.from('vwxyz') ]) ])
t.equal(bl.length, 26)
t.equal(bl.slice().toString('ascii'), 'abcdefghijklmnopqrstuvwxyz')
t.end()
})
tape('consuming from multiple buffers', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append(Buffer.from('hi'))
bl.append(Buffer.from('j'))
t.equal(bl.length, 10)
t.equal(bl.slice(0, 10).toString('ascii'), 'abcdefghij')
bl.consume(3)
t.equal(bl.length, 7)
t.equal(bl.slice(0, 7).toString('ascii'), 'defghij')
bl.consume(2)
t.equal(bl.length, 5)
t.equal(bl.slice(0, 5).toString('ascii'), 'fghij')
bl.consume(1)
t.equal(bl.length, 4)
t.equal(bl.slice(0, 4).toString('ascii'), 'ghij')
bl.consume(1)
t.equal(bl.length, 3)
t.equal(bl.slice(0, 3).toString('ascii'), 'hij')
bl.consume(2)
t.equal(bl.length, 1)
t.equal(bl.slice(0, 1).toString('ascii'), 'j')
t.end()
})
tape('complete consumption', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('a'))
bl.append(Buffer.from('b'))
bl.consume(2)
t.equal(bl.length, 0)
t.equal(bl._bufs.length, 0)
t.end()
})
tape('test readUInt8 / readInt8', function (t) {
var buf1 = Buffer.alloc(1)
, buf2 = Buffer.alloc(3)
, buf3 = Buffer.alloc(3)
, bl = new BufferList()
buf2[1] = 0x3
buf2[2] = 0x4
buf3[0] = 0x23
buf3[1] = 0x42
bl.append(buf1)
bl.append(buf2)
bl.append(buf3)
t.equal(bl.readUInt8(2), 0x3)
t.equal(bl.readInt8(2), 0x3)
t.equal(bl.readUInt8(3), 0x4)
t.equal(bl.readInt8(3), 0x4)
t.equal(bl.readUInt8(4), 0x23)
t.equal(bl.readInt8(4), 0x23)
t.equal(bl.readUInt8(5), 0x42)
t.equal(bl.readInt8(5), 0x42)
t.end()
})
tape('test readUInt16LE / readUInt16BE / readInt16LE / readInt16BE', function (t) {
var buf1 = Buffer.alloc(1)
, buf2 = Buffer.alloc(3)
, buf3 = Buffer.alloc(3)
, bl = new BufferList()
buf2[1] = 0x3
buf2[2] = 0x4
buf3[0] = 0x23
buf3[1] = 0x42
bl.append(buf1)
bl.append(buf2)
bl.append(buf3)
t.equal(bl.readUInt16BE(2), 0x0304)
t.equal(bl.readUInt16LE(2), 0x0403)
t.equal(bl.readInt16BE(2), 0x0304)
t.equal(bl.readInt16LE(2), 0x0403)
t.equal(bl.readUInt16BE(3), 0x0423)
t.equal(bl.readUInt16LE(3), 0x2304)
t.equal(bl.readInt16BE(3), 0x0423)
t.equal(bl.readInt16LE(3), 0x2304)
t.equal(bl.readUInt16BE(4), 0x2342)
t.equal(bl.readUInt16LE(4), 0x4223)
t.equal(bl.readInt16BE(4), 0x2342)
t.equal(bl.readInt16LE(4), 0x4223)
t.end()
})
tape('test readUInt32LE / readUInt32BE / readInt32LE / readInt32BE', function (t) {
var buf1 = Buffer.alloc(1)
, buf2 = Buffer.alloc(3)
, buf3 = Buffer.alloc(3)
, bl = new BufferList()
buf2[1] = 0x3
buf2[2] = 0x4
buf3[0] = 0x23
buf3[1] = 0x42
bl.append(buf1)
bl.append(buf2)
bl.append(buf3)
t.equal(bl.readUInt32BE(2), 0x03042342)
t.equal(bl.readUInt32LE(2), 0x42230403)
t.equal(bl.readInt32BE(2), 0x03042342)
t.equal(bl.readInt32LE(2), 0x42230403)
t.end()
})
tape('test readFloatLE / readFloatBE', function (t) {
var buf1 = Buffer.alloc(1)
, buf2 = Buffer.alloc(3)
, buf3 = Buffer.alloc(3)
, bl = new BufferList()
buf2[1] = 0x00
buf2[2] = 0x00
buf3[0] = 0x80
buf3[1] = 0x3f
bl.append(buf1)
bl.append(buf2)
bl.append(buf3)
t.equal(bl.readFloatLE(2), 0x01)
t.end()
})
tape('test readDoubleLE / readDoubleBE', function (t) {
var buf1 = Buffer.alloc(1)
, buf2 = Buffer.alloc(3)
, buf3 = Buffer.alloc(10)
, bl = new BufferList()
buf2[1] = 0x55
buf2[2] = 0x55
buf3[0] = 0x55
buf3[1] = 0x55
buf3[2] = 0x55
buf3[3] = 0x55
buf3[4] = 0xd5
buf3[5] = 0x3f
bl.append(buf1)
bl.append(buf2)
bl.append(buf3)
t.equal(bl.readDoubleLE(2), 0.3333333333333333)
t.end()
})
tape('test toString', function (t) {
var bl = new BufferList()
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append(Buffer.from('hi'))
bl.append(Buffer.from('j'))
t.equal(bl.toString('ascii', 0, 10), 'abcdefghij')
t.equal(bl.toString('ascii', 3, 10), 'defghij')
t.equal(bl.toString('ascii', 3, 6), 'def')
t.equal(bl.toString('ascii', 3, 8), 'defgh')
t.equal(bl.toString('ascii', 5, 10), 'fghij')
t.end()
})
tape('test toString encoding', function (t) {
var bl = new BufferList()
, b = Buffer.from('abcdefghij\xff\x00')
bl.append(Buffer.from('abcd'))
bl.append(Buffer.from('efg'))
bl.append(Buffer.from('hi'))
bl.append(Buffer.from('j'))
bl.append(Buffer.from('\xff\x00'))
encodings.forEach(function (enc) {
t.equal(bl.toString(enc), b.toString(enc), enc)
})
t.end()
})
!process.browser && tape('test stream', function (t) {
var random = crypto.randomBytes(65534)
, rndhash = hash(random, 'md5')
, md5sum = crypto.createHash('md5')
, bl = new BufferList(function (err, buf) {
t.ok(Buffer.isBuffer(buf))
t.ok(err === null)
t.equal(rndhash, hash(bl.slice(), 'md5'))
t.equal(rndhash, hash(buf, 'md5'))
bl.pipe(fs.createWriteStream('/tmp/bl_test_rnd_out.dat'))
.on('close', function () {
var s = fs.createReadStream('/tmp/bl_test_rnd_out.dat')
s.on('data', md5sum.update.bind(md5sum))
s.on('end', function() {
t.equal(rndhash, md5sum.digest('hex'), 'woohoo! correct hash!')
t.end()
})
})
})
fs.writeFileSync('/tmp/bl_test_rnd.dat', random)
fs.createReadStream('/tmp/bl_test_rnd.dat').pipe(bl)
})
tape('instantiation with Buffer', function (t) {
var buf = crypto.randomBytes(1024)
, buf2 = crypto.randomBytes(1024)
, b = BufferList(buf)
t.equal(buf.toString('hex'), b.slice().toString('hex'), 'same buffer')
b = BufferList([ buf, buf2 ])
t.equal(b.slice().toString('hex'), Buffer.concat([ buf, buf2 ]).toString('hex'), 'same buffer')
t.end()
})
tape('test String appendage', function (t) {
var bl = new BufferList()
, b = Buffer.from('abcdefghij\xff\x00')
bl.append('abcd')
bl.append('efg')
bl.append('hi')
bl.append('j')
bl.append('\xff\x00')
encodings.forEach(function (enc) {
t.equal(bl.toString(enc), b.toString(enc))
})
t.end()
})
tape('test Number appendage', function (t) {
var bl = new BufferList()
, b = Buffer.from('1234567890')
bl.append(1234)
bl.append(567)
bl.append(89)
bl.append(0)
encodings.forEach(function (enc) {
t.equal(bl.toString(enc), b.toString(enc))
})
t.end()
})
tape('write nothing, should get empty buffer', function (t) {
t.plan(3)
BufferList(function (err, data) {
t.notOk(err, 'no error')
t.ok(Buffer.isBuffer(data), 'got a buffer')
t.equal(0, data.length, 'got a zero-length buffer')
t.end()
}).end()
})
tape('unicode string', function (t) {
t.plan(2)
var inp1 = '\u2600'
, inp2 = '\u2603'
, exp = inp1 + ' and ' + inp2
, bl = BufferList()
bl.write(inp1)
bl.write(' and ')
bl.write(inp2)
t.equal(exp, bl.toString())
t.equal(Buffer.from(exp).toString('hex'), bl.toString('hex'))
})
tape('should emit finish', function (t) {
var source = BufferList()
, dest = BufferList()
source.write('hello')
source.pipe(dest)
dest.on('finish', function () {
t.equal(dest.toString('utf8'), 'hello')
t.end()
})
})
tape('basic copy', function (t) {
var buf = crypto.randomBytes(1024)
, buf2 = Buffer.alloc(1024)
, b = BufferList(buf)
b.copy(buf2)
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
t.end()
})
tape('copy after many appends', function (t) {
var buf = crypto.randomBytes(512)
, buf2 = Buffer.alloc(1024)
, b = BufferList(buf)
b.append(buf)
b.copy(buf2)
t.equal(b.slice().toString('hex'), buf2.toString('hex'), 'same buffer')
t.end()
})
tape('copy at a precise position', function (t) {
var buf = crypto.randomBytes(1004)
, buf2 = Buffer.alloc(1024)
, b = BufferList(buf)
b.copy(buf2, 20)
t.equal(b.slice().toString('hex'), buf2.slice(20).toString('hex'), 'same buffer')
t.end()
})
tape('copy starting from a precise location', function (t) {
var buf = crypto.randomBytes(10)
, buf2 = Buffer.alloc(5)
, b = BufferList(buf)
b.copy(buf2, 0, 5)
t.equal(b.slice(5).toString('hex'), buf2.toString('hex'), 'same buffer')
t.end()
})
tape('copy in an interval', function (t) {
var rnd = crypto.randomBytes(10)
, b = BufferList(rnd) // put the random bytes there
, actual = Buffer.alloc(3)
, expected = Buffer.alloc(3)
rnd.copy(expected, 0, 5, 8)
b.copy(actual, 0, 5, 8)
t.equal(actual.toString('hex'), expected.toString('hex'), 'same buffer')
t.end()
})
tape('copy an interval between two buffers', function (t) {
var buf = crypto.randomBytes(10)
, buf2 = Buffer.alloc(10)
, b = BufferList(buf)
b.append(buf)
b.copy(buf2, 0, 5, 15)
t.equal(b.slice(5, 15).toString('hex'), buf2.toString('hex'), 'same buffer')
t.end()
})
tape('shallow slice across buffer boundaries', function (t) {
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(3, 13).toString(), 'stSecondTh')
t.end()
})
tape('shallow slice within single buffer', function (t) {
t.plan(2)
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(5, 10).toString(), 'Secon')
t.equal(bl.shallowSlice(7, 10).toString(), 'con')
t.end()
})
tape('shallow slice single buffer', function (t) {
t.plan(3)
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice(0, 5).toString(), 'First')
t.equal(bl.shallowSlice(5, 11).toString(), 'Second')
t.equal(bl.shallowSlice(11, 16).toString(), 'Third')
})
tape('shallow slice with negative or omitted indices', function (t) {
t.plan(4)
var bl = new BufferList(['First', 'Second', 'Third'])
t.equal(bl.shallowSlice().toString(), 'FirstSecondThird')
t.equal(bl.shallowSlice(5).toString(), 'SecondThird')
t.equal(bl.shallowSlice(5, -3).toString(), 'SecondTh')
t.equal(bl.shallowSlice(-8).toString(), 'ondThird')
})
tape('shallow slice does not make a copy', function (t) {
t.plan(1)
var buffers = [Buffer.from('First'), Buffer.from('Second'), Buffer.from('Third')]
var bl = (new BufferList(buffers)).shallowSlice(5, -3)
buffers[1].fill('h')
buffers[2].fill('h')
t.equal(bl.toString(), 'hhhhhhhh')
})
tape('duplicate', function (t) {
t.plan(2)
var bl = new BufferList('abcdefghij\xff\x00')
, dup = bl.duplicate()
t.equal(bl.prototype, dup.prototype)
t.equal(bl.toString('hex'), dup.toString('hex'))
})
tape('destroy no pipe', function (t) {
t.plan(2)
var bl = new BufferList('alsdkfja;lsdkfja;lsdk')
bl.destroy()
t.equal(bl._bufs.length, 0)
t.equal(bl.length, 0)
})
!process.browser && tape('destroy with pipe before read end', function (t) {
t.plan(2)
var bl = new BufferList()
fs.createReadStream(__dirname + '/test.js')
.pipe(bl)
bl.destroy()
t.equal(bl._bufs.length, 0)
t.equal(bl.length, 0)
})
!process.browser && tape('destroy with pipe before read end with race', function (t) {
t.plan(2)
var bl = new BufferList()
fs.createReadStream(__dirname + '/test.js')
.pipe(bl)
setTimeout(function () {
bl.destroy()
setTimeout(function () {
t.equal(bl._bufs.length, 0)
t.equal(bl.length, 0)
}, 500)
}, 500)
})
!process.browser && tape('destroy with pipe after read end', function (t) {
t.plan(2)
var bl = new BufferList()
fs.createReadStream(__dirname + '/test.js')
.on('end', onEnd)
.pipe(bl)
function onEnd () {
bl.destroy()
t.equal(bl._bufs.length, 0)
t.equal(bl.length, 0)
}
})
!process.browser && tape('destroy with pipe while writing to a destination', function (t) {
t.plan(4)
var bl = new BufferList()
, ds = new BufferList()
fs.createReadStream(__dirname + '/test.js')
.on('end', onEnd)
.pipe(bl)
function onEnd () {
bl.pipe(ds)
setTimeout(function () {
bl.destroy()
t.equals(bl._bufs.length, 0)
t.equals(bl.length, 0)
ds.destroy()
t.equals(bl._bufs.length, 0)
t.equals(bl.length, 0)
}, 100)
}
})
!process.browser && tape('handle error', function (t) {
t.plan(2)
fs.createReadStream('/does/not/exist').pipe(BufferList(function (err, data) {
t.ok(err instanceof Error, 'has error')
t.notOk(data, 'no data')
}))
})

View File

@ -1,17 +0,0 @@
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

View File

@ -1,57 +0,0 @@
{
"_from": "buffer-alloc-unsafe@^1.1.0",
"_id": "buffer-alloc-unsafe@1.1.0",
"_inBundle": false,
"_integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==",
"_location": "/buffer-alloc-unsafe",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "buffer-alloc-unsafe@^1.1.0",
"name": "buffer-alloc-unsafe",
"escapedName": "buffer-alloc-unsafe",
"rawSpec": "^1.1.0",
"saveSpec": null,
"fetchSpec": "^1.1.0"
},
"_requiredBy": [
"/buffer-alloc"
],
"_resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz",
"_shasum": "bd7dc26ae2972d0eda253be061dba992349c19f0",
"_spec": "buffer-alloc-unsafe@^1.1.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\buffer-alloc",
"bugs": {
"url": "https://github.com/LinusU/buffer-alloc-unsafe/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "A [ponyfill](https://ponyfill.com) for `Buffer.allocUnsafe`.",
"devDependencies": {
"standard": "^7.1.2"
},
"files": [
"index.js"
],
"homepage": "https://github.com/LinusU/buffer-alloc-unsafe#readme",
"keywords": [
"allocUnsafe",
"allocate",
"buffer allocUnsafe",
"buffer unsafe allocate",
"buffer",
"ponyfill",
"unsafe allocate"
],
"license": "MIT",
"name": "buffer-alloc-unsafe",
"repository": {
"type": "git",
"url": "git+https://github.com/LinusU/buffer-alloc-unsafe.git"
},
"scripts": {
"test": "standard && node test"
},
"version": "1.1.0"
}

View File

@ -1,46 +0,0 @@
# 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`

32
node_modules/buffer-alloc/index.js generated vendored
View File

@ -1,32 +0,0 @@
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)
}

View File

@ -1,59 +0,0 @@
{
"_from": "buffer-alloc@^1.2.0",
"_id": "buffer-alloc@1.2.0",
"_inBundle": false,
"_integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==",
"_location": "/buffer-alloc",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "buffer-alloc@^1.2.0",
"name": "buffer-alloc",
"escapedName": "buffer-alloc",
"rawSpec": "^1.2.0",
"saveSpec": null,
"fetchSpec": "^1.2.0"
},
"_requiredBy": [
"/tar-stream"
],
"_resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz",
"_shasum": "890dd90d923a873e08e10e5fd51a57e5b7cce0ec",
"_spec": "buffer-alloc@^1.2.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\tar-stream",
"bugs": {
"url": "https://github.com/LinusU/buffer-alloc/issues"
},
"bundleDependencies": false,
"dependencies": {
"buffer-alloc-unsafe": "^1.1.0",
"buffer-fill": "^1.0.0"
},
"deprecated": false,
"description": "A [ponyfill](https://ponyfill.com) for `Buffer.alloc`.",
"devDependencies": {
"standard": "^7.1.2"
},
"files": [
"index.js"
],
"homepage": "https://github.com/LinusU/buffer-alloc#readme",
"keywords": [
"alloc",
"allocate",
"buffer alloc",
"buffer allocate",
"buffer"
],
"license": "MIT",
"name": "buffer-alloc",
"repository": {
"type": "git",
"url": "git+https://github.com/LinusU/buffer-alloc.git"
},
"scripts": {
"test": "standard && node test"
},
"version": "1.2.0"
}

43
node_modules/buffer-alloc/readme.md generated vendored
View File

@ -1,43 +0,0 @@
# 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`

19
node_modules/buffer-crc32/LICENSE generated vendored
View File

@ -1,19 +0,0 @@
The MIT License
Copyright (c) 2013 Brian J. Brennan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

47
node_modules/buffer-crc32/README.md generated vendored
View File

@ -1,47 +0,0 @@
# buffer-crc32
[![Build Status](https://secure.travis-ci.org/brianloveswords/buffer-crc32.png?branch=master)](http://travis-ci.org/brianloveswords/buffer-crc32)
crc32 that works with binary data and fancy character sets, outputs
buffer, signed or unsigned data and has tests.
Derived from the sample CRC implementation in the PNG specification: http://www.w3.org/TR/PNG/#D-CRCAppendix
# install
```
npm install buffer-crc32
```
# example
```js
var crc32 = require('buffer-crc32');
// works with buffers
var buf = Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00])
crc32(buf) // -> <Buffer 94 5a ab 4a>
// has convenience methods for getting signed or unsigned ints
crc32.signed(buf) // -> -1805997238
crc32.unsigned(buf) // -> 2488970058
// will cast to buffer if given a string, so you can
// directly use foreign characters safely
crc32('自動販売機') // -> <Buffer cb 03 1a c5>
// and works in append mode too
var partialCrc = crc32('hey');
var partialCrc = crc32(' ', partialCrc);
var partialCrc = crc32('sup', partialCrc);
var partialCrc = crc32(' ', partialCrc);
var finalCrc = crc32('bros', partialCrc); // -> <Buffer 47 fa 55 70>
```
# tests
This was tested against the output of zlib's crc32 method. You can run
the tests with`npm test` (requires tap)
# see also
https://github.com/alexgorbatchev/node-crc, `crc.buffer.crc32` also
supports buffer inputs and return unsigned ints (thanks @tjholowaychuk).
# license
MIT/X11

111
node_modules/buffer-crc32/index.js generated vendored
View File

@ -1,111 +0,0 @@
var Buffer = require('buffer').Buffer;
var CRC_TABLE = [
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
0x2d02ef8d
];
if (typeof Int32Array !== 'undefined') {
CRC_TABLE = new Int32Array(CRC_TABLE);
}
function ensureBuffer(input) {
if (Buffer.isBuffer(input)) {
return input;
}
var hasNewBufferAPI =
typeof Buffer.alloc === "function" &&
typeof Buffer.from === "function";
if (typeof input === "number") {
return hasNewBufferAPI ? Buffer.alloc(input) : new Buffer(input);
}
else if (typeof input === "string") {
return hasNewBufferAPI ? Buffer.from(input) : new Buffer(input);
}
else {
throw new Error("input must be buffer, number, or string, received " +
typeof input);
}
}
function bufferizeInt(num) {
var tmp = ensureBuffer(4);
tmp.writeInt32BE(num, 0);
return tmp;
}
function _crc32(buf, previous) {
buf = ensureBuffer(buf);
if (Buffer.isBuffer(previous)) {
previous = previous.readUInt32BE(0);
}
var crc = ~~previous ^ -1;
for (var n = 0; n < buf.length; n++) {
crc = CRC_TABLE[(crc ^ buf[n]) & 0xff] ^ (crc >>> 8);
}
return (crc ^ -1);
}
function crc32() {
return bufferizeInt(_crc32.apply(null, arguments));
}
crc32.signed = function () {
return _crc32.apply(null, arguments);
};
crc32.unsigned = function () {
return _crc32.apply(null, arguments) >>> 0;
};
module.exports = crc32;

View File

@ -1,69 +0,0 @@
{
"_from": "buffer-crc32@~0.2.3",
"_id": "buffer-crc32@0.2.13",
"_inBundle": false,
"_integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=",
"_location": "/buffer-crc32",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "buffer-crc32@~0.2.3",
"name": "buffer-crc32",
"escapedName": "buffer-crc32",
"rawSpec": "~0.2.3",
"saveSpec": null,
"fetchSpec": "~0.2.3"
},
"_requiredBy": [
"/yauzl"
],
"_resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz",
"_shasum": "0d333e3f00eac50aa1454abd30ef8c2a5d9a7242",
"_spec": "buffer-crc32@~0.2.3",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\yauzl",
"author": {
"name": "Brian J. Brennan",
"email": "brianloveswords@gmail.com"
},
"bugs": {
"url": "https://github.com/brianloveswords/buffer-crc32/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Vladimir Kuznetsov"
}
],
"dependencies": {},
"deprecated": false,
"description": "A pure javascript CRC32 algorithm that plays nice with binary data",
"devDependencies": {
"tap": "~0.2.5"
},
"engines": {
"node": "*"
},
"files": [
"index.js"
],
"homepage": "https://github.com/brianloveswords/buffer-crc32",
"license": "MIT",
"licenses": [
{
"type": "MIT",
"url": "https://github.com/brianloveswords/buffer-crc32/raw/master/LICENSE"
}
],
"main": "index.js",
"name": "buffer-crc32",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git://github.com/brianloveswords/buffer-crc32.git"
},
"scripts": {
"test": "tap tests/*.test.js"
},
"version": "0.2.13"
}

113
node_modules/buffer-fill/index.js generated vendored
View File

@ -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

View File

@ -1,49 +0,0 @@
{
"_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
View File

@ -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`

55
node_modules/buffer/AUTHORS.md generated vendored
View File

@ -1,55 +0,0 @@
# Authors
#### Ordered by first contribution.
- Romain Beauxis (toots@rastageeks.org)
- Tobias Koppers (tobias.koppers@googlemail.com)
- Janus (ysangkok@gmail.com)
- Rainer Dreyer (rdrey1@gmail.com)
- Tõnis Tiigi (tonistiigi@gmail.com)
- James Halliday (mail@substack.net)
- Michael Williamson (mike@zwobble.org)
- elliottcable (github@elliottcable.name)
- rafael (rvalle@livelens.net)
- Andrew Kelley (superjoe30@gmail.com)
- Andreas Madsen (amwebdk@gmail.com)
- Mike Brevoort (mike.brevoort@pearson.com)
- Brian White (mscdex@mscdex.net)
- Feross Aboukhadijeh (feross@feross.org)
- Ruben Verborgh (ruben@verborgh.org)
- eliang (eliang.cs@gmail.com)
- Jesse Tane (jesse.tane@gmail.com)
- Alfonso Boza (alfonso@cloud.com)
- Mathias Buus (mathiasbuus@gmail.com)
- Devon Govett (devongovett@gmail.com)
- Daniel Cousens (github@dcousens.com)
- Joseph Dykstra (josephdykstra@gmail.com)
- Parsha Pourkhomami (parshap+git@gmail.com)
- Damjan Košir (damjan.kosir@gmail.com)
- daverayment (dave.rayment@gmail.com)
- kawanet (u-suke@kawa.net)
- Linus Unnebäck (linus@folkdatorn.se)
- Nolan Lawson (nolan.lawson@gmail.com)
- Calvin Metcalf (calvin.metcalf@gmail.com)
- Koki Takahashi (hakatasiloving@gmail.com)
- Guy Bedford (guybedford@gmail.com)
- Jan Schär (jscissr@gmail.com)
- RaulTsc (tomescu.raul@gmail.com)
- Matthieu Monsch (monsch@alum.mit.edu)
- Dan Ehrenberg (littledan@chromium.org)
- Kirill Fomichev (fanatid@ya.ru)
- Yusuke Kawasaki (u-suke@kawa.net)
- DC (dcposch@dcpos.ch)
- John-David Dalton (john.david.dalton@gmail.com)
- adventure-yunfei (adventure030@gmail.com)
- Emil Bay (github@tixz.dk)
- Sam Sudar (sudar.sam@gmail.com)
- Volker Mische (volker.mische@gmail.com)
- David Walton (support@geekstocks.com)
- Сковорода Никита Андреевич (chalkerx@gmail.com)
- greenkeeper[bot] (greenkeeper[bot]@users.noreply.github.com)
- ukstv (sergey.ukustov@machinomy.com)
- ranbochen (ranbochen@qq.com)
- Vladimir Borovik (bobahbdb@gmail.com)
#### Generated by bin/update-authors.sh.

21
node_modules/buffer/LICENSE generated vendored
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Feross Aboukhadijeh, and other contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

409
node_modules/buffer/README.md generated vendored
View File

@ -1,409 +0,0 @@
# buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
[travis-image]: https://img.shields.io/travis/feross/buffer/master.svg
[travis-url]: https://travis-ci.org/feross/buffer
[npm-image]: https://img.shields.io/npm/v/buffer.svg
[npm-url]: https://npmjs.org/package/buffer
[downloads-image]: https://img.shields.io/npm/dm/buffer.svg
[downloads-url]: https://npmjs.org/package/buffer
[standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
[standard-url]: https://standardjs.com
#### The buffer module from [node.js](https://nodejs.org/), for the browser.
[![saucelabs][saucelabs-image]][saucelabs-url]
[saucelabs-image]: https://saucelabs.com/browser-matrix/buffer.svg
[saucelabs-url]: https://saucelabs.com/u/buffer
With [browserify](http://browserify.org), simply `require('buffer')` or use the `Buffer` global and you will get this module.
The goal is to provide an API that is 100% identical to
[node's Buffer API](https://nodejs.org/api/buffer.html). Read the
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
instance methods, and class methods that are supported.
## features
- Manipulate binary data like a boss, in all browsers!
- Super fast. Backed by Typed Arrays (`Uint8Array`/`ArrayBuffer`, not `Object`)
- Extremely small bundle size (**6.75KB minified + gzipped**, 51.9KB with comments)
- Excellent browser support (Chrome, Firefox, Edge, Safari 9+, IE 11, iOS 9+, Android, etc.)
- Preserves Node API exactly, with one minor difference (see below)
- Square-bracket `buf[4]` notation works!
- Does not modify any browser prototypes or put anything on `window`
- Comprehensive test suite (including all buffer tests from node.js core)
## install
To use this module directly (without browserify), install it:
```bash
npm install buffer
```
This module was previously called **native-buffer-browserify**, but please use **buffer**
from now on.
A standalone bundle is available [here](https://wzrd.in/standalone/buffer), for non-browserify users.
## usage
The module's API is identical to node's `Buffer` API. Read the
[official docs](https://nodejs.org/api/buffer.html) for the full list of properties,
instance methods, and class methods that are supported.
As mentioned above, `require('buffer')` or use the `Buffer` global with
[browserify](http://browserify.org) and this module will automatically be included
in your bundle. Almost any npm module will work in the browser, even if it assumes that
the node `Buffer` API will be available.
To depend on this module explicitly (without browserify), require it like this:
```js
var Buffer = require('buffer/').Buffer // note: the trailing slash is important!
```
To require this module explicitly, use `require('buffer/')` which tells the node.js module
lookup algorithm (also used by browserify) to use the **npm module** named `buffer`
instead of the **node.js core** module named `buffer`!
## how does it work?
The Buffer constructor returns instances of `Uint8Array` that have their prototype
changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of `Uint8Array`,
so the returned instances will have all the node `Buffer` methods and the
`Uint8Array` methods. Square bracket notation works as expected -- it returns a
single octet.
The `Uint8Array` prototype remains unmodified.
## tracking the latest node api
This module tracks the Buffer API in the latest (unstable) version of node.js. The Buffer
API is considered **stable** in the
[node stability index](https://nodejs.org/docs/latest/api/documentation.html#documentation_stability_index),
so it is unlikely that there will ever be breaking changes.
Nonetheless, when/if the Buffer API changes in node, this module's API will change
accordingly.
## related packages
- [`buffer-reverse`](https://www.npmjs.com/package/buffer-reverse) - Reverse a buffer
- [`buffer-xor`](https://www.npmjs.com/package/buffer-xor) - Bitwise xor a buffer
- [`is-buffer`](https://www.npmjs.com/package/is-buffer) - Determine if an object is a Buffer without including the whole `Buffer` package
## conversion packages
### convert typed array to buffer
Use [`typedarray-to-buffer`](https://www.npmjs.com/package/typedarray-to-buffer) to convert any kind of typed array to a `Buffer`. Does not perform a copy, so it's super fast.
### convert buffer to typed array
`Buffer` is a subclass of `Uint8Array` (which is a typed array). So there is no need to explicitly convert to typed array. Just use the buffer as a `Uint8Array`.
### convert blob to buffer
Use [`blob-to-buffer`](https://www.npmjs.com/package/blob-to-buffer) to convert a `Blob` to a `Buffer`.
### convert buffer to blob
To convert a `Buffer` to a `Blob`, use the `Blob` constructor:
```js
var blob = new Blob([ buffer ])
```
Optionally, specify a mimetype:
```js
var blob = new Blob([ buffer ], { type: 'text/html' })
```
### convert arraybuffer to buffer
To convert an `ArrayBuffer` to a `Buffer`, use the `Buffer.from` function. Does not perform a copy, so it's super fast.
```js
var buffer = Buffer.from(arrayBuffer)
```
### convert buffer to arraybuffer
To convert a `Buffer` to an `ArrayBuffer`, use the `.buffer` property (which is present on all `Uint8Array` objects):
```js
var arrayBuffer = buffer.buffer.slice(
buffer.byteOffset, buffer.byteOffset + buffer.byteLength
)
```
Alternatively, use the [`to-arraybuffer`](https://www.npmjs.com/package/to-arraybuffer) module.
## performance
See perf tests in `/perf`.
`BrowserBuffer` is the browser `buffer` module (this repo). `Uint8Array` is included as a
sanity check (since `BrowserBuffer` uses `Uint8Array` under the hood, `Uint8Array` will
always be at least a bit faster). Finally, `NodeBuffer` is the node.js buffer module,
which is included to compare against.
NOTE: Performance has improved since these benchmarks were taken. PR welcome to update the README.
### Chrome 38
| Method | Operations | Accuracy | Sampled | Fastest |
|:-------|:-----------|:---------|:--------|:-------:|
| BrowserBuffer#bracket-notation | 11,457,464 ops/sec | ±0.86% | 66 | ✓ |
| Uint8Array#bracket-notation | 10,824,332 ops/sec | ±0.74% | 65 | |
| | | | |
| BrowserBuffer#concat | 450,532 ops/sec | ±0.76% | 68 | |
| Uint8Array#concat | 1,368,911 ops/sec | ±1.50% | 62 | ✓ |
| | | | |
| BrowserBuffer#copy(16000) | 903,001 ops/sec | ±0.96% | 67 | |
| Uint8Array#copy(16000) | 1,422,441 ops/sec | ±1.04% | 66 | ✓ |
| | | | |
| BrowserBuffer#copy(16) | 11,431,358 ops/sec | ±0.46% | 69 | |
| Uint8Array#copy(16) | 13,944,163 ops/sec | ±1.12% | 68 | ✓ |
| | | | |
| BrowserBuffer#new(16000) | 106,329 ops/sec | ±6.70% | 44 | |
| Uint8Array#new(16000) | 131,001 ops/sec | ±2.85% | 31 | ✓ |
| | | | |
| BrowserBuffer#new(16) | 1,554,491 ops/sec | ±1.60% | 65 | |
| Uint8Array#new(16) | 6,623,930 ops/sec | ±1.66% | 65 | ✓ |
| | | | |
| BrowserBuffer#readDoubleBE | 112,830 ops/sec | ±0.51% | 69 | ✓ |
| DataView#getFloat64 | 93,500 ops/sec | ±0.57% | 68 | |
| | | | |
| BrowserBuffer#readFloatBE | 146,678 ops/sec | ±0.95% | 68 | ✓ |
| DataView#getFloat32 | 99,311 ops/sec | ±0.41% | 67 | |
| | | | |
| BrowserBuffer#readUInt32LE | 843,214 ops/sec | ±0.70% | 69 | ✓ |
| DataView#getUint32 | 103,024 ops/sec | ±0.64% | 67 | |
| | | | |
| BrowserBuffer#slice | 1,013,941 ops/sec | ±0.75% | 67 | |
| Uint8Array#subarray | 1,903,928 ops/sec | ±0.53% | 67 | ✓ |
| | | | |
| BrowserBuffer#writeFloatBE | 61,387 ops/sec | ±0.90% | 67 | |
| DataView#setFloat32 | 141,249 ops/sec | ±0.40% | 66 | ✓ |
### Firefox 33
| Method | Operations | Accuracy | Sampled | Fastest |
|:-------|:-----------|:---------|:--------|:-------:|
| BrowserBuffer#bracket-notation | 20,800,421 ops/sec | ±1.84% | 60 | |
| Uint8Array#bracket-notation | 20,826,235 ops/sec | ±2.02% | 61 | ✓ |
| | | | |
| BrowserBuffer#concat | 153,076 ops/sec | ±2.32% | 61 | |
| Uint8Array#concat | 1,255,674 ops/sec | ±8.65% | 52 | ✓ |
| | | | |
| BrowserBuffer#copy(16000) | 1,105,312 ops/sec | ±1.16% | 63 | |
| Uint8Array#copy(16000) | 1,615,911 ops/sec | ±0.55% | 66 | ✓ |
| | | | |
| BrowserBuffer#copy(16) | 16,357,599 ops/sec | ±0.73% | 68 | |
| Uint8Array#copy(16) | 31,436,281 ops/sec | ±1.05% | 68 | ✓ |
| | | | |
| BrowserBuffer#new(16000) | 52,995 ops/sec | ±6.01% | 35 | |
| Uint8Array#new(16000) | 87,686 ops/sec | ±5.68% | 45 | ✓ |
| | | | |
| BrowserBuffer#new(16) | 252,031 ops/sec | ±1.61% | 66 | |
| Uint8Array#new(16) | 8,477,026 ops/sec | ±0.49% | 68 | ✓ |
| | | | |
| BrowserBuffer#readDoubleBE | 99,871 ops/sec | ±0.41% | 69 | |
| DataView#getFloat64 | 285,663 ops/sec | ±0.70% | 68 | ✓ |
| | | | |
| BrowserBuffer#readFloatBE | 115,540 ops/sec | ±0.42% | 69 | |
| DataView#getFloat32 | 288,722 ops/sec | ±0.82% | 68 | ✓ |
| | | | |
| BrowserBuffer#readUInt32LE | 633,926 ops/sec | ±1.08% | 67 | ✓ |
| DataView#getUint32 | 294,808 ops/sec | ±0.79% | 64 | |
| | | | |
| BrowserBuffer#slice | 349,425 ops/sec | ±0.46% | 69 | |
| Uint8Array#subarray | 5,965,819 ops/sec | ±0.60% | 65 | ✓ |
| | | | |
| BrowserBuffer#writeFloatBE | 59,980 ops/sec | ±0.41% | 67 | |
| DataView#setFloat32 | 317,634 ops/sec | ±0.63% | 68 | ✓ |
### Safari 8
| Method | Operations | Accuracy | Sampled | Fastest |
|:-------|:-----------|:---------|:--------|:-------:|
| BrowserBuffer#bracket-notation | 10,279,729 ops/sec | ±2.25% | 56 | ✓ |
| Uint8Array#bracket-notation | 10,030,767 ops/sec | ±2.23% | 59 | |
| | | | |
| BrowserBuffer#concat | 144,138 ops/sec | ±1.38% | 65 | |
| Uint8Array#concat | 4,950,764 ops/sec | ±1.70% | 63 | ✓ |
| | | | |
| BrowserBuffer#copy(16000) | 1,058,548 ops/sec | ±1.51% | 64 | |
| Uint8Array#copy(16000) | 1,409,666 ops/sec | ±1.17% | 65 | ✓ |
| | | | |
| BrowserBuffer#copy(16) | 6,282,529 ops/sec | ±1.88% | 58 | |
| Uint8Array#copy(16) | 11,907,128 ops/sec | ±2.87% | 58 | ✓ |
| | | | |
| BrowserBuffer#new(16000) | 101,663 ops/sec | ±3.89% | 57 | |
| Uint8Array#new(16000) | 22,050,818 ops/sec | ±6.51% | 46 | ✓ |
| | | | |
| BrowserBuffer#new(16) | 176,072 ops/sec | ±2.13% | 64 | |
| Uint8Array#new(16) | 24,385,731 ops/sec | ±5.01% | 51 | ✓ |
| | | | |
| BrowserBuffer#readDoubleBE | 41,341 ops/sec | ±1.06% | 67 | |
| DataView#getFloat64 | 322,280 ops/sec | ±0.84% | 68 | ✓ |
| | | | |
| BrowserBuffer#readFloatBE | 46,141 ops/sec | ±1.06% | 65 | |
| DataView#getFloat32 | 337,025 ops/sec | ±0.43% | 69 | ✓ |
| | | | |
| BrowserBuffer#readUInt32LE | 151,551 ops/sec | ±1.02% | 66 | |
| DataView#getUint32 | 308,278 ops/sec | ±0.94% | 67 | ✓ |
| | | | |
| BrowserBuffer#slice | 197,365 ops/sec | ±0.95% | 66 | |
| Uint8Array#subarray | 9,558,024 ops/sec | ±3.08% | 58 | ✓ |
| | | | |
| BrowserBuffer#writeFloatBE | 17,518 ops/sec | ±1.03% | 63 | |
| DataView#setFloat32 | 319,751 ops/sec | ±0.48% | 68 | ✓ |
### Node 0.11.14
| Method | Operations | Accuracy | Sampled | Fastest |
|:-------|:-----------|:---------|:--------|:-------:|
| BrowserBuffer#bracket-notation | 10,489,828 ops/sec | ±3.25% | 90 | |
| Uint8Array#bracket-notation | 10,534,884 ops/sec | ±0.81% | 92 | ✓ |
| NodeBuffer#bracket-notation | 10,389,910 ops/sec | ±0.97% | 87 | |
| | | | |
| BrowserBuffer#concat | 487,830 ops/sec | ±2.58% | 88 | |
| Uint8Array#concat | 1,814,327 ops/sec | ±1.28% | 88 | ✓ |
| NodeBuffer#concat | 1,636,523 ops/sec | ±1.88% | 73 | |
| | | | |
| BrowserBuffer#copy(16000) | 1,073,665 ops/sec | ±0.77% | 90 | |
| Uint8Array#copy(16000) | 1,348,517 ops/sec | ±0.84% | 89 | ✓ |
| NodeBuffer#copy(16000) | 1,289,533 ops/sec | ±0.82% | 93 | |
| | | | |
| BrowserBuffer#copy(16) | 12,782,706 ops/sec | ±0.74% | 85 | |
| Uint8Array#copy(16) | 14,180,427 ops/sec | ±0.93% | 92 | ✓ |
| NodeBuffer#copy(16) | 11,083,134 ops/sec | ±1.06% | 89 | |
| | | | |
| BrowserBuffer#new(16000) | 141,678 ops/sec | ±3.30% | 67 | |
| Uint8Array#new(16000) | 161,491 ops/sec | ±2.96% | 60 | |
| NodeBuffer#new(16000) | 292,699 ops/sec | ±3.20% | 55 | ✓ |
| | | | |
| BrowserBuffer#new(16) | 1,655,466 ops/sec | ±2.41% | 82 | |
| Uint8Array#new(16) | 14,399,926 ops/sec | ±0.91% | 94 | ✓ |
| NodeBuffer#new(16) | 3,894,696 ops/sec | ±0.88% | 92 | |
| | | | |
| BrowserBuffer#readDoubleBE | 109,582 ops/sec | ±0.75% | 93 | ✓ |
| DataView#getFloat64 | 91,235 ops/sec | ±0.81% | 90 | |
| NodeBuffer#readDoubleBE | 88,593 ops/sec | ±0.96% | 81 | |
| | | | |
| BrowserBuffer#readFloatBE | 139,854 ops/sec | ±1.03% | 85 | ✓ |
| DataView#getFloat32 | 98,744 ops/sec | ±0.80% | 89 | |
| NodeBuffer#readFloatBE | 92,769 ops/sec | ±0.94% | 93 | |
| | | | |
| BrowserBuffer#readUInt32LE | 710,861 ops/sec | ±0.82% | 92 | |
| DataView#getUint32 | 117,893 ops/sec | ±0.84% | 91 | |
| NodeBuffer#readUInt32LE | 851,412 ops/sec | ±0.72% | 93 | ✓ |
| | | | |
| BrowserBuffer#slice | 1,673,877 ops/sec | ±0.73% | 94 | |
| Uint8Array#subarray | 6,919,243 ops/sec | ±0.67% | 90 | ✓ |
| NodeBuffer#slice | 4,617,604 ops/sec | ±0.79% | 93 | |
| | | | |
| BrowserBuffer#writeFloatBE | 66,011 ops/sec | ±0.75% | 93 | |
| DataView#setFloat32 | 127,760 ops/sec | ±0.72% | 93 | ✓ |
| NodeBuffer#writeFloatBE | 103,352 ops/sec | ±0.83% | 93 | |
### iojs 1.8.1
| Method | Operations | Accuracy | Sampled | Fastest |
|:-------|:-----------|:---------|:--------|:-------:|
| BrowserBuffer#bracket-notation | 10,990,488 ops/sec | ±1.11% | 91 | |
| Uint8Array#bracket-notation | 11,268,757 ops/sec | ±0.65% | 97 | |
| NodeBuffer#bracket-notation | 11,353,260 ops/sec | ±0.83% | 94 | ✓ |
| | | | |
| BrowserBuffer#concat | 378,954 ops/sec | ±0.74% | 94 | |
| Uint8Array#concat | 1,358,288 ops/sec | ±0.97% | 87 | |
| NodeBuffer#concat | 1,934,050 ops/sec | ±1.11% | 78 | ✓ |
| | | | |
| BrowserBuffer#copy(16000) | 894,538 ops/sec | ±0.56% | 84 | |
| Uint8Array#copy(16000) | 1,442,656 ops/sec | ±0.71% | 96 | |
| NodeBuffer#copy(16000) | 1,457,898 ops/sec | ±0.53% | 92 | ✓ |
| | | | |
| BrowserBuffer#copy(16) | 12,870,457 ops/sec | ±0.67% | 95 | |
| Uint8Array#copy(16) | 16,643,989 ops/sec | ±0.61% | 93 | ✓ |
| NodeBuffer#copy(16) | 14,885,848 ops/sec | ±0.74% | 94 | |
| | | | |
| BrowserBuffer#new(16000) | 109,264 ops/sec | ±4.21% | 63 | |
| Uint8Array#new(16000) | 138,916 ops/sec | ±1.87% | 61 | |
| NodeBuffer#new(16000) | 281,449 ops/sec | ±3.58% | 51 | ✓ |
| | | | |
| BrowserBuffer#new(16) | 1,362,935 ops/sec | ±0.56% | 99 | |
| Uint8Array#new(16) | 6,193,090 ops/sec | ±0.64% | 95 | ✓ |
| NodeBuffer#new(16) | 4,745,425 ops/sec | ±1.56% | 90 | |
| | | | |
| BrowserBuffer#readDoubleBE | 118,127 ops/sec | ±0.59% | 93 | ✓ |
| DataView#getFloat64 | 107,332 ops/sec | ±0.65% | 91 | |
| NodeBuffer#readDoubleBE | 116,274 ops/sec | ±0.94% | 95 | |
| | | | |
| BrowserBuffer#readFloatBE | 150,326 ops/sec | ±0.58% | 95 | ✓ |
| DataView#getFloat32 | 110,541 ops/sec | ±0.57% | 98 | |
| NodeBuffer#readFloatBE | 121,599 ops/sec | ±0.60% | 87 | |
| | | | |
| BrowserBuffer#readUInt32LE | 814,147 ops/sec | ±0.62% | 93 | |
| DataView#getUint32 | 137,592 ops/sec | ±0.64% | 90 | |
| NodeBuffer#readUInt32LE | 931,650 ops/sec | ±0.71% | 96 | ✓ |
| | | | |
| BrowserBuffer#slice | 878,590 ops/sec | ±0.68% | 93 | |
| Uint8Array#subarray | 2,843,308 ops/sec | ±1.02% | 90 | |
| NodeBuffer#slice | 4,998,316 ops/sec | ±0.68% | 90 | ✓ |
| | | | |
| BrowserBuffer#writeFloatBE | 65,927 ops/sec | ±0.74% | 93 | |
| DataView#setFloat32 | 139,823 ops/sec | ±0.97% | 89 | ✓ |
| NodeBuffer#writeFloatBE | 135,763 ops/sec | ±0.65% | 96 | |
| | | | |
## Testing the project
First, install the project:
npm install
Then, to run tests in Node.js, run:
npm run test-node
To test locally in a browser, you can run:
npm run test-browser-es5-local # For ES5 browsers that don't support ES6
npm run test-browser-es6-local # For ES6 compliant browsers
This will print out a URL that you can then open in a browser to run the tests, using [airtap](https://www.npmjs.com/package/airtap).
To run automated browser tests using Saucelabs, ensure that your `SAUCE_USERNAME` and `SAUCE_ACCESS_KEY` environment variables are set, then run:
npm test
This is what's run in Travis, to check against various browsers. The list of browsers is kept in the `bin/airtap-es5.yml` and `bin/airtap-es6.yml` files.
## JavaScript Standard Style
This module uses [JavaScript Standard Style](https://github.com/feross/standard).
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
To test that the code conforms to the style, `npm install` and run:
./node_modules/.bin/standard
## credit
This was originally forked from [buffer-browserify](https://github.com/toots/buffer-browserify).
## license
MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org), and other contributors. Originally forked from an MIT-licensed module by Romain Beauxis.

185
node_modules/buffer/index.d.ts generated vendored
View File

@ -1,185 +0,0 @@
export class Buffer extends Uint8Array {
length: number
write(string: string, offset?: number, length?: number, encoding?: string): number;
toString(encoding?: string, start?: number, end?: number): string;
toJSON(): { type: 'Buffer', data: any[] };
equals(otherBuffer: Buffer): boolean;
compare(otherBuffer: Buffer, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
slice(start?: number, end?: number): Buffer;
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
readUInt8(offset: number, noAssert?: boolean): number;
readUInt16LE(offset: number, noAssert?: boolean): number;
readUInt16BE(offset: number, noAssert?: boolean): number;
readUInt32LE(offset: number, noAssert?: boolean): number;
readUInt32BE(offset: number, noAssert?: boolean): number;
readInt8(offset: number, noAssert?: boolean): number;
readInt16LE(offset: number, noAssert?: boolean): number;
readInt16BE(offset: number, noAssert?: boolean): number;
readInt32LE(offset: number, noAssert?: boolean): number;
readInt32BE(offset: number, noAssert?: boolean): number;
readFloatLE(offset: number, noAssert?: boolean): number;
readFloatBE(offset: number, noAssert?: boolean): number;
readDoubleLE(offset: number, noAssert?: boolean): number;
readDoubleBE(offset: number, noAssert?: boolean): number;
swap16(): Buffer;
swap32(): Buffer;
swap64(): Buffer;
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeInt8(value: number, offset: number, noAssert?: boolean): number;
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
fill(value: any, offset?: number, end?: number): this;
indexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
lastIndexOf(value: string | number | Buffer, byteOffset?: number, encoding?: string): number;
includes(value: string | number | Buffer, byteOffset?: number, encoding?: string): boolean;
/**
* Allocates a new buffer containing the given {str}.
*
* @param str String to store in buffer.
* @param encoding encoding to use, optional. Default is 'utf8'
*/
constructor (str: string, encoding?: string);
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
*/
constructor (size: number);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: Uint8Array);
/**
* Produces a Buffer backed by the same allocated memory as
* the given {ArrayBuffer}.
*
*
* @param arrayBuffer The ArrayBuffer with which to share memory.
*/
constructor (arrayBuffer: ArrayBuffer);
/**
* Allocates a new buffer containing the given {array} of octets.
*
* @param array The octets to store.
*/
constructor (array: any[]);
/**
* Copies the passed {buffer} data onto a new {Buffer} instance.
*
* @param buffer The buffer to copy.
*/
constructor (buffer: Buffer);
prototype: Buffer;
/**
* Allocates a new Buffer using an {array} of octets.
*
* @param array
*/
static from(array: any[]): Buffer;
/**
* When passed a reference to the .buffer property of a TypedArray instance,
* the newly created Buffer will share the same allocated memory as the TypedArray.
* The optional {byteOffset} and {length} arguments specify a memory range
* within the {arrayBuffer} that will be shared by the Buffer.
*
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
* @param byteOffset
* @param length
*/
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
/**
* Copies the passed {buffer} data onto a new Buffer instance.
*
* @param buffer
*/
static from(buffer: Buffer): Buffer;
/**
* Creates a new Buffer containing the given JavaScript string {str}.
* If provided, the {encoding} parameter identifies the character encoding.
* If not provided, {encoding} defaults to 'utf8'.
*
* @param str
*/
static from(str: string, encoding?: string): Buffer;
/**
* Returns true if {obj} is a Buffer
*
* @param obj object to test.
*/
static isBuffer(obj: any): obj is Buffer;
/**
* Returns true if {encoding} is a valid encoding argument.
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
*
* @param encoding string to test.
*/
static isEncoding(encoding: string): boolean;
/**
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
* This is not the same as String.prototype.length since that returns the number of characters in a string.
*
* @param string string to test.
* @param encoding encoding used to evaluate (defaults to 'utf8')
*/
static byteLength(string: string, encoding?: string): number;
/**
* Returns a buffer which is the result of concatenating all the buffers in the list together.
*
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
* If the list has exactly one item, then the first item of the list is returned.
* If the list has more than one item, then a new Buffer is created.
*
* @param list An array of Buffer objects to concatenate
* @param totalLength Total length of the buffers when concatenated.
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
*/
static concat(list: Buffer[], totalLength?: number): Buffer;
/**
* The same as buf1.compare(buf2).
*/
static compare(buf1: Buffer, buf2: Buffer): number;
/**
* Allocates a new buffer of {size} octets.
*
* @param size count of octets to allocate.
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
* If parameter is omitted, buffer will be filled with zeros.
* @param encoding encoding used for call to buf.fill while initalizing
*/
static alloc(size: number, fill?: string | Buffer | number, encoding?: string): Buffer;
/**
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafe(size: number): Buffer;
/**
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
* of the newly created Buffer are unknown and may contain sensitive data.
*
* @param size count of octets to allocate
*/
static allocUnsafeSlow(size: number): Buffer;
}

1777
node_modules/buffer/index.js generated vendored

File diff suppressed because it is too large Load Diff

110
node_modules/buffer/package.json generated vendored
View File

@ -1,110 +0,0 @@
{
"_from": "buffer@^5.2.1",
"_id": "buffer@5.2.1",
"_inBundle": false,
"_integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
"_location": "/buffer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "buffer@^5.2.1",
"name": "buffer",
"escapedName": "buffer",
"rawSpec": "^5.2.1",
"saveSpec": null,
"fetchSpec": "^5.2.1"
},
"_requiredBy": [
"/unbzip2-stream"
],
"_resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
"_shasum": "dd57fa0f109ac59c602479044dca7b8b3d0b71d6",
"_spec": "buffer@^5.2.1",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\unbzip2-stream",
"author": {
"name": "Feross Aboukhadijeh",
"email": "feross@feross.org",
"url": "http://feross.org"
},
"bugs": {
"url": "https://github.com/feross/buffer/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Romain Beauxis",
"email": "toots@rastageeks.org"
},
{
"name": "James Halliday",
"email": "mail@substack.net"
}
],
"dependencies": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
},
"deprecated": false,
"description": "Node.js Buffer API, for the browser",
"devDependencies": {
"airtap": "0.1.0",
"benchmark": "^2.0.0",
"browserify": "^16.1.0",
"concat-stream": "^1.4.7",
"hyperquest": "^2.0.0",
"is-buffer": "^2.0.0",
"is-nan": "^1.0.1",
"split": "^1.0.0",
"standard": "*",
"tape": "^4.0.0",
"through2": "^2.0.0",
"uglify-js": "^3.4.5"
},
"homepage": "https://github.com/feross/buffer",
"jspm": {
"map": {
"./index.js": {
"node": "@node/buffer"
}
}
},
"keywords": [
"arraybuffer",
"browser",
"browserify",
"buffer",
"compatible",
"dataview",
"uint8array"
],
"license": "MIT",
"main": "index.js",
"name": "buffer",
"repository": {
"type": "git",
"url": "git://github.com/feross/buffer.git"
},
"scripts": {
"perf": "browserify --debug perf/bracket-notation.js > perf/bundle.js && open perf/index.html",
"perf-node": "node perf/bracket-notation.js && node perf/concat.js && node perf/copy-big.js && node perf/copy.js && node perf/new-big.js && node perf/new.js && node perf/readDoubleBE.js && node perf/readFloatBE.js && node perf/readUInt32LE.js && node perf/slice.js && node perf/writeFloatBE.js",
"size": "browserify -r ./ | uglifyjs -c -m | gzip | wc -c",
"test": "standard && node ./bin/test.js",
"test-browser-es5": "airtap -- test/*.js",
"test-browser-es5-local": "airtap --local -- test/*.js",
"test-browser-es6": "airtap -- test/*.js test/node/*.js",
"test-browser-es6-local": "airtap --local -- test/*.js test/node/*.js",
"test-node": "tape test/*.js test/node/*.js",
"update-authors": "./bin/update-authors.sh"
},
"standard": {
"ignore": [
"test/node/**/*.js",
"test/common.js",
"test/_polyfill.js",
"perf/**/*.js"
]
},
"types": "index.d.ts",
"version": "5.2.1"
}

256
node_modules/commander/History.md generated vendored
View File

@ -1,256 +0,0 @@
2.8.1 / 2015-04-22
==================
* Back out `support multiline description` Close #396 #397
2.8.0 / 2015-04-07
==================
* Add `process.execArg` support, execution args like `--harmony` will be passed to sub-commands #387 @DigitalIO @zhiyelee
* Fix bug in Git-style sub-commands #372 @zhiyelee
* Allow commands to be hidden from help #383 @tonylukasavage
* When git-style sub-commands are in use, yet none are called, display help #382 @claylo
* Add ability to specify arguments syntax for top-level command #258 @rrthomas
* Support multiline descriptions #208 @zxqfox
2.7.1 / 2015-03-11
==================
* Revert #347 (fix collisions when option and first arg have same name) which causes a bug in #367.
2.7.0 / 2015-03-09
==================
* Fix git-style bug when installed globally. Close #335 #349 @zhiyelee
* Fix collisions when option and first arg have same name. Close #346 #347 @tonylukasavage
* Add support for camelCase on `opts()`. Close #353 @nkzawa
* Add node.js 0.12 and io.js to travis.yml
* Allow RegEx options. #337 @palanik
* Fixes exit code when sub-command failing. Close #260 #332 @pirelenito
* git-style `bin` files in $PATH make sense. Close #196 #327 @zhiyelee
2.6.0 / 2014-12-30
==================
* added `Command#allowUnknownOption` method. Close #138 #318 @doozr @zhiyelee
* Add application description to the help msg. Close #112 @dalssoft
2.5.1 / 2014-12-15
==================
* fixed two bugs incurred by variadic arguments. Close #291 @Quentin01 #302 @zhiyelee
2.5.0 / 2014-10-24
==================
* add support for variadic arguments. Closes #277 @whitlockjc
2.4.0 / 2014-10-17
==================
* fixed a bug on executing the coercion function of subcommands option. Closes #270
* added `Command.prototype.name` to retrieve command name. Closes #264 #266 @tonylukasavage
* added `Command.prototype.opts` to retrieve all the options as a simple object of key-value pairs. Closes #262 @tonylukasavage
* fixed a bug on subcommand name. Closes #248 @jonathandelgado
* fixed function normalize doesnt honor option terminator. Closes #216 @abbr
2.3.0 / 2014-07-16
==================
* add command alias'. Closes PR #210
* fix: Typos. Closes #99
* fix: Unused fs module. Closes #217
2.2.0 / 2014-03-29
==================
* add passing of previous option value
* fix: support subcommands on windows. Closes #142
* Now the defaultValue passed as the second argument of the coercion function.
2.1.0 / 2013-11-21
==================
* add: allow cflag style option params, unit test, fixes #174
2.0.0 / 2013-07-18
==================
* remove input methods (.prompt, .confirm, etc)
1.3.2 / 2013-07-18
==================
* add support for sub-commands to co-exist with the original command
1.3.1 / 2013-07-18
==================
* add quick .runningCommand hack so you can opt-out of other logic when running a sub command
1.3.0 / 2013-07-09
==================
* add EACCES error handling
* fix sub-command --help
1.2.0 / 2013-06-13
==================
* allow "-" hyphen as an option argument
* support for RegExp coercion
1.1.1 / 2012-11-20
==================
* add more sub-command padding
* fix .usage() when args are present. Closes #106
1.1.0 / 2012-11-16
==================
* add git-style executable subcommand support. Closes #94
1.0.5 / 2012-10-09
==================
* fix `--name` clobbering. Closes #92
* fix examples/help. Closes #89
1.0.4 / 2012-09-03
==================
* add `outputHelp()` method.
1.0.3 / 2012-08-30
==================
* remove invalid .version() defaulting
1.0.2 / 2012-08-24
==================
* add `--foo=bar` support [arv]
* fix password on node 0.8.8. Make backward compatible with 0.6 [focusaurus]
1.0.1 / 2012-08-03
==================
* fix issue #56
* fix tty.setRawMode(mode) was moved to tty.ReadStream#setRawMode() (i.e. process.stdin.setRawMode())
1.0.0 / 2012-07-05
==================
* add support for optional option descriptions
* add defaulting of `.version()` to package.json's version
0.6.1 / 2012-06-01
==================
* Added: append (yes or no) on confirmation
* Added: allow node.js v0.7.x
0.6.0 / 2012-04-10
==================
* Added `.prompt(obj, callback)` support. Closes #49
* Added default support to .choose(). Closes #41
* Fixed the choice example
0.5.1 / 2011-12-20
==================
* Fixed `password()` for recent nodes. Closes #36
0.5.0 / 2011-12-04
==================
* Added sub-command option support [itay]
0.4.3 / 2011-12-04
==================
* Fixed custom help ordering. Closes #32
0.4.2 / 2011-11-24
==================
* Added travis support
* Fixed: line-buffered input automatically trimmed. Closes #31
0.4.1 / 2011-11-18
==================
* Removed listening for "close" on --help
0.4.0 / 2011-11-15
==================
* Added support for `--`. Closes #24
0.3.3 / 2011-11-14
==================
* Fixed: wait for close event when writing help info [Jerry Hamlet]
0.3.2 / 2011-11-01
==================
* Fixed long flag definitions with values [felixge]
0.3.1 / 2011-10-31
==================
* Changed `--version` short flag to `-V` from `-v`
* Changed `.version()` so it's configurable [felixge]
0.3.0 / 2011-10-31
==================
* Added support for long flags only. Closes #18
0.2.1 / 2011-10-24
==================
* "node": ">= 0.4.x < 0.7.0". Closes #20
0.2.0 / 2011-09-26
==================
* Allow for defaults that are not just boolean. Default peassignment only occurs for --no-*, optional, and required arguments. [Jim Isaacs]
0.1.0 / 2011-08-24
==================
* Added support for custom `--help` output
0.0.5 / 2011-08-18
==================
* Changed: when the user enters nothing prompt for password again
* Fixed issue with passwords beginning with numbers [NuckChorris]
0.0.4 / 2011-08-15
==================
* Fixed `Commander#args`
0.0.3 / 2011-08-15
==================
* Added default option value support
0.0.2 / 2011-08-15
==================
* Added mask support to `Command#password(str[, mask], fn)`
* Added `Command#password(str, fn)`
0.0.1 / 2010-01-03
==================
* Initial release

22
node_modules/commander/LICENSE generated vendored
View File

@ -1,22 +0,0 @@
(The MIT License)
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

342
node_modules/commander/Readme.md generated vendored
View File

@ -1,342 +0,0 @@
# Commander.js
[![Build Status](https://api.travis-ci.org/tj/commander.js.svg)](http://travis-ci.org/tj/commander.js)
[![NPM Version](http://img.shields.io/npm/v/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
[![NPM Downloads](https://img.shields.io/npm/dm/commander.svg?style=flat)](https://www.npmjs.org/package/commander)
[![Join the chat at https://gitter.im/tj/commander.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/tj/commander.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
The complete solution for [node.js](http://nodejs.org) command-line interfaces, inspired by Ruby's [commander](https://github.com/tj/commander).
[API documentation](http://tj.github.com/commander.js/)
## Installation
$ npm install commander
## Option parsing
Options with commander are defined with the `.option()` method, also serving as documentation for the options. The example below parses args and options from `process.argv`, leaving remaining args as the `program.args` array which were not consumed by options.
```js
#!/usr/bin/env node
/**
* Module dependencies.
*/
var program = require('commander');
program
.version('0.0.1')
.option('-p, --peppers', 'Add peppers')
.option('-P, --pineapple', 'Add pineapple')
.option('-b, --bbq-sauce', 'Add bbq sauce')
.option('-c, --cheese [type]', 'Add the specified type of cheese [marble]', 'marble')
.parse(process.argv);
console.log('you ordered a pizza with:');
if (program.peppers) console.log(' - peppers');
if (program.pineapple) console.log(' - pineapple');
if (program.bbqSauce) console.log(' - bbq');
console.log(' - %s cheese', program.cheese);
```
Short flags may be passed as a single arg, for example `-abc` is equivalent to `-a -b -c`. Multi-word options such as "--template-engine" are camel-cased, becoming `program.templateEngine` etc.
## Coercion
```js
function range(val) {
return val.split('..').map(Number);
}
function list(val) {
return val.split(',');
}
function collect(val, memo) {
memo.push(val);
return memo;
}
function increaseVerbosity(v, total) {
return total + 1;
}
program
.version('0.0.1')
.usage('[options] <file ...>')
.option('-i, --integer <n>', 'An integer argument', parseInt)
.option('-f, --float <n>', 'A float argument', parseFloat)
.option('-r, --range <a>..<b>', 'A range', range)
.option('-l, --list <items>', 'A list', list)
.option('-o, --optional [value]', 'An optional value')
.option('-c, --collect [value]', 'A repeatable value', collect, [])
.option('-v, --verbose', 'A value that can be increased', increaseVerbosity, 0)
.parse(process.argv);
console.log(' int: %j', program.integer);
console.log(' float: %j', program.float);
console.log(' optional: %j', program.optional);
program.range = program.range || [];
console.log(' range: %j..%j', program.range[0], program.range[1]);
console.log(' list: %j', program.list);
console.log(' collect: %j', program.collect);
console.log(' verbosity: %j', program.verbose);
console.log(' args: %j', program.args);
```
## Regular Expression
```js
program
.version('0.0.1')
.option('-s --size <size>', 'Pizza size', /^(large|medium|small)$/i, 'medium')
.option('-d --drink [drink]', 'Drink', /^(coke|pepsi|izze)$/i)
.parse(process.argv);
console.log(' size: %j', program.size);
console.log(' drink: %j', program.drink);
```
## Variadic arguments
The last argument of a command can be variadic, and only the last argument. To make an argument variadic you have to
append `...` to the argument name. Here is an example:
```js
#!/usr/bin/env node
/**
* Module dependencies.
*/
var program = require('commander');
program
.version('0.0.1')
.command('rmdir <dir> [otherDirs...]')
.action(function (dir, otherDirs) {
console.log('rmdir %s', dir);
if (otherDirs) {
otherDirs.forEach(function (oDir) {
console.log('rmdir %s', oDir);
});
}
});
program.parse(process.argv);
```
An `Array` is used for the value of a variadic argument. This applies to `program.args` as well as the argument passed
to your action as demonstrated above.
## Specify the argument syntax
```js
#!/usr/bin/env node
var program = require('../');
program
.version('0.0.1')
.arguments('<cmd> [env]')
.action(function (cmd, env) {
cmdValue = cmd;
envValue = env;
});
program.parse(process.argv);
if (typeof cmdValue === 'undefined') {
console.error('no command given!');
process.exit(1);
}
console.log('command:', cmdValue);
console.log('environment:', envValue || "no environment given");
```
## Git-style sub-commands
```js
// file: ./examples/pm
var program = require('..');
program
.version('0.0.1')
.command('install [name]', 'install one or more packages')
.command('search [query]', 'search with optional query')
.command('list', 'list packages installed')
.parse(process.argv);
```
When `.command()` is invoked with a description argument, no `.action(callback)` should be called to handle sub-commands, otherwise there will be an error. This tells commander that you're going to use separate executables for sub-commands, much like `git(1)` and other popular tools.
The commander will try to search the executables in the directory of the entry script (like `./examples/pm`) with the name `program-command`, like `pm-install`, `pm-search`.
If the program is designed to be installed globally, make sure the executables have proper modes, like `755`.
### `--harmony`
You can enable `--harmony` option in two ways:
* Use `#! /usr/bin/env node --harmony` in the sub-commands scripts. Note some os version dont support this pattern.
* Use the `--harmony` option when call the command, like `node --harmony examples/pm publish`. The `--harmony` option will be preserved when spawning sub-command process.
## Automated --help
The help information is auto-generated based on the information commander already knows about your program, so the following `--help` info is for free:
```
$ ./examples/pizza --help
Usage: pizza [options]
An application for pizzas ordering
Options:
-h, --help output usage information
-V, --version output the version number
-p, --peppers Add peppers
-P, --pineapple Add pineapple
-b, --bbq Add bbq sauce
-c, --cheese <type> Add the specified type of cheese [marble]
-C, --no-cheese You do not want any cheese
```
## Custom help
You can display arbitrary `-h, --help` information
by listening for "--help". Commander will automatically
exit once you are done so that the remainder of your program
does not execute causing undesired behaviours, for example
in the following executable "stuff" will not output when
`--help` is used.
```js
#!/usr/bin/env node
/**
* Module dependencies.
*/
var program = require('commander');
program
.version('0.0.1')
.option('-f, --foo', 'enable some foo')
.option('-b, --bar', 'enable some bar')
.option('-B, --baz', 'enable some baz');
// must be before .parse() since
// node's emit() is immediate
program.on('--help', function(){
console.log(' Examples:');
console.log('');
console.log(' $ custom-help --help');
console.log(' $ custom-help -h');
console.log('');
});
program.parse(process.argv);
console.log('stuff');
```
Yields the following help output when `node script-name.js -h` or `node script-name.js --help` are run:
```
Usage: custom-help [options]
Options:
-h, --help output usage information
-V, --version output the version number
-f, --foo enable some foo
-b, --bar enable some bar
-B, --baz enable some baz
Examples:
$ custom-help --help
$ custom-help -h
```
## .outputHelp()
Output help information without exiting.
If you want to display help by default (e.g. if no command was provided), you can use something like:
```js
var program = require('commander');
program
.version('0.0.1')
.command('getstream [url]', 'get stream URL')
.parse(process.argv);
if (!process.argv.slice(2).length) {
program.outputHelp();
}
```
## .help()
Output help information and exit immediately.
## Examples
```js
var program = require('commander');
program
.version('0.0.1')
.option('-C, --chdir <path>', 'change the working directory')
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf')
.option('-T, --no-tests', 'ignore test hook')
program
.command('setup [env]')
.description('run setup commands for all envs')
.option("-s, --setup_mode [mode]", "Which setup mode to use")
.action(function(env, options){
var mode = options.setup_mode || "normal";
env = env || 'all';
console.log('setup for %s env(s) with %s mode', env, mode);
});
program
.command('exec <cmd>')
.alias('ex')
.description('execute the given remote cmd')
.option("-e, --exec_mode <mode>", "Which exec mode to use")
.action(function(cmd, options){
console.log('exec "%s" using %s mode', cmd, options.exec_mode);
}).on('--help', function() {
console.log(' Examples:');
console.log();
console.log(' $ deploy exec sequential');
console.log(' $ deploy exec async');
console.log();
});
program
.command('*')
.action(function(env){
console.log('deploying "%s"', env);
});
program.parse(process.argv);
```
More Demos can be found in the [examples](https://github.com/tj/commander.js/tree/master/examples) directory.
## License
MIT

1103
node_modules/commander/index.js generated vendored

File diff suppressed because it is too large Load Diff

65
node_modules/commander/package.json generated vendored
View File

@ -1,65 +0,0 @@
{
"_from": "commander@~2.8.1",
"_id": "commander@2.8.1",
"_inBundle": false,
"_integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=",
"_location": "/commander",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "commander@~2.8.1",
"name": "commander",
"escapedName": "commander",
"rawSpec": "~2.8.1",
"saveSpec": null,
"fetchSpec": "~2.8.1"
},
"_requiredBy": [
"/seek-bzip"
],
"_resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz",
"_shasum": "06be367febfda0c330aa1e2a072d3dc9762425d4",
"_spec": "commander@~2.8.1",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\seek-bzip",
"author": {
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
},
"bugs": {
"url": "https://github.com/tj/commander.js/issues"
},
"bundleDependencies": false,
"dependencies": {
"graceful-readlink": ">= 1.0.0"
},
"deprecated": false,
"description": "the complete solution for node.js command-line programs",
"devDependencies": {
"should": ">= 0.0.1",
"sinon": ">= 1.14.1"
},
"engines": {
"node": ">= 0.6.x"
},
"files": [
"index.js"
],
"homepage": "https://github.com/tj/commander.js#readme",
"keywords": [
"command",
"option",
"parser"
],
"license": "MIT",
"main": "index",
"name": "commander",
"repository": {
"type": "git",
"url": "git+https://github.com/tj/commander.js.git"
},
"scripts": {
"test": "make test"
},
"version": "2.8.1"
}

59
node_modules/decompress-tar/index.js generated vendored
View File

@ -1,59 +0,0 @@
'use strict';
const fileType = require('file-type');
const isStream = require('is-stream');
const tarStream = require('tar-stream');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'tar')) {
return Promise.resolve([]);
}
const extract = tarStream.extract();
const files = [];
extract.on('entry', (header, stream, cb) => {
const chunk = [];
stream.on('data', data => chunk.push(data));
stream.on('end', () => {
const file = {
data: Buffer.concat(chunk),
mode: header.mode,
mtime: header.mtime,
path: header.name,
type: header.type
};
if (header.type === 'symlink' || header.type === 'link') {
file.linkname = header.linkname;
}
files.push(file);
cb();
});
});
const promise = new Promise((resolve, reject) => {
if (!Buffer.isBuffer(input)) {
input.on('error', reject);
}
extract.on('finish', () => resolve(files));
extract.on('error', reject);
});
extract.then = promise.then.bind(promise);
extract.catch = promise.catch.bind(promise);
if (Buffer.isBuffer(input)) {
extract.end(input);
} else {
input.pipe(extract);
}
return extract;
};

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,73 +0,0 @@
{
"_from": "decompress-tar@^4.0.0",
"_id": "decompress-tar@4.1.1",
"_inBundle": false,
"_integrity": "sha512-JdJMaCrGpB5fESVyxwpCx4Jdj2AagLmv3y58Qy4GE6HMVjWz1FeVQk1Ct4Kye7PftcdOo/7U7UKzYBJgqnGeUQ==",
"_location": "/decompress-tar",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress-tar@^4.0.0",
"name": "decompress-tar",
"escapedName": "decompress-tar",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/decompress",
"/decompress-tarbz2",
"/decompress-targz",
"/decompress-tarxz"
],
"_resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz",
"_shasum": "718cbd3fcb16209716e70a26b84e7ba4592e5af1",
"_spec": "decompress-tar@^4.0.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress-tar/issues"
},
"bundleDependencies": false,
"dependencies": {
"file-type": "^5.2.0",
"is-stream": "^1.1.0",
"tar-stream": "^1.5.2"
},
"deprecated": false,
"description": "decompress tar plugin",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"pify": "^3.0.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress-tar#readme",
"keywords": [
"decompress",
"decompressplugin",
"extract",
"tar"
],
"license": "MIT",
"name": "decompress-tar",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress-tar.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.1.1"
}

View File

@ -1,44 +0,0 @@
# decompress-tar [![Build Status](https://travis-ci.org/kevva/decompress-tar.svg?branch=master)](https://travis-ci.org/kevva/decompress-tar)
> tar decompress plugin
## Install
```
$ npm install decompress-tar
```
## Usage
```js
const decompress = require('decompress');
const decompressTar = require('decompress-tar');
decompress('unicorn.tar', 'dist', {
plugins: [
decompressTar()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressTar()(input)
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### input
Type: `Buffer` `Stream`
Buffer or stream to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

View File

@ -1,22 +0,0 @@
'use strict';
const decompressTar = require('decompress-tar');
const fileType = require('file-type');
const isStream = require('is-stream');
const seekBzip = require('seek-bzip');
const unbzip2Stream = require('unbzip2-stream');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'bz2')) {
return Promise.resolve([]);
}
if (Buffer.isBuffer(input)) {
return decompressTar()(seekBzip.decode(input));
}
return decompressTar()(input.pipe(unbzip2Stream()));
};

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,599 +0,0 @@
'use strict';
const toBytes = s => Array.from(s).map(c => c.charCodeAt(0));
const xpiZipFilename = toBytes('META-INF/mozilla.rsa');
const oxmlContentTypes = toBytes('[Content_Types].xml');
const oxmlRels = toBytes('_rels/.rels');
module.exports = input => {
const buf = new Uint8Array(input);
if (!(buf && buf.length > 1)) {
return null;
}
const check = (header, opts) => {
opts = Object.assign({
offset: 0
}, opts);
for (let i = 0; i < header.length; i++) {
// If a bitmask is set
if (opts.mask) {
// If header doesn't equal `buf` with bits masked off
if (header[i] !== (opts.mask[i] & buf[i + opts.offset])) {
return false;
}
} else if (header[i] !== buf[i + opts.offset]) {
return false;
}
}
return true;
};
if (check([0xFF, 0xD8, 0xFF])) {
return {
ext: 'jpg',
mime: 'image/jpeg'
};
}
if (check([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A])) {
return {
ext: 'png',
mime: 'image/png'
};
}
if (check([0x47, 0x49, 0x46])) {
return {
ext: 'gif',
mime: 'image/gif'
};
}
if (check([0x57, 0x45, 0x42, 0x50], {offset: 8})) {
return {
ext: 'webp',
mime: 'image/webp'
};
}
if (check([0x46, 0x4C, 0x49, 0x46])) {
return {
ext: 'flif',
mime: 'image/flif'
};
}
// Needs to be before `tif` check
if (
(check([0x49, 0x49, 0x2A, 0x0]) || check([0x4D, 0x4D, 0x0, 0x2A])) &&
check([0x43, 0x52], {offset: 8})
) {
return {
ext: 'cr2',
mime: 'image/x-canon-cr2'
};
}
if (
check([0x49, 0x49, 0x2A, 0x0]) ||
check([0x4D, 0x4D, 0x0, 0x2A])
) {
return {
ext: 'tif',
mime: 'image/tiff'
};
}
if (check([0x42, 0x4D])) {
return {
ext: 'bmp',
mime: 'image/bmp'
};
}
if (check([0x49, 0x49, 0xBC])) {
return {
ext: 'jxr',
mime: 'image/vnd.ms-photo'
};
}
if (check([0x38, 0x42, 0x50, 0x53])) {
return {
ext: 'psd',
mime: 'image/vnd.adobe.photoshop'
};
}
// Zip-based file formats
// Need to be before the `zip` check
if (check([0x50, 0x4B, 0x3, 0x4])) {
if (
check([0x6D, 0x69, 0x6D, 0x65, 0x74, 0x79, 0x70, 0x65, 0x61, 0x70, 0x70, 0x6C, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x2F, 0x65, 0x70, 0x75, 0x62, 0x2B, 0x7A, 0x69, 0x70], {offset: 30})
) {
return {
ext: 'epub',
mime: 'application/epub+zip'
};
}
// Assumes signed `.xpi` from addons.mozilla.org
if (check(xpiZipFilename, {offset: 30})) {
return {
ext: 'xpi',
mime: 'application/x-xpinstall'
};
}
// https://github.com/file/file/blob/master/magic/Magdir/msooxml
if (check(oxmlContentTypes, {offset: 30}) || check(oxmlRels, {offset: 30})) {
const sliced = buf.subarray(4, 4 + 2000);
const nextZipHeaderIndex = arr => arr.findIndex((el, i, arr) => arr[i] === 0x50 && arr[i + 1] === 0x4B && arr[i + 2] === 0x3 && arr[i + 3] === 0x4);
const header2Pos = nextZipHeaderIndex(sliced);
if (header2Pos !== -1) {
const slicedAgain = buf.subarray(header2Pos + 8, header2Pos + 8 + 1000);
const header3Pos = nextZipHeaderIndex(slicedAgain);
if (header3Pos !== -1) {
const offset = 8 + header2Pos + header3Pos + 30;
if (check(toBytes('word/'), {offset})) {
return {
ext: 'docx',
mime: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
};
}
if (check(toBytes('ppt/'), {offset})) {
return {
ext: 'pptx',
mime: 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
};
}
if (check(toBytes('xl/'), {offset})) {
return {
ext: 'xlsx',
mime: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
};
}
}
}
}
}
if (
check([0x50, 0x4B]) &&
(buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) &&
(buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)
) {
return {
ext: 'zip',
mime: 'application/zip'
};
}
if (check([0x75, 0x73, 0x74, 0x61, 0x72], {offset: 257})) {
return {
ext: 'tar',
mime: 'application/x-tar'
};
}
if (
check([0x52, 0x61, 0x72, 0x21, 0x1A, 0x7]) &&
(buf[6] === 0x0 || buf[6] === 0x1)
) {
return {
ext: 'rar',
mime: 'application/x-rar-compressed'
};
}
if (check([0x1F, 0x8B, 0x8])) {
return {
ext: 'gz',
mime: 'application/gzip'
};
}
if (check([0x42, 0x5A, 0x68])) {
return {
ext: 'bz2',
mime: 'application/x-bzip2'
};
}
if (check([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C])) {
return {
ext: '7z',
mime: 'application/x-7z-compressed'
};
}
if (check([0x78, 0x01])) {
return {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
};
}
if (check([0x33, 0x67, 0x70, 0x35]) || // 3gp5
(
check([0x0, 0x0, 0x0]) && check([0x66, 0x74, 0x79, 0x70], {offset: 4}) &&
(
check([0x6D, 0x70, 0x34, 0x31], {offset: 8}) || // MP41
check([0x6D, 0x70, 0x34, 0x32], {offset: 8}) || // MP42
check([0x69, 0x73, 0x6F, 0x6D], {offset: 8}) || // ISOM
check([0x69, 0x73, 0x6F, 0x32], {offset: 8}) || // ISO2
check([0x6D, 0x6D, 0x70, 0x34], {offset: 8}) || // MMP4
check([0x4D, 0x34, 0x56], {offset: 8}) || // M4V
check([0x64, 0x61, 0x73, 0x68], {offset: 8}) // DASH
)
)) {
return {
ext: 'mp4',
mime: 'video/mp4'
};
}
if (check([0x4D, 0x54, 0x68, 0x64])) {
return {
ext: 'mid',
mime: 'audio/midi'
};
}
// https://github.com/threatstack/libmagic/blob/master/magic/Magdir/matroska
if (check([0x1A, 0x45, 0xDF, 0xA3])) {
const sliced = buf.subarray(4, 4 + 4096);
const idPos = sliced.findIndex((el, i, arr) => arr[i] === 0x42 && arr[i + 1] === 0x82);
if (idPos !== -1) {
const docTypePos = idPos + 3;
const findDocType = type => Array.from(type).every((c, i) => sliced[docTypePos + i] === c.charCodeAt(0));
if (findDocType('matroska')) {
return {
ext: 'mkv',
mime: 'video/x-matroska'
};
}
if (findDocType('webm')) {
return {
ext: 'webm',
mime: 'video/webm'
};
}
}
}
if (check([0x0, 0x0, 0x0, 0x14, 0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20]) ||
check([0x66, 0x72, 0x65, 0x65], {offset: 4}) ||
check([0x66, 0x74, 0x79, 0x70, 0x71, 0x74, 0x20, 0x20], {offset: 4}) ||
check([0x6D, 0x64, 0x61, 0x74], {offset: 4}) || // MJPEG
check([0x77, 0x69, 0x64, 0x65], {offset: 4})) {
return {
ext: 'mov',
mime: 'video/quicktime'
};
}
if (
check([0x52, 0x49, 0x46, 0x46]) &&
check([0x41, 0x56, 0x49], {offset: 8})
) {
return {
ext: 'avi',
mime: 'video/x-msvideo'
};
}
if (check([0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9])) {
return {
ext: 'wmv',
mime: 'video/x-ms-wmv'
};
}
if (check([0x0, 0x0, 0x1, 0xBA])) {
return {
ext: 'mpg',
mime: 'video/mpeg'
};
}
// Check for MP3 header at different starting offsets
for (let start = 0; start < 2 && start < (buf.length - 16); start++) {
if (
check([0x49, 0x44, 0x33], {offset: start}) || // ID3 header
check([0xFF, 0xE2], {offset: start, mask: [0xFF, 0xE2]}) // MPEG 1 or 2 Layer 3 header
) {
return {
ext: 'mp3',
mime: 'audio/mpeg'
};
}
}
if (
check([0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41], {offset: 4}) ||
check([0x4D, 0x34, 0x41, 0x20])
) {
return {
ext: 'm4a',
mime: 'audio/m4a'
};
}
// Needs to be before `ogg` check
if (check([0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64], {offset: 28})) {
return {
ext: 'opus',
mime: 'audio/opus'
};
}
if (check([0x4F, 0x67, 0x67, 0x53])) {
return {
ext: 'ogg',
mime: 'audio/ogg'
};
}
if (check([0x66, 0x4C, 0x61, 0x43])) {
return {
ext: 'flac',
mime: 'audio/x-flac'
};
}
if (
check([0x52, 0x49, 0x46, 0x46]) &&
check([0x57, 0x41, 0x56, 0x45], {offset: 8})
) {
return {
ext: 'wav',
mime: 'audio/x-wav'
};
}
if (check([0x23, 0x21, 0x41, 0x4D, 0x52, 0x0A])) {
return {
ext: 'amr',
mime: 'audio/amr'
};
}
if (check([0x25, 0x50, 0x44, 0x46])) {
return {
ext: 'pdf',
mime: 'application/pdf'
};
}
if (check([0x4D, 0x5A])) {
return {
ext: 'exe',
mime: 'application/x-msdownload'
};
}
if (
(buf[0] === 0x43 || buf[0] === 0x46) &&
check([0x57, 0x53], {offset: 1})
) {
return {
ext: 'swf',
mime: 'application/x-shockwave-flash'
};
}
if (check([0x7B, 0x5C, 0x72, 0x74, 0x66])) {
return {
ext: 'rtf',
mime: 'application/rtf'
};
}
if (check([0x00, 0x61, 0x73, 0x6D])) {
return {
ext: 'wasm',
mime: 'application/wasm'
};
}
if (
check([0x77, 0x4F, 0x46, 0x46]) &&
(
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
)
) {
return {
ext: 'woff',
mime: 'font/woff'
};
}
if (
check([0x77, 0x4F, 0x46, 0x32]) &&
(
check([0x00, 0x01, 0x00, 0x00], {offset: 4}) ||
check([0x4F, 0x54, 0x54, 0x4F], {offset: 4})
)
) {
return {
ext: 'woff2',
mime: 'font/woff2'
};
}
if (
check([0x4C, 0x50], {offset: 34}) &&
(
check([0x00, 0x00, 0x01], {offset: 8}) ||
check([0x01, 0x00, 0x02], {offset: 8}) ||
check([0x02, 0x00, 0x02], {offset: 8})
)
) {
return {
ext: 'eot',
mime: 'application/octet-stream'
};
}
if (check([0x00, 0x01, 0x00, 0x00, 0x00])) {
return {
ext: 'ttf',
mime: 'font/ttf'
};
}
if (check([0x4F, 0x54, 0x54, 0x4F, 0x00])) {
return {
ext: 'otf',
mime: 'font/otf'
};
}
if (check([0x00, 0x00, 0x01, 0x00])) {
return {
ext: 'ico',
mime: 'image/x-icon'
};
}
if (check([0x46, 0x4C, 0x56, 0x01])) {
return {
ext: 'flv',
mime: 'video/x-flv'
};
}
if (check([0x25, 0x21])) {
return {
ext: 'ps',
mime: 'application/postscript'
};
}
if (check([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])) {
return {
ext: 'xz',
mime: 'application/x-xz'
};
}
if (check([0x53, 0x51, 0x4C, 0x69])) {
return {
ext: 'sqlite',
mime: 'application/x-sqlite3'
};
}
if (check([0x4E, 0x45, 0x53, 0x1A])) {
return {
ext: 'nes',
mime: 'application/x-nintendo-nes-rom'
};
}
if (check([0x43, 0x72, 0x32, 0x34])) {
return {
ext: 'crx',
mime: 'application/x-google-chrome-extension'
};
}
if (
check([0x4D, 0x53, 0x43, 0x46]) ||
check([0x49, 0x53, 0x63, 0x28])
) {
return {
ext: 'cab',
mime: 'application/vnd.ms-cab-compressed'
};
}
// Needs to be before `ar` check
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E, 0x0A, 0x64, 0x65, 0x62, 0x69, 0x61, 0x6E, 0x2D, 0x62, 0x69, 0x6E, 0x61, 0x72, 0x79])) {
return {
ext: 'deb',
mime: 'application/x-deb'
};
}
if (check([0x21, 0x3C, 0x61, 0x72, 0x63, 0x68, 0x3E])) {
return {
ext: 'ar',
mime: 'application/x-unix-archive'
};
}
if (check([0xED, 0xAB, 0xEE, 0xDB])) {
return {
ext: 'rpm',
mime: 'application/x-rpm'
};
}
if (
check([0x1F, 0xA0]) ||
check([0x1F, 0x9D])
) {
return {
ext: 'Z',
mime: 'application/x-compress'
};
}
if (check([0x4C, 0x5A, 0x49, 0x50])) {
return {
ext: 'lz',
mime: 'application/x-lzip'
};
}
if (check([0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1])) {
return {
ext: 'msi',
mime: 'application/x-msi'
};
}
if (check([0x06, 0x0E, 0x2B, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x02])) {
return {
ext: 'mxf',
mime: 'application/mxf'
};
}
if (check([0x47], {offset: 4}) && (check([0x47], {offset: 192}) || check([0x47], {offset: 196}))) {
return {
ext: 'mts',
mime: 'video/mp2t'
};
}
if (check([0x42, 0x4C, 0x45, 0x4E, 0x44, 0x45, 0x52])) {
return {
ext: 'blend',
mime: 'application/x-blender'
};
}
if (check([0x42, 0x50, 0x47, 0xFB])) {
return {
ext: 'bpg',
mime: 'image/bpg'
};
}
return null;
};

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,142 +0,0 @@
{
"_from": "file-type@^6.1.0",
"_id": "file-type@6.2.0",
"_inBundle": false,
"_integrity": "sha512-YPcTBDV+2Tm0VqjybVd32MHdlEGAtuxS3VAYsumFokDSMG+ROT5wawGlnHDoz7bfMcMDt9hxuXvXwoKUx2fkOg==",
"_location": "/decompress-tarbz2/file-type",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "file-type@^6.1.0",
"name": "file-type",
"escapedName": "file-type",
"rawSpec": "^6.1.0",
"saveSpec": null,
"fetchSpec": "^6.1.0"
},
"_requiredBy": [
"/decompress-tarbz2"
],
"_resolved": "https://registry.npmjs.org/file-type/-/file-type-6.2.0.tgz",
"_shasum": "e50cd75d356ffed4e306dc4f5bcf52a79903a919",
"_spec": "file-type@^6.1.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress-tarbz2",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/file-type/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect the file type of a Buffer/Uint8Array",
"devDependencies": {
"ava": "*",
"read-chunk": "^2.0.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/file-type#readme",
"keywords": [
"mime",
"file",
"type",
"archive",
"image",
"img",
"pic",
"picture",
"flash",
"photo",
"video",
"detect",
"check",
"is",
"exif",
"exe",
"binary",
"buffer",
"uint8array",
"jpg",
"png",
"gif",
"webp",
"flif",
"cr2",
"tif",
"bmp",
"jxr",
"psd",
"zip",
"tar",
"rar",
"gz",
"bz2",
"7z",
"dmg",
"mp4",
"m4v",
"mid",
"mkv",
"webm",
"mov",
"avi",
"mpg",
"mp3",
"m4a",
"ogg",
"opus",
"flac",
"wav",
"amr",
"pdf",
"epub",
"swf",
"rtf",
"woff",
"woff2",
"eot",
"ttf",
"otf",
"ico",
"flv",
"ps",
"xz",
"sqlite",
"xpi",
"cab",
"deb",
"ar",
"rpm",
"Z",
"lz",
"msi",
"mxf",
"mts",
"wasm",
"webassembly",
"blend",
"bpg",
"docx",
"pptx",
"xlsx"
],
"license": "MIT",
"name": "file-type",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/file-type.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "6.2.0"
}

View File

@ -1,165 +0,0 @@
# file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type)
> Detect the file type of a Buffer/Uint8Array
The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
## Install
```
$ npm install file-type
```
## Usage
##### Node.js
```js
const readChunk = require('read-chunk');
const fileType = require('file-type');
const buffer = readChunk.sync('unicorn.png', 0, 4100);
fileType(buffer);
//=> {ext: 'png', mime: 'image/png'}
```
Or from a remote location:
```js
const http = require('http');
const fileType = require('file-type');
const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
http.get(url, res => {
res.once('data', chunk => {
res.destroy();
console.log(fileType(chunk));
//=> {ext: 'gif', mime: 'image/gif'}
});
});
```
##### Browser
```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
fileType(new Uint8Array(this.response));
//=> {ext: 'png', mime: 'image/png'}
};
xhr.send();
```
## API
### fileType(input)
Returns an `Object` with:
- `ext` - One of the [supported file types](#supported-file-types)
- `mime` - The [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
Or `null` when no match.
#### input
Type: `Buffer` `Uint8Array`
It only needs the first 4100 bytes.
## Supported file types
- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
- [`gif`](https://en.wikipedia.org/wiki/GIF)
- [`webp`](https://en.wikipedia.org/wiki/WebP)
- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
- [`cr2`](http://fileinfo.com/extension/cr2)
- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
- [`gz`](https://en.wikipedia.org/wiki/Gzip)
- [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
- [`7z`](https://en.wikipedia.org/wiki/7z)
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
- [`m4v`](https://en.wikipedia.org/wiki/M4V)
- [`mid`](https://en.wikipedia.org/wiki/MIDI)
- [`mkv`](https://en.wikipedia.org/wiki/Matroska)
- [`webm`](https://en.wikipedia.org/wiki/WebM)
- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
- [`mp3`](https://en.wikipedia.org/wiki/MP3)
- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
- [`ogg`](https://en.wikipedia.org/wiki/Ogg)
- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
- [`flac`](https://en.wikipedia.org/wiki/FLAC)
- [`wav`](https://en.wikipedia.org/wiki/WAV)
- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
- [`epub`](https://en.wikipedia.org/wiki/EPUB)
- [`exe`](https://en.wikipedia.org/wiki/.exe)
- [`swf`](https://en.wikipedia.org/wiki/SWF)
- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
- [`ttf`](https://en.wikipedia.org/wiki/TrueType)
- [`otf`](https://en.wikipedia.org/wiki/OpenType)
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
- [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
- [`ps`](https://en.wikipedia.org/wiki/Postscript)
- [`xz`](https://en.wikipedia.org/wiki/Xz)
- [`sqlite`](https://www.sqlite.org/fileformat2.html)
- [`nes`](http://fileinfo.com/extension/nes)
- [`crx`](https://developer.chrome.com/extensions/crx)
- [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
- [`rpm`](http://fileinfo.com/extension/rpm)
- [`Z`](http://fileinfo.com/extension/z)
- [`lz`](https://en.wikipedia.org/wiki/Lzip)
- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
- [`mxf`](https://en.wikipedia.org/wiki/Material_Exchange_Format)
- [`mts`](https://en.wikipedia.org/wiki/.m2ts)
- [`wasm`](https://en.wikipedia.org/wiki/WebAssembly)
- [`blend`](https://wiki.blender.org/index.php/Dev:Source/Architecture/File_Format)
- [`bpg`](https://bellard.org/bpg/)
- [`docx`](https://en.wikipedia.org/wiki/Office_Open_XML)
- [`pptx`](https://en.wikipedia.org/wiki/Office_Open_XML)
- [`xlsx`](https://en.wikipedia.org/wiki/Office_Open_XML)
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
*Pull request welcome for additional commonly used file types.*
## Related
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
## Created by
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Mikael Finstad](https://github.com/mifi)
## License
MIT

View File

@ -1,74 +0,0 @@
{
"_from": "decompress-tarbz2@^4.0.0",
"_id": "decompress-tarbz2@4.1.1",
"_inBundle": false,
"_integrity": "sha512-s88xLzf1r81ICXLAVQVzaN6ZmX4A6U4z2nMbOwobxkLoIIfjVMBg7TeguTUXkKeXni795B6y5rnvDw7rxhAq9A==",
"_location": "/decompress-tarbz2",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress-tarbz2@^4.0.0",
"name": "decompress-tarbz2",
"escapedName": "decompress-tarbz2",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/decompress"
],
"_resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz",
"_shasum": "3082a5b880ea4043816349f378b56c516be1a39b",
"_spec": "decompress-tarbz2@^4.0.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress-tarbz2/issues"
},
"bundleDependencies": false,
"dependencies": {
"decompress-tar": "^4.1.0",
"file-type": "^6.1.0",
"is-stream": "^1.1.0",
"seek-bzip": "^1.0.5",
"unbzip2-stream": "^1.0.9"
},
"deprecated": false,
"description": "decompress tar.bz2 plugin",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress-tarbz2#readme",
"keywords": [
"bz2",
"decompress",
"decompressplugin",
"extract",
"tar",
"tar.bz2",
"tarbz2"
],
"license": "MIT",
"name": "decompress-tarbz2",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress-tarbz2.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.1.1"
}

View File

@ -1,44 +0,0 @@
# decompress-tarbz2 [![Build Status](https://travis-ci.org/kevva/decompress-tarbz2.svg?branch=master)](https://travis-ci.org/kevva/decompress-tarbz2)
> tar.bz2 decompress plugin
## Install
```
$ npm install decompress-tarbz2
```
## Usage
```js
const decompress = require('decompress');
const decompressTarbz = require('decompress-tarbz2');
decompress('unicorn.tar.gz', 'dist', {
plugins: [
decompressTarbz()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressTarbz()(input)
Returns both a `Promise` for a `Buffer` and a [`Duplex stream`](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### input
Type: `Buffer` `Stream`
Buffer to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

View File

@ -1,26 +0,0 @@
'use strict';
const zlib = require('zlib');
const decompressTar = require('decompress-tar');
const fileType = require('file-type');
const isStream = require('is-stream');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'gz')) {
return Promise.resolve([]);
}
const unzip = zlib.createGunzip();
const result = decompressTar()(unzip);
if (Buffer.isBuffer(input)) {
unzip.end(input);
} else {
input.pipe(unzip);
}
return result;
};

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com> (github.com/kevva)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,71 +0,0 @@
{
"_from": "decompress-targz@^4.0.0",
"_id": "decompress-targz@4.1.1",
"_inBundle": false,
"_integrity": "sha512-4z81Znfr6chWnRDNfFNqLwPvm4db3WuZkqV+UgXQzSngG3CEKdBkw5jrv3axjjL96glyiiKjsxJG3X6WBZwX3w==",
"_location": "/decompress-targz",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress-targz@^4.0.0",
"name": "decompress-targz",
"escapedName": "decompress-targz",
"rawSpec": "^4.0.0",
"saveSpec": null,
"fetchSpec": "^4.0.0"
},
"_requiredBy": [
"/decompress"
],
"_resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz",
"_shasum": "c09bc35c4d11f3de09f2d2da53e9de23e7ce1eee",
"_spec": "decompress-targz@^4.0.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress-targz/issues"
},
"bundleDependencies": false,
"dependencies": {
"decompress-tar": "^4.1.1",
"file-type": "^5.2.0",
"is-stream": "^1.1.0"
},
"deprecated": false,
"description": "decompress tar.gz plugin",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"pify": "^3.0.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress-targz#readme",
"keywords": [
"decompress",
"decompressplugin",
"extract",
"tar.gz",
"targz"
],
"license": "MIT",
"name": "decompress-targz",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress-targz.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.1.1"
}

View File

@ -1,44 +0,0 @@
# decompress-targz [![Build Status](https://travis-ci.org/kevva/decompress-targz.svg?branch=master)](https://travis-ci.org/kevva/decompress-targz)
> tar.gz decompress plugin
## Install
```
$ npm install decompress-targz
```
## Usage
```js
const decompress = require('decompress');
const decompressTargz = require('decompress-targz');
decompress('unicorn.tar.gz', 'dist', {
plugins: [
decompressTargz()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressTargz()(input)
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### input
Type: `Buffer` `Stream`
Buffer or stream to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

View File

@ -1,26 +0,0 @@
'use strict';
const decompressTar = require('decompress-tar');
const fileType = require('file-type');
const isStream = require('is-stream');
const lzmaNative = require('lzma-native');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'xz')) {
return Promise.resolve([]);
}
const decompressor = lzmaNative.createDecompressor();
const result = decompressTar()(decompressor);
if (Buffer.isBuffer(input)) {
decompressor.end(input);
} else {
input.pipe(decompressor);
}
return result;
};

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,452 +0,0 @@
'use strict';
module.exports = function (buf) {
if (!(buf && buf.length > 1)) {
return null;
}
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
return {
ext: 'jpg',
mime: 'image/jpeg'
};
}
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
return {
ext: 'png',
mime: 'image/png'
};
}
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
return {
ext: 'gif',
mime: 'image/gif'
};
}
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
return {
ext: 'webp',
mime: 'image/webp'
};
}
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x49 && buf[3] === 0x46) {
return {
ext: 'flif',
mime: 'image/flif'
};
}
// needs to be before `tif` check
if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) {
return {
ext: 'cr2',
mime: 'image/x-canon-cr2'
};
}
if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) {
return {
ext: 'tif',
mime: 'image/tiff'
};
}
if (buf[0] === 0x42 && buf[1] === 0x4D) {
return {
ext: 'bmp',
mime: 'image/bmp'
};
}
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
return {
ext: 'jxr',
mime: 'image/vnd.ms-photo'
};
}
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
return {
ext: 'psd',
mime: 'image/vnd.adobe.photoshop'
};
}
// needs to be before `zip` check
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) {
return {
ext: 'epub',
mime: 'application/epub+zip'
};
}
// needs to be before `zip` check
// assumes signed .xpi from addons.mozilla.org
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x4D && buf[31] === 0x45 && buf[32] === 0x54 && buf[33] === 0x41 && buf[34] === 0x2D && buf[35] === 0x49 && buf[36] === 0x4E && buf[37] === 0x46 && buf[38] === 0x2F && buf[39] === 0x6D && buf[40] === 0x6F && buf[41] === 0x7A && buf[42] === 0x69 && buf[43] === 0x6C && buf[44] === 0x6C && buf[45] === 0x61 && buf[46] === 0x2E && buf[47] === 0x72 && buf[48] === 0x73 && buf[49] === 0x61) {
return {
ext: 'xpi',
mime: 'application/x-xpinstall'
};
}
if (buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)) {
return {
ext: 'zip',
mime: 'application/zip'
};
}
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
return {
ext: 'tar',
mime: 'application/x-tar'
};
}
if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) {
return {
ext: 'rar',
mime: 'application/x-rar-compressed'
};
}
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
return {
ext: 'gz',
mime: 'application/gzip'
};
}
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
return {
ext: 'bz2',
mime: 'application/x-bzip2'
};
}
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
return {
ext: '7z',
mime: 'application/x-7z-compressed'
};
}
if (buf[0] === 0x78 && buf[1] === 0x01) {
return {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
};
}
if (
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) ||
(buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x69 && buf[9] === 0x73 && buf[10] === 0x6F && buf[11] === 0x6D) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1c && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[12] === 0x0 && buf[13] === 0x0 && buf[14] === 0x0 && buf[15] === 0x0)
) {
return {
ext: 'mp4',
mime: 'video/mp4'
};
}
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) {
return {
ext: 'm4v',
mime: 'video/x-m4v'
};
}
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
return {
ext: 'mid',
mime: 'audio/midi'
};
}
// needs to be before the `webm` check
if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) {
return {
ext: 'mkv',
mime: 'video/x-matroska'
};
}
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
return {
ext: 'webm',
mime: 'video/webm'
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
return {
ext: 'mov',
mime: 'video/quicktime'
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
return {
ext: 'avi',
mime: 'video/x-msvideo'
};
}
if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) {
return {
ext: 'wmv',
mime: 'video/x-ms-wmv'
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') {
return {
ext: 'mpg',
mime: 'video/mpeg'
};
}
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
return {
ext: 'mp3',
mime: 'audio/mpeg'
};
}
if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) {
return {
ext: 'm4a',
mime: 'audio/m4a'
};
}
// needs to be before `ogg` check
if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) {
return {
ext: 'opus',
mime: 'audio/opus'
};
}
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
return {
ext: 'ogg',
mime: 'audio/ogg'
};
}
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
return {
ext: 'flac',
mime: 'audio/x-flac'
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
return {
ext: 'wav',
mime: 'audio/x-wav'
};
}
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
return {
ext: 'amr',
mime: 'audio/amr'
};
}
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
return {
ext: 'pdf',
mime: 'application/pdf'
};
}
if (buf[0] === 0x4D && buf[1] === 0x5A) {
return {
ext: 'exe',
mime: 'application/x-msdownload'
};
}
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
return {
ext: 'swf',
mime: 'application/x-shockwave-flash'
};
}
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
return {
ext: 'rtf',
mime: 'application/rtf'
};
}
if (
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) &&
(
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
)
) {
return {
ext: 'woff',
mime: 'application/font-woff'
};
}
if (
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) &&
(
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
)
) {
return {
ext: 'woff2',
mime: 'application/font-woff'
};
}
if (
(buf[34] === 0x4C && buf[35] === 0x50) &&
(
(buf[8] === 0x00 && buf[9] === 0x00 && buf[10] === 0x01) ||
(buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x02) ||
(buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02)
)
) {
return {
ext: 'eot',
mime: 'application/octet-stream'
};
}
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
return {
ext: 'ttf',
mime: 'application/font-sfnt'
};
}
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
return {
ext: 'otf',
mime: 'application/font-sfnt'
};
}
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
return {
ext: 'ico',
mime: 'image/x-icon'
};
}
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
return {
ext: 'flv',
mime: 'video/x-flv'
};
}
if (buf[0] === 0x25 && buf[1] === 0x21) {
return {
ext: 'ps',
mime: 'application/postscript'
};
}
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
return {
ext: 'xz',
mime: 'application/x-xz'
};
}
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
return {
ext: 'sqlite',
mime: 'application/x-sqlite3'
};
}
if (buf[0] === 0x4E && buf[1] === 0x45 && buf[2] === 0x53 && buf[3] === 0x1A) {
return {
ext: 'nes',
mime: 'application/x-nintendo-nes-rom'
};
}
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) {
return {
ext: 'crx',
mime: 'application/x-google-chrome-extension'
};
}
if (
(buf[0] === 0x4D && buf[1] === 0x53 && buf[2] === 0x43 && buf[3] === 0x46) ||
(buf[0] === 0x49 && buf[1] === 0x53 && buf[2] === 0x63 && buf[3] === 0x28)
) {
return {
ext: 'cab',
mime: 'application/vnd.ms-cab-compressed'
};
}
// needs to be before `ar` check
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E && buf[7] === 0x0A && buf[8] === 0x64 && buf[9] === 0x65 && buf[10] === 0x62 && buf[11] === 0x69 && buf[12] === 0x61 && buf[13] === 0x6E && buf[14] === 0x2D && buf[15] === 0x62 && buf[16] === 0x69 && buf[17] === 0x6E && buf[18] === 0x61 && buf[19] === 0x72 && buf[20] === 0x79) {
return {
ext: 'deb',
mime: 'application/x-deb'
};
}
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E) {
return {
ext: 'ar',
mime: 'application/x-unix-archive'
};
}
if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) {
return {
ext: 'rpm',
mime: 'application/x-rpm'
};
}
if (
(buf[0] === 0x1F && buf[1] === 0xA0) ||
(buf[0] === 0x1F && buf[1] === 0x9D)
) {
return {
ext: 'Z',
mime: 'application/x-compress'
};
}
if (buf[0] === 0x4C && buf[1] === 0x5A && buf[2] === 0x49 && buf[3] === 0x50) {
return {
ext: 'lz',
mime: 'application/x-lzip'
};
}
if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
return {
ext: 'msi',
mime: 'application/x-msi'
};
}
return null;
};

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,135 +0,0 @@
{
"_from": "file-type@^3.8.0",
"_id": "file-type@3.9.0",
"_inBundle": false,
"_integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=",
"_location": "/decompress-tarxz/file-type",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "file-type@^3.8.0",
"name": "file-type",
"escapedName": "file-type",
"rawSpec": "^3.8.0",
"saveSpec": null,
"fetchSpec": "^3.8.0"
},
"_requiredBy": [
"/decompress-tarxz"
],
"_resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"_shasum": "257a078384d1db8087bc449d107d52a52672b9e9",
"_spec": "file-type@^3.8.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress-tarxz",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/file-type/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect the file type of a Buffer/Uint8Array",
"devDependencies": {
"ava": "*",
"read-chunk": "^2.0.0",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/file-type#readme",
"keywords": [
"mime",
"file",
"type",
"archive",
"image",
"img",
"pic",
"picture",
"flash",
"photo",
"video",
"type",
"detect",
"check",
"is",
"exif",
"exe",
"binary",
"buffer",
"uint8array",
"jpg",
"png",
"gif",
"webp",
"flif",
"cr2",
"tif",
"bmp",
"jxr",
"psd",
"zip",
"tar",
"rar",
"gz",
"bz2",
"7z",
"dmg",
"mp4",
"m4v",
"mid",
"mkv",
"webm",
"mov",
"avi",
"mpg",
"mp3",
"m4a",
"ogg",
"opus",
"flac",
"wav",
"amr",
"pdf",
"epub",
"exe",
"swf",
"rtf",
"woff",
"woff2",
"eot",
"ttf",
"otf",
"ico",
"flv",
"ps",
"xz",
"sqlite",
"xpi",
"cab",
"deb",
"ar",
"rpm",
"Z",
"lz",
"msi"
],
"license": "MIT",
"name": "file-type",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/file-type.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.9.0"
}

View File

@ -1,149 +0,0 @@
# file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type)
> Detect the file type of a Buffer/Uint8Array
The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
## Install
```
$ npm install --save file-type
```
## Usage
##### Node.js
```js
const readChunk = require('read-chunk'); // npm install read-chunk
const fileType = require('file-type');
const buffer = readChunk.sync('unicorn.png', 0, 262);
fileType(buffer);
//=> {ext: 'png', mime: 'image/png'}
```
or from a remote location:
```js
const http = require('http');
const fileType = require('file-type');
const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
http.get(url, res => {
res.once('data', chunk => {
res.destroy();
console.log(fileType(chunk));
//=> {ext: 'gif', mime: 'image/gif'}
});
});
```
##### Browser
```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
fileType(new Uint8Array(this.response));
//=> {ext: 'png', mime: 'image/png'}
};
xhr.send();
```
## API
### fileType(buffer)
Returns an `Object` (or `null` when no match) with:
- `ext` - one of the [supported file types](#supported-file-types)
- `mime` - the [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
#### buffer
Type: `Buffer` `Uint8Array`
It only needs the first 262 bytes.
## Supported file types
- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
- [`gif`](https://en.wikipedia.org/wiki/GIF)
- [`webp`](https://en.wikipedia.org/wiki/WebP)
- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
- [`cr2`](http://fileinfo.com/extension/cr2)
- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
- [`gz`](https://en.wikipedia.org/wiki/Gzip)
- [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
- [`7z`](https://en.wikipedia.org/wiki/7z)
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
- [`m4v`](https://en.wikipedia.org/wiki/M4V)
- [`mid`](https://en.wikipedia.org/wiki/MIDI)
- [`mkv`](https://en.wikipedia.org/wiki/Matroska)
- [`webm`](https://en.wikipedia.org/wiki/WebM)
- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
- [`mp3`](https://en.wikipedia.org/wiki/MP3)
- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
- [`ogg`](https://en.wikipedia.org/wiki/Ogg)
- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
- [`flac`](https://en.wikipedia.org/wiki/FLAC)
- [`wav`](https://en.wikipedia.org/wiki/WAV)
- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
- [`epub`](https://en.wikipedia.org/wiki/EPUB)
- [`exe`](https://en.wikipedia.org/wiki/.exe)
- [`swf`](https://en.wikipedia.org/wiki/SWF)
- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
- [`ttf`](https://en.wikipedia.org/wiki/TrueType)
- [`otf`](https://en.wikipedia.org/wiki/OpenType)
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
- [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
- [`ps`](https://en.wikipedia.org/wiki/Postscript)
- [`xz`](https://en.wikipedia.org/wiki/Xz)
- [`sqlite`](https://www.sqlite.org/fileformat2.html)
- [`nes`](http://fileinfo.com/extension/nes)
- [`crx`](https://developer.chrome.com/extensions/crx)
- [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
- [`rpm`](http://fileinfo.com/extension/rpm)
- [`Z`](http://fileinfo.com/extension/z)
- [`lz`](https://en.wikipedia.org/wiki/Lzip)
- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
*PR welcome for additional commonly used file types.*
## Related
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@ -1,73 +0,0 @@
{
"_from": "decompress-tarxz@^2.1.1",
"_id": "decompress-tarxz@2.1.1",
"_inBundle": false,
"_integrity": "sha512-U7LniyhLTpCc07lAmNXMX4NBW60ONkpGTwo6KxIDk9zk22GYh5NKjEI09F8I1oYkGr9WGOA6OH7scqLo7Xu5lA==",
"_location": "/decompress-tarxz",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress-tarxz@^2.1.1",
"name": "decompress-tarxz",
"escapedName": "decompress-tarxz",
"rawSpec": "^2.1.1",
"saveSpec": null,
"fetchSpec": "^2.1.1"
},
"_requiredBy": [
"/ffmpeg-binaries"
],
"_resolved": "https://registry.npmjs.org/decompress-tarxz/-/decompress-tarxz-2.1.1.tgz",
"_shasum": "1c657dc69322a5a0bac8431f2574a77e5884d3f5",
"_spec": "decompress-tarxz@^2.1.1",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\ffmpeg-binaries",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress-tarxz/issues"
},
"bundleDependencies": false,
"dependencies": {
"decompress-tar": "^4.1.0",
"file-type": "^3.8.0",
"is-stream": "^1.1.0",
"lzma-native": "^3.0.1"
},
"deprecated": false,
"description": "decompress tar.xz plugin",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"pify": "^2.3.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress-tarxz#readme",
"keywords": [
"decompress",
"decompressplugin",
"extract",
"tar",
"tarxz",
"xz"
],
"license": "MIT",
"name": "decompress-tarxz",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress-tarxz.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "2.1.1"
}

View File

@ -1,44 +0,0 @@
# decompress-tarxz [![Build Status](https://travis-ci.org/kevva/decompress-tarxz.svg?branch=master)](https://travis-ci.org/kevva/decompress-tarxz)
> tar.xz decompress plugin
## Install
```
$ npm install --save decompress-tarxz
```
## Usage
```js
const decompress = require('decompress');
const decompressTarxz = require('decompress-tarxz');
decompress('unicorn.tar.xz', 'dist', {
plugins: [
decompressTarxz()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressTarxz()(input)
Returns both a Promise for a Buffer and a [Duplex stream](https://nodejs.org/api/stream.html#stream_class_stream_duplex).
#### input
Type: `Buffer` `Stream`
Buffer or stream to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

View File

@ -1,86 +0,0 @@
'use strict';
const fileType = require('file-type');
const getStream = require('get-stream');
const pify = require('pify');
const yauzl = require('yauzl');
const getType = (entry, mode) => {
const IFMT = 61440;
const IFDIR = 16384;
const IFLNK = 40960;
const madeBy = entry.versionMadeBy >> 8;
if ((mode & IFMT) === IFLNK) {
return 'symlink';
}
if ((mode & IFMT) === IFDIR || (madeBy === 0 && entry.externalFileAttributes === 16)) {
return 'directory';
}
return 'file';
};
const extractEntry = (entry, zip) => {
const file = {
mode: (entry.externalFileAttributes >> 16) & 0xFFFF,
mtime: entry.getLastModDate(),
path: entry.fileName
};
file.type = getType(entry, file.mode);
if (file.mode === 0 && file.type === 'directory') {
file.mode = 493;
}
if (file.mode === 0) {
file.mode = 420;
}
return pify(zip.openReadStream.bind(zip))(entry)
.then(getStream.buffer)
.then(buf => {
file.data = buf;
if (file.type === 'symlink') {
file.linkname = buf.toString();
}
return file;
})
.catch(err => {
zip.close();
throw err;
});
};
const extractFile = zip => new Promise((resolve, reject) => {
const files = [];
zip.readEntry();
zip.on('entry', entry => {
extractEntry(entry, zip)
.catch(reject)
.then(file => {
files.push(file);
zip.readEntry();
});
});
zip.on('error', reject);
zip.on('end', () => resolve(files));
});
module.exports = () => buf => {
if (!Buffer.isBuffer(buf)) {
return Promise.reject(new TypeError(`Expected a Buffer, got ${typeof buf}`));
}
if (!fileType(buf) || fileType(buf).ext !== 'zip') {
return Promise.resolve([]);
}
return pify(yauzl.fromBuffer)(buf, {lazyEntries: true}).then(extractFile);
};

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,452 +0,0 @@
'use strict';
module.exports = function (buf) {
if (!(buf && buf.length > 1)) {
return null;
}
if (buf[0] === 0xFF && buf[1] === 0xD8 && buf[2] === 0xFF) {
return {
ext: 'jpg',
mime: 'image/jpeg'
};
}
if (buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4E && buf[3] === 0x47) {
return {
ext: 'png',
mime: 'image/png'
};
}
if (buf[0] === 0x47 && buf[1] === 0x49 && buf[2] === 0x46) {
return {
ext: 'gif',
mime: 'image/gif'
};
}
if (buf[8] === 0x57 && buf[9] === 0x45 && buf[10] === 0x42 && buf[11] === 0x50) {
return {
ext: 'webp',
mime: 'image/webp'
};
}
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x49 && buf[3] === 0x46) {
return {
ext: 'flif',
mime: 'image/flif'
};
}
// needs to be before `tif` check
if (((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) && buf[8] === 0x43 && buf[9] === 0x52) {
return {
ext: 'cr2',
mime: 'image/x-canon-cr2'
};
}
if ((buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0x2A && buf[3] === 0x0) || (buf[0] === 0x4D && buf[1] === 0x4D && buf[2] === 0x0 && buf[3] === 0x2A)) {
return {
ext: 'tif',
mime: 'image/tiff'
};
}
if (buf[0] === 0x42 && buf[1] === 0x4D) {
return {
ext: 'bmp',
mime: 'image/bmp'
};
}
if (buf[0] === 0x49 && buf[1] === 0x49 && buf[2] === 0xBC) {
return {
ext: 'jxr',
mime: 'image/vnd.ms-photo'
};
}
if (buf[0] === 0x38 && buf[1] === 0x42 && buf[2] === 0x50 && buf[3] === 0x53) {
return {
ext: 'psd',
mime: 'image/vnd.adobe.photoshop'
};
}
// needs to be before `zip` check
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x6D && buf[31] === 0x69 && buf[32] === 0x6D && buf[33] === 0x65 && buf[34] === 0x74 && buf[35] === 0x79 && buf[36] === 0x70 && buf[37] === 0x65 && buf[38] === 0x61 && buf[39] === 0x70 && buf[40] === 0x70 && buf[41] === 0x6C && buf[42] === 0x69 && buf[43] === 0x63 && buf[44] === 0x61 && buf[45] === 0x74 && buf[46] === 0x69 && buf[47] === 0x6F && buf[48] === 0x6E && buf[49] === 0x2F && buf[50] === 0x65 && buf[51] === 0x70 && buf[52] === 0x75 && buf[53] === 0x62 && buf[54] === 0x2B && buf[55] === 0x7A && buf[56] === 0x69 && buf[57] === 0x70) {
return {
ext: 'epub',
mime: 'application/epub+zip'
};
}
// needs to be before `zip` check
// assumes signed .xpi from addons.mozilla.org
if (buf[0] === 0x50 && buf[1] === 0x4B && buf[2] === 0x3 && buf[3] === 0x4 && buf[30] === 0x4D && buf[31] === 0x45 && buf[32] === 0x54 && buf[33] === 0x41 && buf[34] === 0x2D && buf[35] === 0x49 && buf[36] === 0x4E && buf[37] === 0x46 && buf[38] === 0x2F && buf[39] === 0x6D && buf[40] === 0x6F && buf[41] === 0x7A && buf[42] === 0x69 && buf[43] === 0x6C && buf[44] === 0x6C && buf[45] === 0x61 && buf[46] === 0x2E && buf[47] === 0x72 && buf[48] === 0x73 && buf[49] === 0x61) {
return {
ext: 'xpi',
mime: 'application/x-xpinstall'
};
}
if (buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x3 || buf[2] === 0x5 || buf[2] === 0x7) && (buf[3] === 0x4 || buf[3] === 0x6 || buf[3] === 0x8)) {
return {
ext: 'zip',
mime: 'application/zip'
};
}
if (buf[257] === 0x75 && buf[258] === 0x73 && buf[259] === 0x74 && buf[260] === 0x61 && buf[261] === 0x72) {
return {
ext: 'tar',
mime: 'application/x-tar'
};
}
if (buf[0] === 0x52 && buf[1] === 0x61 && buf[2] === 0x72 && buf[3] === 0x21 && buf[4] === 0x1A && buf[5] === 0x7 && (buf[6] === 0x0 || buf[6] === 0x1)) {
return {
ext: 'rar',
mime: 'application/x-rar-compressed'
};
}
if (buf[0] === 0x1F && buf[1] === 0x8B && buf[2] === 0x8) {
return {
ext: 'gz',
mime: 'application/gzip'
};
}
if (buf[0] === 0x42 && buf[1] === 0x5A && buf[2] === 0x68) {
return {
ext: 'bz2',
mime: 'application/x-bzip2'
};
}
if (buf[0] === 0x37 && buf[1] === 0x7A && buf[2] === 0xBC && buf[3] === 0xAF && buf[4] === 0x27 && buf[5] === 0x1C) {
return {
ext: '7z',
mime: 'application/x-7z-compressed'
};
}
if (buf[0] === 0x78 && buf[1] === 0x01) {
return {
ext: 'dmg',
mime: 'application/x-apple-diskimage'
};
}
if (
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && (buf[3] === 0x18 || buf[3] === 0x20) && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) ||
(buf[0] === 0x33 && buf[1] === 0x67 && buf[2] === 0x70 && buf[3] === 0x35) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[16] === 0x6D && buf[17] === 0x70 && buf[18] === 0x34 && buf[19] === 0x31 && buf[20] === 0x6D && buf[21] === 0x70 && buf[22] === 0x34 && buf[23] === 0x32 && buf[24] === 0x69 && buf[25] === 0x73 && buf[26] === 0x6F && buf[27] === 0x6D) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x69 && buf[9] === 0x73 && buf[10] === 0x6F && buf[11] === 0x6D) ||
(buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1c && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x6D && buf[9] === 0x70 && buf[10] === 0x34 && buf[11] === 0x32 && buf[12] === 0x0 && buf[13] === 0x0 && buf[14] === 0x0 && buf[15] === 0x0)
) {
return {
ext: 'mp4',
mime: 'video/mp4'
};
}
if ((buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x1C && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x56)) {
return {
ext: 'm4v',
mime: 'video/x-m4v'
};
}
if (buf[0] === 0x4D && buf[1] === 0x54 && buf[2] === 0x68 && buf[3] === 0x64) {
return {
ext: 'mid',
mime: 'audio/midi'
};
}
// needs to be before the `webm` check
if (buf[31] === 0x6D && buf[32] === 0x61 && buf[33] === 0x74 && buf[34] === 0x72 && buf[35] === 0x6f && buf[36] === 0x73 && buf[37] === 0x6B && buf[38] === 0x61) {
return {
ext: 'mkv',
mime: 'video/x-matroska'
};
}
if (buf[0] === 0x1A && buf[1] === 0x45 && buf[2] === 0xDF && buf[3] === 0xA3) {
return {
ext: 'webm',
mime: 'video/webm'
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x0 && buf[3] === 0x14 && buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70) {
return {
ext: 'mov',
mime: 'video/quicktime'
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x41 && buf[9] === 0x56 && buf[10] === 0x49) {
return {
ext: 'avi',
mime: 'video/x-msvideo'
};
}
if (buf[0] === 0x30 && buf[1] === 0x26 && buf[2] === 0xB2 && buf[3] === 0x75 && buf[4] === 0x8E && buf[5] === 0x66 && buf[6] === 0xCF && buf[7] === 0x11 && buf[8] === 0xA6 && buf[9] === 0xD9) {
return {
ext: 'wmv',
mime: 'video/x-ms-wmv'
};
}
if (buf[0] === 0x0 && buf[1] === 0x0 && buf[2] === 0x1 && buf[3].toString(16)[0] === 'b') {
return {
ext: 'mpg',
mime: 'video/mpeg'
};
}
if ((buf[0] === 0x49 && buf[1] === 0x44 && buf[2] === 0x33) || (buf[0] === 0xFF && buf[1] === 0xfb)) {
return {
ext: 'mp3',
mime: 'audio/mpeg'
};
}
if ((buf[4] === 0x66 && buf[5] === 0x74 && buf[6] === 0x79 && buf[7] === 0x70 && buf[8] === 0x4D && buf[9] === 0x34 && buf[10] === 0x41) || (buf[0] === 0x4D && buf[1] === 0x34 && buf[2] === 0x41 && buf[3] === 0x20)) {
return {
ext: 'm4a',
mime: 'audio/m4a'
};
}
// needs to be before `ogg` check
if (buf[28] === 0x4F && buf[29] === 0x70 && buf[30] === 0x75 && buf[31] === 0x73 && buf[32] === 0x48 && buf[33] === 0x65 && buf[34] === 0x61 && buf[35] === 0x64) {
return {
ext: 'opus',
mime: 'audio/opus'
};
}
if (buf[0] === 0x4F && buf[1] === 0x67 && buf[2] === 0x67 && buf[3] === 0x53) {
return {
ext: 'ogg',
mime: 'audio/ogg'
};
}
if (buf[0] === 0x66 && buf[1] === 0x4C && buf[2] === 0x61 && buf[3] === 0x43) {
return {
ext: 'flac',
mime: 'audio/x-flac'
};
}
if (buf[0] === 0x52 && buf[1] === 0x49 && buf[2] === 0x46 && buf[3] === 0x46 && buf[8] === 0x57 && buf[9] === 0x41 && buf[10] === 0x56 && buf[11] === 0x45) {
return {
ext: 'wav',
mime: 'audio/x-wav'
};
}
if (buf[0] === 0x23 && buf[1] === 0x21 && buf[2] === 0x41 && buf[3] === 0x4D && buf[4] === 0x52 && buf[5] === 0x0A) {
return {
ext: 'amr',
mime: 'audio/amr'
};
}
if (buf[0] === 0x25 && buf[1] === 0x50 && buf[2] === 0x44 && buf[3] === 0x46) {
return {
ext: 'pdf',
mime: 'application/pdf'
};
}
if (buf[0] === 0x4D && buf[1] === 0x5A) {
return {
ext: 'exe',
mime: 'application/x-msdownload'
};
}
if ((buf[0] === 0x43 || buf[0] === 0x46) && buf[1] === 0x57 && buf[2] === 0x53) {
return {
ext: 'swf',
mime: 'application/x-shockwave-flash'
};
}
if (buf[0] === 0x7B && buf[1] === 0x5C && buf[2] === 0x72 && buf[3] === 0x74 && buf[4] === 0x66) {
return {
ext: 'rtf',
mime: 'application/rtf'
};
}
if (
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x46) &&
(
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
)
) {
return {
ext: 'woff',
mime: 'application/font-woff'
};
}
if (
(buf[0] === 0x77 && buf[1] === 0x4F && buf[2] === 0x46 && buf[3] === 0x32) &&
(
(buf[4] === 0x00 && buf[5] === 0x01 && buf[6] === 0x00 && buf[7] === 0x00) ||
(buf[4] === 0x4F && buf[5] === 0x54 && buf[6] === 0x54 && buf[7] === 0x4F)
)
) {
return {
ext: 'woff2',
mime: 'application/font-woff'
};
}
if (
(buf[34] === 0x4C && buf[35] === 0x50) &&
(
(buf[8] === 0x00 && buf[9] === 0x00 && buf[10] === 0x01) ||
(buf[8] === 0x01 && buf[9] === 0x00 && buf[10] === 0x02) ||
(buf[8] === 0x02 && buf[9] === 0x00 && buf[10] === 0x02)
)
) {
return {
ext: 'eot',
mime: 'application/octet-stream'
};
}
if (buf[0] === 0x00 && buf[1] === 0x01 && buf[2] === 0x00 && buf[3] === 0x00 && buf[4] === 0x00) {
return {
ext: 'ttf',
mime: 'application/font-sfnt'
};
}
if (buf[0] === 0x4F && buf[1] === 0x54 && buf[2] === 0x54 && buf[3] === 0x4F && buf[4] === 0x00) {
return {
ext: 'otf',
mime: 'application/font-sfnt'
};
}
if (buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0x01 && buf[3] === 0x00) {
return {
ext: 'ico',
mime: 'image/x-icon'
};
}
if (buf[0] === 0x46 && buf[1] === 0x4C && buf[2] === 0x56 && buf[3] === 0x01) {
return {
ext: 'flv',
mime: 'video/x-flv'
};
}
if (buf[0] === 0x25 && buf[1] === 0x21) {
return {
ext: 'ps',
mime: 'application/postscript'
};
}
if (buf[0] === 0xFD && buf[1] === 0x37 && buf[2] === 0x7A && buf[3] === 0x58 && buf[4] === 0x5A && buf[5] === 0x00) {
return {
ext: 'xz',
mime: 'application/x-xz'
};
}
if (buf[0] === 0x53 && buf[1] === 0x51 && buf[2] === 0x4C && buf[3] === 0x69) {
return {
ext: 'sqlite',
mime: 'application/x-sqlite3'
};
}
if (buf[0] === 0x4E && buf[1] === 0x45 && buf[2] === 0x53 && buf[3] === 0x1A) {
return {
ext: 'nes',
mime: 'application/x-nintendo-nes-rom'
};
}
if (buf[0] === 0x43 && buf[1] === 0x72 && buf[2] === 0x32 && buf[3] === 0x34) {
return {
ext: 'crx',
mime: 'application/x-google-chrome-extension'
};
}
if (
(buf[0] === 0x4D && buf[1] === 0x53 && buf[2] === 0x43 && buf[3] === 0x46) ||
(buf[0] === 0x49 && buf[1] === 0x53 && buf[2] === 0x63 && buf[3] === 0x28)
) {
return {
ext: 'cab',
mime: 'application/vnd.ms-cab-compressed'
};
}
// needs to be before `ar` check
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E && buf[7] === 0x0A && buf[8] === 0x64 && buf[9] === 0x65 && buf[10] === 0x62 && buf[11] === 0x69 && buf[12] === 0x61 && buf[13] === 0x6E && buf[14] === 0x2D && buf[15] === 0x62 && buf[16] === 0x69 && buf[17] === 0x6E && buf[18] === 0x61 && buf[19] === 0x72 && buf[20] === 0x79) {
return {
ext: 'deb',
mime: 'application/x-deb'
};
}
if (buf[0] === 0x21 && buf[1] === 0x3C && buf[2] === 0x61 && buf[3] === 0x72 && buf[4] === 0x63 && buf[5] === 0x68 && buf[6] === 0x3E) {
return {
ext: 'ar',
mime: 'application/x-unix-archive'
};
}
if (buf[0] === 0xED && buf[1] === 0xAB && buf[2] === 0xEE && buf[3] === 0xDB) {
return {
ext: 'rpm',
mime: 'application/x-rpm'
};
}
if (
(buf[0] === 0x1F && buf[1] === 0xA0) ||
(buf[0] === 0x1F && buf[1] === 0x9D)
) {
return {
ext: 'Z',
mime: 'application/x-compress'
};
}
if (buf[0] === 0x4C && buf[1] === 0x5A && buf[2] === 0x49 && buf[3] === 0x50) {
return {
ext: 'lz',
mime: 'application/x-lzip'
};
}
if (buf[0] === 0xD0 && buf[1] === 0xCF && buf[2] === 0x11 && buf[3] === 0xE0 && buf[4] === 0xA1 && buf[5] === 0xB1 && buf[6] === 0x1A && buf[7] === 0xE1) {
return {
ext: 'msi',
mime: 'application/x-msi'
};
}
return null;
};

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,135 +0,0 @@
{
"_from": "file-type@^3.8.0",
"_id": "file-type@3.9.0",
"_inBundle": false,
"_integrity": "sha1-JXoHg4TR24CHvESdEH1SpSZyuek=",
"_location": "/decompress-unzip/file-type",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "file-type@^3.8.0",
"name": "file-type",
"escapedName": "file-type",
"rawSpec": "^3.8.0",
"saveSpec": null,
"fetchSpec": "^3.8.0"
},
"_requiredBy": [
"/decompress-unzip"
],
"_resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz",
"_shasum": "257a078384d1db8087bc449d107d52a52672b9e9",
"_spec": "file-type@^3.8.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\decompress-unzip",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/file-type/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect the file type of a Buffer/Uint8Array",
"devDependencies": {
"ava": "*",
"read-chunk": "^2.0.0",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/file-type#readme",
"keywords": [
"mime",
"file",
"type",
"archive",
"image",
"img",
"pic",
"picture",
"flash",
"photo",
"video",
"type",
"detect",
"check",
"is",
"exif",
"exe",
"binary",
"buffer",
"uint8array",
"jpg",
"png",
"gif",
"webp",
"flif",
"cr2",
"tif",
"bmp",
"jxr",
"psd",
"zip",
"tar",
"rar",
"gz",
"bz2",
"7z",
"dmg",
"mp4",
"m4v",
"mid",
"mkv",
"webm",
"mov",
"avi",
"mpg",
"mp3",
"m4a",
"ogg",
"opus",
"flac",
"wav",
"amr",
"pdf",
"epub",
"exe",
"swf",
"rtf",
"woff",
"woff2",
"eot",
"ttf",
"otf",
"ico",
"flv",
"ps",
"xz",
"sqlite",
"xpi",
"cab",
"deb",
"ar",
"rpm",
"Z",
"lz",
"msi"
],
"license": "MIT",
"name": "file-type",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/file-type.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "3.9.0"
}

View File

@ -1,149 +0,0 @@
# file-type [![Build Status](https://travis-ci.org/sindresorhus/file-type.svg?branch=master)](https://travis-ci.org/sindresorhus/file-type)
> Detect the file type of a Buffer/Uint8Array
The file type is detected by checking the [magic number](http://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of the buffer.
## Install
```
$ npm install --save file-type
```
## Usage
##### Node.js
```js
const readChunk = require('read-chunk'); // npm install read-chunk
const fileType = require('file-type');
const buffer = readChunk.sync('unicorn.png', 0, 262);
fileType(buffer);
//=> {ext: 'png', mime: 'image/png'}
```
or from a remote location:
```js
const http = require('http');
const fileType = require('file-type');
const url = 'http://assets-cdn.github.com/images/spinners/octocat-spinner-32.gif';
http.get(url, res => {
res.once('data', chunk => {
res.destroy();
console.log(fileType(chunk));
//=> {ext: 'gif', mime: 'image/gif'}
});
});
```
##### Browser
```js
const xhr = new XMLHttpRequest();
xhr.open('GET', 'unicorn.png');
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
fileType(new Uint8Array(this.response));
//=> {ext: 'png', mime: 'image/png'}
};
xhr.send();
```
## API
### fileType(buffer)
Returns an `Object` (or `null` when no match) with:
- `ext` - one of the [supported file types](#supported-file-types)
- `mime` - the [MIME type](http://en.wikipedia.org/wiki/Internet_media_type)
#### buffer
Type: `Buffer` `Uint8Array`
It only needs the first 262 bytes.
## Supported file types
- [`jpg`](https://en.wikipedia.org/wiki/JPEG)
- [`png`](https://en.wikipedia.org/wiki/Portable_Network_Graphics)
- [`gif`](https://en.wikipedia.org/wiki/GIF)
- [`webp`](https://en.wikipedia.org/wiki/WebP)
- [`flif`](https://en.wikipedia.org/wiki/Free_Lossless_Image_Format)
- [`cr2`](http://fileinfo.com/extension/cr2)
- [`tif`](https://en.wikipedia.org/wiki/Tagged_Image_File_Format)
- [`bmp`](https://en.wikipedia.org/wiki/BMP_file_format)
- [`jxr`](https://en.wikipedia.org/wiki/JPEG_XR)
- [`psd`](https://en.wikipedia.org/wiki/Adobe_Photoshop#File_format)
- [`zip`](https://en.wikipedia.org/wiki/Zip_(file_format))
- [`tar`](https://en.wikipedia.org/wiki/Tar_(computing)#File_format)
- [`rar`](https://en.wikipedia.org/wiki/RAR_(file_format))
- [`gz`](https://en.wikipedia.org/wiki/Gzip)
- [`bz2`](https://en.wikipedia.org/wiki/Bzip2)
- [`7z`](https://en.wikipedia.org/wiki/7z)
- [`dmg`](https://en.wikipedia.org/wiki/Apple_Disk_Image)
- [`mp4`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#Filename_extensions)
- [`m4v`](https://en.wikipedia.org/wiki/M4V)
- [`mid`](https://en.wikipedia.org/wiki/MIDI)
- [`mkv`](https://en.wikipedia.org/wiki/Matroska)
- [`webm`](https://en.wikipedia.org/wiki/WebM)
- [`mov`](https://en.wikipedia.org/wiki/QuickTime_File_Format)
- [`avi`](https://en.wikipedia.org/wiki/Audio_Video_Interleave)
- [`wmv`](https://en.wikipedia.org/wiki/Windows_Media_Video)
- [`mpg`](https://en.wikipedia.org/wiki/MPEG-1)
- [`mp3`](https://en.wikipedia.org/wiki/MP3)
- [`m4a`](https://en.wikipedia.org/wiki/MPEG-4_Part_14#.MP4_versus_.M4A)
- [`ogg`](https://en.wikipedia.org/wiki/Ogg)
- [`opus`](https://en.wikipedia.org/wiki/Opus_(audio_format))
- [`flac`](https://en.wikipedia.org/wiki/FLAC)
- [`wav`](https://en.wikipedia.org/wiki/WAV)
- [`amr`](https://en.wikipedia.org/wiki/Adaptive_Multi-Rate_audio_codec)
- [`pdf`](https://en.wikipedia.org/wiki/Portable_Document_Format)
- [`epub`](https://en.wikipedia.org/wiki/EPUB)
- [`exe`](https://en.wikipedia.org/wiki/.exe)
- [`swf`](https://en.wikipedia.org/wiki/SWF)
- [`rtf`](https://en.wikipedia.org/wiki/Rich_Text_Format)
- [`woff`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`woff2`](https://en.wikipedia.org/wiki/Web_Open_Font_Format)
- [`eot`](https://en.wikipedia.org/wiki/Embedded_OpenType)
- [`ttf`](https://en.wikipedia.org/wiki/TrueType)
- [`otf`](https://en.wikipedia.org/wiki/OpenType)
- [`ico`](https://en.wikipedia.org/wiki/ICO_(file_format))
- [`flv`](https://en.wikipedia.org/wiki/Flash_Video)
- [`ps`](https://en.wikipedia.org/wiki/Postscript)
- [`xz`](https://en.wikipedia.org/wiki/Xz)
- [`sqlite`](https://www.sqlite.org/fileformat2.html)
- [`nes`](http://fileinfo.com/extension/nes)
- [`crx`](https://developer.chrome.com/extensions/crx)
- [`xpi`](https://en.wikipedia.org/wiki/XPInstall)
- [`cab`](https://en.wikipedia.org/wiki/Cabinet_(file_format))
- [`deb`](https://en.wikipedia.org/wiki/Deb_(file_format))
- [`ar`](https://en.wikipedia.org/wiki/Ar_(Unix))
- [`rpm`](http://fileinfo.com/extension/rpm)
- [`Z`](http://fileinfo.com/extension/z)
- [`lz`](https://en.wikipedia.org/wiki/Lzip)
- [`msi`](https://en.wikipedia.org/wiki/Windows_Installer)
*SVG isn't included as it requires the whole file to be read, but you can get it [here](https://github.com/sindresorhus/is-svg).*
*PR welcome for additional commonly used file types.*
## Related
- [file-type-cli](https://github.com/sindresorhus/file-type-cli) - CLI for this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

View File

@ -1,74 +0,0 @@
{
"_from": "decompress-unzip@^4.0.1",
"_id": "decompress-unzip@4.0.1",
"_inBundle": false,
"_integrity": "sha1-3qrM39FK6vhVePczroIQ+bSEj2k=",
"_location": "/decompress-unzip",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress-unzip@^4.0.1",
"name": "decompress-unzip",
"escapedName": "decompress-unzip",
"rawSpec": "^4.0.1",
"saveSpec": null,
"fetchSpec": "^4.0.1"
},
"_requiredBy": [
"/decompress",
"/ffmpeg-binaries"
],
"_resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz",
"_shasum": "deaaccdfd14aeaf85578f733ae8210f9b4848f69",
"_spec": "decompress-unzip@^4.0.1",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\ffmpeg-binaries",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "https://github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress-unzip/issues"
},
"bundleDependencies": false,
"dependencies": {
"file-type": "^3.8.0",
"get-stream": "^2.2.0",
"pify": "^2.3.0",
"yauzl": "^2.4.2"
},
"deprecated": false,
"description": "decompress zip plugin",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress-unzip#readme",
"keywords": [
"decompress",
"decompressplugin",
"extract",
"zip"
],
"license": "MIT",
"name": "decompress-unzip",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress-unzip.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.0.1",
"xo": {
"esnext": true
}
}

View File

@ -1,42 +0,0 @@
# decompress-unzip [![Build Status](https://travis-ci.org/kevva/decompress-unzip.svg?branch=master)](https://travis-ci.org/kevva/decompress-unzip)
> zip decompress plugin
## Install
```
$ npm install --save decompress-unzip
```
## Usage
```js
const decompress = require('decompress');
const decompressUnzip = require('decompress-unzip');
decompress('unicorn.zip', 'dist', {
plugins: [
decompressUnzip()
]
}).then(() => {
console.log('Files decompressed');
});
```
## API
### decompressUnzip()(buf)
#### buf
Type: `Buffer`
Buffer to decompress.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

96
node_modules/decompress/index.js generated vendored
View File

@ -1,96 +0,0 @@
'use strict';
const path = require('path');
const fs = require('graceful-fs');
const decompressTar = require('decompress-tar');
const decompressTarbz2 = require('decompress-tarbz2');
const decompressTargz = require('decompress-targz');
const decompressUnzip = require('decompress-unzip');
const makeDir = require('make-dir');
const pify = require('pify');
const stripDirs = require('strip-dirs');
const fsP = pify(fs);
const runPlugins = (input, opts) => {
if (opts.plugins.length === 0) {
return Promise.resolve([]);
}
return Promise.all(opts.plugins.map(x => x(input, opts))).then(files => files.reduce((a, b) => a.concat(b)));
};
const extractFile = (input, output, opts) => runPlugins(input, opts).then(files => {
if (opts.strip > 0) {
files = files
.map(x => {
x.path = stripDirs(x.path, opts.strip);
return x;
})
.filter(x => x.path !== '.');
}
if (typeof opts.filter === 'function') {
files = files.filter(opts.filter);
}
if (typeof opts.map === 'function') {
files = files.map(opts.map);
}
if (!output) {
return files;
}
return Promise.all(files.map(x => {
const dest = path.join(output, x.path);
const mode = x.mode & ~process.umask();
const now = new Date();
if (x.type === 'directory') {
return makeDir(dest)
.then(() => fsP.utimes(dest, now, x.mtime))
.then(() => x);
}
return makeDir(path.dirname(dest))
.then(() => {
if (x.type === 'link') {
return fsP.link(x.linkname, dest);
}
if (x.type === 'symlink' && process.platform === 'win32') {
return fsP.link(x.linkname, dest);
}
if (x.type === 'symlink') {
return fsP.symlink(x.linkname, dest);
}
return fsP.writeFile(dest, x.data, {mode});
})
.then(() => x.type === 'file' && fsP.utimes(dest, now, x.mtime))
.then(() => x);
}));
});
module.exports = (input, output, opts) => {
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
return Promise.reject(new TypeError('Input file required'));
}
if (typeof output === 'object') {
opts = output;
output = null;
}
opts = Object.assign({plugins: [
decompressTar(),
decompressTarbz2(),
decompressTargz(),
decompressUnzip()
]}, opts);
const read = typeof input === 'string' ? fsP.readFile(input) : Promise.resolve(input);
return read.then(buf => extractFile(buf, output, opts));
};

21
node_modules/decompress/license generated vendored
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) Kevin Mårtensson <kevinmartensson@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

81
node_modules/decompress/package.json generated vendored
View File

@ -1,81 +0,0 @@
{
"_from": "decompress@^4.2.0",
"_id": "decompress@4.2.0",
"_inBundle": false,
"_integrity": "sha1-eu3YVCflqS2s/lVnSnxQXpbQH50=",
"_location": "/decompress",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "decompress@^4.2.0",
"name": "decompress",
"escapedName": "decompress",
"rawSpec": "^4.2.0",
"saveSpec": null,
"fetchSpec": "^4.2.0"
},
"_requiredBy": [
"/ffmpeg-binaries"
],
"_resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.0.tgz",
"_shasum": "7aedd85427e5a92dacfe55674a7c505e96d01f9d",
"_spec": "decompress@^4.2.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\ffmpeg-binaries",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"bugs": {
"url": "https://github.com/kevva/decompress/issues"
},
"bundleDependencies": false,
"dependencies": {
"decompress-tar": "^4.0.0",
"decompress-tarbz2": "^4.0.0",
"decompress-targz": "^4.0.0",
"decompress-unzip": "^4.0.1",
"graceful-fs": "^4.1.10",
"make-dir": "^1.0.0",
"pify": "^2.3.0",
"strip-dirs": "^2.0.0"
},
"deprecated": false,
"description": "Extracting archives made easy",
"devDependencies": {
"ava": "*",
"is-jpg": "^1.0.0",
"path-exists": "^3.0.0",
"pify": "^2.3.0",
"xo": "*"
},
"engines": {
"node": ">=4"
},
"files": [
"index.js"
],
"homepage": "https://github.com/kevva/decompress#readme",
"keywords": [
"bz2",
"bzip2",
"decompress",
"extract",
"tar",
"tar.bz",
"tar.gz",
"zip",
"unzip"
],
"license": "MIT",
"name": "decompress",
"repository": {
"type": "git",
"url": "git+https://github.com/kevva/decompress.git"
},
"scripts": {
"test": "xo && ava"
},
"version": "4.2.0"
}

103
node_modules/decompress/readme.md generated vendored
View File

@ -1,103 +0,0 @@
# decompress [![Build Status](https://travis-ci.org/kevva/decompress.svg?branch=master)](https://travis-ci.org/kevva/decompress)
> Extracting archives made easy
*See [decompress-cli](https://github.com/kevva/decompress-cli) for the command-line version.*
## Install
```
$ npm install --save decompress
```
## Usage
```js
const decompress = require('decompress');
decompress('unicorn.zip', 'dist').then(files => {
console.log('done!');
});
```
## API
### decompress(input, [output], [options])
Returns a Promise for an array of files in the following format:
```js
{
data: Buffer,
mode: Number,
mtime: String,
path: String,
type: String
}
```
#### input
Type: `string` `Buffer`
File to decompress.
#### output
Type: `string`
Output directory.
#### options
##### filter
Type: `Function`
Filter out files before extracting. E.g:
```js
decompress('unicorn.zip', 'dist', {
filter: file => path.extname(file.path) !== '.exe'
}).then(files => {
console.log('done!');
});
```
##### map
Type: `Function`
Map files before extracting: E.g:
```js
decompress('unicorn.zip', 'dist', {
map: file => {
file.path = `unicorn-${file.path}`;
return file;
}
}).then(files => {
console.log('done!');
});
```
##### plugins
Type: `Array`<br>
Default: `[decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()]`
Array of [plugins](https://www.npmjs.com/browse/keyword/decompressplugin) to use.
##### strip
Type: `number`<br>
Default: `0`
Remove leading directory components from extracted files.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

21
node_modules/end-of-stream/LICENSE generated vendored
View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Mathias Buus
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

52
node_modules/end-of-stream/README.md generated vendored
View File

@ -1,52 +0,0 @@
# end-of-stream
A node module that calls a callback when a readable/writable/duplex stream has completed or failed.
npm install end-of-stream
## Usage
Simply pass a stream and a callback to the `eos`.
Both legacy streams, streams2 and stream3 are supported.
``` js
var eos = require('end-of-stream');
eos(readableStream, function(err) {
// this will be set to the stream instance
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended', this === readableStream);
});
eos(writableStream, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has finished', this === writableStream);
});
eos(duplexStream, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended and finished', this === duplexStream);
});
eos(duplexStream, {readable:false}, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has finished but might still be readable');
});
eos(duplexStream, {writable:false}, function(err) {
if (err) return console.log('stream had an error or closed early');
console.log('stream has ended but might still be writable');
});
eos(readableStream, {error:false}, function(err) {
// do not treat emit('error', err) as a end-of-stream
});
```
## License
MIT
## Related
`end-of-stream` is part of the [mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one.

87
node_modules/end-of-stream/index.js generated vendored
View File

@ -1,87 +0,0 @@
var once = require('once');
var noop = function() {};
var isRequest = function(stream) {
return stream.setHeader && typeof stream.abort === 'function';
};
var isChildProcess = function(stream) {
return stream.stdio && Array.isArray(stream.stdio) && stream.stdio.length === 3
};
var eos = function(stream, opts, callback) {
if (typeof opts === 'function') return eos(stream, null, opts);
if (!opts) opts = {};
callback = once(callback || noop);
var ws = stream._writableState;
var rs = stream._readableState;
var readable = opts.readable || (opts.readable !== false && stream.readable);
var writable = opts.writable || (opts.writable !== false && stream.writable);
var onlegacyfinish = function() {
if (!stream.writable) onfinish();
};
var onfinish = function() {
writable = false;
if (!readable) callback.call(stream);
};
var onend = function() {
readable = false;
if (!writable) callback.call(stream);
};
var onexit = function(exitCode) {
callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null);
};
var onerror = function(err) {
callback.call(stream, err);
};
var onclose = function() {
if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close'));
if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close'));
};
var onrequest = function() {
stream.req.on('finish', onfinish);
};
if (isRequest(stream)) {
stream.on('complete', onfinish);
stream.on('abort', onclose);
if (stream.req) onrequest();
else stream.on('request', onrequest);
} else if (writable && !ws) { // legacy streams
stream.on('end', onlegacyfinish);
stream.on('close', onlegacyfinish);
}
if (isChildProcess(stream)) stream.on('exit', onexit);
stream.on('end', onend);
stream.on('finish', onfinish);
if (opts.error !== false) stream.on('error', onerror);
stream.on('close', onclose);
return function() {
stream.removeListener('complete', onfinish);
stream.removeListener('abort', onclose);
stream.removeListener('request', onrequest);
if (stream.req) stream.req.removeListener('finish', onfinish);
stream.removeListener('end', onlegacyfinish);
stream.removeListener('close', onlegacyfinish);
stream.removeListener('finish', onfinish);
stream.removeListener('exit', onexit);
stream.removeListener('end', onend);
stream.removeListener('error', onerror);
stream.removeListener('close', onclose);
};
};
module.exports = eos;

View File

@ -1,62 +0,0 @@
{
"_from": "end-of-stream@^1.0.0",
"_id": "end-of-stream@1.4.1",
"_inBundle": false,
"_integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
"_location": "/end-of-stream",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "end-of-stream@^1.0.0",
"name": "end-of-stream",
"escapedName": "end-of-stream",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/tar-stream"
],
"_resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
"_shasum": "ed29634d19baba463b6ce6b80a37213eab71ec43",
"_spec": "end-of-stream@^1.0.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\tar-stream",
"author": {
"name": "Mathias Buus",
"email": "mathiasbuus@gmail.com"
},
"bugs": {
"url": "https://github.com/mafintosh/end-of-stream/issues"
},
"bundleDependencies": false,
"dependencies": {
"once": "^1.4.0"
},
"deprecated": false,
"description": "Call a callback when a readable/writable/duplex stream has completed or failed.",
"files": [
"index.js"
],
"homepage": "https://github.com/mafintosh/end-of-stream",
"keywords": [
"stream",
"streams",
"callback",
"finish",
"close",
"end",
"wait"
],
"license": "MIT",
"main": "index.js",
"name": "end-of-stream",
"repository": {
"type": "git",
"url": "git://github.com/mafintosh/end-of-stream.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.4.1"
}

2
node_modules/fd-slicer/.npmignore generated vendored
View File

@ -1,2 +0,0 @@
/coverage
/node_modules

7
node_modules/fd-slicer/.travis.yml generated vendored
View File

@ -1,7 +0,0 @@
language: node_js
node_js:
- "0.10"
script:
- "npm run test-travis"
after_script:
- "npm install coveralls@2 && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"

49
node_modules/fd-slicer/CHANGELOG.md generated vendored
View File

@ -1,49 +0,0 @@
### 1.0.1
* use `setImmediate` instead of `nextTick`
### 1.0.0
* `new FdSlicer(fd, options)` must now be `fdSlicer.createFromFd(fd, options)`
* fix behavior when `end` is 0.
* fix `createWriteStream` when using `createFromBuffer`
### 0.4.0
* add ability to create an FdSlicer instance from a Buffer
### 0.3.2
* fix write stream and read stream destroy behavior
### 0.3.1
* write stream: fix end option behavior
### 0.3.0
* write stream emits 'progress' events
* write stream supports 'end' option which causes the stream to emit an error
if a maximum size is exceeded
* improve documentation
### 0.2.1
* Update pend dependency to latest bugfix version.
### 0.2.0
* Add read and write functions
### 0.1.0
* Add `autoClose` option and `ref()` and `unref()`.
### 0.0.2
* Add API documentation
* read stream: create buffer at last possible moment
### 0.0.1
* Initial release

21
node_modules/fd-slicer/LICENSE generated vendored
View File

@ -1,21 +0,0 @@
Copyright (c) 2014 Andrew Kelley
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

199
node_modules/fd-slicer/README.md generated vendored
View File

@ -1,199 +0,0 @@
# fd-slicer
[![Build Status](https://travis-ci.org/andrewrk/node-fd-slicer.svg?branch=master)](https://travis-ci.org/andrewrk/node-fd-slicer)
Safe `fs.ReadStream` and `fs.WriteStream` using the same fd.
Let's say that you want to perform a parallel upload of a file to a remote
server. To do this, we want to create multiple read streams. The first thing
you might think of is to use the `{start: 0, end: 0}` API of
`fs.createReadStream`. This gives you two choices:
0. Use the same file descriptor for all `fs.ReadStream` objects.
0. Open the file multiple times, resulting in a separate file descriptor
for each read stream.
Neither of these are acceptable options. The first one is a severe bug,
because the API docs for `fs.write` state:
> Note that it is unsafe to use `fs.write` multiple times on the same file
> without waiting for the callback. For this scenario, `fs.createWriteStream`
> is strongly recommended.
`fs.createWriteStream` will solve the problem if you only create one of them
for the file descriptor, but it will exhibit this unsafety if you create
multiple write streams per file descriptor.
The second option suffers from a race condition. For each additional time the
file is opened after the first, it is possible that the file is modified. So
in our parallel uploading example, we might upload a corrupt file that never
existed on the client's computer.
This module solves this problem by providing `createReadStream` and
`createWriteStream` that operate on a shared file descriptor and provides
the convenient stream API while still allowing slicing and dicing.
This module also gives you some additional power that the builtin
`fs.createWriteStream` do not give you. These features are:
* Emitting a 'progress' event on write.
* Ability to set a maximum size and emit an error if this size is exceeded.
* Ability to create an `FdSlicer` instance from a `Buffer`. This enables you
to provide API for handling files as well as buffers using the same API.
## Usage
```js
var fdSlicer = require('fd-slicer');
var fs = require('fs');
fs.open("file.txt", 'r', function(err, fd) {
if (err) throw err;
var slicer = fdSlicer.createFromFd(fd);
var firstPart = slicer.createReadStream({start: 0, end: 100});
var secondPart = slicer.createReadStream({start: 100});
var firstOut = fs.createWriteStream("first.txt");
var secondOut = fs.createWriteStream("second.txt");
firstPart.pipe(firstOut);
secondPart.pipe(secondOut);
});
```
You can also create from a buffer:
```js
var fdSlicer = require('fd-slicer');
var slicer = FdSlicer.createFromBuffer(someBuffer);
var firstPart = slicer.createReadStream({start: 0, end: 100});
var secondPart = slicer.createReadStream({start: 100});
var firstOut = fs.createWriteStream("first.txt");
var secondOut = fs.createWriteStream("second.txt");
firstPart.pipe(firstOut);
secondPart.pipe(secondOut);
```
## API Documentation
### fdSlicer.createFromFd(fd, [options])
```js
var fdSlicer = require('fd-slicer');
fs.open("file.txt", 'r', function(err, fd) {
if (err) throw err;
var slicer = fdSlicer.createFromFd(fd);
// ...
});
```
Make sure `fd` is a properly initialized file descriptor. If you want to
use `createReadStream` make sure you open it for reading and if you want
to use `createWriteStream` make sure you open it for writing.
`options` is an optional object which can contain:
* `autoClose` - if set to `true`, the file descriptor will be automatically
closed once the last stream that references it is closed. Defaults to
`false`. `ref()` and `unref()` can be used to increase or decrease the
reference count, respectively.
### fdSlicer.createFromBuffer(buffer, [options])
```js
var fdSlicer = require('fd-slicer');
var slicer = fdSlicer.createFromBuffer(someBuffer);
// ...
```
`options` is an optional object which can contain:
* `maxChunkSize` - A `Number` of bytes. see `createReadStream()`.
If falsey, defaults to unlimited.
#### Properties
##### fd
The file descriptor passed in. `undefined` if created from a buffer.
#### Methods
##### createReadStream(options)
Available `options`:
* `start` - Number. The offset into the file to start reading from. Defaults
to 0.
* `end` - Number. Exclusive upper bound offset into the file to stop reading
from.
* `highWaterMark` - Number. The maximum number of bytes to store in the
internal buffer before ceasing to read from the underlying resource.
Defaults to 16 KB.
* `encoding` - String. If specified, then buffers will be decoded to strings
using the specified encoding. Defaults to `null`.
The ReadableStream that this returns has these additional methods:
* `destroy(err)` - stop streaming. `err` is optional and is the error that
will be emitted in order to cause the streaming to stop. Defaults to
`new Error("stream destroyed")`.
If `maxChunkSize` was specified (see `createFromBuffer()`), the read stream
will provide chunks of at most that size. Normally, the read stream provides
the entire range requested in a single chunk, but this can cause performance
problems in some circumstances.
See [thejoshwolfe/yauzl#87](https://github.com/thejoshwolfe/yauzl/issues/87).
##### createWriteStream(options)
Available `options`:
* `start` - Number. The offset into the file to start writing to. Defaults to
0.
* `end` - Number. Exclusive upper bound offset into the file. If this offset
is reached, the write stream will emit an 'error' event and stop functioning.
In this situation, `err.code === 'ETOOBIG'`. Defaults to `Infinity`.
* `highWaterMark` - Number. Buffer level when `write()` starts returning
false. Defaults to 16KB.
* `decodeStrings` - Boolean. Whether or not to decode strings into Buffers
before passing them to` _write()`. Defaults to `true`.
The WritableStream that this returns has these additional methods:
* `destroy()` - stop streaming
And these additional properties:
* `bytesWritten` - number of bytes written to the stream
And these additional events:
* 'progress' - emitted when `bytesWritten` changes.
##### read(buffer, offset, length, position, callback)
Equivalent to `fs.read`, but with concurrency protection.
`callback` must be defined.
##### write(buffer, offset, length, position, callback)
Equivalent to `fs.write`, but with concurrency protection.
`callback` must be defined.
##### ref()
Increase the `autoClose` reference count by 1.
##### unref()
Decrease the `autoClose` reference count by 1.
#### Events
##### 'error'
Emitted if `fs.close` returns an error when auto closing.
##### 'close'
Emitted when fd-slicer closes the file descriptor due to `autoClose`. Never
emitted if created from a buffer.

296
node_modules/fd-slicer/index.js generated vendored
View File

@ -1,296 +0,0 @@
var fs = require('fs');
var util = require('util');
var stream = require('stream');
var Readable = stream.Readable;
var Writable = stream.Writable;
var PassThrough = stream.PassThrough;
var Pend = require('pend');
var EventEmitter = require('events').EventEmitter;
exports.createFromBuffer = createFromBuffer;
exports.createFromFd = createFromFd;
exports.BufferSlicer = BufferSlicer;
exports.FdSlicer = FdSlicer;
util.inherits(FdSlicer, EventEmitter);
function FdSlicer(fd, options) {
options = options || {};
EventEmitter.call(this);
this.fd = fd;
this.pend = new Pend();
this.pend.max = 1;
this.refCount = 0;
this.autoClose = !!options.autoClose;
}
FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
var self = this;
self.pend.go(function(cb) {
fs.read(self.fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
cb();
callback(err, bytesRead, buffer);
});
});
};
FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
var self = this;
self.pend.go(function(cb) {
fs.write(self.fd, buffer, offset, length, position, function(err, written, buffer) {
cb();
callback(err, written, buffer);
});
});
};
FdSlicer.prototype.createReadStream = function(options) {
return new ReadStream(this, options);
};
FdSlicer.prototype.createWriteStream = function(options) {
return new WriteStream(this, options);
};
FdSlicer.prototype.ref = function() {
this.refCount += 1;
};
FdSlicer.prototype.unref = function() {
var self = this;
self.refCount -= 1;
if (self.refCount > 0) return;
if (self.refCount < 0) throw new Error("invalid unref");
if (self.autoClose) {
fs.close(self.fd, onCloseDone);
}
function onCloseDone(err) {
if (err) {
self.emit('error', err);
} else {
self.emit('close');
}
}
};
util.inherits(ReadStream, Readable);
function ReadStream(context, options) {
options = options || {};
Readable.call(this, options);
this.context = context;
this.context.ref();
this.start = options.start || 0;
this.endOffset = options.end;
this.pos = this.start;
this.destroyed = false;
}
ReadStream.prototype._read = function(n) {
var self = this;
if (self.destroyed) return;
var toRead = Math.min(self._readableState.highWaterMark, n);
if (self.endOffset != null) {
toRead = Math.min(toRead, self.endOffset - self.pos);
}
if (toRead <= 0) {
self.destroyed = true;
self.push(null);
self.context.unref();
return;
}
self.context.pend.go(function(cb) {
if (self.destroyed) return cb();
var buffer = new Buffer(toRead);
fs.read(self.context.fd, buffer, 0, toRead, self.pos, function(err, bytesRead) {
if (err) {
self.destroy(err);
} else if (bytesRead === 0) {
self.destroyed = true;
self.push(null);
self.context.unref();
} else {
self.pos += bytesRead;
self.push(buffer.slice(0, bytesRead));
}
cb();
});
});
};
ReadStream.prototype.destroy = function(err) {
if (this.destroyed) return;
err = err || new Error("stream destroyed");
this.destroyed = true;
this.emit('error', err);
this.context.unref();
};
util.inherits(WriteStream, Writable);
function WriteStream(context, options) {
options = options || {};
Writable.call(this, options);
this.context = context;
this.context.ref();
this.start = options.start || 0;
this.endOffset = (options.end == null) ? Infinity : +options.end;
this.bytesWritten = 0;
this.pos = this.start;
this.destroyed = false;
this.on('finish', this.destroy.bind(this));
}
WriteStream.prototype._write = function(buffer, encoding, callback) {
var self = this;
if (self.destroyed) return;
if (self.pos + buffer.length > self.endOffset) {
var err = new Error("maximum file length exceeded");
err.code = 'ETOOBIG';
self.destroy();
callback(err);
return;
}
self.context.pend.go(function(cb) {
if (self.destroyed) return cb();
fs.write(self.context.fd, buffer, 0, buffer.length, self.pos, function(err, bytes) {
if (err) {
self.destroy();
cb();
callback(err);
} else {
self.bytesWritten += bytes;
self.pos += bytes;
self.emit('progress');
cb();
callback();
}
});
});
};
WriteStream.prototype.destroy = function() {
if (this.destroyed) return;
this.destroyed = true;
this.context.unref();
};
util.inherits(BufferSlicer, EventEmitter);
function BufferSlicer(buffer, options) {
EventEmitter.call(this);
options = options || {};
this.refCount = 0;
this.buffer = buffer;
this.maxChunkSize = options.maxChunkSize || Number.MAX_SAFE_INTEGER;
}
BufferSlicer.prototype.read = function(buffer, offset, length, position, callback) {
var end = position + length;
var delta = end - this.buffer.length;
var written = (delta > 0) ? delta : length;
this.buffer.copy(buffer, offset, position, end);
setImmediate(function() {
callback(null, written);
});
};
BufferSlicer.prototype.write = function(buffer, offset, length, position, callback) {
buffer.copy(this.buffer, position, offset, offset + length);
setImmediate(function() {
callback(null, length, buffer);
});
};
BufferSlicer.prototype.createReadStream = function(options) {
options = options || {};
var readStream = new PassThrough(options);
readStream.destroyed = false;
readStream.start = options.start || 0;
readStream.endOffset = options.end;
// by the time this function returns, we'll be done.
readStream.pos = readStream.endOffset || this.buffer.length;
// respect the maxChunkSize option to slice up the chunk into smaller pieces.
var entireSlice = this.buffer.slice(readStream.start, readStream.pos);
var offset = 0;
while (true) {
var nextOffset = offset + this.maxChunkSize;
if (nextOffset >= entireSlice.length) {
// last chunk
if (offset < entireSlice.length) {
readStream.write(entireSlice.slice(offset, entireSlice.length));
}
break;
}
readStream.write(entireSlice.slice(offset, nextOffset));
offset = nextOffset;
}
readStream.end();
readStream.destroy = function() {
readStream.destroyed = true;
};
return readStream;
};
BufferSlicer.prototype.createWriteStream = function(options) {
var bufferSlicer = this;
options = options || {};
var writeStream = new Writable(options);
writeStream.start = options.start || 0;
writeStream.endOffset = (options.end == null) ? this.buffer.length : +options.end;
writeStream.bytesWritten = 0;
writeStream.pos = writeStream.start;
writeStream.destroyed = false;
writeStream._write = function(buffer, encoding, callback) {
if (writeStream.destroyed) return;
var end = writeStream.pos + buffer.length;
if (end > writeStream.endOffset) {
var err = new Error("maximum file length exceeded");
err.code = 'ETOOBIG';
writeStream.destroyed = true;
callback(err);
return;
}
buffer.copy(bufferSlicer.buffer, writeStream.pos, 0, buffer.length);
writeStream.bytesWritten += buffer.length;
writeStream.pos = end;
writeStream.emit('progress');
callback();
};
writeStream.destroy = function() {
writeStream.destroyed = true;
};
return writeStream;
};
BufferSlicer.prototype.ref = function() {
this.refCount += 1;
};
BufferSlicer.prototype.unref = function() {
this.refCount -= 1;
if (this.refCount < 0) {
throw new Error("invalid unref");
}
};
function createFromBuffer(buffer, options) {
return new BufferSlicer(buffer, options);
}
function createFromFd(fd, options) {
return new FdSlicer(fd, options);
}

65
node_modules/fd-slicer/package.json generated vendored
View File

@ -1,65 +0,0 @@
{
"_from": "fd-slicer@~1.1.0",
"_id": "fd-slicer@1.1.0",
"_inBundle": false,
"_integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"_location": "/fd-slicer",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "fd-slicer@~1.1.0",
"name": "fd-slicer",
"escapedName": "fd-slicer",
"rawSpec": "~1.1.0",
"saveSpec": null,
"fetchSpec": "~1.1.0"
},
"_requiredBy": [
"/yauzl"
],
"_resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"_shasum": "25c7c89cb1f9077f8891bbe61d8f390eae256f1e",
"_spec": "fd-slicer@~1.1.0",
"_where": "C:\\Users\\matia\\Musix\\node_modules\\yauzl",
"author": {
"name": "Andrew Kelley",
"email": "superjoe30@gmail.com"
},
"bugs": {
"url": "https://github.com/andrewrk/node-fd-slicer/issues"
},
"bundleDependencies": false,
"dependencies": {
"pend": "~1.2.0"
},
"deprecated": false,
"description": "safely create multiple ReadStream or WriteStream objects from the same file descriptor",
"devDependencies": {
"istanbul": "~0.3.3",
"mocha": "~2.0.1",
"stream-equal": "~0.1.5",
"streamsink": "~1.2.0"
},
"directories": {
"test": "test"
},
"homepage": "https://github.com/andrewrk/node-fd-slicer#readme",
"keywords": [
"createReadStream",
"createWriteStream"
],
"license": "MIT",
"main": "index.js",
"name": "fd-slicer",
"repository": {
"type": "git",
"url": "git://github.com/andrewrk/node-fd-slicer.git"
},
"scripts": {
"test": "mocha --reporter spec --check-leaks",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/test.js",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --timeout 10000 --reporter spec --check-leaks test/test.js"
},
"version": "1.1.0"
}

350
node_modules/fd-slicer/test/test.js generated vendored
View File

@ -1,350 +0,0 @@
var fdSlicer = require('../');
var fs = require('fs');
var crypto = require('crypto');
var path = require('path');
var streamEqual = require('stream-equal');
var assert = require('assert');
var Pend = require('pend');
var StreamSink = require('streamsink');
var describe = global.describe;
var it = global.it;
var before = global.before;
var beforeEach = global.beforeEach;
var after = global.after;
var testBlobFile = path.join(__dirname, "test-blob.bin");
var testBlobFileSize = 20 * 1024 * 1024;
var testOutBlobFile = path.join(__dirname, "test-blob-out.bin");
describe("FdSlicer", function() {
before(function(done) {
var out = fs.createWriteStream(testBlobFile);
for (var i = 0; i < testBlobFileSize / 1024; i += 1) {
out.write(crypto.pseudoRandomBytes(1024));
}
out.end();
out.on('close', done);
});
beforeEach(function() {
try {
fs.unlinkSync(testOutBlobFile);
} catch (err) {
}
});
after(function() {
try {
fs.unlinkSync(testBlobFile);
fs.unlinkSync(testOutBlobFile);
} catch (err) {
}
});
it("reads a 20MB file (autoClose on)", function(done) {
fs.open(testBlobFile, 'r', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var actualStream = slicer.createReadStream();
var expectedStream = fs.createReadStream(testBlobFile);
var pend = new Pend();
pend.go(function(cb) {
slicer.on('close', cb);
});
pend.go(function(cb) {
streamEqual(expectedStream, actualStream, function(err, equal) {
if (err) return done(err);
assert.ok(equal);
cb();
});
});
pend.wait(done);
});
});
it("reads 4 chunks simultaneously", function(done) {
fs.open(testBlobFile, 'r', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd);
var actualPart1 = slicer.createReadStream({start: testBlobFileSize * 0/4, end: testBlobFileSize * 1/4});
var actualPart2 = slicer.createReadStream({start: testBlobFileSize * 1/4, end: testBlobFileSize * 2/4});
var actualPart3 = slicer.createReadStream({start: testBlobFileSize * 2/4, end: testBlobFileSize * 3/4});
var actualPart4 = slicer.createReadStream({start: testBlobFileSize * 3/4, end: testBlobFileSize * 4/4});
var expectedPart1 = slicer.createReadStream({start: testBlobFileSize * 0/4, end: testBlobFileSize * 1/4});
var expectedPart2 = slicer.createReadStream({start: testBlobFileSize * 1/4, end: testBlobFileSize * 2/4});
var expectedPart3 = slicer.createReadStream({start: testBlobFileSize * 2/4, end: testBlobFileSize * 3/4});
var expectedPart4 = slicer.createReadStream({start: testBlobFileSize * 3/4, end: testBlobFileSize * 4/4});
var pend = new Pend();
pend.go(function(cb) {
streamEqual(expectedPart1, actualPart1, function(err, equal) {
assert.ok(equal);
cb(err);
});
});
pend.go(function(cb) {
streamEqual(expectedPart2, actualPart2, function(err, equal) {
assert.ok(equal);
cb(err);
});
});
pend.go(function(cb) {
streamEqual(expectedPart3, actualPart3, function(err, equal) {
assert.ok(equal);
cb(err);
});
});
pend.go(function(cb) {
streamEqual(expectedPart4, actualPart4, function(err, equal) {
assert.ok(equal);
cb(err);
});
});
pend.wait(function(err) {
if (err) return done(err);
fs.close(fd, done);
});
});
});
it("writes a 20MB file (autoClose on)", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var actualStream = slicer.createWriteStream();
var inStream = fs.createReadStream(testBlobFile);
slicer.on('close', function() {
var expected = fs.createReadStream(testBlobFile);
var actual = fs.createReadStream(testOutBlobFile);
streamEqual(expected, actual, function(err, equal) {
if (err) return done(err);
assert.ok(equal);
done();
});
});
inStream.pipe(actualStream);
});
});
it("writes 4 chunks simultaneously", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd);
var actualPart1 = slicer.createWriteStream({start: testBlobFileSize * 0/4});
var actualPart2 = slicer.createWriteStream({start: testBlobFileSize * 1/4});
var actualPart3 = slicer.createWriteStream({start: testBlobFileSize * 2/4});
var actualPart4 = slicer.createWriteStream({start: testBlobFileSize * 3/4});
var in1 = fs.createReadStream(testBlobFile, {start: testBlobFileSize * 0/4, end: testBlobFileSize * 1/4});
var in2 = fs.createReadStream(testBlobFile, {start: testBlobFileSize * 1/4, end: testBlobFileSize * 2/4});
var in3 = fs.createReadStream(testBlobFile, {start: testBlobFileSize * 2/4, end: testBlobFileSize * 3/4});
var in4 = fs.createReadStream(testBlobFile, {start: testBlobFileSize * 3/4, end: testBlobFileSize * 4/4});
var pend = new Pend();
pend.go(function(cb) {
actualPart1.on('finish', cb);
});
pend.go(function(cb) {
actualPart2.on('finish', cb);
});
pend.go(function(cb) {
actualPart3.on('finish', cb);
});
pend.go(function(cb) {
actualPart4.on('finish', cb);
});
in1.pipe(actualPart1);
in2.pipe(actualPart2);
in3.pipe(actualPart3);
in4.pipe(actualPart4);
pend.wait(function() {
fs.close(fd, function(err) {
if (err) return done(err);
var expected = fs.createReadStream(testBlobFile);
var actual = fs.createReadStream(testOutBlobFile);
streamEqual(expected, actual, function(err, equal) {
if (err) return done(err);
assert.ok(equal);
done();
});
});
});
});
});
it("throws on invalid ref", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
assert.throws(function() {
slicer.unref();
}, /invalid unref/);
fs.close(fd, done);
});
});
it("write stream emits error when max size exceeded", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var ws = slicer.createWriteStream({start: 0, end: 1000});
ws.on('error', function(err) {
assert.strictEqual(err.code, 'ETOOBIG');
slicer.on('close', done);
});
ws.end(new Buffer(1001));
});
});
it("write stream does not emit error when max size not exceeded", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var ws = slicer.createWriteStream({end: 1000});
slicer.on('close', done);
ws.end(new Buffer(1000));
});
});
it("write stream start and end work together", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var ws = slicer.createWriteStream({start: 1, end: 1000});
ws.on('error', function(err) {
assert.strictEqual(err.code, 'ETOOBIG');
slicer.on('close', done);
});
ws.end(new Buffer(1000));
});
});
it("write stream emits progress events", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var ws = slicer.createWriteStream();
var progressEventCount = 0;
var prevBytesWritten = 0;
ws.on('progress', function() {
progressEventCount += 1;
assert.ok(ws.bytesWritten > prevBytesWritten);
prevBytesWritten = ws.bytesWritten;
});
slicer.on('close', function() {
assert.ok(progressEventCount > 5);
done();
});
for (var i = 0; i < 10; i += 1) {
ws.write(new Buffer(16 * 1024 * 2));
}
ws.end();
});
});
it("write stream unrefs when destroyed", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var ws = slicer.createWriteStream();
slicer.on('close', done);
ws.write(new Buffer(1000));
ws.destroy();
});
});
it("read stream unrefs when destroyed", function(done) {
fs.open(testBlobFile, 'r', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd, {autoClose: true});
var rs = slicer.createReadStream();
rs.on('error', function(err) {
assert.strictEqual(err.message, "stream destroyed");
slicer.on('close', done);
});
rs.destroy();
});
});
it("fdSlicer.read", function(done) {
fs.open(testBlobFile, 'r', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd);
var outBuf = new Buffer(1024);
slicer.read(outBuf, 0, 10, 0, function(err, bytesRead, buf) {
assert.strictEqual(bytesRead, 10);
fs.close(fd, done);
});
});
});
it("fdSlicer.write", function(done) {
fs.open(testOutBlobFile, 'w', function(err, fd) {
if (err) return done(err);
var slicer = fdSlicer.createFromFd(fd);
slicer.write(new Buffer("blah\n"), 0, 5, 0, function() {
if (err) return done(err);
fs.close(fd, done);
});
});
});
});
describe("BufferSlicer", function() {
it("invalid ref", function() {
var slicer = fdSlicer.createFromBuffer(new Buffer(16));
slicer.ref();
slicer.unref();
assert.throws(function() {
slicer.unref();
}, /invalid unref/);
});
it("read and write", function(done) {
var buf = new Buffer("through the tangled thread the needle finds its way");
var slicer = fdSlicer.createFromBuffer(buf);
var outBuf = new Buffer(1024);
slicer.read(outBuf, 10, 11, 8, function(err) {
if (err) return done(err);
assert.strictEqual(outBuf.toString('utf8', 10, 21), "the tangled");
slicer.write(new Buffer("derp"), 0, 4, 7, function(err) {
if (err) return done(err);
assert.strictEqual(buf.toString('utf8', 7, 19), "derp tangled");
done();
});
});
});
it("createReadStream", function(done) {
var str = "I never conquered rarely came, 16 just held such better days";
var buf = new Buffer(str);
var slicer = fdSlicer.createFromBuffer(buf);
var inStream = slicer.createReadStream();
var sink = new StreamSink();
inStream.pipe(sink);
sink.on('finish', function() {
assert.strictEqual(sink.toString(), str);
inStream.destroy();
done();
});
});
it("createWriteStream exceed buffer size", function(done) {
var slicer = fdSlicer.createFromBuffer(new Buffer(4));
var outStream = slicer.createWriteStream();
outStream.on('error', function(err) {
assert.strictEqual(err.code, 'ETOOBIG');
done();
});
outStream.write("hi!\n");
outStream.write("it warked\n");
outStream.end();
});
it("createWriteStream ok", function(done) {
var buf = new Buffer(1024);
var slicer = fdSlicer.createFromBuffer(buf);
var outStream = slicer.createWriteStream();
outStream.on('finish', function() {
assert.strictEqual(buf.toString('utf8', 0, "hi!\nit warked\n".length), "hi!\nit warked\n");
outStream.destroy();
done();
});
outStream.write("hi!\n");
outStream.write("it warked\n");
outStream.end();
});
});

21
node_modules/ffmpeg-binaries/LICENSE generated vendored
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2018 Zachary Vacura
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,17 +0,0 @@
# node-ffmpeg-binaries
A platform indepindependent installer of [FFmpeg](https://ffmpeg.org/)
Supported architectures:
Linux | Windows | Mac
----- | ------- | ---
x64 | x64 | x64
ia32 | ia32 |
arm | |
arm64 | |
## API
`node-ffmpeg-binaries` exports a string containing the path to the FFmpeg executable.
This software uses code of <a href=http://ffmpeg.org>FFmpeg</a> licensed under the <a href=http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>LGPLv2.1</a> and its source can be downloaded [here](ffmpeg)

Binary file not shown.

View File

@ -1,3 +0,0 @@
const { join } = require('path');
module.exports = join(__dirname, 'bin', `ffmpeg${process.platform === 'win32' ? '.exe' : ''}`);

View File

@ -1,81 +0,0 @@
const { get } = require('https');
const { cursorTo } = require('readline');
const decompress = require('decompress');
const tarxz = require('decompress-tarxz');
const unzip = require('decompress-unzip');
function callback(res) {
let last;
let complete = 0;
const total = parseInt(res.headers['content-length'], 10);
let index = 0;
const buf = Buffer.alloc(total);
res.on('data', (chunk) => {
chunk.copy(buf, index);
index += chunk.length;
complete += chunk.length;
const progress = Math.round((complete / total) * 20);
if (progress !== last) {
cursorTo(process.stdout, 0, null);
process.stdout.write(`Downloading binary: [${'='.repeat(progress)}${[' '.repeat(20 - progress)]}] ${Math.round((complete / total) * 100)}%`);
last = progress;
}
});
res.on('end', () => {
cursorTo(process.stdout, 0, null);
console.log(`Downloading binary: [${'='.repeat(20)}] 100%`);
decompress(buf, 'bin', {
plugins: process.platform === 'linux' ? [tarxz()] : [unzip()],
strip: process.platform === 'linux' ? 1 : 2,
filter: x => x.path === (process.platform === 'win32' ? 'ffmpeg.exe' : 'ffmpeg'),
});
});
}
if (process.platform === 'win32') {
switch (process.arch) {
case 'x64':
get('https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-latest-win64-static.zip', callback);
break;
case 'ia32':
get('https://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-latest-win32-static.zip', callback);
break;
default:
throw new Error('unsupported platform');
}
} else if (process.platform === 'linux') {
switch (process.arch) {
case 'x64':
get('https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-64bit-static.tar.xz', callback);
break;
case 'ia32':
get('https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-32bit-static.tar.xz', callback);
break;
case 'arm':
get('https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-32bit-static.tar.xz', callback);
break;
case 'arm64':
get('https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-64bit-static.tar.xz', callback);
break;
default:
throw new Error('unsupported platform');
}
} else if (process.platform === 'darwin') {
switch (process.arch) {
case 'x64':
get('https://ffmpeg.zeranoe.com/builds/macos64/static/ffmpeg-latest-macos64-static.zip', callback);
break;
default:
throw new Error('unsupported platform');
}
} else {
throw new Error('unsupported platform');
}

View File

@ -1,71 +0,0 @@
{
"_from": "ffmpeg-binaries",
"_id": "ffmpeg-binaries@4.0.0",
"_inBundle": false,
"_integrity": "sha512-a4ceKPIB51x7pHEK3BEOoCMgOUOm51MKi8UEOocfDOpN9aHgtTEDGo8SgLRhrRVllNnpNmW9AjkXeySvmeoU1w==",
"_location": "/ffmpeg-binaries",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "ffmpeg-binaries",
"name": "ffmpeg-binaries",
"escapedName": "ffmpeg-binaries",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/ffmpeg-binaries/-/ffmpeg-binaries-4.0.0.tgz",
"_shasum": "698fa082c0512b1b083a1298e3fab4e41feeede3",
"_spec": "ffmpeg-binaries",
"_where": "C:\\Users\\matia\\Musix",
"author": {
"name": "Hackzzila",
"email": "zach@hackzzila.com"
},
"bugs": {
"url": "https://github.com/Hackzzila/node-ffmpeg-binaries/issues"
},
"bundleDependencies": false,
"dependencies": {
"decompress": "^4.2.0",
"decompress-tarxz": "^2.1.1",
"decompress-unzip": "^4.0.1"
},
"deprecated": false,
"description": "ffmpeg binaries",
"devDependencies": {
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-plugin-import": "^2.10.0"
},
"eslintConfig": {
"extends": "airbnb-base"
},
"homepage": "https://github.com/Hackzzila/node-ffmpeg-binaries#readme",
"keywords": [
"ffmpeg",
"binaries"
],
"license": "MIT",
"main": "index.js",
"name": "ffmpeg-binaries",
"os": [
"win32",
"linux",
"darwin"
],
"repository": {
"type": "git",
"url": "git+https://github.com/Hackzzila/node-ffmpeg-binaries.git"
},
"scripts": {
"install": "node install",
"test": "eslint *.js"
},
"version": "4.0.0"
}

Some files were not shown because too many files have changed in this diff Show More