mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-13 02:20:18 +00:00
2 lines
109 KiB
JavaScript
2 lines
109 KiB
JavaScript
|
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.unbzip2Stream=f()}})(function(){var define,module,exports;return function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){(function(Buffer){var through=require("through");var bz2=require("./lib/bzip2");var bitIterator=require("./lib/bit_iterator");module.exports=unbzip2Stream;function unbzip2Stream(){var bufferQueue=[];var hasBytes=0;var blockSize=0;var broken=false;var done=false;var bitReader=null;var streamCRC=null;function decompressBlock(push){if(!blockSize){blockSize=bz2.header(bitReader);return true}else{var bufsize=1e5*blockSize;var buf=new Int32Array(bufsize);var chunk=[];var f=function(b){chunk.push(b)};streamCRC=bz2.decompress(bitReader,f,buf,bufsize,streamCRC);if(streamCRC===null){blockSize=0;return false}else{push(Buffer.from(chunk));return true}}}var outlength=0;function decompressAndQueue(stream){if(broken)return;try{return decompressBlock(function(d){stream.queue(d);if(d!==null){outlength+=d.length}else{}})}catch(e){stream.emit("error",e);broken=true;return false}}return through(function write(data){bufferQueue.push(data);hasBytes+=data.length;if(bitReader===null){bitReader=bitIterator(function(){return bufferQueue.shift()})}while(!broken&&hasBytes-bitReader.bytesRead+1>=(25e3+1e5*blockSize||4)){decompressAndQueue(this)}},function end(x){while(!broken&&hasBytes>bitReader.bytesRead){decompressAndQueue(this)}if(!broken){if(streamCRC!==null)stream.emit("error",new Error("input stream ended prematurely"));this.queue(null)}})}}).call(this,require("buffer").Buffer)},{"./lib/bit_iterator":2,"./lib/bzip2":3,buffer:6,through:31}],2:[function(require,module,exports){var BITMASK=[0,1,3,7,15,31,63,127,255];module.exports=function bitIterator(nextBuffer){var bit=0,byte=0;var bytes=nextBuffer();var f=function(n){if(n===null&&bit!=0){bit=0;byte++;return}var result=0;while(n>0){if(byte>=bytes.length){byte=0;bytes=nextBuffer()}var left=8-bit;if(bit===0&&n>0)f.bytesRead++;if(n>=left){result<<=left;result|=BITMASK[left]&bytes[byte++];bit=0;n-=left}else{result<<=n;result|=(bytes[byte]&BITMASK[n]<<8-n-bit)>>8-n-bit;bit+=n;n=0}}return result};f.bytesRead=0;return f}},{}],3:[function(require,module,exports){function Bzip2Error(message){this.name="Bzip2Error";this.message=message;this.stack=(new Error).stack}Bzip2Error.prototype=new Error;var message={Error:function(message){throw new Bzip2Error(message)}};var bzip2={};bzip2.Bzip2Error=Bzip2Error;bzip2.crcTable=[0,79764919,159529838,222504665,319059676,398814059,445009330,507990021,638119352,583659535,797628118,726387553,890018660,835552979,1015980042,944750013,1276238704,1221641927,1167319070,1095957929,1595256236,1540665371,1452775106,1381403509,1780037320,1859660671,1671105958,1733955601,2031960084,2111593891,1889500026,1952343757,2552477408,2632100695,2443283854,2506133561,2334638140,2414271883,2191915858,2254759653,3190512472,3135915759,3081330742,3009969537,2905550212,2850959411,2762807018,2691435357,3560074640,3505614887,3719321342,3648080713,3342211916,3287746299,3467911202,3396681109,4063920168,4143685023,4223187782,4286162673,3779000052,3858754371,3904687514,3967668269,881225847,809987520,1023691545,969234094,662832811,591600412,771767749,717299826,311336399,374308984,453813921,533576470,25881363,88864420,134795389,214552010,2023205639,2086057648,1897238633,1976864222,1804852699,1867694188,1645340341,1724971778,1587496639,1516133128,14615
|