1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
2 | (function (global){
|
3 | !function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.objectHash=e()}}(function(){return function o(i,u,a){function f(n,e){if(!u[n]){if(!i[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(s)return s(n,!0);throw new Error("Cannot find module '"+n+"'")}var r=u[n]={exports:{}};i[n][0].call(r.exports,function(e){var t=i[n][1][e];return f(t||e)},r,r.exports,o,i,u,a)}return u[n].exports}for(var s="function"==typeof require&&require,e=0;e<a.length;e++)f(a[e]);return f}({1:[function(w,b,m){(function(e,t,s,n,r,o,i,u,a){"use strict";var f=w("crypto");function c(e,t){return function(e,t){var n;n="passthrough"!==t.algorithm?f.createHash(t.algorithm):new y;void 0===n.write&&(n.write=n.update,n.end=n.update);g(t,n).dispatch(e),n.update||n.end("");if(n.digest)return n.digest("buffer"===t.encoding?void 0:t.encoding);var r=n.read();return"buffer"!==t.encoding?r.toString(t.encoding):r}(e,t=h(e,t))}(m=b.exports=c).sha1=function(e){return c(e)},m.keys=function(e){return c(e,{excludeValues:!0,algorithm:"sha1",encoding:"hex"})},m.MD5=function(e){return c(e,{algorithm:"md5",encoding:"hex"})},m.keysMD5=function(e){return c(e,{algorithm:"md5",encoding:"hex",excludeValues:!0})};var l=f.getHashes?f.getHashes().slice():["sha1","md5"];l.push("passthrough");var d=["buffer","hex","binary","base64"];function h(e,t){t=t||{};var n={};if(n.algorithm=t.algorithm||"sha1",n.encoding=t.encoding||"hex",n.excludeValues=!!t.excludeValues,n.algorithm=n.algorithm.toLowerCase(),n.encoding=n.encoding.toLowerCase(),n.ignoreUnknown=!0===t.ignoreUnknown,n.respectType=!1!==t.respectType,n.respectFunctionNames=!1!==t.respectFunctionNames,n.respectFunctionProperties=!1!==t.respectFunctionProperties,n.unorderedArrays=!0===t.unorderedArrays,n.unorderedSets=!1!==t.unorderedSets,n.unorderedObjects=!1!==t.unorderedObjects,n.replacer=t.replacer||void 0,n.excludeKeys=t.excludeKeys||void 0,void 0===e)throw new Error("Object argument required.");for(var r=0;r<l.length;++r)l[r].toLowerCase()===n.algorithm.toLowerCase()&&(n.algorithm=l[r]);if(-1===l.indexOf(n.algorithm))throw new Error('Algorithm "'+n.algorithm+'" not supported. supported values: '+l.join(", "));if(-1===d.indexOf(n.encoding)&&"passthrough"!==n.algorithm)throw new Error('Encoding "'+n.encoding+'" not supported. supported values: '+d.join(", "));return n}function p(e){if("function"!=typeof e)return!1;return null!=/^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(e))}function g(u,t,a){a=a||[];function f(e){return t.update?t.update(e,"utf8"):t.write(e,"utf8")}return{dispatch:function(e){u.replacer&&(e=u.replacer(e));var t=typeof e;return null===e&&(t="null"),this["_"+t](e)},_object:function(t){var e=Object.prototype.toString.call(t),n=/\[object (.*)\]/i.exec(e);n=(n=n?n[1]:"unknown:["+e+"]").toLowerCase();var r;if(0<=(r=a.indexOf(t)))return this.dispatch("[CIRCULAR:"+r+"]");if(a.push(t),void 0!==s&&s.isBuffer&&s.isBuffer(t))return f("buffer:"),f(t);if("object"===n||"function"===n||"asyncfunction"===n){var o=Object.keys(t);u.unorderedObjects&&(o=o.sort()),!1===u.respectType||p(t)||o.splice(0,0,"prototype","__proto__","constructor"),u.excludeKeys&&(o=o.filter(function(e){return!u.excludeKeys(e)})),f("object:"+o.length+":");var i=this;return o.forEach(function(e){i.dispatch(e),f(":"),u.excludeValues||i.dispatch(t[e]),f(",")})}if(!this["_"+n]){if(u.ignoreUnknown)return f("["+n+"]");throw new Error('Unknown object type "'+n+'"')}this["_"+n](t)},_array:function(e,t){t=void 0!==t?t:!1!==u.unorderedArrays;var n=this;if(f("array:"+e.length+":"),!t||e.length<=1)return e.forEach(function(e){return n.dispatch(e)});var r=[],o=e.map(function(e){var t=new y,n=a.slice();return g(u,t,n).dispatch(e),r=r.concat(n.slice(a.length)),t.read().toString()});return a=a.concat(r),o.sort(),this._array(o,!1)},_date:function(e){return f("date:"+e.toJSON())},_symbol:function(e){return f("symbol:"+e.toString())},_error:function(e){return f("error:"+e.toString())},_boolean:function(e){return f("bool:"+e.toString())},_string:function(e){f("string:"+e.length+":"),f(e.toString())},_function:function(e){f("fn:"),p(e)?this.dispatch("[native]"):this.dispatch(e.toString()),!1!==u.respectFunctionNames&&this.dispatch("function-name:"+String(e.name)),u.respectFunctionProperties&&this._object(e)},_number:function(e){return f("number:"+e.toString())},_xml:function(e){return f("xml:"+e.toString())},_null:function(){return f("Null")},_undefined:function(){return f("Undefined")},_regexp:function(e){return f("regex:"+e.toString())},_uint8array:function(e){return f("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint8clampedarray:function(e){return f("uint8clampedarray:"),this.dispatch(Array.prototype.slice.call(e))},_int8array:function(e){return f("uint8array:"),this.dispatch(Array.prototype.slice.call(e))},_uint16array:function(e){return f("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_int16array:function(e){return f("uint16array:"),this.dispatch(Array.prototype.slice.call(e))},_uint32array:function(e){return f("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_int32array:function(e){return f("uint32array:"),this.dispatch(Array.prototype.slice.call(e))},_float32array:function(e){return f("float32array:"),this.dispatch(Array.prototype.slice.call(e))},_float64array:function(e){return f("float64array:"),this.dispatch(Array.prototype.slice.call(e))},_arraybuffer:function(e){return f("arraybuffer:"),this.dispatch(new Uint8Array(e))},_url:function(e){return f("url:"+e.toString())},_map:function(e){f("map:");var t=Array.from(e);return this._array(t,!1!==u.unorderedSets)},_set:function(e){f("set:");var t=Array.from(e);return this._array(t,!1!==u.unorderedSets)},_blob:function(){if(u.ignoreUnknown)return f("[blob]");throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n')},_domwindow:function(){return f("domwindow")},_process:function(){return f("process")},_timer:function(){return f("timer")},_pipe:function(){return f("pipe")},_tcp:function(){return f("tcp")},_udp:function(){return f("udp")},_tty:function(){return f("tty")},_statwatcher:function(){return f("statwatcher")},_securecontext:function(){return f("securecontext")},_connection:function(){return f("connection")},_zlib:function(){return f("zlib")},_context:function(){return f("context")},_nodescript:function(){return f("nodescript")},_httpparser:function(){return f("httpparser")},_dataview:function(){return f("dataview")},_signal:function(){return f("signal")},_fsevent:function(){return f("fsevent")},_tlswrap:function(){return f("tlswrap")}}}function y(){return{buf:"",write:function(e){this.buf+=e},end:function(e){this.buf+=e},read:function(){return this.buf}}}m.writeToStream=function(e,t,n){return void 0===n&&(n=t,t={}),g(t=h(e,t),n).dispatch(e)}}).call(this,w("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},w("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/fake_274613e1.js","/")},{buffer:3,crypto:5,lYpoI2:10}],2:[function(e,t,s){(function(e,t,n,r,o,i,u,a,f){!function(e){"use strict";var s="undefined"!=typeof Uint8Array?Uint8Array:Array,n="+".charCodeAt(0),r="/".charCodeAt(0),o="0".charCodeAt(0),i="a".charCodeAt(0),u="A".charCodeAt(0),a="-".charCodeAt(0),f="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);return t===n||t===a?62:t===r||t===f?63:t<o?-1:t<o+10?t-o+26+26:t<u+26?t-u:t<i+26?t-i+26:void 0}e.toByteArray=function(e){var t,n,r,o,i;if(0<e.length%4)throw new Error("Invalid string. Length must be a multiple of 4");var u=e.length;o="="===e.charAt(u-2)?2:"="===e.charAt(u-1)?1:0,i=new s(3*e.length/4-o),n=0<o?e.length-4:e.length;var a=0;function f(e){i[a++]=e}for(t=0;t<n;t+=4,3)f((16711680&(r=c(e.charAt(t))<<18|c(e.charAt(t+1))<<12|c(e.charAt(t+2))<<6|c(e.charAt(t+3))))>>16),f((65280&r)>>8),f(255&r);return 2==o?f(255&(r=c(e.charAt(t))<<2|c(e.charAt(t+1))>>4)):1==o&&(f((r=c(e.charAt(t))<<10|c(e.charAt(t+1))<<4|c(e.charAt(t+2))>>2)>>8&255),f(255&r)),i},e.fromByteArray=function(e){var t,n,r,o,i=e.length%3,u="";function a(e){return"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)}for(t=0,r=e.length-i;t<r;t+=3)n=(e[t]<<16)+(e[t+1]<<8)+e[t+2],u+=a((o=n)>>18&63)+a(o>>12&63)+a(o>>6&63)+a(63&o);switch(i){case 1:u+=a((n=e[e.length-1])>>2),u+=a(n<<4&63),u+="==";break;case 2:u+=a((n=(e[e.length-2]<<8)+e[e.length-1])>>10),u+=a(n>>4&63),u+=a(n<<2&63),u+="="}return u}}(void 0===s?this.base64js={}:s)}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js","/node_modules/gulp-browserify/node_modules/base64-js/lib")},{buffer:3,lYpoI2:10}],3:[function(D,e,O){(function(e,t,f,n,r,o,i,u,a){var s=D("base64-js"),c=D("ieee754");function f(e,t,n){if(!(this instanceof f))return new f(e,t,n);var r,o,i,u=typeof e;if("base64"===t&&"string"==u)for(e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e);e.length%4!=0;)e+="=";if("number"==u)r=U(e);else if("string"==u)r=f.byteLength(e,t);else{if("object"!=u)throw new Error("First argument needs to be a number, array or string.");r=U(e.length)}if(f._useTypedArrays?o=f._augment(new Uint8Array(r)):((o=this).length=r,o._isBuffer=!0),f._useTypedArrays&&"number"==typeof e.byteLength)o._set(e);else if(function(e){return x(e)||f.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}(e))for(i=0;i<r;i++)f.isBuffer(e)?o[i]=e.readUInt8(i):o[i]=e[i];else if("string"==u)o.write(e,0,t);else if("number"==u&&!f._useTypedArrays&&!n)for(i=0;i<r;i++)o[i]=0;return o}function l(e,t,n,r){return f._charsWritten=k(function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function d(e,t,n){var r="";n=Math.min(e.length,n);for(var o=t;o<n;o++)r+=String.fromCharCode(e[o]);return r}function h(e,t,n,r){r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=t,"missing offset"),F(t+1<e.length,"Trying to read beyond buffer length"));var o,i=e.length;if(!(i<=t))return n?(o=e[t],t+1<i&&(o|=e[t+1]<<8)):(o=e[t]<<8,t+1<i&&(o|=e[t+1])),o}function p(e,t,n,r){r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=t,"missing offset"),F(t+3<e.length,"Trying to read beyond buffer length"));var o,i=e.length;if(!(i<=t))return n?(t+2<i&&(o=e[t+2]<<16),t+1<i&&(o|=e[t+1]<<8),o|=e[t],t+3<i&&(o+=e[t+3]<<24>>>0)):(t+1<i&&(o=e[t+1]<<16),t+2<i&&(o|=e[t+2]<<8),t+3<i&&(o|=e[t+3]),o+=e[t]<<24>>>0),o}function g(e,t,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=t,"missing offset"),F(t+1<e.length,"Trying to read beyond buffer length")),!(e.length<=t)){var o=h(e,t,n,!0);return 32768&o?-1*(65535-o+1):o}}function y(e,t,n,r){if(r||(F("boolean"==typeof n,"missing or invalid endian"),F(null!=t,"missing offset"),F(t+3<e.length,"Trying to read beyond buffer length")),!(e.length<=t)){var o=p(e,t,n,!0);return 2147483648&o?-1*(4294967295-o+1):o}}function w(e,t,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(t+3<e.length,"Trying to read beyond buffer length")),c.read(e,t,n,23,4)}function b(e,t,n,r){return r||(F("boolean"==typeof n,"missing or invalid endian"),F(t+7<e.length,"Trying to read beyond buffer length")),c.read(e,t,n,52,8)}function m(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<e.length,"trying to write beyond buffer length"),M(t,65535));var i=e.length;if(!(i<=n))for(var u=0,a=Math.min(i-n,2);u<a;u++)e[n+u]=(t&255<<8*(r?u:1-u))>>>8*(r?u:1-u)}function v(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<e.length,"trying to write beyond buffer length"),M(t,4294967295));var i=e.length;if(!(i<=n))for(var u=0,a=Math.min(i-n,4);u<a;u++)e[n+u]=t>>>8*(r?u:3-u)&255}function _(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+1<e.length,"Trying to write beyond buffer length"),N(t,32767,-32768)),e.length<=n||m(e,0<=t?t:65535+t+1,n,r,o)}function E(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<e.length,"Trying to write beyond buffer length"),N(t,2147483647,-2147483648)),e.length<=n||v(e,0<=t?t:4294967295+t+1,n,r,o)}function I(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+3<e.length,"Trying to write beyond buffer length"),Y(t,34028234663852886e22,-34028234663852886e22)),e.length<=n||c.write(e,t,n,r,23,4)}function A(e,t,n,r,o){o||(F(null!=t,"missing value"),F("boolean"==typeof r,"missing or invalid endian"),F(null!=n,"missing offset"),F(n+7<e.length,"Trying to write beyond buffer length"),Y(t,17976931348623157e292,-17976931348623157e292)),e.length<=n||c.write(e,t,n,r,52,8)}O.Buffer=f,O.SlowBuffer=f,O.INSPECT_MAX_BYTES=50,f.poolSize=8192,f._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(e){return!1}}(),f.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.isBuffer=function(e){return!(null==e||!e._isBuffer)},f.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=j(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=C(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},f.concat=function(e,t){if(F(x(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new f(0);if(1===e.length)return e[0];var n;if("number"!=typeof t)for(n=t=0;n<e.length;n++)t+=e[n].length;var r=new f(t),o=0;for(n=0;n<e.length;n++){var i=e[n];i.copy(r,o),o+=i.length}return r},f.prototype.write=function(e,t,n,r){if(isFinite(t))isFinite(n)||(r=n,n=void 0);else{var o=r;r=t,t=n,n=o}t=Number(t)||0;var i,u=this.length-t;switch(n?u<(n=Number(n))&&(n=u):n=u,r=String(r||"utf8").toLowerCase()){case"hex":i=function(e,t,n,r){n=Number(n)||0;var o=e.length-n;r?o<(r=Number(r))&&(r=o):r=o;var i=t.length;F(i%2==0,"Invalid hex string"),i/2<r&&(r=i/2);for(var u=0;u<r;u++){var a=parseInt(t.substr(2*u,2),16);F(!isNaN(a),"Invalid hex string"),e[n+u]=a}return f._charsWritten=2*u,u}(this,e,t,n);break;case"utf8":case"utf-8":i=function(e,t,n,r){return f._charsWritten=k(j(t),e,n,r)}(this,e,t,n);break;case"ascii":i=l(this,e,t,n);break;case"binary":i=function(e,t,n,r){return l(e,t,n,r)}(this,e,t,n);break;case"base64":i=function(e,t,n,r){return f._charsWritten=k(C(t),e,n,r)}(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=function(e,t,n,r){return f._charsWritten=k(function(e){for(var t,n,r,o=[],i=0;i<e.length;i++)t=e.charCodeAt(i),n=t>>8,r=t%256,o.push(r),o.push(n);return o}(t),e,n,r)}(this,e,t,n);break;default:throw new Error("Unknown encoding")}return i},f.prototype.toString=function(e,t,n){var r,o=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,(n=void 0!==n?Number(n):n=o.length)===t)return"";switch(e){case"hex":r=function(e,t,n){var r=e.length;(!t||t<0)&&(t=0);(!n||n<0||r<n)&&(n=r);for(var o="",i=t;i<n;i++)o+=S(e[i]);return o}(o,t,n);break;case"utf8":case"utf-8":r=function(e,t,n){var r="",o="";n=Math.min(e.length,n);for(var i=t;i<n;i++)e[i]<=127?(r+=T(o)+String.fromCharCode(e[i]),o=""):o+="%"+e[i].toString(16);return r+T(o)}(o,t,n);break;case"ascii":r=d(o,t,n);break;case"binary":r=function(e,t,n){return d(e,t,n)}(o,t,n);break;case"base64":r=function(e,t,n){return 0===t&&n===e.length?s.fromByteArray(e):s.fromByteArray(e.slice(t,n))}(o,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=function(e,t,n){for(var r=e.slice(t,n),o="",i=0;i<r.length;i+=2)o+=String.fromCharCode(r[i]+256*r[i+1]);return o}(o,t,n);break;default:throw new Error("Unknown encoding")}return r},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},f.prototype.copy=function(e,t,n,r){if(n=n||0,r||0===r||(r=this.length),t=t||0,r!==n&&0!==e.length&&0!==this.length){F(n<=r,"sourceEnd < sourceStart"),F(0<=t&&t<e.length,"targetStart out of bounds"),F(0<=n&&n<this.length,"sourceStart out of bounds"),F(0<=r&&r<=this.length,"sourceEnd out of bounds"),r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var o=r-n;if(o<100||!f._useTypedArrays)for(var i=0;i<o;i++)e[i+t]=this[i+n];else e._set(this.subarray(n,n+o),t)}},f.prototype.slice=function(e,t){var n=this.length;if(e=L(e,n,0),t=L(t,n,n),f._useTypedArrays)return f._augment(this.subarray(e,t));for(var r=t-e,o=new f(r,void 0,!0),i=0;i<r;i++)o[i]=this[i+e];return o},f.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},f.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},f.prototype.readUInt8=function(e,t){if(t||(F(null!=e,"missing offset"),F(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return this[e]},f.prototype.readUInt16LE=function(e,t){return h(this,e,!0,t)},f.prototype.readUInt16BE=function(e,t){return h(this,e,!1,t)},f.prototype.readUInt32LE=function(e,t){return p(this,e,!0,t)},f.prototype.readUInt32BE=function(e,t){return p(this,e,!1,t)},f.prototype.readInt8=function(e,t){if(t||(F(null!=e,"missing offset"),F(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length))return 128&this[e]?-1*(255-this[e]+1):this[e]},f.prototype.readInt16LE=function(e,t){return g(this,e,!0,t)},f.prototype.readInt16BE=function(e,t){return g(this,e,!1,t)},f.prototype.readInt32LE=function(e,t){return y(this,e,!0,t)},f.prototype.readInt32BE=function(e,t){return y(this,e,!1,t)},f.prototype.readFloatLE=function(e,t){return w(this,e,!0,t)},f.prototype.readFloatBE=function(e,t){return w(this,e,!1,t)},f.prototype.readDoubleLE=function(e,t){return b(this,e,!0,t)},f.prototype.readDoubleBE=function(e,t){return b(this,e,!1,t)},f.prototype.writeUInt8=function(e,t,n){n||(F(null!=e,"missing value"),F(null!=t,"missing offset"),F(t<this.length,"trying to write beyond buffer length"),M(e,255)),t>=this.length||(this[t]=e)},f.prototype.writeUInt16LE=function(e,t,n){m(this,e,t,!0,n)},f.prototype.writeUInt16BE=function(e,t,n){m(this,e,t,!1,n)},f.prototype.writeUInt32LE=function(e,t,n){v(this,e,t,!0,n)},f.prototype.writeUInt32BE=function(e,t,n){v(this,e,t,!1,n)},f.prototype.writeInt8=function(e,t,n){n||(F(null!=e,"missing value"),F(null!=t,"missing offset"),F(t<this.length,"Trying to write beyond buffer length"),N(e,127,-128)),t>=this.length||(0<=e?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},f.prototype.writeInt16LE=function(e,t,n){_(this,e,t,!0,n)},f.prototype.writeInt16BE=function(e,t,n){_(this,e,t,!1,n)},f.prototype.writeInt32LE=function(e,t,n){E(this,e,t,!0,n)},f.prototype.writeInt32BE=function(e,t,n){E(this,e,t,!1,n)},f.prototype.writeFloatLE=function(e,t,n){I(this,e,t,!0,n)},f.prototype.writeFloatBE=function(e,t,n){I(this,e,t,!1,n)},f.prototype.writeDoubleLE=function(e,t,n){A(this,e,t,!0,n)},f.prototype.writeDoubleBE=function(e,t,n){A(this,e,t,!1,n)},f.prototype.fill=function(e,t,n){if(e=e||0,t=t||0,n=n||this.length,"string"==typeof e&&(e=e.charCodeAt(0)),F("number"==typeof e&&!isNaN(e),"value is not a number"),F(t<=n,"end < start"),n!==t&&0!==this.length){F(0<=t&&t<this.length,"start out of bounds"),F(0<=n&&n<=this.length,"end out of bounds");for(var r=t;r<n;r++)this[r]=e}},f.prototype.inspect=function(){for(var e=[],t=this.length,n=0;n<t;n++)if(e[n]=S(this[n]),n===O.INSPECT_MAX_BYTES){e[n+1]="...";break}return"<Buffer "+e.join(" ")+">"},f.prototype.toArrayBuffer=function(){if("undefined"==typeof Uint8Array)throw new Error("Buffer.toArrayBuffer not supported in this browser");if(f._useTypedArrays)return new f(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;t<n;t+=1)e[t]=this[t];return e.buffer};var B=f.prototype;function L(e,t,n){return"number"!=typeof e?n:t<=(e=~~e)?t:0<=e?e:0<=(e+=t)?e:0}function U(e){return(e=~~Math.ceil(+e))<0?0:e}function x(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function S(e){return e<16?"0"+e.toString(16):e.toString(16)}function j(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<=127)t.push(e.charCodeAt(n));else{var o=n;55296<=r&&r<=57343&&n++;for(var i=encodeURIComponent(e.slice(o,n+1)).substr(1).split("%"),u=0;u<i.length;u++)t.push(parseInt(i[u],16))}}return t}function C(e){return s.toByteArray(e)}function k(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);o++)t[o+n]=e[o];return o}function T(e){try{return decodeURIComponent(e)}catch(e){return String.fromCharCode(65533)}}function M(e,t){F("number"==typeof e,"cannot write a non-number as a number"),F(0<=e,"specified a negative value for writing an unsigned value"),F(e<=t,"value is larger than maximum value for type"),F(Math.floor(e)===e,"value has a fractional component")}function N(e,t,n){F("number"==typeof e,"cannot write a non-number as a number"),F(e<=t,"value larger than maximum allowed value"),F(n<=e,"value smaller than minimum allowed value"),F(Math.floor(e)===e,"value has a fractional component")}function Y(e,t,n){F("number"==typeof e,"cannot write a non-number as a number"),F(e<=t,"value larger than maximum allowed value"),F(n<=e,"value smaller than minimum allowed value")}function F(e,t){if(!e)throw new Error(t||"Failed assertion")}f._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=B.get,e.set=B.set,e.write=B.write,e.toString=B.toString,e.toLocaleString=B.toString,e.toJSON=B.toJSON,e.copy=B.copy,e.slice=B.slice,e.readUInt8=B.readUInt8,e.readUInt16LE=B.readUInt16LE,e.readUInt16BE=B.readUInt16BE,e.readUInt32LE=B.readUInt32LE,e.readUInt32BE=B.readUInt32BE,e.readInt8=B.readInt8,e.readInt16LE=B.readInt16LE,e.readInt16BE=B.readInt16BE,e.readInt32LE=B.readInt32LE,e.readInt32BE=B.readInt32BE,e.readFloatLE=B.readFloatLE,e.readFloatBE=B.readFloatBE,e.readDoubleLE=B.readDoubleLE,e.readDoubleBE=B.readDoubleBE,e.writeUInt8=B.writeUInt8,e.writeUInt16LE=B.writeUInt16LE,e.writeUInt16BE=B.writeUInt16BE,e.writeUInt32LE=B.writeUInt32LE,e.writeUInt32BE=B.writeUInt32BE,e.writeInt8=B.writeInt8,e.writeInt16LE=B.writeInt16LE,e.writeInt16BE=B.writeInt16BE,e.writeInt32LE=B.writeInt32LE,e.writeInt32BE=B.writeInt32BE,e.writeFloatLE=B.writeFloatLE,e.writeFloatBE=B.writeFloatBE,e.writeDoubleLE=B.writeDoubleLE,e.writeDoubleBE=B.writeDoubleBE,e.fill=B.fill,e.inspect=B.inspect,e.toArrayBuffer=B.toArrayBuffer,e}}).call(this,D("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},D("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/buffer/index.js","/node_modules/gulp-browserify/node_modules/buffer")},{"base64-js":2,buffer:3,ieee754:11,lYpoI2:10}],4:[function(l,d,e){(function(e,t,u,n,r,o,i,a,f){u=l("buffer").Buffer;var s=4,c=new u(s);c.fill(0);d.exports={hash:function(e,t,n,r){return u.isBuffer(e)||(e=new u(e)),function(e,t,n){for(var r=new u(t),o=n?r.writeInt32BE:r.writeInt32LE,i=0;i<e.length;i++)o.call(r,e[i],4*i,!0);return r}(t(function(e,t){if(e.length%s!=0){var n=e.length+(s-e.length%s);e=u.concat([e,c],n)}for(var r=[],o=t?e.readInt32BE:e.readInt32LE,i=0;i<e.length;i+=s)r.push(o.call(e,i));return r}(e,r),8*e.length),n,r)}}}).call(this,l("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:10}],5:[function(w,e,b){(function(e,t,a,n,r,o,i,u,f){a=w("buffer").Buffer;var s=w("./sha"),c=w("./sha256"),l=w("./rng"),d={sha1:s,sha256:c,md5:w("./md5")},h=64,p=new a(h);function g(e,r){var o=d[e=e||"sha1"],i=[];return o||y("algorithm:",e,"is not yet supported"),{update:function(e){return a.isBuffer(e)||(e=new a(e)),i.push(e),e.length,this},digest:function(e){var t=a.concat(i),n=r?function(e,t,n){a.isBuffer(t)||(t=new a(t)),a.isBuffer(n)||(n=new a(n)),t.length>h?t=e(t):t.length<h&&(t=a.concat([t,p],h));for(var r=new a(h),o=new a(h),i=0;i<h;i++)r[i]=54^t[i],o[i]=92^t[i];var u=e(a.concat([r,n]));return e(a.concat([o,u]))}(o,r,t):o(t);return i=null,e?n.toString(e):n}}}function y(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}p.fill(0),b.createHash=function(e){return g(e)},b.createHmac=function(e,t){return g(e,t)},b.randomBytes=function(e,t){if(!t||!t.call)return new a(l(e));try{t.call(this,void 0,new a(l(e)))}catch(e){t(e)}},function(e,t){for(var n in e)t(e[n],n)}(["createCredentials","createCipher","createCipheriv","createDecipher","createDecipheriv","createSign","createVerify","createDiffieHellman","pbkdf2"],function(e){b[e]=function(){y("sorry,",e,"is not implemented yet")}})}).call(this,w("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},w("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./md5":6,"./rng":7,"./sha":8,"./sha256":9,buffer:3,lYpoI2:10}],6:[function(w,b,e){(function(e,t,n,r,o,i,u,a,f){var s=w("./helpers");function c(e,t){e[t>>5]|=128<<t%32,e[14+(t+64>>>9<<4)]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,u=0;u<e.length;u+=16){var a=n,f=r,s=o,c=i;r=g(r=g(r=g(r=g(r=p(r=p(r=p(r=p(r=h(r=h(r=h(r=h(r=d(r=d(r=d(r=d(r,o=d(o,i=d(i,n=d(n,r,o,i,e[u+0],7,-680876936),r,o,e[u+1],12,-389564586),n,r,e[u+2],17,606105819),i,n,e[u+3],22,-1044525330),o=d(o,i=d(i,n=d(n,r,o,i,e[u+4],7,-176418897),r,o,e[u+5],12,1200080426),n,r,e[u+6],17,-1473231341),i,n,e[u+7],22,-45705983),o=d(o,i=d(i,n=d(n,r,o,i,e[u+8],7,1770035416),r,o,e[u+9],12,-1958414417),n,r,e[u+10],17,-42063),i,n,e[u+11],22,-1990404162),o=d(o,i=d(i,n=d(n,r,o,i,e[u+12],7,1804603682),r,o,e[u+13],12,-40341101),n,r,e[u+14],17,-1502002290),i,n,e[u+15],22,1236535329),o=h(o,i=h(i,n=h(n,r,o,i,e[u+1],5,-165796510),r,o,e[u+6],9,-1069501632),n,r,e[u+11],14,643717713),i,n,e[u+0],20,-373897302),o=h(o,i=h(i,n=h(n,r,o,i,e[u+5],5,-701558691),r,o,e[u+10],9,38016083),n,r,e[u+15],14,-660478335),i,n,e[u+4],20,-405537848),o=h(o,i=h(i,n=h(n,r,o,i,e[u+9],5,568446438),r,o,e[u+14],9,-1019803690),n,r,e[u+3],14,-187363961),i,n,e[u+8],20,1163531501),o=h(o,i=h(i,n=h(n,r,o,i,e[u+13],5,-1444681467),r,o,e[u+2],9,-51403784),n,r,e[u+7],14,1735328473),i,n,e[u+12],20,-1926607734),o=p(o,i=p(i,n=p(n,r,o,i,e[u+5],4,-378558),r,o,e[u+8],11,-2022574463),n,r,e[u+11],16,1839030562),i,n,e[u+14],23,-35309556),o=p(o,i=p(i,n=p(n,r,o,i,e[u+1],4,-1530992060),r,o,e[u+4],11,1272893353),n,r,e[u+7],16,-155497632),i,n,e[u+10],23,-1094730640),o=p(o,i=p(i,n=p(n,r,o,i,e[u+13],4,681279174),r,o,e[u+0],11,-358537222),n,r,e[u+3],16,-722521979),i,n,e[u+6],23,76029189),o=p(o,i=p(i,n=p(n,r,o,i,e[u+9],4,-640364487),r,o,e[u+12],11,-421815835),n,r,e[u+15],16,530742520),i,n,e[u+2],23,-995338651),o=g(o,i=g(i,n=g(n,r,o,i,e[u+0],6,-198630844),r,o,e[u+7],10,1126891415),n,r,e[u+14],15,-1416354905),i,n,e[u+5],21,-57434055),o=g(o,i=g(i,n=g(n,r,o,i,e[u+12],6,1700485571),r,o,e[u+3],10,-1894986606),n,r,e[u+10],15,-1051523),i,n,e[u+1],21,-2054922799),o=g(o,i=g(i,n=g(n,r,o,i,e[u+8],6,1873313359),r,o,e[u+15],10,-30611744),n,r,e[u+6],15,-1560198380),i,n,e[u+13],21,1309151649),o=g(o,i=g(i,n=g(n,r,o,i,e[u+4],6,-145523070),r,o,e[u+11],10,-1120210379),n,r,e[u+2],15,718787259),i,n,e[u+9],21,-343485551),n=y(n,a),r=y(r,f),o=y(o,s),i=y(i,c)}return Array(n,r,o,i)}function l(e,t,n,r,o,i){return y(function(e,t){return e<<t|e>>>32-t}(y(y(t,e),y(r,i)),o),n)}function d(e,t,n,r,o,i,u){return l(t&n|~t&r,e,t,o,i,u)}function h(e,t,n,r,o,i,u){return l(t&r|n&~r,e,t,o,i,u)}function p(e,t,n,r,o,i,u){return l(t^n^r,e,t,o,i,u)}function g(e,t,n,r,o,i,u){return l(n^(t|~r),e,t,o,i,u)}function y(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}b.exports=function(e){return s.hash(e,c,16)}}).call(this,w("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},w("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:10}],7:[function(e,l,t){(function(e,t,n,r,o,i,u,a,f){var s,c;s=function(e){for(var t,n=new Array(e),r=0;r<e;r++)0==(3&r)&&(t=4294967296*Math.random()),n[r]=t>>>((3&r)<<3)&255;return n},l.exports=c||s}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{buffer:3,lYpoI2:10}],8:[function(l,d,e){(function(e,t,n,r,o,i,u,a,f){var s=l("./helpers");function c(e,t){e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var n,r=Array(80),o=1732584193,i=-271733879,u=-1732584194,a=271733878,f=-1009589776,s=0;s<e.length;s+=16){for(var c=o,l=i,d=u,h=a,p=f,g=0;g<80;g++){r[g]=g<16?e[s+g]:m(r[g-3]^r[g-8]^r[g-14]^r[g-16],1);var y=b(b(m(o,5),w(g,i,u,a)),b(b(f,r[g]),(n=g)<20?1518500249:n<40?1859775393:n<60?-1894007588:-899497514));f=a,a=u,u=m(i,30),i=o,o=y}o=b(o,c),i=b(i,l),u=b(u,d),a=b(a,h),f=b(f,p)}return Array(o,i,u,a,f)}function w(e,t,n,r){return e<20?t&n|~t&r:e<40?t^n^r:e<60?t&n|t&r|n&r:t^n^r}function b(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function m(e,t){return e<<t|e>>>32-t}d.exports=function(e){return s.hash(e,c,20,!0)}}).call(this,l("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:10}],9:[function(l,d,e){(function(e,t,n,r,o,i,u,a,f){function B(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function L(e,t){return e>>>t|e<<32-t}function U(e,t){return e>>>t}function s(e,t){var n,r,o,i,u,a,f,s,c,l,d,h,p,g,y,w,b,m,v=new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298),_=new Array(1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225),E=new Array(64);e[t>>5]|=128<<24-t%32,e[15+(t+64>>9<<4)]=t;for(var I=0;I<e.length;I+=16){n=_[0],r=_[1],o=_[2],i=_[3],u=_[4],a=_[5],f=_[6],s=_[7];for(var A=0;A<64;A++)E[A]=A<16?e[A+I]:B(B(B((m=E[A-2],L(m,17)^L(m,19)^U(m,10)),E[A-7]),(b=E[A-15],L(b,7)^L(b,18)^U(b,3))),E[A-16]),c=B(B(B(B(s,L(w=u,6)^L(w,11)^L(w,25)),(y=u)&a^~y&f),v[A]),E[A]),l=B(L(g=n,2)^L(g,13)^L(g,22),(d=n)&(h=r)^d&(p=o)^h&p),s=f,f=a,a=u,u=B(i,c),i=o,o=r,r=n,n=B(c,l);_[0]=B(n,_[0]),_[1]=B(r,_[1]),_[2]=B(o,_[2]),_[3]=B(i,_[3]),_[4]=B(u,_[4]),_[5]=B(a,_[5]),_[6]=B(f,_[6]),_[7]=B(s,_[7])}return _}var c=l("./helpers");d.exports=function(e){return c.hash(e,s,32,!0)}}).call(this,l("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},l("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js","/node_modules/gulp-browserify/node_modules/crypto-browserify")},{"./helpers":4,buffer:3,lYpoI2:10}],10:[function(e,c,t){(function(e,t,n,r,o,i,u,a,f){function s(){}(e=c.exports={}).nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;t!==window&&null!==t||"process-tick"!==e.data||(e.stopPropagation(),0<n.length&&n.shift()())},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.on=s,e.addListener=s,e.once=s,e.off=s,e.removeListener=s,e.removeAllListeners=s,e.emit=s,e.binding=function(e){throw new Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(e){throw new Error("process.chdir is not supported")}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/gulp-browserify/node_modules/process/browser.js","/node_modules/gulp-browserify/node_modules/process")},{buffer:3,lYpoI2:10}],11:[function(e,t,s){(function(e,t,n,r,o,i,u,a,f){s.read=function(e,t,n,r,o){var i,u,a=8*o-r-1,f=(1<<a)-1,s=f>>1,c=-7,l=n?o-1:0,d=n?-1:1,h=e[t+l];for(l+=d,i=h&(1<<-c)-1,h>>=-c,c+=a;0<c;i=256*i+e[t+l],l+=d,c-=8);for(u=i&(1<<-c)-1,i>>=-c,c+=r;0<c;u=256*u+e[t+l],l+=d,c-=8);if(0===i)i=1-s;else{if(i===f)return u?NaN:1/0*(h?-1:1);u+=Math.pow(2,r),i-=s}return(h?-1:1)*u*Math.pow(2,i-r)},s.write=function(e,t,n,r,o,i){var u,a,f,s=8*i-o-1,c=(1<<s)-1,l=c>>1,d=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,h=r?0:i-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,u=c):(u=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-u))<1&&(u--,f*=2),2<=(t+=1<=u+l?d/f:d*Math.pow(2,1-l))*f&&(u++,f/=2),c<=u+l?(a=0,u=c):1<=u+l?(a=(t*f-1)*Math.pow(2,o),u+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,o),u=0));8<=o;e[n+h]=255&a,h+=p,a/=256,o-=8);for(u=u<<o|a,s+=o;0<s;e[n+h]=255&u,h+=p,u/=256,s-=8);e[n+h-p]|=128*g}}).call(this,e("lYpoI2"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer,arguments[3],arguments[4],arguments[5],arguments[6],"/node_modules/ieee754/index.js","/node_modules/ieee754")},{buffer:3,lYpoI2:10}]},{},[1])(1)});
|
4 | }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
5 | },{}],2:[function(require,module,exports){
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | var util = require('util/');
|
34 |
|
35 | var pSlice = Array.prototype.slice;
|
36 | var hasOwn = Object.prototype.hasOwnProperty;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | var assert = module.exports = ok;
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | assert.AssertionError = function AssertionError(options) {
|
50 | this.name = 'AssertionError';
|
51 | this.actual = options.actual;
|
52 | this.expected = options.expected;
|
53 | this.operator = options.operator;
|
54 | if (options.message) {
|
55 | this.message = options.message;
|
56 | this.generatedMessage = false;
|
57 | } else {
|
58 | this.message = getMessage(this);
|
59 | this.generatedMessage = true;
|
60 | }
|
61 | var stackStartFunction = options.stackStartFunction || fail;
|
62 |
|
63 | if (Error.captureStackTrace) {
|
64 | Error.captureStackTrace(this, stackStartFunction);
|
65 | }
|
66 | else {
|
67 |
|
68 | var err = new Error();
|
69 | if (err.stack) {
|
70 | var out = err.stack;
|
71 |
|
72 |
|
73 | var fn_name = stackStartFunction.name;
|
74 | var idx = out.indexOf('\n' + fn_name);
|
75 | if (idx >= 0) {
|
76 |
|
77 |
|
78 | var next_line = out.indexOf('\n', idx + 1);
|
79 | out = out.substring(next_line + 1);
|
80 | }
|
81 |
|
82 | this.stack = out;
|
83 | }
|
84 | }
|
85 | };
|
86 |
|
87 |
|
88 | util.inherits(assert.AssertionError, Error);
|
89 |
|
90 | function replacer(key, value) {
|
91 | if (util.isUndefined(value)) {
|
92 | return '' + value;
|
93 | }
|
94 | if (util.isNumber(value) && (isNaN(value) || !isFinite(value))) {
|
95 | return value.toString();
|
96 | }
|
97 | if (util.isFunction(value) || util.isRegExp(value)) {
|
98 | return value.toString();
|
99 | }
|
100 | return value;
|
101 | }
|
102 |
|
103 | function truncate(s, n) {
|
104 | if (util.isString(s)) {
|
105 | return s.length < n ? s : s.slice(0, n);
|
106 | } else {
|
107 | return s;
|
108 | }
|
109 | }
|
110 |
|
111 | function getMessage(self) {
|
112 | return truncate(JSON.stringify(self.actual, replacer), 128) + ' ' +
|
113 | self.operator + ' ' +
|
114 | truncate(JSON.stringify(self.expected, replacer), 128);
|
115 | }
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | function fail(actual, expected, message, operator, stackStartFunction) {
|
129 | throw new assert.AssertionError({
|
130 | message: message,
|
131 | actual: actual,
|
132 | expected: expected,
|
133 | operator: operator,
|
134 | stackStartFunction: stackStartFunction
|
135 | });
|
136 | }
|
137 |
|
138 |
|
139 | assert.fail = fail;
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | function ok(value, message) {
|
149 | if (!value) fail(value, true, message, '==', assert.ok);
|
150 | }
|
151 | assert.ok = ok;
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 | assert.equal = function equal(actual, expected, message) {
|
158 | if (actual != expected) fail(actual, expected, message, '==', assert.equal);
|
159 | };
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | assert.notEqual = function notEqual(actual, expected, message) {
|
165 | if (actual == expected) {
|
166 | fail(actual, expected, message, '!=', assert.notEqual);
|
167 | }
|
168 | };
|
169 |
|
170 |
|
171 |
|
172 |
|
173 | assert.deepEqual = function deepEqual(actual, expected, message) {
|
174 | if (!_deepEqual(actual, expected)) {
|
175 | fail(actual, expected, message, 'deepEqual', assert.deepEqual);
|
176 | }
|
177 | };
|
178 |
|
179 | function _deepEqual(actual, expected) {
|
180 |
|
181 | if (actual === expected) {
|
182 | return true;
|
183 |
|
184 | } else if (util.isBuffer(actual) && util.isBuffer(expected)) {
|
185 | if (actual.length != expected.length) return false;
|
186 |
|
187 | for (var i = 0; i < actual.length; i++) {
|
188 | if (actual[i] !== expected[i]) return false;
|
189 | }
|
190 |
|
191 | return true;
|
192 |
|
193 |
|
194 |
|
195 | } else if (util.isDate(actual) && util.isDate(expected)) {
|
196 | return actual.getTime() === expected.getTime();
|
197 |
|
198 |
|
199 |
|
200 |
|
201 | } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
|
202 | return actual.source === expected.source &&
|
203 | actual.global === expected.global &&
|
204 | actual.multiline === expected.multiline &&
|
205 | actual.lastIndex === expected.lastIndex &&
|
206 | actual.ignoreCase === expected.ignoreCase;
|
207 |
|
208 |
|
209 |
|
210 | } else if (!util.isObject(actual) && !util.isObject(expected)) {
|
211 | return actual == expected;
|
212 |
|
213 |
|
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 | } else {
|
220 | return objEquiv(actual, expected);
|
221 | }
|
222 | }
|
223 |
|
224 | function isArguments(object) {
|
225 | return Object.prototype.toString.call(object) == '[object Arguments]';
|
226 | }
|
227 |
|
228 | function objEquiv(a, b) {
|
229 | if (util.isNullOrUndefined(a) || util.isNullOrUndefined(b))
|
230 | return false;
|
231 |
|
232 | if (a.prototype !== b.prototype) return false;
|
233 |
|
234 |
|
235 | if (isArguments(a)) {
|
236 | if (!isArguments(b)) {
|
237 | return false;
|
238 | }
|
239 | a = pSlice.call(a);
|
240 | b = pSlice.call(b);
|
241 | return _deepEqual(a, b);
|
242 | }
|
243 | try {
|
244 | var ka = objectKeys(a),
|
245 | kb = objectKeys(b),
|
246 | key, i;
|
247 | } catch (e) {
|
248 | return false;
|
249 | }
|
250 |
|
251 |
|
252 | if (ka.length != kb.length)
|
253 | return false;
|
254 |
|
255 | ka.sort();
|
256 | kb.sort();
|
257 |
|
258 | for (i = ka.length - 1; i >= 0; i--) {
|
259 | if (ka[i] != kb[i])
|
260 | return false;
|
261 | }
|
262 |
|
263 |
|
264 | for (i = ka.length - 1; i >= 0; i--) {
|
265 | key = ka[i];
|
266 | if (!_deepEqual(a[key], b[key])) return false;
|
267 | }
|
268 | return true;
|
269 | }
|
270 |
|
271 |
|
272 |
|
273 |
|
274 | assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
|
275 | if (_deepEqual(actual, expected)) {
|
276 | fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
|
277 | }
|
278 | };
|
279 |
|
280 |
|
281 |
|
282 |
|
283 | assert.strictEqual = function strictEqual(actual, expected, message) {
|
284 | if (actual !== expected) {
|
285 | fail(actual, expected, message, '===', assert.strictEqual);
|
286 | }
|
287 | };
|
288 |
|
289 |
|
290 |
|
291 |
|
292 | assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
|
293 | if (actual === expected) {
|
294 | fail(actual, expected, message, '!==', assert.notStrictEqual);
|
295 | }
|
296 | };
|
297 |
|
298 | function expectedException(actual, expected) {
|
299 | if (!actual || !expected) {
|
300 | return false;
|
301 | }
|
302 |
|
303 | if (Object.prototype.toString.call(expected) == '[object RegExp]') {
|
304 | return expected.test(actual);
|
305 | } else if (actual instanceof expected) {
|
306 | return true;
|
307 | } else if (expected.call({}, actual) === true) {
|
308 | return true;
|
309 | }
|
310 |
|
311 | return false;
|
312 | }
|
313 |
|
314 | function _throws(shouldThrow, block, expected, message) {
|
315 | var actual;
|
316 |
|
317 | if (util.isString(expected)) {
|
318 | message = expected;
|
319 | expected = null;
|
320 | }
|
321 |
|
322 | try {
|
323 | block();
|
324 | } catch (e) {
|
325 | actual = e;
|
326 | }
|
327 |
|
328 | message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
|
329 | (message ? ' ' + message : '.');
|
330 |
|
331 | if (shouldThrow && !actual) {
|
332 | fail(actual, expected, 'Missing expected exception' + message);
|
333 | }
|
334 |
|
335 | if (!shouldThrow && expectedException(actual, expected)) {
|
336 | fail(actual, expected, 'Got unwanted exception' + message);
|
337 | }
|
338 |
|
339 | if ((shouldThrow && actual && expected &&
|
340 | !expectedException(actual, expected)) || (!shouldThrow && actual)) {
|
341 | throw actual;
|
342 | }
|
343 | }
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | assert.throws = function(block, /*optional*/error, /*optional*/message) {
|
349 | _throws.apply(this, [true].concat(pSlice.call(arguments)));
|
350 | };
|
351 |
|
352 |
|
353 | assert.doesNotThrow = function(block, /*optional*/message) {
|
354 | _throws.apply(this, [false].concat(pSlice.call(arguments)));
|
355 | };
|
356 |
|
357 | assert.ifError = function(err) { if (err) {throw err;}};
|
358 |
|
359 | var objectKeys = Object.keys || function (obj) {
|
360 | var keys = [];
|
361 | for (var key in obj) {
|
362 | if (hasOwn.call(obj, key)) keys.push(key);
|
363 | }
|
364 | return keys;
|
365 | };
|
366 |
|
367 | },{"util/":5}],3:[function(require,module,exports){
|
368 | if (typeof Object.create === 'function') {
|
369 |
|
370 | module.exports = function inherits(ctor, superCtor) {
|
371 | ctor.super_ = superCtor
|
372 | ctor.prototype = Object.create(superCtor.prototype, {
|
373 | constructor: {
|
374 | value: ctor,
|
375 | enumerable: false,
|
376 | writable: true,
|
377 | configurable: true
|
378 | }
|
379 | });
|
380 | };
|
381 | } else {
|
382 |
|
383 | module.exports = function inherits(ctor, superCtor) {
|
384 | ctor.super_ = superCtor
|
385 | var TempCtor = function () {}
|
386 | TempCtor.prototype = superCtor.prototype
|
387 | ctor.prototype = new TempCtor()
|
388 | ctor.prototype.constructor = ctor
|
389 | }
|
390 | }
|
391 |
|
392 | },{}],4:[function(require,module,exports){
|
393 | module.exports = function isBuffer(arg) {
|
394 | return arg && typeof arg === 'object'
|
395 | && typeof arg.copy === 'function'
|
396 | && typeof arg.fill === 'function'
|
397 | && typeof arg.readUInt8 === 'function';
|
398 | }
|
399 | },{}],5:[function(require,module,exports){
|
400 | (function (process,global){
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 |
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 | var formatRegExp = /%[sdj%]/g;
|
423 | exports.format = function(f) {
|
424 | if (!isString(f)) {
|
425 | var objects = [];
|
426 | for (var i = 0; i < arguments.length; i++) {
|
427 | objects.push(inspect(arguments[i]));
|
428 | }
|
429 | return objects.join(' ');
|
430 | }
|
431 |
|
432 | var i = 1;
|
433 | var args = arguments;
|
434 | var len = args.length;
|
435 | var str = String(f).replace(formatRegExp, function(x) {
|
436 | if (x === '%%') return '%';
|
437 | if (i >= len) return x;
|
438 | switch (x) {
|
439 | case '%s': return String(args[i++]);
|
440 | case '%d': return Number(args[i++]);
|
441 | case '%j':
|
442 | try {
|
443 | return JSON.stringify(args[i++]);
|
444 | } catch (_) {
|
445 | return '[Circular]';
|
446 | }
|
447 | default:
|
448 | return x;
|
449 | }
|
450 | });
|
451 | for (var x = args[i]; i < len; x = args[++i]) {
|
452 | if (isNull(x) || !isObject(x)) {
|
453 | str += ' ' + x;
|
454 | } else {
|
455 | str += ' ' + inspect(x);
|
456 | }
|
457 | }
|
458 | return str;
|
459 | };
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 | exports.deprecate = function(fn, msg) {
|
466 |
|
467 | if (isUndefined(global.process)) {
|
468 | return function() {
|
469 | return exports.deprecate(fn, msg).apply(this, arguments);
|
470 | };
|
471 | }
|
472 |
|
473 | if (process.noDeprecation === true) {
|
474 | return fn;
|
475 | }
|
476 |
|
477 | var warned = false;
|
478 | function deprecated() {
|
479 | if (!warned) {
|
480 | if (process.throwDeprecation) {
|
481 | throw new Error(msg);
|
482 | } else if (process.traceDeprecation) {
|
483 | console.trace(msg);
|
484 | } else {
|
485 | console.error(msg);
|
486 | }
|
487 | warned = true;
|
488 | }
|
489 | return fn.apply(this, arguments);
|
490 | }
|
491 |
|
492 | return deprecated;
|
493 | };
|
494 |
|
495 |
|
496 | var debugs = {};
|
497 | var debugEnviron;
|
498 | exports.debuglog = function(set) {
|
499 | if (isUndefined(debugEnviron))
|
500 | debugEnviron = process.env.NODE_DEBUG || '';
|
501 | set = set.toUpperCase();
|
502 | if (!debugs[set]) {
|
503 | if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
|
504 | var pid = process.pid;
|
505 | debugs[set] = function() {
|
506 | var msg = exports.format.apply(exports, arguments);
|
507 | console.error('%s %d: %s', set, pid, msg);
|
508 | };
|
509 | } else {
|
510 | debugs[set] = function() {};
|
511 | }
|
512 | }
|
513 | return debugs[set];
|
514 | };
|
515 |
|
516 |
|
517 | /**
|
518 | * Echos the value of a value. Trys to print the value out
|
519 | * in the best way possible given the different types.
|
520 | *
|
521 | * @param {Object} obj The object to print out.
|
522 | * @param {Object} opts Optional options object that alters the output.
|
523 | */
|
524 |
|
525 | function inspect(obj, opts) {
|
526 |
|
527 | var ctx = {
|
528 | seen: [],
|
529 | stylize: stylizeNoColor
|
530 | };
|
531 |
|
532 | if (arguments.length >= 3) ctx.depth = arguments[2];
|
533 | if (arguments.length >= 4) ctx.colors = arguments[3];
|
534 | if (isBoolean(opts)) {
|
535 |
|
536 | ctx.showHidden = opts;
|
537 | } else if (opts) {
|
538 |
|
539 | exports._extend(ctx, opts);
|
540 | }
|
541 |
|
542 | if (isUndefined(ctx.showHidden)) ctx.showHidden = false;
|
543 | if (isUndefined(ctx.depth)) ctx.depth = 2;
|
544 | if (isUndefined(ctx.colors)) ctx.colors = false;
|
545 | if (isUndefined(ctx.customInspect)) ctx.customInspect = true;
|
546 | if (ctx.colors) ctx.stylize = stylizeWithColor;
|
547 | return formatValue(ctx, obj, ctx.depth);
|
548 | }
|
549 | exports.inspect = inspect;
|
550 |
|
551 |
|
552 |
|
553 | inspect.colors = {
|
554 | 'bold' : [1, 22],
|
555 | 'italic' : [3, 23],
|
556 | 'underline' : [4, 24],
|
557 | 'inverse' : [7, 27],
|
558 | 'white' : [37, 39],
|
559 | 'grey' : [90, 39],
|
560 | 'black' : [30, 39],
|
561 | 'blue' : [34, 39],
|
562 | 'cyan' : [36, 39],
|
563 | 'green' : [32, 39],
|
564 | 'magenta' : [35, 39],
|
565 | 'red' : [31, 39],
|
566 | 'yellow' : [33, 39]
|
567 | };
|
568 |
|
569 |
|
570 | inspect.styles = {
|
571 | 'special': 'cyan',
|
572 | 'number': 'yellow',
|
573 | 'boolean': 'yellow',
|
574 | 'undefined': 'grey',
|
575 | 'null': 'bold',
|
576 | 'string': 'green',
|
577 | 'date': 'magenta',
|
578 |
|
579 | 'regexp': 'red'
|
580 | };
|
581 |
|
582 |
|
583 | function stylizeWithColor(str, styleType) {
|
584 | var style = inspect.styles[styleType];
|
585 |
|
586 | if (style) {
|
587 | return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
588 | '\u001b[' + inspect.colors[style][1] + 'm';
|
589 | } else {
|
590 | return str;
|
591 | }
|
592 | }
|
593 |
|
594 |
|
595 | function stylizeNoColor(str, styleType) {
|
596 | return str;
|
597 | }
|
598 |
|
599 |
|
600 | function arrayToHash(array) {
|
601 | var hash = {};
|
602 |
|
603 | array.forEach(function(val, idx) {
|
604 | hash[val] = true;
|
605 | });
|
606 |
|
607 | return hash;
|
608 | }
|
609 |
|
610 |
|
611 | function formatValue(ctx, value, recurseTimes) {
|
612 |
|
613 |
|
614 | if (ctx.customInspect &&
|
615 | value &&
|
616 | isFunction(value.inspect) &&
|
617 |
|
618 | value.inspect !== exports.inspect &&
|
619 |
|
620 | !(value.constructor && value.constructor.prototype === value)) {
|
621 | var ret = value.inspect(recurseTimes, ctx);
|
622 | if (!isString(ret)) {
|
623 | ret = formatValue(ctx, ret, recurseTimes);
|
624 | }
|
625 | return ret;
|
626 | }
|
627 |
|
628 |
|
629 | var primitive = formatPrimitive(ctx, value);
|
630 | if (primitive) {
|
631 | return primitive;
|
632 | }
|
633 |
|
634 |
|
635 | var keys = Object.keys(value);
|
636 | var visibleKeys = arrayToHash(keys);
|
637 |
|
638 | if (ctx.showHidden) {
|
639 | keys = Object.getOwnPropertyNames(value);
|
640 | }
|
641 |
|
642 |
|
643 |
|
644 | if (isError(value)
|
645 | && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {
|
646 | return formatError(value);
|
647 | }
|
648 |
|
649 |
|
650 | if (keys.length === 0) {
|
651 | if (isFunction(value)) {
|
652 | var name = value.name ? ': ' + value.name : '';
|
653 | return ctx.stylize('[Function' + name + ']', 'special');
|
654 | }
|
655 | if (isRegExp(value)) {
|
656 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
657 | }
|
658 | if (isDate(value)) {
|
659 | return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
660 | }
|
661 | if (isError(value)) {
|
662 | return formatError(value);
|
663 | }
|
664 | }
|
665 |
|
666 | var base = '', array = false, braces = ['{', '}'];
|
667 |
|
668 |
|
669 | if (isArray(value)) {
|
670 | array = true;
|
671 | braces = ['[', ']'];
|
672 | }
|
673 |
|
674 |
|
675 | if (isFunction(value)) {
|
676 | var n = value.name ? ': ' + value.name : '';
|
677 | base = ' [Function' + n + ']';
|
678 | }
|
679 |
|
680 |
|
681 | if (isRegExp(value)) {
|
682 | base = ' ' + RegExp.prototype.toString.call(value);
|
683 | }
|
684 |
|
685 |
|
686 | if (isDate(value)) {
|
687 | base = ' ' + Date.prototype.toUTCString.call(value);
|
688 | }
|
689 |
|
690 |
|
691 | if (isError(value)) {
|
692 | base = ' ' + formatError(value);
|
693 | }
|
694 |
|
695 | if (keys.length === 0 && (!array || value.length == 0)) {
|
696 | return braces[0] + base + braces[1];
|
697 | }
|
698 |
|
699 | if (recurseTimes < 0) {
|
700 | if (isRegExp(value)) {
|
701 | return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
702 | } else {
|
703 | return ctx.stylize('[Object]', 'special');
|
704 | }
|
705 | }
|
706 |
|
707 | ctx.seen.push(value);
|
708 |
|
709 | var output;
|
710 | if (array) {
|
711 | output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
712 | } else {
|
713 | output = keys.map(function(key) {
|
714 | return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
715 | });
|
716 | }
|
717 |
|
718 | ctx.seen.pop();
|
719 |
|
720 | return reduceToSingleString(output, base, braces);
|
721 | }
|
722 |
|
723 |
|
724 | function formatPrimitive(ctx, value) {
|
725 | if (isUndefined(value))
|
726 | return ctx.stylize('undefined', 'undefined');
|
727 | if (isString(value)) {
|
728 | var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
729 | .replace(/'/g, "\\'")
|
730 | .replace(/\\"/g, '"') + '\'';
|
731 | return ctx.stylize(simple, 'string');
|
732 | }
|
733 | if (isNumber(value))
|
734 | return ctx.stylize('' + value, 'number');
|
735 | if (isBoolean(value))
|
736 | return ctx.stylize('' + value, 'boolean');
|
737 |
|
738 | if (isNull(value))
|
739 | return ctx.stylize('null', 'null');
|
740 | }
|
741 |
|
742 |
|
743 | function formatError(value) {
|
744 | return '[' + Error.prototype.toString.call(value) + ']';
|
745 | }
|
746 |
|
747 |
|
748 | function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
749 | var output = [];
|
750 | for (var i = 0, l = value.length; i < l; ++i) {
|
751 | if (hasOwnProperty(value, String(i))) {
|
752 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
753 | String(i), true));
|
754 | } else {
|
755 | output.push('');
|
756 | }
|
757 | }
|
758 | keys.forEach(function(key) {
|
759 | if (!key.match(/^\d+$/)) {
|
760 | output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
761 | key, true));
|
762 | }
|
763 | });
|
764 | return output;
|
765 | }
|
766 |
|
767 |
|
768 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
769 | var name, str, desc;
|
770 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
771 | if (desc.get) {
|
772 | if (desc.set) {
|
773 | str = ctx.stylize('[Getter/Setter]', 'special');
|
774 | } else {
|
775 | str = ctx.stylize('[Getter]', 'special');
|
776 | }
|
777 | } else {
|
778 | if (desc.set) {
|
779 | str = ctx.stylize('[Setter]', 'special');
|
780 | }
|
781 | }
|
782 | if (!hasOwnProperty(visibleKeys, key)) {
|
783 | name = '[' + key + ']';
|
784 | }
|
785 | if (!str) {
|
786 | if (ctx.seen.indexOf(desc.value) < 0) {
|
787 | if (isNull(recurseTimes)) {
|
788 | str = formatValue(ctx, desc.value, null);
|
789 | } else {
|
790 | str = formatValue(ctx, desc.value, recurseTimes - 1);
|
791 | }
|
792 | if (str.indexOf('\n') > -1) {
|
793 | if (array) {
|
794 | str = str.split('\n').map(function(line) {
|
795 | return ' ' + line;
|
796 | }).join('\n').substr(2);
|
797 | } else {
|
798 | str = '\n' + str.split('\n').map(function(line) {
|
799 | return ' ' + line;
|
800 | }).join('\n');
|
801 | }
|
802 | }
|
803 | } else {
|
804 | str = ctx.stylize('[Circular]', 'special');
|
805 | }
|
806 | }
|
807 | if (isUndefined(name)) {
|
808 | if (array && key.match(/^\d+$/)) {
|
809 | return str;
|
810 | }
|
811 | name = JSON.stringify('' + key);
|
812 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
813 | name = name.substr(1, name.length - 2);
|
814 | name = ctx.stylize(name, 'name');
|
815 | } else {
|
816 | name = name.replace(/'/g, "\\'")
|
817 | .replace(/\\"/g, '"')
|
818 | .replace(/(^"|"$)/g, "'");
|
819 | name = ctx.stylize(name, 'string');
|
820 | }
|
821 | }
|
822 |
|
823 | return name + ': ' + str;
|
824 | }
|
825 |
|
826 |
|
827 | function reduceToSingleString(output, base, braces) {
|
828 | var numLinesEst = 0;
|
829 | var length = output.reduce(function(prev, cur) {
|
830 | numLinesEst++;
|
831 | if (cur.indexOf('\n') >= 0) numLinesEst++;
|
832 | return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1;
|
833 | }, 0);
|
834 |
|
835 | if (length > 60) {
|
836 | return braces[0] +
|
837 | (base === '' ? '' : base + '\n ') +
|
838 | ' ' +
|
839 | output.join(',\n ') +
|
840 | ' ' +
|
841 | braces[1];
|
842 | }
|
843 |
|
844 | return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
845 | }
|
846 |
|
847 |
|
848 |
|
849 |
|
850 | function isArray(ar) {
|
851 | return Array.isArray(ar);
|
852 | }
|
853 | exports.isArray = isArray;
|
854 |
|
855 | function isBoolean(arg) {
|
856 | return typeof arg === 'boolean';
|
857 | }
|
858 | exports.isBoolean = isBoolean;
|
859 |
|
860 | function isNull(arg) {
|
861 | return arg === null;
|
862 | }
|
863 | exports.isNull = isNull;
|
864 |
|
865 | function isNullOrUndefined(arg) {
|
866 | return arg == null;
|
867 | }
|
868 | exports.isNullOrUndefined = isNullOrUndefined;
|
869 |
|
870 | function isNumber(arg) {
|
871 | return typeof arg === 'number';
|
872 | }
|
873 | exports.isNumber = isNumber;
|
874 |
|
875 | function isString(arg) {
|
876 | return typeof arg === 'string';
|
877 | }
|
878 | exports.isString = isString;
|
879 |
|
880 | function isSymbol(arg) {
|
881 | return typeof arg === 'symbol';
|
882 | }
|
883 | exports.isSymbol = isSymbol;
|
884 |
|
885 | function isUndefined(arg) {
|
886 | return arg === void 0;
|
887 | }
|
888 | exports.isUndefined = isUndefined;
|
889 |
|
890 | function isRegExp(re) {
|
891 | return isObject(re) && objectToString(re) === '[object RegExp]';
|
892 | }
|
893 | exports.isRegExp = isRegExp;
|
894 |
|
895 | function isObject(arg) {
|
896 | return typeof arg === 'object' && arg !== null;
|
897 | }
|
898 | exports.isObject = isObject;
|
899 |
|
900 | function isDate(d) {
|
901 | return isObject(d) && objectToString(d) === '[object Date]';
|
902 | }
|
903 | exports.isDate = isDate;
|
904 |
|
905 | function isError(e) {
|
906 | return isObject(e) &&
|
907 | (objectToString(e) === '[object Error]' || e instanceof Error);
|
908 | }
|
909 | exports.isError = isError;
|
910 |
|
911 | function isFunction(arg) {
|
912 | return typeof arg === 'function';
|
913 | }
|
914 | exports.isFunction = isFunction;
|
915 |
|
916 | function isPrimitive(arg) {
|
917 | return arg === null ||
|
918 | typeof arg === 'boolean' ||
|
919 | typeof arg === 'number' ||
|
920 | typeof arg === 'string' ||
|
921 | typeof arg === 'symbol' ||
|
922 | typeof arg === 'undefined';
|
923 | }
|
924 | exports.isPrimitive = isPrimitive;
|
925 |
|
926 | exports.isBuffer = require('./support/isBuffer');
|
927 |
|
928 | function objectToString(o) {
|
929 | return Object.prototype.toString.call(o);
|
930 | }
|
931 |
|
932 |
|
933 | function pad(n) {
|
934 | return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
935 | }
|
936 |
|
937 |
|
938 | var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
939 | 'Oct', 'Nov', 'Dec'];
|
940 |
|
941 |
|
942 | function timestamp() {
|
943 | var d = new Date();
|
944 | var time = [pad(d.getHours()),
|
945 | pad(d.getMinutes()),
|
946 | pad(d.getSeconds())].join(':');
|
947 | return [d.getDate(), months[d.getMonth()], time].join(' ');
|
948 | }
|
949 |
|
950 |
|
951 |
|
952 | exports.log = function() {
|
953 | console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments));
|
954 | };
|
955 |
|
956 |
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 | exports.inherits = require('inherits');
|
971 |
|
972 | exports._extend = function(origin, add) {
|
973 |
|
974 | if (!add || !isObject(add)) return origin;
|
975 |
|
976 | var keys = Object.keys(add);
|
977 | var i = keys.length;
|
978 | while (i--) {
|
979 | origin[keys[i]] = add[keys[i]];
|
980 | }
|
981 | return origin;
|
982 | };
|
983 |
|
984 | function hasOwnProperty(obj, prop) {
|
985 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
986 | }
|
987 |
|
988 | }).call(this,require("7YKIPe"),typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
989 | },{"./support/isBuffer":4,"7YKIPe":9,"inherits":3}],6:[function(require,module,exports){
|
990 | var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
991 |
|
992 | ;(function (exports) {
|
993 | 'use strict';
|
994 |
|
995 | var Arr = (typeof Uint8Array !== 'undefined')
|
996 | ? Uint8Array
|
997 | : Array
|
998 |
|
999 | var PLUS = '+'.charCodeAt(0)
|
1000 | var SLASH = '/'.charCodeAt(0)
|
1001 | var NUMBER = '0'.charCodeAt(0)
|
1002 | var LOWER = 'a'.charCodeAt(0)
|
1003 | var UPPER = 'A'.charCodeAt(0)
|
1004 | var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
1005 | var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
1006 |
|
1007 | function decode (elt) {
|
1008 | var code = elt.charCodeAt(0)
|
1009 | if (code === PLUS ||
|
1010 | code === PLUS_URL_SAFE)
|
1011 | return 62
|
1012 | if (code === SLASH ||
|
1013 | code === SLASH_URL_SAFE)
|
1014 | return 63
|
1015 | if (code < NUMBER)
|
1016 | return -1
|
1017 | if (code < NUMBER + 10)
|
1018 | return code - NUMBER + 26 + 26
|
1019 | if (code < UPPER + 26)
|
1020 | return code - UPPER
|
1021 | if (code < LOWER + 26)
|
1022 | return code - LOWER + 26
|
1023 | }
|
1024 |
|
1025 | function b64ToByteArray (b64) {
|
1026 | var i, j, l, tmp, placeHolders, arr
|
1027 |
|
1028 | if (b64.length % 4 > 0) {
|
1029 | throw new Error('Invalid string. Length must be a multiple of 4')
|
1030 | }
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 | var len = b64.length
|
1038 | placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
1039 |
|
1040 |
|
1041 | arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
1042 |
|
1043 |
|
1044 | l = placeHolders > 0 ? b64.length - 4 : b64.length
|
1045 |
|
1046 | var L = 0
|
1047 |
|
1048 | function push (v) {
|
1049 | arr[L++] = v
|
1050 | }
|
1051 |
|
1052 | for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
1053 | tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
1054 | push((tmp & 0xFF0000) >> 16)
|
1055 | push((tmp & 0xFF00) >> 8)
|
1056 | push(tmp & 0xFF)
|
1057 | }
|
1058 |
|
1059 | if (placeHolders === 2) {
|
1060 | tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
1061 | push(tmp & 0xFF)
|
1062 | } else if (placeHolders === 1) {
|
1063 | tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
1064 | push((tmp >> 8) & 0xFF)
|
1065 | push(tmp & 0xFF)
|
1066 | }
|
1067 |
|
1068 | return arr
|
1069 | }
|
1070 |
|
1071 | function uint8ToBase64 (uint8) {
|
1072 | var i,
|
1073 | extraBytes = uint8.length % 3,
|
1074 | output = "",
|
1075 | temp, length
|
1076 |
|
1077 | function encode (num) {
|
1078 | return lookup.charAt(num)
|
1079 | }
|
1080 |
|
1081 | function tripletToBase64 (num) {
|
1082 | return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
1083 | }
|
1084 |
|
1085 |
|
1086 | for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
1087 | temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
1088 | output += tripletToBase64(temp)
|
1089 | }
|
1090 |
|
1091 |
|
1092 | switch (extraBytes) {
|
1093 | case 1:
|
1094 | temp = uint8[uint8.length - 1]
|
1095 | output += encode(temp >> 2)
|
1096 | output += encode((temp << 4) & 0x3F)
|
1097 | output += '=='
|
1098 | break
|
1099 | case 2:
|
1100 | temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
1101 | output += encode(temp >> 10)
|
1102 | output += encode((temp >> 4) & 0x3F)
|
1103 | output += encode((temp << 2) & 0x3F)
|
1104 | output += '='
|
1105 | break
|
1106 | }
|
1107 |
|
1108 | return output
|
1109 | }
|
1110 |
|
1111 | exports.toByteArray = b64ToByteArray
|
1112 | exports.fromByteArray = uint8ToBase64
|
1113 | }(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
1114 |
|
1115 | },{}],7:[function(require,module,exports){
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 |
|
1123 | var base64 = require('base64-js')
|
1124 | var ieee754 = require('ieee754')
|
1125 |
|
1126 | exports.Buffer = Buffer
|
1127 | exports.SlowBuffer = Buffer
|
1128 | exports.INSPECT_MAX_BYTES = 50
|
1129 | Buffer.poolSize = 8192
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 | Buffer._useTypedArrays = (function () {
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 | try {
|
1143 | var buf = new ArrayBuffer(0)
|
1144 | var arr = new Uint8Array(buf)
|
1145 | arr.foo = function () { return 42 }
|
1146 | return 42 === arr.foo() &&
|
1147 | typeof arr.subarray === 'function'
|
1148 | } catch (e) {
|
1149 | return false
|
1150 | }
|
1151 | })()
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 | function Buffer (subject, encoding, noZero) {
|
1166 | if (!(this instanceof Buffer))
|
1167 | return new Buffer(subject, encoding, noZero)
|
1168 |
|
1169 | var type = typeof subject
|
1170 |
|
1171 |
|
1172 |
|
1173 | if (encoding === 'base64' && type === 'string') {
|
1174 | subject = stringtrim(subject)
|
1175 | while (subject.length % 4 !== 0) {
|
1176 | subject = subject + '='
|
1177 | }
|
1178 | }
|
1179 |
|
1180 |
|
1181 | var length
|
1182 | if (type === 'number')
|
1183 | length = coerce(subject)
|
1184 | else if (type === 'string')
|
1185 | length = Buffer.byteLength(subject, encoding)
|
1186 | else if (type === 'object')
|
1187 | length = coerce(subject.length)
|
1188 | else
|
1189 | throw new Error('First argument needs to be a number, array or string.')
|
1190 |
|
1191 | var buf
|
1192 | if (Buffer._useTypedArrays) {
|
1193 |
|
1194 | buf = Buffer._augment(new Uint8Array(length))
|
1195 | } else {
|
1196 |
|
1197 | buf = this
|
1198 | buf.length = length
|
1199 | buf._isBuffer = true
|
1200 | }
|
1201 |
|
1202 | var i
|
1203 | if (Buffer._useTypedArrays && typeof subject.byteLength === 'number') {
|
1204 |
|
1205 | buf._set(subject)
|
1206 | } else if (isArrayish(subject)) {
|
1207 |
|
1208 | for (i = 0; i < length; i++) {
|
1209 | if (Buffer.isBuffer(subject))
|
1210 | buf[i] = subject.readUInt8(i)
|
1211 | else
|
1212 | buf[i] = subject[i]
|
1213 | }
|
1214 | } else if (type === 'string') {
|
1215 | buf.write(subject, 0, encoding)
|
1216 | } else if (type === 'number' && !Buffer._useTypedArrays && !noZero) {
|
1217 | for (i = 0; i < length; i++) {
|
1218 | buf[i] = 0
|
1219 | }
|
1220 | }
|
1221 |
|
1222 | return buf
|
1223 | }
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 | Buffer.isEncoding = function (encoding) {
|
1229 | switch (String(encoding).toLowerCase()) {
|
1230 | case 'hex':
|
1231 | case 'utf8':
|
1232 | case 'utf-8':
|
1233 | case 'ascii':
|
1234 | case 'binary':
|
1235 | case 'base64':
|
1236 | case 'raw':
|
1237 | case 'ucs2':
|
1238 | case 'ucs-2':
|
1239 | case 'utf16le':
|
1240 | case 'utf-16le':
|
1241 | return true
|
1242 | default:
|
1243 | return false
|
1244 | }
|
1245 | }
|
1246 |
|
1247 | Buffer.isBuffer = function (b) {
|
1248 | return !!(b !== null && b !== undefined && b._isBuffer)
|
1249 | }
|
1250 |
|
1251 | Buffer.byteLength = function (str, encoding) {
|
1252 | var ret
|
1253 | str = str + ''
|
1254 | switch (encoding || 'utf8') {
|
1255 | case 'hex':
|
1256 | ret = str.length / 2
|
1257 | break
|
1258 | case 'utf8':
|
1259 | case 'utf-8':
|
1260 | ret = utf8ToBytes(str).length
|
1261 | break
|
1262 | case 'ascii':
|
1263 | case 'binary':
|
1264 | case 'raw':
|
1265 | ret = str.length
|
1266 | break
|
1267 | case 'base64':
|
1268 | ret = base64ToBytes(str).length
|
1269 | break
|
1270 | case 'ucs2':
|
1271 | case 'ucs-2':
|
1272 | case 'utf16le':
|
1273 | case 'utf-16le':
|
1274 | ret = str.length * 2
|
1275 | break
|
1276 | default:
|
1277 | throw new Error('Unknown encoding')
|
1278 | }
|
1279 | return ret
|
1280 | }
|
1281 |
|
1282 | Buffer.concat = function (list, totalLength) {
|
1283 | assert(isArray(list), 'Usage: Buffer.concat(list, [totalLength])\n' +
|
1284 | 'list should be an Array.')
|
1285 |
|
1286 | if (list.length === 0) {
|
1287 | return new Buffer(0)
|
1288 | } else if (list.length === 1) {
|
1289 | return list[0]
|
1290 | }
|
1291 |
|
1292 | var i
|
1293 | if (typeof totalLength !== 'number') {
|
1294 | totalLength = 0
|
1295 | for (i = 0; i < list.length; i++) {
|
1296 | totalLength += list[i].length
|
1297 | }
|
1298 | }
|
1299 |
|
1300 | var buf = new Buffer(totalLength)
|
1301 | var pos = 0
|
1302 | for (i = 0; i < list.length; i++) {
|
1303 | var item = list[i]
|
1304 | item.copy(buf, pos)
|
1305 | pos += item.length
|
1306 | }
|
1307 | return buf
|
1308 | }
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 | function _hexWrite (buf, string, offset, length) {
|
1314 | offset = Number(offset) || 0
|
1315 | var remaining = buf.length - offset
|
1316 | if (!length) {
|
1317 | length = remaining
|
1318 | } else {
|
1319 | length = Number(length)
|
1320 | if (length > remaining) {
|
1321 | length = remaining
|
1322 | }
|
1323 | }
|
1324 |
|
1325 |
|
1326 | var strLen = string.length
|
1327 | assert(strLen % 2 === 0, 'Invalid hex string')
|
1328 |
|
1329 | if (length > strLen / 2) {
|
1330 | length = strLen / 2
|
1331 | }
|
1332 | for (var i = 0; i < length; i++) {
|
1333 | var byte = parseInt(string.substr(i * 2, 2), 16)
|
1334 | assert(!isNaN(byte), 'Invalid hex string')
|
1335 | buf[offset + i] = byte
|
1336 | }
|
1337 | Buffer._charsWritten = i * 2
|
1338 | return i
|
1339 | }
|
1340 |
|
1341 | function _utf8Write (buf, string, offset, length) {
|
1342 | var charsWritten = Buffer._charsWritten =
|
1343 | blitBuffer(utf8ToBytes(string), buf, offset, length)
|
1344 | return charsWritten
|
1345 | }
|
1346 |
|
1347 | function _asciiWrite (buf, string, offset, length) {
|
1348 | var charsWritten = Buffer._charsWritten =
|
1349 | blitBuffer(asciiToBytes(string), buf, offset, length)
|
1350 | return charsWritten
|
1351 | }
|
1352 |
|
1353 | function _binaryWrite (buf, string, offset, length) {
|
1354 | return _asciiWrite(buf, string, offset, length)
|
1355 | }
|
1356 |
|
1357 | function _base64Write (buf, string, offset, length) {
|
1358 | var charsWritten = Buffer._charsWritten =
|
1359 | blitBuffer(base64ToBytes(string), buf, offset, length)
|
1360 | return charsWritten
|
1361 | }
|
1362 |
|
1363 | function _utf16leWrite (buf, string, offset, length) {
|
1364 | var charsWritten = Buffer._charsWritten =
|
1365 | blitBuffer(utf16leToBytes(string), buf, offset, length)
|
1366 | return charsWritten
|
1367 | }
|
1368 |
|
1369 | Buffer.prototype.write = function (string, offset, length, encoding) {
|
1370 |
|
1371 |
|
1372 | if (isFinite(offset)) {
|
1373 | if (!isFinite(length)) {
|
1374 | encoding = length
|
1375 | length = undefined
|
1376 | }
|
1377 | } else {
|
1378 | var swap = encoding
|
1379 | encoding = offset
|
1380 | offset = length
|
1381 | length = swap
|
1382 | }
|
1383 |
|
1384 | offset = Number(offset) || 0
|
1385 | var remaining = this.length - offset
|
1386 | if (!length) {
|
1387 | length = remaining
|
1388 | } else {
|
1389 | length = Number(length)
|
1390 | if (length > remaining) {
|
1391 | length = remaining
|
1392 | }
|
1393 | }
|
1394 | encoding = String(encoding || 'utf8').toLowerCase()
|
1395 |
|
1396 | var ret
|
1397 | switch (encoding) {
|
1398 | case 'hex':
|
1399 | ret = _hexWrite(this, string, offset, length)
|
1400 | break
|
1401 | case 'utf8':
|
1402 | case 'utf-8':
|
1403 | ret = _utf8Write(this, string, offset, length)
|
1404 | break
|
1405 | case 'ascii':
|
1406 | ret = _asciiWrite(this, string, offset, length)
|
1407 | break
|
1408 | case 'binary':
|
1409 | ret = _binaryWrite(this, string, offset, length)
|
1410 | break
|
1411 | case 'base64':
|
1412 | ret = _base64Write(this, string, offset, length)
|
1413 | break
|
1414 | case 'ucs2':
|
1415 | case 'ucs-2':
|
1416 | case 'utf16le':
|
1417 | case 'utf-16le':
|
1418 | ret = _utf16leWrite(this, string, offset, length)
|
1419 | break
|
1420 | default:
|
1421 | throw new Error('Unknown encoding')
|
1422 | }
|
1423 | return ret
|
1424 | }
|
1425 |
|
1426 | Buffer.prototype.toString = function (encoding, start, end) {
|
1427 | var self = this
|
1428 |
|
1429 | encoding = String(encoding || 'utf8').toLowerCase()
|
1430 | start = Number(start) || 0
|
1431 | end = (end !== undefined)
|
1432 | ? Number(end)
|
1433 | : end = self.length
|
1434 |
|
1435 |
|
1436 | if (end === start)
|
1437 | return ''
|
1438 |
|
1439 | var ret
|
1440 | switch (encoding) {
|
1441 | case 'hex':
|
1442 | ret = _hexSlice(self, start, end)
|
1443 | break
|
1444 | case 'utf8':
|
1445 | case 'utf-8':
|
1446 | ret = _utf8Slice(self, start, end)
|
1447 | break
|
1448 | case 'ascii':
|
1449 | ret = _asciiSlice(self, start, end)
|
1450 | break
|
1451 | case 'binary':
|
1452 | ret = _binarySlice(self, start, end)
|
1453 | break
|
1454 | case 'base64':
|
1455 | ret = _base64Slice(self, start, end)
|
1456 | break
|
1457 | case 'ucs2':
|
1458 | case 'ucs-2':
|
1459 | case 'utf16le':
|
1460 | case 'utf-16le':
|
1461 | ret = _utf16leSlice(self, start, end)
|
1462 | break
|
1463 | default:
|
1464 | throw new Error('Unknown encoding')
|
1465 | }
|
1466 | return ret
|
1467 | }
|
1468 |
|
1469 | Buffer.prototype.toJSON = function () {
|
1470 | return {
|
1471 | type: 'Buffer',
|
1472 | data: Array.prototype.slice.call(this._arr || this, 0)
|
1473 | }
|
1474 | }
|
1475 |
|
1476 |
|
1477 | Buffer.prototype.copy = function (target, target_start, start, end) {
|
1478 | var source = this
|
1479 |
|
1480 | if (!start) start = 0
|
1481 | if (!end && end !== 0) end = this.length
|
1482 | if (!target_start) target_start = 0
|
1483 |
|
1484 |
|
1485 | if (end === start) return
|
1486 | if (target.length === 0 || source.length === 0) return
|
1487 |
|
1488 |
|
1489 | assert(end >= start, 'sourceEnd < sourceStart')
|
1490 | assert(target_start >= 0 && target_start < target.length,
|
1491 | 'targetStart out of bounds')
|
1492 | assert(start >= 0 && start < source.length, 'sourceStart out of bounds')
|
1493 | assert(end >= 0 && end <= source.length, 'sourceEnd out of bounds')
|
1494 |
|
1495 |
|
1496 | if (end > this.length)
|
1497 | end = this.length
|
1498 | if (target.length - target_start < end - start)
|
1499 | end = target.length - target_start + start
|
1500 |
|
1501 | var len = end - start
|
1502 |
|
1503 | if (len < 100 || !Buffer._useTypedArrays) {
|
1504 | for (var i = 0; i < len; i++)
|
1505 | target[i + target_start] = this[i + start]
|
1506 | } else {
|
1507 | target._set(this.subarray(start, start + len), target_start)
|
1508 | }
|
1509 | }
|
1510 |
|
1511 | function _base64Slice (buf, start, end) {
|
1512 | if (start === 0 && end === buf.length) {
|
1513 | return base64.fromByteArray(buf)
|
1514 | } else {
|
1515 | return base64.fromByteArray(buf.slice(start, end))
|
1516 | }
|
1517 | }
|
1518 |
|
1519 | function _utf8Slice (buf, start, end) {
|
1520 | var res = ''
|
1521 | var tmp = ''
|
1522 | end = Math.min(buf.length, end)
|
1523 |
|
1524 | for (var i = start; i < end; i++) {
|
1525 | if (buf[i] <= 0x7F) {
|
1526 | res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i])
|
1527 | tmp = ''
|
1528 | } else {
|
1529 | tmp += '%' + buf[i].toString(16)
|
1530 | }
|
1531 | }
|
1532 |
|
1533 | return res + decodeUtf8Char(tmp)
|
1534 | }
|
1535 |
|
1536 | function _asciiSlice (buf, start, end) {
|
1537 | var ret = ''
|
1538 | end = Math.min(buf.length, end)
|
1539 |
|
1540 | for (var i = start; i < end; i++)
|
1541 | ret += String.fromCharCode(buf[i])
|
1542 | return ret
|
1543 | }
|
1544 |
|
1545 | function _binarySlice (buf, start, end) {
|
1546 | return _asciiSlice(buf, start, end)
|
1547 | }
|
1548 |
|
1549 | function _hexSlice (buf, start, end) {
|
1550 | var len = buf.length
|
1551 |
|
1552 | if (!start || start < 0) start = 0
|
1553 | if (!end || end < 0 || end > len) end = len
|
1554 |
|
1555 | var out = ''
|
1556 | for (var i = start; i < end; i++) {
|
1557 | out += toHex(buf[i])
|
1558 | }
|
1559 | return out
|
1560 | }
|
1561 |
|
1562 | function _utf16leSlice (buf, start, end) {
|
1563 | var bytes = buf.slice(start, end)
|
1564 | var res = ''
|
1565 | for (var i = 0; i < bytes.length; i += 2) {
|
1566 | res += String.fromCharCode(bytes[i] + bytes[i+1] * 256)
|
1567 | }
|
1568 | return res
|
1569 | }
|
1570 |
|
1571 | Buffer.prototype.slice = function (start, end) {
|
1572 | var len = this.length
|
1573 | start = clamp(start, len, 0)
|
1574 | end = clamp(end, len, len)
|
1575 |
|
1576 | if (Buffer._useTypedArrays) {
|
1577 | return Buffer._augment(this.subarray(start, end))
|
1578 | } else {
|
1579 | var sliceLen = end - start
|
1580 | var newBuf = new Buffer(sliceLen, undefined, true)
|
1581 | for (var i = 0; i < sliceLen; i++) {
|
1582 | newBuf[i] = this[i + start]
|
1583 | }
|
1584 | return newBuf
|
1585 | }
|
1586 | }
|
1587 |
|
1588 |
|
1589 | Buffer.prototype.get = function (offset) {
|
1590 | console.log('.get() is deprecated. Access using array indexes instead.')
|
1591 | return this.readUInt8(offset)
|
1592 | }
|
1593 |
|
1594 |
|
1595 | Buffer.prototype.set = function (v, offset) {
|
1596 | console.log('.set() is deprecated. Access using array indexes instead.')
|
1597 | return this.writeUInt8(v, offset)
|
1598 | }
|
1599 |
|
1600 | Buffer.prototype.readUInt8 = function (offset, noAssert) {
|
1601 | if (!noAssert) {
|
1602 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1603 | assert(offset < this.length, 'Trying to read beyond buffer length')
|
1604 | }
|
1605 |
|
1606 | if (offset >= this.length)
|
1607 | return
|
1608 |
|
1609 | return this[offset]
|
1610 | }
|
1611 |
|
1612 | function _readUInt16 (buf, offset, littleEndian, noAssert) {
|
1613 | if (!noAssert) {
|
1614 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1615 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1616 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
1617 | }
|
1618 |
|
1619 | var len = buf.length
|
1620 | if (offset >= len)
|
1621 | return
|
1622 |
|
1623 | var val
|
1624 | if (littleEndian) {
|
1625 | val = buf[offset]
|
1626 | if (offset + 1 < len)
|
1627 | val |= buf[offset + 1] << 8
|
1628 | } else {
|
1629 | val = buf[offset] << 8
|
1630 | if (offset + 1 < len)
|
1631 | val |= buf[offset + 1]
|
1632 | }
|
1633 | return val
|
1634 | }
|
1635 |
|
1636 | Buffer.prototype.readUInt16LE = function (offset, noAssert) {
|
1637 | return _readUInt16(this, offset, true, noAssert)
|
1638 | }
|
1639 |
|
1640 | Buffer.prototype.readUInt16BE = function (offset, noAssert) {
|
1641 | return _readUInt16(this, offset, false, noAssert)
|
1642 | }
|
1643 |
|
1644 | function _readUInt32 (buf, offset, littleEndian, noAssert) {
|
1645 | if (!noAssert) {
|
1646 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1647 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1648 | assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
1649 | }
|
1650 |
|
1651 | var len = buf.length
|
1652 | if (offset >= len)
|
1653 | return
|
1654 |
|
1655 | var val
|
1656 | if (littleEndian) {
|
1657 | if (offset + 2 < len)
|
1658 | val = buf[offset + 2] << 16
|
1659 | if (offset + 1 < len)
|
1660 | val |= buf[offset + 1] << 8
|
1661 | val |= buf[offset]
|
1662 | if (offset + 3 < len)
|
1663 | val = val + (buf[offset + 3] << 24 >>> 0)
|
1664 | } else {
|
1665 | if (offset + 1 < len)
|
1666 | val = buf[offset + 1] << 16
|
1667 | if (offset + 2 < len)
|
1668 | val |= buf[offset + 2] << 8
|
1669 | if (offset + 3 < len)
|
1670 | val |= buf[offset + 3]
|
1671 | val = val + (buf[offset] << 24 >>> 0)
|
1672 | }
|
1673 | return val
|
1674 | }
|
1675 |
|
1676 | Buffer.prototype.readUInt32LE = function (offset, noAssert) {
|
1677 | return _readUInt32(this, offset, true, noAssert)
|
1678 | }
|
1679 |
|
1680 | Buffer.prototype.readUInt32BE = function (offset, noAssert) {
|
1681 | return _readUInt32(this, offset, false, noAssert)
|
1682 | }
|
1683 |
|
1684 | Buffer.prototype.readInt8 = function (offset, noAssert) {
|
1685 | if (!noAssert) {
|
1686 | assert(offset !== undefined && offset !== null,
|
1687 | 'missing offset')
|
1688 | assert(offset < this.length, 'Trying to read beyond buffer length')
|
1689 | }
|
1690 |
|
1691 | if (offset >= this.length)
|
1692 | return
|
1693 |
|
1694 | var neg = this[offset] & 0x80
|
1695 | if (neg)
|
1696 | return (0xff - this[offset] + 1) * -1
|
1697 | else
|
1698 | return this[offset]
|
1699 | }
|
1700 |
|
1701 | function _readInt16 (buf, offset, littleEndian, noAssert) {
|
1702 | if (!noAssert) {
|
1703 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1704 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1705 | assert(offset + 1 < buf.length, 'Trying to read beyond buffer length')
|
1706 | }
|
1707 |
|
1708 | var len = buf.length
|
1709 | if (offset >= len)
|
1710 | return
|
1711 |
|
1712 | var val = _readUInt16(buf, offset, littleEndian, true)
|
1713 | var neg = val & 0x8000
|
1714 | if (neg)
|
1715 | return (0xffff - val + 1) * -1
|
1716 | else
|
1717 | return val
|
1718 | }
|
1719 |
|
1720 | Buffer.prototype.readInt16LE = function (offset, noAssert) {
|
1721 | return _readInt16(this, offset, true, noAssert)
|
1722 | }
|
1723 |
|
1724 | Buffer.prototype.readInt16BE = function (offset, noAssert) {
|
1725 | return _readInt16(this, offset, false, noAssert)
|
1726 | }
|
1727 |
|
1728 | function _readInt32 (buf, offset, littleEndian, noAssert) {
|
1729 | if (!noAssert) {
|
1730 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1731 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1732 | assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
1733 | }
|
1734 |
|
1735 | var len = buf.length
|
1736 | if (offset >= len)
|
1737 | return
|
1738 |
|
1739 | var val = _readUInt32(buf, offset, littleEndian, true)
|
1740 | var neg = val & 0x80000000
|
1741 | if (neg)
|
1742 | return (0xffffffff - val + 1) * -1
|
1743 | else
|
1744 | return val
|
1745 | }
|
1746 |
|
1747 | Buffer.prototype.readInt32LE = function (offset, noAssert) {
|
1748 | return _readInt32(this, offset, true, noAssert)
|
1749 | }
|
1750 |
|
1751 | Buffer.prototype.readInt32BE = function (offset, noAssert) {
|
1752 | return _readInt32(this, offset, false, noAssert)
|
1753 | }
|
1754 |
|
1755 | function _readFloat (buf, offset, littleEndian, noAssert) {
|
1756 | if (!noAssert) {
|
1757 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1758 | assert(offset + 3 < buf.length, 'Trying to read beyond buffer length')
|
1759 | }
|
1760 |
|
1761 | return ieee754.read(buf, offset, littleEndian, 23, 4)
|
1762 | }
|
1763 |
|
1764 | Buffer.prototype.readFloatLE = function (offset, noAssert) {
|
1765 | return _readFloat(this, offset, true, noAssert)
|
1766 | }
|
1767 |
|
1768 | Buffer.prototype.readFloatBE = function (offset, noAssert) {
|
1769 | return _readFloat(this, offset, false, noAssert)
|
1770 | }
|
1771 |
|
1772 | function _readDouble (buf, offset, littleEndian, noAssert) {
|
1773 | if (!noAssert) {
|
1774 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1775 | assert(offset + 7 < buf.length, 'Trying to read beyond buffer length')
|
1776 | }
|
1777 |
|
1778 | return ieee754.read(buf, offset, littleEndian, 52, 8)
|
1779 | }
|
1780 |
|
1781 | Buffer.prototype.readDoubleLE = function (offset, noAssert) {
|
1782 | return _readDouble(this, offset, true, noAssert)
|
1783 | }
|
1784 |
|
1785 | Buffer.prototype.readDoubleBE = function (offset, noAssert) {
|
1786 | return _readDouble(this, offset, false, noAssert)
|
1787 | }
|
1788 |
|
1789 | Buffer.prototype.writeUInt8 = function (value, offset, noAssert) {
|
1790 | if (!noAssert) {
|
1791 | assert(value !== undefined && value !== null, 'missing value')
|
1792 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1793 | assert(offset < this.length, 'trying to write beyond buffer length')
|
1794 | verifuint(value, 0xff)
|
1795 | }
|
1796 |
|
1797 | if (offset >= this.length) return
|
1798 |
|
1799 | this[offset] = value
|
1800 | }
|
1801 |
|
1802 | function _writeUInt16 (buf, value, offset, littleEndian, noAssert) {
|
1803 | if (!noAssert) {
|
1804 | assert(value !== undefined && value !== null, 'missing value')
|
1805 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1806 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1807 | assert(offset + 1 < buf.length, 'trying to write beyond buffer length')
|
1808 | verifuint(value, 0xffff)
|
1809 | }
|
1810 |
|
1811 | var len = buf.length
|
1812 | if (offset >= len)
|
1813 | return
|
1814 |
|
1815 | for (var i = 0, j = Math.min(len - offset, 2); i < j; i++) {
|
1816 | buf[offset + i] =
|
1817 | (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
|
1818 | (littleEndian ? i : 1 - i) * 8
|
1819 | }
|
1820 | }
|
1821 |
|
1822 | Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) {
|
1823 | _writeUInt16(this, value, offset, true, noAssert)
|
1824 | }
|
1825 |
|
1826 | Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) {
|
1827 | _writeUInt16(this, value, offset, false, noAssert)
|
1828 | }
|
1829 |
|
1830 | function _writeUInt32 (buf, value, offset, littleEndian, noAssert) {
|
1831 | if (!noAssert) {
|
1832 | assert(value !== undefined && value !== null, 'missing value')
|
1833 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1834 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1835 | assert(offset + 3 < buf.length, 'trying to write beyond buffer length')
|
1836 | verifuint(value, 0xffffffff)
|
1837 | }
|
1838 |
|
1839 | var len = buf.length
|
1840 | if (offset >= len)
|
1841 | return
|
1842 |
|
1843 | for (var i = 0, j = Math.min(len - offset, 4); i < j; i++) {
|
1844 | buf[offset + i] =
|
1845 | (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
|
1846 | }
|
1847 | }
|
1848 |
|
1849 | Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) {
|
1850 | _writeUInt32(this, value, offset, true, noAssert)
|
1851 | }
|
1852 |
|
1853 | Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) {
|
1854 | _writeUInt32(this, value, offset, false, noAssert)
|
1855 | }
|
1856 |
|
1857 | Buffer.prototype.writeInt8 = function (value, offset, noAssert) {
|
1858 | if (!noAssert) {
|
1859 | assert(value !== undefined && value !== null, 'missing value')
|
1860 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1861 | assert(offset < this.length, 'Trying to write beyond buffer length')
|
1862 | verifsint(value, 0x7f, -0x80)
|
1863 | }
|
1864 |
|
1865 | if (offset >= this.length)
|
1866 | return
|
1867 |
|
1868 | if (value >= 0)
|
1869 | this.writeUInt8(value, offset, noAssert)
|
1870 | else
|
1871 | this.writeUInt8(0xff + value + 1, offset, noAssert)
|
1872 | }
|
1873 |
|
1874 | function _writeInt16 (buf, value, offset, littleEndian, noAssert) {
|
1875 | if (!noAssert) {
|
1876 | assert(value !== undefined && value !== null, 'missing value')
|
1877 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1878 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1879 | assert(offset + 1 < buf.length, 'Trying to write beyond buffer length')
|
1880 | verifsint(value, 0x7fff, -0x8000)
|
1881 | }
|
1882 |
|
1883 | var len = buf.length
|
1884 | if (offset >= len)
|
1885 | return
|
1886 |
|
1887 | if (value >= 0)
|
1888 | _writeUInt16(buf, value, offset, littleEndian, noAssert)
|
1889 | else
|
1890 | _writeUInt16(buf, 0xffff + value + 1, offset, littleEndian, noAssert)
|
1891 | }
|
1892 |
|
1893 | Buffer.prototype.writeInt16LE = function (value, offset, noAssert) {
|
1894 | _writeInt16(this, value, offset, true, noAssert)
|
1895 | }
|
1896 |
|
1897 | Buffer.prototype.writeInt16BE = function (value, offset, noAssert) {
|
1898 | _writeInt16(this, value, offset, false, noAssert)
|
1899 | }
|
1900 |
|
1901 | function _writeInt32 (buf, value, offset, littleEndian, noAssert) {
|
1902 | if (!noAssert) {
|
1903 | assert(value !== undefined && value !== null, 'missing value')
|
1904 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1905 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1906 | assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
1907 | verifsint(value, 0x7fffffff, -0x80000000)
|
1908 | }
|
1909 |
|
1910 | var len = buf.length
|
1911 | if (offset >= len)
|
1912 | return
|
1913 |
|
1914 | if (value >= 0)
|
1915 | _writeUInt32(buf, value, offset, littleEndian, noAssert)
|
1916 | else
|
1917 | _writeUInt32(buf, 0xffffffff + value + 1, offset, littleEndian, noAssert)
|
1918 | }
|
1919 |
|
1920 | Buffer.prototype.writeInt32LE = function (value, offset, noAssert) {
|
1921 | _writeInt32(this, value, offset, true, noAssert)
|
1922 | }
|
1923 |
|
1924 | Buffer.prototype.writeInt32BE = function (value, offset, noAssert) {
|
1925 | _writeInt32(this, value, offset, false, noAssert)
|
1926 | }
|
1927 |
|
1928 | function _writeFloat (buf, value, offset, littleEndian, noAssert) {
|
1929 | if (!noAssert) {
|
1930 | assert(value !== undefined && value !== null, 'missing value')
|
1931 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1932 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1933 | assert(offset + 3 < buf.length, 'Trying to write beyond buffer length')
|
1934 | verifIEEE754(value, 3.4028234663852886e+38, -3.4028234663852886e+38)
|
1935 | }
|
1936 |
|
1937 | var len = buf.length
|
1938 | if (offset >= len)
|
1939 | return
|
1940 |
|
1941 | ieee754.write(buf, value, offset, littleEndian, 23, 4)
|
1942 | }
|
1943 |
|
1944 | Buffer.prototype.writeFloatLE = function (value, offset, noAssert) {
|
1945 | _writeFloat(this, value, offset, true, noAssert)
|
1946 | }
|
1947 |
|
1948 | Buffer.prototype.writeFloatBE = function (value, offset, noAssert) {
|
1949 | _writeFloat(this, value, offset, false, noAssert)
|
1950 | }
|
1951 |
|
1952 | function _writeDouble (buf, value, offset, littleEndian, noAssert) {
|
1953 | if (!noAssert) {
|
1954 | assert(value !== undefined && value !== null, 'missing value')
|
1955 | assert(typeof littleEndian === 'boolean', 'missing or invalid endian')
|
1956 | assert(offset !== undefined && offset !== null, 'missing offset')
|
1957 | assert(offset + 7 < buf.length,
|
1958 | 'Trying to write beyond buffer length')
|
1959 | verifIEEE754(value, 1.7976931348623157E+308, -1.7976931348623157E+308)
|
1960 | }
|
1961 |
|
1962 | var len = buf.length
|
1963 | if (offset >= len)
|
1964 | return
|
1965 |
|
1966 | ieee754.write(buf, value, offset, littleEndian, 52, 8)
|
1967 | }
|
1968 |
|
1969 | Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) {
|
1970 | _writeDouble(this, value, offset, true, noAssert)
|
1971 | }
|
1972 |
|
1973 | Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) {
|
1974 | _writeDouble(this, value, offset, false, noAssert)
|
1975 | }
|
1976 |
|
1977 |
|
1978 | Buffer.prototype.fill = function (value, start, end) {
|
1979 | if (!value) value = 0
|
1980 | if (!start) start = 0
|
1981 | if (!end) end = this.length
|
1982 |
|
1983 | if (typeof value === 'string') {
|
1984 | value = value.charCodeAt(0)
|
1985 | }
|
1986 |
|
1987 | assert(typeof value === 'number' && !isNaN(value), 'value is not a number')
|
1988 | assert(end >= start, 'end < start')
|
1989 |
|
1990 |
|
1991 | if (end === start) return
|
1992 | if (this.length === 0) return
|
1993 |
|
1994 | assert(start >= 0 && start < this.length, 'start out of bounds')
|
1995 | assert(end >= 0 && end <= this.length, 'end out of bounds')
|
1996 |
|
1997 | for (var i = start; i < end; i++) {
|
1998 | this[i] = value
|
1999 | }
|
2000 | }
|
2001 |
|
2002 | Buffer.prototype.inspect = function () {
|
2003 | var out = []
|
2004 | var len = this.length
|
2005 | for (var i = 0; i < len; i++) {
|
2006 | out[i] = toHex(this[i])
|
2007 | if (i === exports.INSPECT_MAX_BYTES) {
|
2008 | out[i + 1] = '...'
|
2009 | break
|
2010 | }
|
2011 | }
|
2012 | return '<Buffer ' + out.join(' ') + '>'
|
2013 | }
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 | Buffer.prototype.toArrayBuffer = function () {
|
2020 | if (typeof Uint8Array !== 'undefined') {
|
2021 | if (Buffer._useTypedArrays) {
|
2022 | return (new Buffer(this)).buffer
|
2023 | } else {
|
2024 | var buf = new Uint8Array(this.length)
|
2025 | for (var i = 0, len = buf.length; i < len; i += 1)
|
2026 | buf[i] = this[i]
|
2027 | return buf.buffer
|
2028 | }
|
2029 | } else {
|
2030 | throw new Error('Buffer.toArrayBuffer not supported in this browser')
|
2031 | }
|
2032 | }
|
2033 |
|
2034 |
|
2035 |
|
2036 |
|
2037 | function stringtrim (str) {
|
2038 | if (str.trim) return str.trim()
|
2039 | return str.replace(/^\s+|\s+$/g, '')
|
2040 | }
|
2041 |
|
2042 | var BP = Buffer.prototype
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 | Buffer._augment = function (arr) {
|
2048 | arr._isBuffer = true
|
2049 |
|
2050 |
|
2051 | arr._get = arr.get
|
2052 | arr._set = arr.set
|
2053 |
|
2054 |
|
2055 | arr.get = BP.get
|
2056 | arr.set = BP.set
|
2057 |
|
2058 | arr.write = BP.write
|
2059 | arr.toString = BP.toString
|
2060 | arr.toLocaleString = BP.toString
|
2061 | arr.toJSON = BP.toJSON
|
2062 | arr.copy = BP.copy
|
2063 | arr.slice = BP.slice
|
2064 | arr.readUInt8 = BP.readUInt8
|
2065 | arr.readUInt16LE = BP.readUInt16LE
|
2066 | arr.readUInt16BE = BP.readUInt16BE
|
2067 | arr.readUInt32LE = BP.readUInt32LE
|
2068 | arr.readUInt32BE = BP.readUInt32BE
|
2069 | arr.readInt8 = BP.readInt8
|
2070 | arr.readInt16LE = BP.readInt16LE
|
2071 | arr.readInt16BE = BP.readInt16BE
|
2072 | arr.readInt32LE = BP.readInt32LE
|
2073 | arr.readInt32BE = BP.readInt32BE
|
2074 | arr.readFloatLE = BP.readFloatLE
|
2075 | arr.readFloatBE = BP.readFloatBE
|
2076 | arr.readDoubleLE = BP.readDoubleLE
|
2077 | arr.readDoubleBE = BP.readDoubleBE
|
2078 | arr.writeUInt8 = BP.writeUInt8
|
2079 | arr.writeUInt16LE = BP.writeUInt16LE
|
2080 | arr.writeUInt16BE = BP.writeUInt16BE
|
2081 | arr.writeUInt32LE = BP.writeUInt32LE
|
2082 | arr.writeUInt32BE = BP.writeUInt32BE
|
2083 | arr.writeInt8 = BP.writeInt8
|
2084 | arr.writeInt16LE = BP.writeInt16LE
|
2085 | arr.writeInt16BE = BP.writeInt16BE
|
2086 | arr.writeInt32LE = BP.writeInt32LE
|
2087 | arr.writeInt32BE = BP.writeInt32BE
|
2088 | arr.writeFloatLE = BP.writeFloatLE
|
2089 | arr.writeFloatBE = BP.writeFloatBE
|
2090 | arr.writeDoubleLE = BP.writeDoubleLE
|
2091 | arr.writeDoubleBE = BP.writeDoubleBE
|
2092 | arr.fill = BP.fill
|
2093 | arr.inspect = BP.inspect
|
2094 | arr.toArrayBuffer = BP.toArrayBuffer
|
2095 |
|
2096 | return arr
|
2097 | }
|
2098 |
|
2099 |
|
2100 | function clamp (index, len, defaultValue) {
|
2101 | if (typeof index !== 'number') return defaultValue
|
2102 | index = ~~index;
|
2103 | if (index >= len) return len
|
2104 | if (index >= 0) return index
|
2105 | index += len
|
2106 | if (index >= 0) return index
|
2107 | return 0
|
2108 | }
|
2109 |
|
2110 | function coerce (length) {
|
2111 |
|
2112 |
|
2113 |
|
2114 | length = ~~Math.ceil(+length)
|
2115 | return length < 0 ? 0 : length
|
2116 | }
|
2117 |
|
2118 | function isArray (subject) {
|
2119 | return (Array.isArray || function (subject) {
|
2120 | return Object.prototype.toString.call(subject) === '[object Array]'
|
2121 | })(subject)
|
2122 | }
|
2123 |
|
2124 | function isArrayish (subject) {
|
2125 | return isArray(subject) || Buffer.isBuffer(subject) ||
|
2126 | subject && typeof subject === 'object' &&
|
2127 | typeof subject.length === 'number'
|
2128 | }
|
2129 |
|
2130 | function toHex (n) {
|
2131 | if (n < 16) return '0' + n.toString(16)
|
2132 | return n.toString(16)
|
2133 | }
|
2134 |
|
2135 | function utf8ToBytes (str) {
|
2136 | var byteArray = []
|
2137 | for (var i = 0; i < str.length; i++) {
|
2138 | var b = str.charCodeAt(i)
|
2139 | if (b <= 0x7F)
|
2140 | byteArray.push(str.charCodeAt(i))
|
2141 | else {
|
2142 | var start = i
|
2143 | if (b >= 0xD800 && b <= 0xDFFF) i++
|
2144 | var h = encodeURIComponent(str.slice(start, i+1)).substr(1).split('%')
|
2145 | for (var j = 0; j < h.length; j++)
|
2146 | byteArray.push(parseInt(h[j], 16))
|
2147 | }
|
2148 | }
|
2149 | return byteArray
|
2150 | }
|
2151 |
|
2152 | function asciiToBytes (str) {
|
2153 | var byteArray = []
|
2154 | for (var i = 0; i < str.length; i++) {
|
2155 |
|
2156 | byteArray.push(str.charCodeAt(i) & 0xFF)
|
2157 | }
|
2158 | return byteArray
|
2159 | }
|
2160 |
|
2161 | function utf16leToBytes (str) {
|
2162 | var c, hi, lo
|
2163 | var byteArray = []
|
2164 | for (var i = 0; i < str.length; i++) {
|
2165 | c = str.charCodeAt(i)
|
2166 | hi = c >> 8
|
2167 | lo = c % 256
|
2168 | byteArray.push(lo)
|
2169 | byteArray.push(hi)
|
2170 | }
|
2171 |
|
2172 | return byteArray
|
2173 | }
|
2174 |
|
2175 | function base64ToBytes (str) {
|
2176 | return base64.toByteArray(str)
|
2177 | }
|
2178 |
|
2179 | function blitBuffer (src, dst, offset, length) {
|
2180 | var pos
|
2181 | for (var i = 0; i < length; i++) {
|
2182 | if ((i + offset >= dst.length) || (i >= src.length))
|
2183 | break
|
2184 | dst[i + offset] = src[i]
|
2185 | }
|
2186 | return i
|
2187 | }
|
2188 |
|
2189 | function decodeUtf8Char (str) {
|
2190 | try {
|
2191 | return decodeURIComponent(str)
|
2192 | } catch (err) {
|
2193 | return String.fromCharCode(0xFFFD)
|
2194 | }
|
2195 | }
|
2196 |
|
2197 |
|
2198 |
|
2199 |
|
2200 |
|
2201 |
|
2202 | function verifuint (value, max) {
|
2203 | assert(typeof value === 'number', 'cannot write a non-number as a number')
|
2204 | assert(value >= 0, 'specified a negative value for writing an unsigned value')
|
2205 | assert(value <= max, 'value is larger than maximum value for type')
|
2206 | assert(Math.floor(value) === value, 'value has a fractional component')
|
2207 | }
|
2208 |
|
2209 | function verifsint (value, max, min) {
|
2210 | assert(typeof value === 'number', 'cannot write a non-number as a number')
|
2211 | assert(value <= max, 'value larger than maximum allowed value')
|
2212 | assert(value >= min, 'value smaller than minimum allowed value')
|
2213 | assert(Math.floor(value) === value, 'value has a fractional component')
|
2214 | }
|
2215 |
|
2216 | function verifIEEE754 (value, max, min) {
|
2217 | assert(typeof value === 'number', 'cannot write a non-number as a number')
|
2218 | assert(value <= max, 'value larger than maximum allowed value')
|
2219 | assert(value >= min, 'value smaller than minimum allowed value')
|
2220 | }
|
2221 |
|
2222 | function assert (test, message) {
|
2223 | if (!test) throw new Error(message || 'Failed assertion')
|
2224 | }
|
2225 |
|
2226 | },{"base64-js":6,"ieee754":18}],8:[function(require,module,exports){
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 |
|
2242 |
|
2243 |
|
2244 |
|
2245 |
|
2246 |
|
2247 |
|
2248 | function EventEmitter() {
|
2249 | this._events = this._events || {};
|
2250 | this._maxListeners = this._maxListeners || undefined;
|
2251 | }
|
2252 | module.exports = EventEmitter;
|
2253 |
|
2254 |
|
2255 | EventEmitter.EventEmitter = EventEmitter;
|
2256 |
|
2257 | EventEmitter.prototype._events = undefined;
|
2258 | EventEmitter.prototype._maxListeners = undefined;
|
2259 |
|
2260 |
|
2261 |
|
2262 | EventEmitter.defaultMaxListeners = 10;
|
2263 |
|
2264 |
|
2265 |
|
2266 | EventEmitter.prototype.setMaxListeners = function(n) {
|
2267 | if (!isNumber(n) || n < 0 || isNaN(n))
|
2268 | throw TypeError('n must be a positive number');
|
2269 | this._maxListeners = n;
|
2270 | return this;
|
2271 | };
|
2272 |
|
2273 | EventEmitter.prototype.emit = function(type) {
|
2274 | var er, handler, len, args, i, listeners;
|
2275 |
|
2276 | if (!this._events)
|
2277 | this._events = {};
|
2278 |
|
2279 |
|
2280 | if (type === 'error') {
|
2281 | if (!this._events.error ||
|
2282 | (isObject(this._events.error) && !this._events.error.length)) {
|
2283 | er = arguments[1];
|
2284 | if (er instanceof Error) {
|
2285 | throw er;
|
2286 | }
|
2287 | throw TypeError('Uncaught, unspecified "error" event.');
|
2288 | }
|
2289 | }
|
2290 |
|
2291 | handler = this._events[type];
|
2292 |
|
2293 | if (isUndefined(handler))
|
2294 | return false;
|
2295 |
|
2296 | if (isFunction(handler)) {
|
2297 | switch (arguments.length) {
|
2298 |
|
2299 | case 1:
|
2300 | handler.call(this);
|
2301 | break;
|
2302 | case 2:
|
2303 | handler.call(this, arguments[1]);
|
2304 | break;
|
2305 | case 3:
|
2306 | handler.call(this, arguments[1], arguments[2]);
|
2307 | break;
|
2308 |
|
2309 | default:
|
2310 | len = arguments.length;
|
2311 | args = new Array(len - 1);
|
2312 | for (i = 1; i < len; i++)
|
2313 | args[i - 1] = arguments[i];
|
2314 | handler.apply(this, args);
|
2315 | }
|
2316 | } else if (isObject(handler)) {
|
2317 | len = arguments.length;
|
2318 | args = new Array(len - 1);
|
2319 | for (i = 1; i < len; i++)
|
2320 | args[i - 1] = arguments[i];
|
2321 |
|
2322 | listeners = handler.slice();
|
2323 | len = listeners.length;
|
2324 | for (i = 0; i < len; i++)
|
2325 | listeners[i].apply(this, args);
|
2326 | }
|
2327 |
|
2328 | return true;
|
2329 | };
|
2330 |
|
2331 | EventEmitter.prototype.addListener = function(type, listener) {
|
2332 | var m;
|
2333 |
|
2334 | if (!isFunction(listener))
|
2335 | throw TypeError('listener must be a function');
|
2336 |
|
2337 | if (!this._events)
|
2338 | this._events = {};
|
2339 |
|
2340 |
|
2341 |
|
2342 | if (this._events.newListener)
|
2343 | this.emit('newListener', type,
|
2344 | isFunction(listener.listener) ?
|
2345 | listener.listener : listener);
|
2346 |
|
2347 | if (!this._events[type])
|
2348 |
|
2349 | this._events[type] = listener;
|
2350 | else if (isObject(this._events[type]))
|
2351 |
|
2352 | this._events[type].push(listener);
|
2353 | else
|
2354 |
|
2355 | this._events[type] = [this._events[type], listener];
|
2356 |
|
2357 |
|
2358 | if (isObject(this._events[type]) && !this._events[type].warned) {
|
2359 | var m;
|
2360 | if (!isUndefined(this._maxListeners)) {
|
2361 | m = this._maxListeners;
|
2362 | } else {
|
2363 | m = EventEmitter.defaultMaxListeners;
|
2364 | }
|
2365 |
|
2366 | if (m && m > 0 && this._events[type].length > m) {
|
2367 | this._events[type].warned = true;
|
2368 | console.error('(node) warning: possible EventEmitter memory ' +
|
2369 | 'leak detected. %d listeners added. ' +
|
2370 | 'Use emitter.setMaxListeners() to increase limit.',
|
2371 | this._events[type].length);
|
2372 | if (typeof console.trace === 'function') {
|
2373 |
|
2374 | console.trace();
|
2375 | }
|
2376 | }
|
2377 | }
|
2378 |
|
2379 | return this;
|
2380 | };
|
2381 |
|
2382 | EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
2383 |
|
2384 | EventEmitter.prototype.once = function(type, listener) {
|
2385 | if (!isFunction(listener))
|
2386 | throw TypeError('listener must be a function');
|
2387 |
|
2388 | var fired = false;
|
2389 |
|
2390 | function g() {
|
2391 | this.removeListener(type, g);
|
2392 |
|
2393 | if (!fired) {
|
2394 | fired = true;
|
2395 | listener.apply(this, arguments);
|
2396 | }
|
2397 | }
|
2398 |
|
2399 | g.listener = listener;
|
2400 | this.on(type, g);
|
2401 |
|
2402 | return this;
|
2403 | };
|
2404 |
|
2405 |
|
2406 | EventEmitter.prototype.removeListener = function(type, listener) {
|
2407 | var list, position, length, i;
|
2408 |
|
2409 | if (!isFunction(listener))
|
2410 | throw TypeError('listener must be a function');
|
2411 |
|
2412 | if (!this._events || !this._events[type])
|
2413 | return this;
|
2414 |
|
2415 | list = this._events[type];
|
2416 | length = list.length;
|
2417 | position = -1;
|
2418 |
|
2419 | if (list === listener ||
|
2420 | (isFunction(list.listener) && list.listener === listener)) {
|
2421 | delete this._events[type];
|
2422 | if (this._events.removeListener)
|
2423 | this.emit('removeListener', type, listener);
|
2424 |
|
2425 | } else if (isObject(list)) {
|
2426 | for (i = length; i-- > 0;) {
|
2427 | if (list[i] === listener ||
|
2428 | (list[i].listener && list[i].listener === listener)) {
|
2429 | position = i;
|
2430 | break;
|
2431 | }
|
2432 | }
|
2433 |
|
2434 | if (position < 0)
|
2435 | return this;
|
2436 |
|
2437 | if (list.length === 1) {
|
2438 | list.length = 0;
|
2439 | delete this._events[type];
|
2440 | } else {
|
2441 | list.splice(position, 1);
|
2442 | }
|
2443 |
|
2444 | if (this._events.removeListener)
|
2445 | this.emit('removeListener', type, listener);
|
2446 | }
|
2447 |
|
2448 | return this;
|
2449 | };
|
2450 |
|
2451 | EventEmitter.prototype.removeAllListeners = function(type) {
|
2452 | var key, listeners;
|
2453 |
|
2454 | if (!this._events)
|
2455 | return this;
|
2456 |
|
2457 |
|
2458 | if (!this._events.removeListener) {
|
2459 | if (arguments.length === 0)
|
2460 | this._events = {};
|
2461 | else if (this._events[type])
|
2462 | delete this._events[type];
|
2463 | return this;
|
2464 | }
|
2465 |
|
2466 |
|
2467 | if (arguments.length === 0) {
|
2468 | for (key in this._events) {
|
2469 | if (key === 'removeListener') continue;
|
2470 | this.removeAllListeners(key);
|
2471 | }
|
2472 | this.removeAllListeners('removeListener');
|
2473 | this._events = {};
|
2474 | return this;
|
2475 | }
|
2476 |
|
2477 | listeners = this._events[type];
|
2478 |
|
2479 | if (isFunction(listeners)) {
|
2480 | this.removeListener(type, listeners);
|
2481 | } else {
|
2482 |
|
2483 | while (listeners.length)
|
2484 | this.removeListener(type, listeners[listeners.length - 1]);
|
2485 | }
|
2486 | delete this._events[type];
|
2487 |
|
2488 | return this;
|
2489 | };
|
2490 |
|
2491 | EventEmitter.prototype.listeners = function(type) {
|
2492 | var ret;
|
2493 | if (!this._events || !this._events[type])
|
2494 | ret = [];
|
2495 | else if (isFunction(this._events[type]))
|
2496 | ret = [this._events[type]];
|
2497 | else
|
2498 | ret = this._events[type].slice();
|
2499 | return ret;
|
2500 | };
|
2501 |
|
2502 | EventEmitter.listenerCount = function(emitter, type) {
|
2503 | var ret;
|
2504 | if (!emitter._events || !emitter._events[type])
|
2505 | ret = 0;
|
2506 | else if (isFunction(emitter._events[type]))
|
2507 | ret = 1;
|
2508 | else
|
2509 | ret = emitter._events[type].length;
|
2510 | return ret;
|
2511 | };
|
2512 |
|
2513 | function isFunction(arg) {
|
2514 | return typeof arg === 'function';
|
2515 | }
|
2516 |
|
2517 | function isNumber(arg) {
|
2518 | return typeof arg === 'number';
|
2519 | }
|
2520 |
|
2521 | function isObject(arg) {
|
2522 | return typeof arg === 'object' && arg !== null;
|
2523 | }
|
2524 |
|
2525 | function isUndefined(arg) {
|
2526 | return arg === void 0;
|
2527 | }
|
2528 |
|
2529 | },{}],9:[function(require,module,exports){
|
2530 |
|
2531 |
|
2532 | var process = module.exports = {};
|
2533 |
|
2534 | process.nextTick = (function () {
|
2535 | var canSetImmediate = typeof window !== 'undefined'
|
2536 | && window.setImmediate;
|
2537 | var canPost = typeof window !== 'undefined'
|
2538 | && window.postMessage && window.addEventListener
|
2539 | ;
|
2540 |
|
2541 | if (canSetImmediate) {
|
2542 | return function (f) { return window.setImmediate(f) };
|
2543 | }
|
2544 |
|
2545 | if (canPost) {
|
2546 | var queue = [];
|
2547 | window.addEventListener('message', function (ev) {
|
2548 | var source = ev.source;
|
2549 | if ((source === window || source === null) && ev.data === 'process-tick') {
|
2550 | ev.stopPropagation();
|
2551 | if (queue.length > 0) {
|
2552 | var fn = queue.shift();
|
2553 | fn();
|
2554 | }
|
2555 | }
|
2556 | }, true);
|
2557 |
|
2558 | return function nextTick(fn) {
|
2559 | queue.push(fn);
|
2560 | window.postMessage('process-tick', '*');
|
2561 | };
|
2562 | }
|
2563 |
|
2564 | return function nextTick(fn) {
|
2565 | setTimeout(fn, 0);
|
2566 | };
|
2567 | })();
|
2568 |
|
2569 | process.title = 'browser';
|
2570 | process.browser = true;
|
2571 | process.env = {};
|
2572 | process.argv = [];
|
2573 |
|
2574 | function noop() {}
|
2575 |
|
2576 | process.on = noop;
|
2577 | process.addListener = noop;
|
2578 | process.once = noop;
|
2579 | process.off = noop;
|
2580 | process.removeListener = noop;
|
2581 | process.removeAllListeners = noop;
|
2582 | process.emit = noop;
|
2583 |
|
2584 | process.binding = function (name) {
|
2585 | throw new Error('process.binding is not supported');
|
2586 | }
|
2587 |
|
2588 |
|
2589 | process.cwd = function () { return '/' };
|
2590 | process.chdir = function (dir) {
|
2591 | throw new Error('process.chdir is not supported');
|
2592 | };
|
2593 |
|
2594 | },{}],10:[function(require,module,exports){
|
2595 |
|
2596 |
|
2597 |
|
2598 |
|
2599 |
|
2600 |
|
2601 |
|
2602 |
|
2603 |
|
2604 |
|
2605 |
|
2606 |
|
2607 |
|
2608 |
|
2609 |
|
2610 |
|
2611 |
|
2612 |
|
2613 |
|
2614 |
|
2615 |
|
2616 |
|
2617 |
|
2618 |
|
2619 |
|
2620 |
|
2621 | module.exports = Duplex;
|
2622 | var inherits = require('inherits');
|
2623 | var setImmediate = require('process/browser.js').nextTick;
|
2624 | var Readable = require('./readable.js');
|
2625 | var Writable = require('./writable.js');
|
2626 |
|
2627 | inherits(Duplex, Readable);
|
2628 |
|
2629 | Duplex.prototype.write = Writable.prototype.write;
|
2630 | Duplex.prototype.end = Writable.prototype.end;
|
2631 | Duplex.prototype._write = Writable.prototype._write;
|
2632 |
|
2633 | function Duplex(options) {
|
2634 | if (!(this instanceof Duplex))
|
2635 | return new Duplex(options);
|
2636 |
|
2637 | Readable.call(this, options);
|
2638 | Writable.call(this, options);
|
2639 |
|
2640 | if (options && options.readable === false)
|
2641 | this.readable = false;
|
2642 |
|
2643 | if (options && options.writable === false)
|
2644 | this.writable = false;
|
2645 |
|
2646 | this.allowHalfOpen = true;
|
2647 | if (options && options.allowHalfOpen === false)
|
2648 | this.allowHalfOpen = false;
|
2649 |
|
2650 | this.once('end', onend);
|
2651 | }
|
2652 |
|
2653 |
|
2654 | function onend() {
|
2655 |
|
2656 |
|
2657 | if (this.allowHalfOpen || this._writableState.ended)
|
2658 | return;
|
2659 |
|
2660 |
|
2661 |
|
2662 | var self = this;
|
2663 | setImmediate(function () {
|
2664 | self.end();
|
2665 | });
|
2666 | }
|
2667 |
|
2668 | },{"./readable.js":14,"./writable.js":16,"inherits":19,"process/browser.js":12}],11:[function(require,module,exports){
|
2669 |
|
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 | module.exports = Stream;
|
2691 |
|
2692 | var EE = require('events').EventEmitter;
|
2693 | var inherits = require('inherits');
|
2694 |
|
2695 | inherits(Stream, EE);
|
2696 | Stream.Readable = require('./readable.js');
|
2697 | Stream.Writable = require('./writable.js');
|
2698 | Stream.Duplex = require('./duplex.js');
|
2699 | Stream.Transform = require('./transform.js');
|
2700 | Stream.PassThrough = require('./passthrough.js');
|
2701 |
|
2702 |
|
2703 | Stream.Stream = Stream;
|
2704 |
|
2705 |
|
2706 |
|
2707 |
|
2708 |
|
2709 |
|
2710 | function Stream() {
|
2711 | EE.call(this);
|
2712 | }
|
2713 |
|
2714 | Stream.prototype.pipe = function(dest, options) {
|
2715 | var source = this;
|
2716 |
|
2717 | function ondata(chunk) {
|
2718 | if (dest.writable) {
|
2719 | if (false === dest.write(chunk) && source.pause) {
|
2720 | source.pause();
|
2721 | }
|
2722 | }
|
2723 | }
|
2724 |
|
2725 | source.on('data', ondata);
|
2726 |
|
2727 | function ondrain() {
|
2728 | if (source.readable && source.resume) {
|
2729 | source.resume();
|
2730 | }
|
2731 | }
|
2732 |
|
2733 | dest.on('drain', ondrain);
|
2734 |
|
2735 |
|
2736 |
|
2737 | if (!dest._isStdio && (!options || options.end !== false)) {
|
2738 | source.on('end', onend);
|
2739 | source.on('close', onclose);
|
2740 | }
|
2741 |
|
2742 | var didOnEnd = false;
|
2743 | function onend() {
|
2744 | if (didOnEnd) return;
|
2745 | didOnEnd = true;
|
2746 |
|
2747 | dest.end();
|
2748 | }
|
2749 |
|
2750 |
|
2751 | function onclose() {
|
2752 | if (didOnEnd) return;
|
2753 | didOnEnd = true;
|
2754 |
|
2755 | if (typeof dest.destroy === 'function') dest.destroy();
|
2756 | }
|
2757 |
|
2758 |
|
2759 | function onerror(er) {
|
2760 | cleanup();
|
2761 | if (EE.listenerCount(this, 'error') === 0) {
|
2762 | throw er;
|
2763 | }
|
2764 | }
|
2765 |
|
2766 | source.on('error', onerror);
|
2767 | dest.on('error', onerror);
|
2768 |
|
2769 |
|
2770 | function cleanup() {
|
2771 | source.removeListener('data', ondata);
|
2772 | dest.removeListener('drain', ondrain);
|
2773 |
|
2774 | source.removeListener('end', onend);
|
2775 | source.removeListener('close', onclose);
|
2776 |
|
2777 | source.removeListener('error', onerror);
|
2778 | dest.removeListener('error', onerror);
|
2779 |
|
2780 | source.removeListener('end', cleanup);
|
2781 | source.removeListener('close', cleanup);
|
2782 |
|
2783 | dest.removeListener('close', cleanup);
|
2784 | }
|
2785 |
|
2786 | source.on('end', cleanup);
|
2787 | source.on('close', cleanup);
|
2788 |
|
2789 | dest.on('close', cleanup);
|
2790 |
|
2791 | dest.emit('pipe', source);
|
2792 |
|
2793 |
|
2794 | return dest;
|
2795 | };
|
2796 |
|
2797 | },{"./duplex.js":10,"./passthrough.js":13,"./readable.js":14,"./transform.js":15,"./writable.js":16,"events":8,"inherits":19}],12:[function(require,module,exports){
|
2798 |
|
2799 |
|
2800 | var process = module.exports = {};
|
2801 |
|
2802 | process.nextTick = (function () {
|
2803 | var canSetImmediate = typeof window !== 'undefined'
|
2804 | && window.setImmediate;
|
2805 | var canPost = typeof window !== 'undefined'
|
2806 | && window.postMessage && window.addEventListener
|
2807 | ;
|
2808 |
|
2809 | if (canSetImmediate) {
|
2810 | return function (f) { return window.setImmediate(f) };
|
2811 | }
|
2812 |
|
2813 | if (canPost) {
|
2814 | var queue = [];
|
2815 | window.addEventListener('message', function (ev) {
|
2816 | var source = ev.source;
|
2817 | if ((source === window || source === null) && ev.data === 'process-tick') {
|
2818 | ev.stopPropagation();
|
2819 | if (queue.length > 0) {
|
2820 | var fn = queue.shift();
|
2821 | fn();
|
2822 | }
|
2823 | }
|
2824 | }, true);
|
2825 |
|
2826 | return function nextTick(fn) {
|
2827 | queue.push(fn);
|
2828 | window.postMessage('process-tick', '*');
|
2829 | };
|
2830 | }
|
2831 |
|
2832 | return function nextTick(fn) {
|
2833 | setTimeout(fn, 0);
|
2834 | };
|
2835 | })();
|
2836 |
|
2837 | process.title = 'browser';
|
2838 | process.browser = true;
|
2839 | process.env = {};
|
2840 | process.argv = [];
|
2841 |
|
2842 | process.binding = function (name) {
|
2843 | throw new Error('process.binding is not supported');
|
2844 | }
|
2845 |
|
2846 |
|
2847 | process.cwd = function () { return '/' };
|
2848 | process.chdir = function (dir) {
|
2849 | throw new Error('process.chdir is not supported');
|
2850 | };
|
2851 |
|
2852 | },{}],13:[function(require,module,exports){
|
2853 |
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 |
|
2868 |
|
2869 |
|
2870 |
|
2871 |
|
2872 |
|
2873 |
|
2874 |
|
2875 |
|
2876 |
|
2877 |
|
2878 | module.exports = PassThrough;
|
2879 |
|
2880 | var Transform = require('./transform.js');
|
2881 | var inherits = require('inherits');
|
2882 | inherits(PassThrough, Transform);
|
2883 |
|
2884 | function PassThrough(options) {
|
2885 | if (!(this instanceof PassThrough))
|
2886 | return new PassThrough(options);
|
2887 |
|
2888 | Transform.call(this, options);
|
2889 | }
|
2890 |
|
2891 | PassThrough.prototype._transform = function(chunk, encoding, cb) {
|
2892 | cb(null, chunk);
|
2893 | };
|
2894 |
|
2895 | },{"./transform.js":15,"inherits":19}],14:[function(require,module,exports){
|
2896 | (function (process){
|
2897 |
|
2898 |
|
2899 |
|
2900 |
|
2901 |
|
2902 |
|
2903 |
|
2904 |
|
2905 |
|
2906 |
|
2907 |
|
2908 |
|
2909 |
|
2910 |
|
2911 |
|
2912 |
|
2913 |
|
2914 |
|
2915 |
|
2916 |
|
2917 |
|
2918 | module.exports = Readable;
|
2919 | Readable.ReadableState = ReadableState;
|
2920 |
|
2921 | var EE = require('events').EventEmitter;
|
2922 | var Stream = require('./index.js');
|
2923 | var Buffer = require('buffer').Buffer;
|
2924 | var setImmediate = require('process/browser.js').nextTick;
|
2925 | var StringDecoder;
|
2926 |
|
2927 | var inherits = require('inherits');
|
2928 | inherits(Readable, Stream);
|
2929 |
|
2930 | function ReadableState(options, stream) {
|
2931 | options = options || {};
|
2932 |
|
2933 |
|
2934 |
|
2935 | var hwm = options.highWaterMark;
|
2936 | this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
2937 |
|
2938 |
|
2939 | this.highWaterMark = ~~this.highWaterMark;
|
2940 |
|
2941 | this.buffer = [];
|
2942 | this.length = 0;
|
2943 | this.pipes = null;
|
2944 | this.pipesCount = 0;
|
2945 | this.flowing = false;
|
2946 | this.ended = false;
|
2947 | this.endEmitted = false;
|
2948 | this.reading = false;
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 | this.calledRead = false;
|
2955 |
|
2956 |
|
2957 |
|
2958 |
|
2959 |
|
2960 | this.sync = true;
|
2961 |
|
2962 |
|
2963 |
|
2964 | this.needReadable = false;
|
2965 | this.emittedReadable = false;
|
2966 | this.readableListening = false;
|
2967 |
|
2968 |
|
2969 |
|
2970 |
|
2971 | this.objectMode = !!options.objectMode;
|
2972 |
|
2973 |
|
2974 |
|
2975 |
|
2976 | this.defaultEncoding = options.defaultEncoding || 'utf8';
|
2977 |
|
2978 |
|
2979 |
|
2980 | this.ranOut = false;
|
2981 |
|
2982 |
|
2983 | this.awaitDrain = 0;
|
2984 |
|
2985 |
|
2986 | this.readingMore = false;
|
2987 |
|
2988 | this.decoder = null;
|
2989 | this.encoding = null;
|
2990 | if (options.encoding) {
|
2991 | if (!StringDecoder)
|
2992 | StringDecoder = require('string_decoder').StringDecoder;
|
2993 | this.decoder = new StringDecoder(options.encoding);
|
2994 | this.encoding = options.encoding;
|
2995 | }
|
2996 | }
|
2997 |
|
2998 | function Readable(options) {
|
2999 | if (!(this instanceof Readable))
|
3000 | return new Readable(options);
|
3001 |
|
3002 | this._readableState = new ReadableState(options, this);
|
3003 |
|
3004 |
|
3005 | this.readable = true;
|
3006 |
|
3007 | Stream.call(this);
|
3008 | }
|
3009 |
|
3010 |
|
3011 |
|
3012 |
|
3013 |
|
3014 | Readable.prototype.push = function(chunk, encoding) {
|
3015 | var state = this._readableState;
|
3016 |
|
3017 | if (typeof chunk === 'string' && !state.objectMode) {
|
3018 | encoding = encoding || state.defaultEncoding;
|
3019 | if (encoding !== state.encoding) {
|
3020 | chunk = new Buffer(chunk, encoding);
|
3021 | encoding = '';
|
3022 | }
|
3023 | }
|
3024 |
|
3025 | return readableAddChunk(this, state, chunk, encoding, false);
|
3026 | };
|
3027 |
|
3028 |
|
3029 | Readable.prototype.unshift = function(chunk) {
|
3030 | var state = this._readableState;
|
3031 | return readableAddChunk(this, state, chunk, '', true);
|
3032 | };
|
3033 |
|
3034 | function readableAddChunk(stream, state, chunk, encoding, addToFront) {
|
3035 | var er = chunkInvalid(state, chunk);
|
3036 | if (er) {
|
3037 | stream.emit('error', er);
|
3038 | } else if (chunk === null || chunk === undefined) {
|
3039 | state.reading = false;
|
3040 | if (!state.ended)
|
3041 | onEofChunk(stream, state);
|
3042 | } else if (state.objectMode || chunk && chunk.length > 0) {
|
3043 | if (state.ended && !addToFront) {
|
3044 | var e = new Error('stream.push() after EOF');
|
3045 | stream.emit('error', e);
|
3046 | } else if (state.endEmitted && addToFront) {
|
3047 | var e = new Error('stream.unshift() after end event');
|
3048 | stream.emit('error', e);
|
3049 | } else {
|
3050 | if (state.decoder && !addToFront && !encoding)
|
3051 | chunk = state.decoder.write(chunk);
|
3052 |
|
3053 |
|
3054 | state.length += state.objectMode ? 1 : chunk.length;
|
3055 | if (addToFront) {
|
3056 | state.buffer.unshift(chunk);
|
3057 | } else {
|
3058 | state.reading = false;
|
3059 | state.buffer.push(chunk);
|
3060 | }
|
3061 |
|
3062 | if (state.needReadable)
|
3063 | emitReadable(stream);
|
3064 |
|
3065 | maybeReadMore(stream, state);
|
3066 | }
|
3067 | } else if (!addToFront) {
|
3068 | state.reading = false;
|
3069 | }
|
3070 |
|
3071 | return needMoreData(state);
|
3072 | }
|
3073 |
|
3074 |
|
3075 |
|
3076 |
|
3077 |
|
3078 |
|
3079 |
|
3080 |
|
3081 |
|
3082 |
|
3083 | function needMoreData(state) {
|
3084 | return !state.ended &&
|
3085 | (state.needReadable ||
|
3086 | state.length < state.highWaterMark ||
|
3087 | state.length === 0);
|
3088 | }
|
3089 |
|
3090 |
|
3091 | Readable.prototype.setEncoding = function(enc) {
|
3092 | if (!StringDecoder)
|
3093 | StringDecoder = require('string_decoder').StringDecoder;
|
3094 | this._readableState.decoder = new StringDecoder(enc);
|
3095 | this._readableState.encoding = enc;
|
3096 | };
|
3097 |
|
3098 |
|
3099 | var MAX_HWM = 0x800000;
|
3100 | function roundUpToNextPowerOf2(n) {
|
3101 | if (n >= MAX_HWM) {
|
3102 | n = MAX_HWM;
|
3103 | } else {
|
3104 |
|
3105 | n--;
|
3106 | for (var p = 1; p < 32; p <<= 1) n |= n >> p;
|
3107 | n++;
|
3108 | }
|
3109 | return n;
|
3110 | }
|
3111 |
|
3112 | function howMuchToRead(n, state) {
|
3113 | if (state.length === 0 && state.ended)
|
3114 | return 0;
|
3115 |
|
3116 | if (state.objectMode)
|
3117 | return n === 0 ? 0 : 1;
|
3118 |
|
3119 | if (isNaN(n) || n === null) {
|
3120 |
|
3121 | if (state.flowing && state.buffer.length)
|
3122 | return state.buffer[0].length;
|
3123 | else
|
3124 | return state.length;
|
3125 | }
|
3126 |
|
3127 | if (n <= 0)
|
3128 | return 0;
|
3129 |
|
3130 |
|
3131 |
|
3132 |
|
3133 |
|
3134 | if (n > state.highWaterMark)
|
3135 | state.highWaterMark = roundUpToNextPowerOf2(n);
|
3136 |
|
3137 |
|
3138 | if (n > state.length) {
|
3139 | if (!state.ended) {
|
3140 | state.needReadable = true;
|
3141 | return 0;
|
3142 | } else
|
3143 | return state.length;
|
3144 | }
|
3145 |
|
3146 | return n;
|
3147 | }
|
3148 |
|
3149 |
|
3150 | Readable.prototype.read = function(n) {
|
3151 | var state = this._readableState;
|
3152 | state.calledRead = true;
|
3153 | var nOrig = n;
|
3154 |
|
3155 | if (typeof n !== 'number' || n > 0)
|
3156 | state.emittedReadable = false;
|
3157 |
|
3158 |
|
3159 |
|
3160 |
|
3161 | if (n === 0 &&
|
3162 | state.needReadable &&
|
3163 | (state.length >= state.highWaterMark || state.ended)) {
|
3164 | emitReadable(this);
|
3165 | return null;
|
3166 | }
|
3167 |
|
3168 | n = howMuchToRead(n, state);
|
3169 |
|
3170 |
|
3171 | if (n === 0 && state.ended) {
|
3172 | if (state.length === 0)
|
3173 | endReadable(this);
|
3174 | return null;
|
3175 | }
|
3176 |
|
3177 |
|
3178 |
|
3179 |
|
3180 |
|
3181 |
|
3182 |
|
3183 |
|
3184 |
|
3185 |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 |
|
3192 |
|
3193 |
|
3194 |
|
3195 |
|
3196 |
|
3197 |
|
3198 |
|
3199 |
|
3200 | var doRead = state.needReadable;
|
3201 |
|
3202 |
|
3203 | if (state.length - n <= state.highWaterMark)
|
3204 | doRead = true;
|
3205 |
|
3206 |
|
3207 |
|
3208 | if (state.ended || state.reading)
|
3209 | doRead = false;
|
3210 |
|
3211 | if (doRead) {
|
3212 | state.reading = true;
|
3213 | state.sync = true;
|
3214 |
|
3215 | if (state.length === 0)
|
3216 | state.needReadable = true;
|
3217 |
|
3218 | this._read(state.highWaterMark);
|
3219 | state.sync = false;
|
3220 | }
|
3221 |
|
3222 |
|
3223 |
|
3224 |
|
3225 | if (doRead && !state.reading)
|
3226 | n = howMuchToRead(nOrig, state);
|
3227 |
|
3228 | var ret;
|
3229 | if (n > 0)
|
3230 | ret = fromList(n, state);
|
3231 | else
|
3232 | ret = null;
|
3233 |
|
3234 | if (ret === null) {
|
3235 | state.needReadable = true;
|
3236 | n = 0;
|
3237 | }
|
3238 |
|
3239 | state.length -= n;
|
3240 |
|
3241 |
|
3242 |
|
3243 | if (state.length === 0 && !state.ended)
|
3244 | state.needReadable = true;
|
3245 |
|
3246 |
|
3247 |
|
3248 |
|
3249 | if (state.ended && !state.endEmitted && state.length === 0)
|
3250 | endReadable(this);
|
3251 |
|
3252 | return ret;
|
3253 | };
|
3254 |
|
3255 | function chunkInvalid(state, chunk) {
|
3256 | var er = null;
|
3257 | if (!Buffer.isBuffer(chunk) &&
|
3258 | 'string' !== typeof chunk &&
|
3259 | chunk !== null &&
|
3260 | chunk !== undefined &&
|
3261 | !state.objectMode &&
|
3262 | !er) {
|
3263 | er = new TypeError('Invalid non-string/buffer chunk');
|
3264 | }
|
3265 | return er;
|
3266 | }
|
3267 |
|
3268 |
|
3269 | function onEofChunk(stream, state) {
|
3270 | if (state.decoder && !state.ended) {
|
3271 | var chunk = state.decoder.end();
|
3272 | if (chunk && chunk.length) {
|
3273 | state.buffer.push(chunk);
|
3274 | state.length += state.objectMode ? 1 : chunk.length;
|
3275 | }
|
3276 | }
|
3277 | state.ended = true;
|
3278 |
|
3279 |
|
3280 |
|
3281 | if (state.length > 0)
|
3282 | emitReadable(stream);
|
3283 | else
|
3284 | endReadable(stream);
|
3285 | }
|
3286 |
|
3287 |
|
3288 |
|
3289 |
|
3290 | function emitReadable(stream) {
|
3291 | var state = stream._readableState;
|
3292 | state.needReadable = false;
|
3293 | if (state.emittedReadable)
|
3294 | return;
|
3295 |
|
3296 | state.emittedReadable = true;
|
3297 | if (state.sync)
|
3298 | setImmediate(function() {
|
3299 | emitReadable_(stream);
|
3300 | });
|
3301 | else
|
3302 | emitReadable_(stream);
|
3303 | }
|
3304 |
|
3305 | function emitReadable_(stream) {
|
3306 | stream.emit('readable');
|
3307 | }
|
3308 |
|
3309 |
|
3310 |
|
3311 |
|
3312 |
|
3313 |
|
3314 |
|
3315 |
|
3316 | function maybeReadMore(stream, state) {
|
3317 | if (!state.readingMore) {
|
3318 | state.readingMore = true;
|
3319 | setImmediate(function() {
|
3320 | maybeReadMore_(stream, state);
|
3321 | });
|
3322 | }
|
3323 | }
|
3324 |
|
3325 | function maybeReadMore_(stream, state) {
|
3326 | var len = state.length;
|
3327 | while (!state.reading && !state.flowing && !state.ended &&
|
3328 | state.length < state.highWaterMark) {
|
3329 | stream.read(0);
|
3330 | if (len === state.length)
|
3331 |
|
3332 | break;
|
3333 | else
|
3334 | len = state.length;
|
3335 | }
|
3336 | state.readingMore = false;
|
3337 | }
|
3338 |
|
3339 |
|
3340 |
|
3341 |
|
3342 |
|
3343 | Readable.prototype._read = function(n) {
|
3344 | this.emit('error', new Error('not implemented'));
|
3345 | };
|
3346 |
|
3347 | Readable.prototype.pipe = function(dest, pipeOpts) {
|
3348 | var src = this;
|
3349 | var state = this._readableState;
|
3350 |
|
3351 | switch (state.pipesCount) {
|
3352 | case 0:
|
3353 | state.pipes = dest;
|
3354 | break;
|
3355 | case 1:
|
3356 | state.pipes = [state.pipes, dest];
|
3357 | break;
|
3358 | default:
|
3359 | state.pipes.push(dest);
|
3360 | break;
|
3361 | }
|
3362 | state.pipesCount += 1;
|
3363 |
|
3364 | var doEnd = (!pipeOpts || pipeOpts.end !== false) &&
|
3365 | dest !== process.stdout &&
|
3366 | dest !== process.stderr;
|
3367 |
|
3368 | var endFn = doEnd ? onend : cleanup;
|
3369 | if (state.endEmitted)
|
3370 | setImmediate(endFn);
|
3371 | else
|
3372 | src.once('end', endFn);
|
3373 |
|
3374 | dest.on('unpipe', onunpipe);
|
3375 | function onunpipe(readable) {
|
3376 | if (readable !== src) return;
|
3377 | cleanup();
|
3378 | }
|
3379 |
|
3380 | function onend() {
|
3381 | dest.end();
|
3382 | }
|
3383 |
|
3384 |
|
3385 |
|
3386 |
|
3387 |
|
3388 | var ondrain = pipeOnDrain(src);
|
3389 | dest.on('drain', ondrain);
|
3390 |
|
3391 | function cleanup() {
|
3392 |
|
3393 | dest.removeListener('close', onclose);
|
3394 | dest.removeListener('finish', onfinish);
|
3395 | dest.removeListener('drain', ondrain);
|
3396 | dest.removeListener('error', onerror);
|
3397 | dest.removeListener('unpipe', onunpipe);
|
3398 | src.removeListener('end', onend);
|
3399 | src.removeListener('end', cleanup);
|
3400 |
|
3401 |
|
3402 |
|
3403 |
|
3404 |
|
3405 |
|
3406 | if (!dest._writableState || dest._writableState.needDrain)
|
3407 | ondrain();
|
3408 | }
|
3409 |
|
3410 |
|
3411 |
|
3412 |
|
3413 | var errListeners = EE.listenerCount(dest, 'error');
|
3414 | function onerror(er) {
|
3415 | unpipe();
|
3416 | if (errListeners === 0 && EE.listenerCount(dest, 'error') === 0)
|
3417 | dest.emit('error', er);
|
3418 | }
|
3419 | dest.once('error', onerror);
|
3420 |
|
3421 |
|
3422 | function onclose() {
|
3423 | dest.removeListener('finish', onfinish);
|
3424 | unpipe();
|
3425 | }
|
3426 | dest.once('close', onclose);
|
3427 | function onfinish() {
|
3428 | dest.removeListener('close', onclose);
|
3429 | unpipe();
|
3430 | }
|
3431 | dest.once('finish', onfinish);
|
3432 |
|
3433 | function unpipe() {
|
3434 | src.unpipe(dest);
|
3435 | }
|
3436 |
|
3437 |
|
3438 | dest.emit('pipe', src);
|
3439 |
|
3440 |
|
3441 | if (!state.flowing) {
|
3442 |
|
3443 |
|
3444 |
|
3445 |
|
3446 | this.on('readable', pipeOnReadable);
|
3447 |
|
3448 | state.flowing = true;
|
3449 | setImmediate(function() {
|
3450 | flow(src);
|
3451 | });
|
3452 | }
|
3453 |
|
3454 | return dest;
|
3455 | };
|
3456 |
|
3457 | function pipeOnDrain(src) {
|
3458 | return function() {
|
3459 | var dest = this;
|
3460 | var state = src._readableState;
|
3461 | state.awaitDrain--;
|
3462 | if (state.awaitDrain === 0)
|
3463 | flow(src);
|
3464 | };
|
3465 | }
|
3466 |
|
3467 | function flow(src) {
|
3468 | var state = src._readableState;
|
3469 | var chunk;
|
3470 | state.awaitDrain = 0;
|
3471 |
|
3472 | function write(dest, i, list) {
|
3473 | var written = dest.write(chunk);
|
3474 | if (false === written) {
|
3475 | state.awaitDrain++;
|
3476 | }
|
3477 | }
|
3478 |
|
3479 | while (state.pipesCount && null !== (chunk = src.read())) {
|
3480 |
|
3481 | if (state.pipesCount === 1)
|
3482 | write(state.pipes, 0, null);
|
3483 | else
|
3484 | forEach(state.pipes, write);
|
3485 |
|
3486 | src.emit('data', chunk);
|
3487 |
|
3488 |
|
3489 | if (state.awaitDrain > 0)
|
3490 | return;
|
3491 | }
|
3492 |
|
3493 |
|
3494 |
|
3495 |
|
3496 |
|
3497 | if (state.pipesCount === 0) {
|
3498 | state.flowing = false;
|
3499 |
|
3500 |
|
3501 | if (EE.listenerCount(src, 'data') > 0)
|
3502 | emitDataEvents(src);
|
3503 | return;
|
3504 | }
|
3505 |
|
3506 |
|
3507 |
|
3508 | state.ranOut = true;
|
3509 | }
|
3510 |
|
3511 | function pipeOnReadable() {
|
3512 | if (this._readableState.ranOut) {
|
3513 | this._readableState.ranOut = false;
|
3514 | flow(this);
|
3515 | }
|
3516 | }
|
3517 |
|
3518 |
|
3519 | Readable.prototype.unpipe = function(dest) {
|
3520 | var state = this._readableState;
|
3521 |
|
3522 |
|
3523 | if (state.pipesCount === 0)
|
3524 | return this;
|
3525 |
|
3526 |
|
3527 | if (state.pipesCount === 1) {
|
3528 |
|
3529 | if (dest && dest !== state.pipes)
|
3530 | return this;
|
3531 |
|
3532 | if (!dest)
|
3533 | dest = state.pipes;
|
3534 |
|
3535 |
|
3536 | state.pipes = null;
|
3537 | state.pipesCount = 0;
|
3538 | this.removeListener('readable', pipeOnReadable);
|
3539 | state.flowing = false;
|
3540 | if (dest)
|
3541 | dest.emit('unpipe', this);
|
3542 | return this;
|
3543 | }
|
3544 |
|
3545 |
|
3546 |
|
3547 | if (!dest) {
|
3548 |
|
3549 | var dests = state.pipes;
|
3550 | var len = state.pipesCount;
|
3551 | state.pipes = null;
|
3552 | state.pipesCount = 0;
|
3553 | this.removeListener('readable', pipeOnReadable);
|
3554 | state.flowing = false;
|
3555 |
|
3556 | for (var i = 0; i < len; i++)
|
3557 | dests[i].emit('unpipe', this);
|
3558 | return this;
|
3559 | }
|
3560 |
|
3561 |
|
3562 | var i = indexOf(state.pipes, dest);
|
3563 | if (i === -1)
|
3564 | return this;
|
3565 |
|
3566 | state.pipes.splice(i, 1);
|
3567 | state.pipesCount -= 1;
|
3568 | if (state.pipesCount === 1)
|
3569 | state.pipes = state.pipes[0];
|
3570 |
|
3571 | dest.emit('unpipe', this);
|
3572 |
|
3573 | return this;
|
3574 | };
|
3575 |
|
3576 |
|
3577 |
|
3578 | Readable.prototype.on = function(ev, fn) {
|
3579 | var res = Stream.prototype.on.call(this, ev, fn);
|
3580 |
|
3581 | if (ev === 'data' && !this._readableState.flowing)
|
3582 | emitDataEvents(this);
|
3583 |
|
3584 | if (ev === 'readable' && this.readable) {
|
3585 | var state = this._readableState;
|
3586 | if (!state.readableListening) {
|
3587 | state.readableListening = true;
|
3588 | state.emittedReadable = false;
|
3589 | state.needReadable = true;
|
3590 | if (!state.reading) {
|
3591 | this.read(0);
|
3592 | } else if (state.length) {
|
3593 | emitReadable(this, state);
|
3594 | }
|
3595 | }
|
3596 | }
|
3597 |
|
3598 | return res;
|
3599 | };
|
3600 | Readable.prototype.addListener = Readable.prototype.on;
|
3601 |
|
3602 |
|
3603 |
|
3604 | Readable.prototype.resume = function() {
|
3605 | emitDataEvents(this);
|
3606 | this.read(0);
|
3607 | this.emit('resume');
|
3608 | };
|
3609 |
|
3610 | Readable.prototype.pause = function() {
|
3611 | emitDataEvents(this, true);
|
3612 | this.emit('pause');
|
3613 | };
|
3614 |
|
3615 | function emitDataEvents(stream, startPaused) {
|
3616 | var state = stream._readableState;
|
3617 |
|
3618 | if (state.flowing) {
|
3619 |
|
3620 | throw new Error('Cannot switch to old mode now.');
|
3621 | }
|
3622 |
|
3623 | var paused = startPaused || false;
|
3624 | var readable = false;
|
3625 |
|
3626 |
|
3627 | stream.readable = true;
|
3628 | stream.pipe = Stream.prototype.pipe;
|
3629 | stream.on = stream.addListener = Stream.prototype.on;
|
3630 |
|
3631 | stream.on('readable', function() {
|
3632 | readable = true;
|
3633 |
|
3634 | var c;
|
3635 | while (!paused && (null !== (c = stream.read())))
|
3636 | stream.emit('data', c);
|
3637 |
|
3638 | if (c === null) {
|
3639 | readable = false;
|
3640 | stream._readableState.needReadable = true;
|
3641 | }
|
3642 | });
|
3643 |
|
3644 | stream.pause = function() {
|
3645 | paused = true;
|
3646 | this.emit('pause');
|
3647 | };
|
3648 |
|
3649 | stream.resume = function() {
|
3650 | paused = false;
|
3651 | if (readable)
|
3652 | setImmediate(function() {
|
3653 | stream.emit('readable');
|
3654 | });
|
3655 | else
|
3656 | this.read(0);
|
3657 | this.emit('resume');
|
3658 | };
|
3659 |
|
3660 |
|
3661 | stream.emit('readable');
|
3662 | }
|
3663 |
|
3664 |
|
3665 |
|
3666 |
|
3667 | Readable.prototype.wrap = function(stream) {
|
3668 | var state = this._readableState;
|
3669 | var paused = false;
|
3670 |
|
3671 | var self = this;
|
3672 | stream.on('end', function() {
|
3673 | if (state.decoder && !state.ended) {
|
3674 | var chunk = state.decoder.end();
|
3675 | if (chunk && chunk.length)
|
3676 | self.push(chunk);
|
3677 | }
|
3678 |
|
3679 | self.push(null);
|
3680 | });
|
3681 |
|
3682 | stream.on('data', function(chunk) {
|
3683 | if (state.decoder)
|
3684 | chunk = state.decoder.write(chunk);
|
3685 | if (!chunk || !state.objectMode && !chunk.length)
|
3686 | return;
|
3687 |
|
3688 | var ret = self.push(chunk);
|
3689 | if (!ret) {
|
3690 | paused = true;
|
3691 | stream.pause();
|
3692 | }
|
3693 | });
|
3694 |
|
3695 |
|
3696 |
|
3697 | for (var i in stream) {
|
3698 | if (typeof stream[i] === 'function' &&
|
3699 | typeof this[i] === 'undefined') {
|
3700 | this[i] = function(method) { return function() {
|
3701 | return stream[method].apply(stream, arguments);
|
3702 | }}(i);
|
3703 | }
|
3704 | }
|
3705 |
|
3706 |
|
3707 | var events = ['error', 'close', 'destroy', 'pause', 'resume'];
|
3708 | forEach(events, function(ev) {
|
3709 | stream.on(ev, function (x) {
|
3710 | return self.emit.apply(self, ev, x);
|
3711 | });
|
3712 | });
|
3713 |
|
3714 |
|
3715 |
|
3716 | self._read = function(n) {
|
3717 | if (paused) {
|
3718 | paused = false;
|
3719 | stream.resume();
|
3720 | }
|
3721 | };
|
3722 |
|
3723 | return self;
|
3724 | };
|
3725 |
|
3726 |
|
3727 |
|
3728 |
|
3729 | Readable._fromList = fromList;
|
3730 |
|
3731 |
|
3732 |
|
3733 | function fromList(n, state) {
|
3734 | var list = state.buffer;
|
3735 | var length = state.length;
|
3736 | var stringMode = !!state.decoder;
|
3737 | var objectMode = !!state.objectMode;
|
3738 | var ret;
|
3739 |
|
3740 |
|
3741 | if (list.length === 0)
|
3742 | return null;
|
3743 |
|
3744 | if (length === 0)
|
3745 | ret = null;
|
3746 | else if (objectMode)
|
3747 | ret = list.shift();
|
3748 | else if (!n || n >= length) {
|
3749 |
|
3750 | if (stringMode)
|
3751 | ret = list.join('');
|
3752 | else
|
3753 | ret = Buffer.concat(list, length);
|
3754 | list.length = 0;
|
3755 | } else {
|
3756 |
|
3757 | if (n < list[0].length) {
|
3758 |
|
3759 |
|
3760 | var buf = list[0];
|
3761 | ret = buf.slice(0, n);
|
3762 | list[0] = buf.slice(n);
|
3763 | } else if (n === list[0].length) {
|
3764 |
|
3765 | ret = list.shift();
|
3766 | } else {
|
3767 |
|
3768 |
|
3769 | if (stringMode)
|
3770 | ret = '';
|
3771 | else
|
3772 | ret = new Buffer(n);
|
3773 |
|
3774 | var c = 0;
|
3775 | for (var i = 0, l = list.length; i < l && c < n; i++) {
|
3776 | var buf = list[0];
|
3777 | var cpy = Math.min(n - c, buf.length);
|
3778 |
|
3779 | if (stringMode)
|
3780 | ret += buf.slice(0, cpy);
|
3781 | else
|
3782 | buf.copy(ret, c, 0, cpy);
|
3783 |
|
3784 | if (cpy < buf.length)
|
3785 | list[0] = buf.slice(cpy);
|
3786 | else
|
3787 | list.shift();
|
3788 |
|
3789 | c += cpy;
|
3790 | }
|
3791 | }
|
3792 | }
|
3793 |
|
3794 | return ret;
|
3795 | }
|
3796 |
|
3797 | function endReadable(stream) {
|
3798 | var state = stream._readableState;
|
3799 |
|
3800 |
|
3801 |
|
3802 | if (state.length > 0)
|
3803 | throw new Error('endReadable called on non-empty stream');
|
3804 |
|
3805 | if (!state.endEmitted && state.calledRead) {
|
3806 | state.ended = true;
|
3807 | setImmediate(function() {
|
3808 |
|
3809 | if (!state.endEmitted && state.length === 0) {
|
3810 | state.endEmitted = true;
|
3811 | stream.readable = false;
|
3812 | stream.emit('end');
|
3813 | }
|
3814 | });
|
3815 | }
|
3816 | }
|
3817 |
|
3818 | function forEach (xs, f) {
|
3819 | for (var i = 0, l = xs.length; i < l; i++) {
|
3820 | f(xs[i], i);
|
3821 | }
|
3822 | }
|
3823 |
|
3824 | function indexOf (xs, x) {
|
3825 | for (var i = 0, l = xs.length; i < l; i++) {
|
3826 | if (xs[i] === x) return i;
|
3827 | }
|
3828 | return -1;
|
3829 | }
|
3830 |
|
3831 | }).call(this,require("7YKIPe"))
|
3832 | },{"./index.js":11,"7YKIPe":9,"buffer":7,"events":8,"inherits":19,"process/browser.js":12,"string_decoder":17}],15:[function(require,module,exports){
|
3833 |
|
3834 |
|
3835 |
|
3836 |
|
3837 |
|
3838 |
|
3839 |
|
3840 |
|
3841 |
|
3842 |
|
3843 |
|
3844 |
|
3845 |
|
3846 |
|
3847 |
|
3848 |
|
3849 |
|
3850 |
|
3851 |
|
3852 |
|
3853 |
|
3854 |
|
3855 |
|
3856 |
|
3857 |
|
3858 |
|
3859 |
|
3860 |
|
3861 |
|
3862 |
|
3863 |
|
3864 |
|
3865 |
|
3866 |
|
3867 |
|
3868 |
|
3869 |
|
3870 |
|
3871 |
|
3872 |
|
3873 |
|
3874 |
|
3875 |
|
3876 |
|
3877 |
|
3878 |
|
3879 |
|
3880 |
|
3881 |
|
3882 |
|
3883 |
|
3884 |
|
3885 |
|
3886 |
|
3887 |
|
3888 |
|
3889 |
|
3890 |
|
3891 |
|
3892 |
|
3893 |
|
3894 |
|
3895 |
|
3896 | module.exports = Transform;
|
3897 |
|
3898 | var Duplex = require('./duplex.js');
|
3899 | var inherits = require('inherits');
|
3900 | inherits(Transform, Duplex);
|
3901 |
|
3902 |
|
3903 | function TransformState(options, stream) {
|
3904 | this.afterTransform = function(er, data) {
|
3905 | return afterTransform(stream, er, data);
|
3906 | };
|
3907 |
|
3908 | this.needTransform = false;
|
3909 | this.transforming = false;
|
3910 | this.writecb = null;
|
3911 | this.writechunk = null;
|
3912 | }
|
3913 |
|
3914 | function afterTransform(stream, er, data) {
|
3915 | var ts = stream._transformState;
|
3916 | ts.transforming = false;
|
3917 |
|
3918 | var cb = ts.writecb;
|
3919 |
|
3920 | if (!cb)
|
3921 | return stream.emit('error', new Error('no writecb in Transform class'));
|
3922 |
|
3923 | ts.writechunk = null;
|
3924 | ts.writecb = null;
|
3925 |
|
3926 | if (data !== null && data !== undefined)
|
3927 | stream.push(data);
|
3928 |
|
3929 | if (cb)
|
3930 | cb(er);
|
3931 |
|
3932 | var rs = stream._readableState;
|
3933 | rs.reading = false;
|
3934 | if (rs.needReadable || rs.length < rs.highWaterMark) {
|
3935 | stream._read(rs.highWaterMark);
|
3936 | }
|
3937 | }
|
3938 |
|
3939 |
|
3940 | function Transform(options) {
|
3941 | if (!(this instanceof Transform))
|
3942 | return new Transform(options);
|
3943 |
|
3944 | Duplex.call(this, options);
|
3945 |
|
3946 | var ts = this._transformState = new TransformState(options, this);
|
3947 |
|
3948 |
|
3949 | var stream = this;
|
3950 |
|
3951 |
|
3952 | this._readableState.needReadable = true;
|
3953 |
|
3954 |
|
3955 |
|
3956 |
|
3957 | this._readableState.sync = false;
|
3958 |
|
3959 | this.once('finish', function() {
|
3960 | if ('function' === typeof this._flush)
|
3961 | this._flush(function(er) {
|
3962 | done(stream, er);
|
3963 | });
|
3964 | else
|
3965 | done(stream);
|
3966 | });
|
3967 | }
|
3968 |
|
3969 | Transform.prototype.push = function(chunk, encoding) {
|
3970 | this._transformState.needTransform = false;
|
3971 | return Duplex.prototype.push.call(this, chunk, encoding);
|
3972 | };
|
3973 |
|
3974 |
|
3975 |
|
3976 |
|
3977 |
|
3978 |
|
3979 |
|
3980 |
|
3981 |
|
3982 |
|
3983 |
|
3984 | Transform.prototype._transform = function(chunk, encoding, cb) {
|
3985 | throw new Error('not implemented');
|
3986 | };
|
3987 |
|
3988 | Transform.prototype._write = function(chunk, encoding, cb) {
|
3989 | var ts = this._transformState;
|
3990 | ts.writecb = cb;
|
3991 | ts.writechunk = chunk;
|
3992 | ts.writeencoding = encoding;
|
3993 | if (!ts.transforming) {
|
3994 | var rs = this._readableState;
|
3995 | if (ts.needTransform ||
|
3996 | rs.needReadable ||
|
3997 | rs.length < rs.highWaterMark)
|
3998 | this._read(rs.highWaterMark);
|
3999 | }
|
4000 | };
|
4001 |
|
4002 |
|
4003 |
|
4004 |
|
4005 | Transform.prototype._read = function(n) {
|
4006 | var ts = this._transformState;
|
4007 |
|
4008 | if (ts.writechunk && ts.writecb && !ts.transforming) {
|
4009 | ts.transforming = true;
|
4010 | this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
|
4011 | } else {
|
4012 |
|
4013 |
|
4014 | ts.needTransform = true;
|
4015 | }
|
4016 | };
|
4017 |
|
4018 |
|
4019 | function done(stream, er) {
|
4020 | if (er)
|
4021 | return stream.emit('error', er);
|
4022 |
|
4023 |
|
4024 |
|
4025 | var ws = stream._writableState;
|
4026 | var rs = stream._readableState;
|
4027 | var ts = stream._transformState;
|
4028 |
|
4029 | if (ws.length)
|
4030 | throw new Error('calling transform done when ws.length != 0');
|
4031 |
|
4032 | if (ts.transforming)
|
4033 | throw new Error('calling transform done when still transforming');
|
4034 |
|
4035 | return stream.push(null);
|
4036 | }
|
4037 |
|
4038 | },{"./duplex.js":10,"inherits":19}],16:[function(require,module,exports){
|
4039 |
|
4040 |
|
4041 |
|
4042 |
|
4043 |
|
4044 |
|
4045 |
|
4046 |
|
4047 |
|
4048 |
|
4049 |
|
4050 |
|
4051 |
|
4052 |
|
4053 |
|
4054 |
|
4055 |
|
4056 |
|
4057 |
|
4058 |
|
4059 |
|
4060 |
|
4061 |
|
4062 |
|
4063 |
|
4064 | module.exports = Writable;
|
4065 | Writable.WritableState = WritableState;
|
4066 |
|
4067 | var isUint8Array = typeof Uint8Array !== 'undefined'
|
4068 | ? function (x) { return x instanceof Uint8Array }
|
4069 | : function (x) {
|
4070 | return x && x.constructor && x.constructor.name === 'Uint8Array'
|
4071 | }
|
4072 | ;
|
4073 | var isArrayBuffer = typeof ArrayBuffer !== 'undefined'
|
4074 | ? function (x) { return x instanceof ArrayBuffer }
|
4075 | : function (x) {
|
4076 | return x && x.constructor && x.constructor.name === 'ArrayBuffer'
|
4077 | }
|
4078 | ;
|
4079 |
|
4080 | var inherits = require('inherits');
|
4081 | var Stream = require('./index.js');
|
4082 | var setImmediate = require('process/browser.js').nextTick;
|
4083 | var Buffer = require('buffer').Buffer;
|
4084 |
|
4085 | inherits(Writable, Stream);
|
4086 |
|
4087 | function WriteReq(chunk, encoding, cb) {
|
4088 | this.chunk = chunk;
|
4089 | this.encoding = encoding;
|
4090 | this.callback = cb;
|
4091 | }
|
4092 |
|
4093 | function WritableState(options, stream) {
|
4094 | options = options || {};
|
4095 |
|
4096 |
|
4097 |
|
4098 |
|
4099 | var hwm = options.highWaterMark;
|
4100 | this.highWaterMark = (hwm || hwm === 0) ? hwm : 16 * 1024;
|
4101 |
|
4102 |
|
4103 |
|
4104 | this.objectMode = !!options.objectMode;
|
4105 |
|
4106 |
|
4107 | this.highWaterMark = ~~this.highWaterMark;
|
4108 |
|
4109 | this.needDrain = false;
|
4110 |
|
4111 | this.ending = false;
|
4112 |
|
4113 | this.ended = false;
|
4114 |
|
4115 | this.finished = false;
|
4116 |
|
4117 |
|
4118 |
|
4119 |
|
4120 | var noDecode = options.decodeStrings === false;
|
4121 | this.decodeStrings = !noDecode;
|
4122 |
|
4123 |
|
4124 |
|
4125 |
|
4126 | this.defaultEncoding = options.defaultEncoding || 'utf8';
|
4127 |
|
4128 |
|
4129 |
|
4130 |
|
4131 | this.length = 0;
|
4132 |
|
4133 |
|
4134 | this.writing = false;
|
4135 |
|
4136 |
|
4137 |
|
4138 |
|
4139 |
|
4140 | this.sync = true;
|
4141 |
|
4142 |
|
4143 |
|
4144 |
|
4145 | this.bufferProcessing = false;
|
4146 |
|
4147 |
|
4148 | this.onwrite = function(er) {
|
4149 | onwrite(stream, er);
|
4150 | };
|
4151 |
|
4152 |
|
4153 | this.writecb = null;
|
4154 |
|
4155 |
|
4156 | this.writelen = 0;
|
4157 |
|
4158 | this.buffer = [];
|
4159 | }
|
4160 |
|
4161 | function Writable(options) {
|
4162 |
|
4163 |
|
4164 | if (!(this instanceof Writable) && !(this instanceof Stream.Duplex))
|
4165 | return new Writable(options);
|
4166 |
|
4167 | this._writableState = new WritableState(options, this);
|
4168 |
|
4169 |
|
4170 | this.writable = true;
|
4171 |
|
4172 | Stream.call(this);
|
4173 | }
|
4174 |
|
4175 |
|
4176 | Writable.prototype.pipe = function() {
|
4177 | this.emit('error', new Error('Cannot pipe. Not readable.'));
|
4178 | };
|
4179 |
|
4180 |
|
4181 | function writeAfterEnd(stream, state, cb) {
|
4182 | var er = new Error('write after end');
|
4183 |
|
4184 | stream.emit('error', er);
|
4185 | setImmediate(function() {
|
4186 | cb(er);
|
4187 | });
|
4188 | }
|
4189 |
|
4190 |
|
4191 |
|
4192 |
|
4193 |
|
4194 |
|
4195 | function validChunk(stream, state, chunk, cb) {
|
4196 | var valid = true;
|
4197 | if (!Buffer.isBuffer(chunk) &&
|
4198 | 'string' !== typeof chunk &&
|
4199 | chunk !== null &&
|
4200 | chunk !== undefined &&
|
4201 | !state.objectMode) {
|
4202 | var er = new TypeError('Invalid non-string/buffer chunk');
|
4203 | stream.emit('error', er);
|
4204 | setImmediate(function() {
|
4205 | cb(er);
|
4206 | });
|
4207 | valid = false;
|
4208 | }
|
4209 | return valid;
|
4210 | }
|
4211 |
|
4212 | Writable.prototype.write = function(chunk, encoding, cb) {
|
4213 | var state = this._writableState;
|
4214 | var ret = false;
|
4215 |
|
4216 | if (typeof encoding === 'function') {
|
4217 | cb = encoding;
|
4218 | encoding = null;
|
4219 | }
|
4220 |
|
4221 | if (!Buffer.isBuffer(chunk) && isUint8Array(chunk))
|
4222 | chunk = new Buffer(chunk);
|
4223 | if (isArrayBuffer(chunk) && typeof Uint8Array !== 'undefined')
|
4224 | chunk = new Buffer(new Uint8Array(chunk));
|
4225 |
|
4226 | if (Buffer.isBuffer(chunk))
|
4227 | encoding = 'buffer';
|
4228 | else if (!encoding)
|
4229 | encoding = state.defaultEncoding;
|
4230 |
|
4231 | if (typeof cb !== 'function')
|
4232 | cb = function() {};
|
4233 |
|
4234 | if (state.ended)
|
4235 | writeAfterEnd(this, state, cb);
|
4236 | else if (validChunk(this, state, chunk, cb))
|
4237 | ret = writeOrBuffer(this, state, chunk, encoding, cb);
|
4238 |
|
4239 | return ret;
|
4240 | };
|
4241 |
|
4242 | function decodeChunk(state, chunk, encoding) {
|
4243 | if (!state.objectMode &&
|
4244 | state.decodeStrings !== false &&
|
4245 | typeof chunk === 'string') {
|
4246 | chunk = new Buffer(chunk, encoding);
|
4247 | }
|
4248 | return chunk;
|
4249 | }
|
4250 |
|
4251 |
|
4252 |
|
4253 |
|
4254 | function writeOrBuffer(stream, state, chunk, encoding, cb) {
|
4255 | chunk = decodeChunk(state, chunk, encoding);
|
4256 | var len = state.objectMode ? 1 : chunk.length;
|
4257 |
|
4258 | state.length += len;
|
4259 |
|
4260 | var ret = state.length < state.highWaterMark;
|
4261 | state.needDrain = !ret;
|
4262 |
|
4263 | if (state.writing)
|
4264 | state.buffer.push(new WriteReq(chunk, encoding, cb));
|
4265 | else
|
4266 | doWrite(stream, state, len, chunk, encoding, cb);
|
4267 |
|
4268 | return ret;
|
4269 | }
|
4270 |
|
4271 | function doWrite(stream, state, len, chunk, encoding, cb) {
|
4272 | state.writelen = len;
|
4273 | state.writecb = cb;
|
4274 | state.writing = true;
|
4275 | state.sync = true;
|
4276 | stream._write(chunk, encoding, state.onwrite);
|
4277 | state.sync = false;
|
4278 | }
|
4279 |
|
4280 | function onwriteError(stream, state, sync, er, cb) {
|
4281 | if (sync)
|
4282 | setImmediate(function() {
|
4283 | cb(er);
|
4284 | });
|
4285 | else
|
4286 | cb(er);
|
4287 |
|
4288 | stream.emit('error', er);
|
4289 | }
|
4290 |
|
4291 | function onwriteStateUpdate(state) {
|
4292 | state.writing = false;
|
4293 | state.writecb = null;
|
4294 | state.length -= state.writelen;
|
4295 | state.writelen = 0;
|
4296 | }
|
4297 |
|
4298 | function onwrite(stream, er) {
|
4299 | var state = stream._writableState;
|
4300 | var sync = state.sync;
|
4301 | var cb = state.writecb;
|
4302 |
|
4303 | onwriteStateUpdate(state);
|
4304 |
|
4305 | if (er)
|
4306 | onwriteError(stream, state, sync, er, cb);
|
4307 | else {
|
4308 |
|
4309 | var finished = needFinish(stream, state);
|
4310 |
|
4311 | if (!finished && !state.bufferProcessing && state.buffer.length)
|
4312 | clearBuffer(stream, state);
|
4313 |
|
4314 | if (sync) {
|
4315 | setImmediate(function() {
|
4316 | afterWrite(stream, state, finished, cb);
|
4317 | });
|
4318 | } else {
|
4319 | afterWrite(stream, state, finished, cb);
|
4320 | }
|
4321 | }
|
4322 | }
|
4323 |
|
4324 | function afterWrite(stream, state, finished, cb) {
|
4325 | if (!finished)
|
4326 | onwriteDrain(stream, state);
|
4327 | cb();
|
4328 | if (finished)
|
4329 | finishMaybe(stream, state);
|
4330 | }
|
4331 |
|
4332 |
|
4333 |
|
4334 |
|
4335 | function onwriteDrain(stream, state) {
|
4336 | if (state.length === 0 && state.needDrain) {
|
4337 | state.needDrain = false;
|
4338 | stream.emit('drain');
|
4339 | }
|
4340 | }
|
4341 |
|
4342 |
|
4343 |
|
4344 | function clearBuffer(stream, state) {
|
4345 | state.bufferProcessing = true;
|
4346 |
|
4347 | for (var c = 0; c < state.buffer.length; c++) {
|
4348 | var entry = state.buffer[c];
|
4349 | var chunk = entry.chunk;
|
4350 | var encoding = entry.encoding;
|
4351 | var cb = entry.callback;
|
4352 | var len = state.objectMode ? 1 : chunk.length;
|
4353 |
|
4354 | doWrite(stream, state, len, chunk, encoding, cb);
|
4355 |
|
4356 |
|
4357 |
|
4358 |
|
4359 |
|
4360 | if (state.writing) {
|
4361 | c++;
|
4362 | break;
|
4363 | }
|
4364 | }
|
4365 |
|
4366 | state.bufferProcessing = false;
|
4367 | if (c < state.buffer.length)
|
4368 | state.buffer = state.buffer.slice(c);
|
4369 | else
|
4370 | state.buffer.length = 0;
|
4371 | }
|
4372 |
|
4373 | Writable.prototype._write = function(chunk, encoding, cb) {
|
4374 | cb(new Error('not implemented'));
|
4375 | };
|
4376 |
|
4377 | Writable.prototype.end = function(chunk, encoding, cb) {
|
4378 | var state = this._writableState;
|
4379 |
|
4380 | if (typeof chunk === 'function') {
|
4381 | cb = chunk;
|
4382 | chunk = null;
|
4383 | encoding = null;
|
4384 | } else if (typeof encoding === 'function') {
|
4385 | cb = encoding;
|
4386 | encoding = null;
|
4387 | }
|
4388 |
|
4389 | if (typeof chunk !== 'undefined' && chunk !== null)
|
4390 | this.write(chunk, encoding);
|
4391 |
|
4392 |
|
4393 | if (!state.ending && !state.finished)
|
4394 | endWritable(this, state, cb);
|
4395 | };
|
4396 |
|
4397 |
|
4398 | function needFinish(stream, state) {
|
4399 | return (state.ending &&
|
4400 | state.length === 0 &&
|
4401 | !state.finished &&
|
4402 | !state.writing);
|
4403 | }
|
4404 |
|
4405 | function finishMaybe(stream, state) {
|
4406 | var need = needFinish(stream, state);
|
4407 | if (need) {
|
4408 | state.finished = true;
|
4409 | stream.emit('finish');
|
4410 | }
|
4411 | return need;
|
4412 | }
|
4413 |
|
4414 | function endWritable(stream, state, cb) {
|
4415 | state.ending = true;
|
4416 | finishMaybe(stream, state);
|
4417 | if (cb) {
|
4418 | if (state.finished)
|
4419 | setImmediate(cb);
|
4420 | else
|
4421 | stream.once('finish', cb);
|
4422 | }
|
4423 | state.ended = true;
|
4424 | }
|
4425 |
|
4426 | },{"./index.js":11,"buffer":7,"inherits":19,"process/browser.js":12}],17:[function(require,module,exports){
|
4427 |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 |
|
4433 |
|
4434 |
|
4435 |
|
4436 |
|
4437 |
|
4438 |
|
4439 |
|
4440 |
|
4441 |
|
4442 |
|
4443 |
|
4444 |
|
4445 |
|
4446 |
|
4447 |
|
4448 | var Buffer = require('buffer').Buffer;
|
4449 |
|
4450 | function assertEncoding(encoding) {
|
4451 | if (encoding && !Buffer.isEncoding(encoding)) {
|
4452 | throw new Error('Unknown encoding: ' + encoding);
|
4453 | }
|
4454 | }
|
4455 |
|
4456 | var StringDecoder = exports.StringDecoder = function(encoding) {
|
4457 | this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
|
4458 | assertEncoding(encoding);
|
4459 | switch (this.encoding) {
|
4460 | case 'utf8':
|
4461 |
|
4462 | this.surrogateSize = 3;
|
4463 | break;
|
4464 | case 'ucs2':
|
4465 | case 'utf16le':
|
4466 |
|
4467 | this.surrogateSize = 2;
|
4468 | this.detectIncompleteChar = utf16DetectIncompleteChar;
|
4469 | break;
|
4470 | case 'base64':
|
4471 |
|
4472 | this.surrogateSize = 3;
|
4473 | this.detectIncompleteChar = base64DetectIncompleteChar;
|
4474 | break;
|
4475 | default:
|
4476 | this.write = passThroughWrite;
|
4477 | return;
|
4478 | }
|
4479 |
|
4480 | this.charBuffer = new Buffer(6);
|
4481 | this.charReceived = 0;
|
4482 | this.charLength = 0;
|
4483 | };
|
4484 |
|
4485 |
|
4486 | StringDecoder.prototype.write = function(buffer) {
|
4487 | var charStr = '';
|
4488 | var offset = 0;
|
4489 |
|
4490 |
|
4491 | while (this.charLength) {
|
4492 |
|
4493 | var i = (buffer.length >= this.charLength - this.charReceived) ?
|
4494 | this.charLength - this.charReceived :
|
4495 | buffer.length;
|
4496 |
|
4497 |
|
4498 | buffer.copy(this.charBuffer, this.charReceived, offset, i);
|
4499 | this.charReceived += (i - offset);
|
4500 | offset = i;
|
4501 |
|
4502 | if (this.charReceived < this.charLength) {
|
4503 |
|
4504 | return '';
|
4505 | }
|
4506 |
|
4507 |
|
4508 | charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
|
4509 |
|
4510 |
|
4511 | var charCode = charStr.charCodeAt(charStr.length - 1);
|
4512 | if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
4513 | this.charLength += this.surrogateSize;
|
4514 | charStr = '';
|
4515 | continue;
|
4516 | }
|
4517 | this.charReceived = this.charLength = 0;
|
4518 |
|
4519 |
|
4520 | if (i == buffer.length) return charStr;
|
4521 |
|
4522 |
|
4523 | buffer = buffer.slice(i, buffer.length);
|
4524 | break;
|
4525 | }
|
4526 |
|
4527 | var lenIncomplete = this.detectIncompleteChar(buffer);
|
4528 |
|
4529 | var end = buffer.length;
|
4530 | if (this.charLength) {
|
4531 |
|
4532 | buffer.copy(this.charBuffer, 0, buffer.length - lenIncomplete, end);
|
4533 | this.charReceived = lenIncomplete;
|
4534 | end -= lenIncomplete;
|
4535 | }
|
4536 |
|
4537 | charStr += buffer.toString(this.encoding, 0, end);
|
4538 |
|
4539 | var end = charStr.length - 1;
|
4540 | var charCode = charStr.charCodeAt(end);
|
4541 |
|
4542 | if (charCode >= 0xD800 && charCode <= 0xDBFF) {
|
4543 | var size = this.surrogateSize;
|
4544 | this.charLength += size;
|
4545 | this.charReceived += size;
|
4546 | this.charBuffer.copy(this.charBuffer, size, 0, size);
|
4547 | this.charBuffer.write(charStr.charAt(charStr.length - 1), this.encoding);
|
4548 | return charStr.substring(0, end);
|
4549 | }
|
4550 |
|
4551 |
|
4552 | return charStr;
|
4553 | };
|
4554 |
|
4555 | StringDecoder.prototype.detectIncompleteChar = function(buffer) {
|
4556 |
|
4557 | var i = (buffer.length >= 3) ? 3 : buffer.length;
|
4558 |
|
4559 |
|
4560 |
|
4561 | for (; i > 0; i--) {
|
4562 | var c = buffer[buffer.length - i];
|
4563 |
|
4564 |
|
4565 |
|
4566 |
|
4567 | if (i == 1 && c >> 5 == 0x06) {
|
4568 | this.charLength = 2;
|
4569 | break;
|
4570 | }
|
4571 |
|
4572 |
|
4573 | if (i <= 2 && c >> 4 == 0x0E) {
|
4574 | this.charLength = 3;
|
4575 | break;
|
4576 | }
|
4577 |
|
4578 |
|
4579 | if (i <= 3 && c >> 3 == 0x1E) {
|
4580 | this.charLength = 4;
|
4581 | break;
|
4582 | }
|
4583 | }
|
4584 |
|
4585 | return i;
|
4586 | };
|
4587 |
|
4588 | StringDecoder.prototype.end = function(buffer) {
|
4589 | var res = '';
|
4590 | if (buffer && buffer.length)
|
4591 | res = this.write(buffer);
|
4592 |
|
4593 | if (this.charReceived) {
|
4594 | var cr = this.charReceived;
|
4595 | var buf = this.charBuffer;
|
4596 | var enc = this.encoding;
|
4597 | res += buf.slice(0, cr).toString(enc);
|
4598 | }
|
4599 |
|
4600 | return res;
|
4601 | };
|
4602 |
|
4603 | function passThroughWrite(buffer) {
|
4604 | return buffer.toString(this.encoding);
|
4605 | }
|
4606 |
|
4607 | function utf16DetectIncompleteChar(buffer) {
|
4608 | var incomplete = this.charReceived = buffer.length % 2;
|
4609 | this.charLength = incomplete ? 2 : 0;
|
4610 | return incomplete;
|
4611 | }
|
4612 |
|
4613 | function base64DetectIncompleteChar(buffer) {
|
4614 | var incomplete = this.charReceived = buffer.length % 3;
|
4615 | this.charLength = incomplete ? 3 : 0;
|
4616 | return incomplete;
|
4617 | }
|
4618 |
|
4619 | },{"buffer":7}],18:[function(require,module,exports){
|
4620 | exports.read = function (buffer, offset, isLE, mLen, nBytes) {
|
4621 | var e, m
|
4622 | var eLen = (nBytes * 8) - mLen - 1
|
4623 | var eMax = (1 << eLen) - 1
|
4624 | var eBias = eMax >> 1
|
4625 | var nBits = -7
|
4626 | var i = isLE ? (nBytes - 1) : 0
|
4627 | var d = isLE ? -1 : 1
|
4628 | var s = buffer[offset + i]
|
4629 |
|
4630 | i += d
|
4631 |
|
4632 | e = s & ((1 << (-nBits)) - 1)
|
4633 | s >>= (-nBits)
|
4634 | nBits += eLen
|
4635 | for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
4636 |
|
4637 | m = e & ((1 << (-nBits)) - 1)
|
4638 | e >>= (-nBits)
|
4639 | nBits += mLen
|
4640 | for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
|
4641 |
|
4642 | if (e === 0) {
|
4643 | e = 1 - eBias
|
4644 | } else if (e === eMax) {
|
4645 | return m ? NaN : ((s ? -1 : 1) * Infinity)
|
4646 | } else {
|
4647 | m = m + Math.pow(2, mLen)
|
4648 | e = e - eBias
|
4649 | }
|
4650 | return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
|
4651 | }
|
4652 |
|
4653 | exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
|
4654 | var e, m, c
|
4655 | var eLen = (nBytes * 8) - mLen - 1
|
4656 | var eMax = (1 << eLen) - 1
|
4657 | var eBias = eMax >> 1
|
4658 | var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
|
4659 | var i = isLE ? 0 : (nBytes - 1)
|
4660 | var d = isLE ? 1 : -1
|
4661 | var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
|
4662 |
|
4663 | value = Math.abs(value)
|
4664 |
|
4665 | if (isNaN(value) || value === Infinity) {
|
4666 | m = isNaN(value) ? 1 : 0
|
4667 | e = eMax
|
4668 | } else {
|
4669 | e = Math.floor(Math.log(value) / Math.LN2)
|
4670 | if (value * (c = Math.pow(2, -e)) < 1) {
|
4671 | e--
|
4672 | c *= 2
|
4673 | }
|
4674 | if (e + eBias >= 1) {
|
4675 | value += rt / c
|
4676 | } else {
|
4677 | value += rt * Math.pow(2, 1 - eBias)
|
4678 | }
|
4679 | if (value * c >= 2) {
|
4680 | e++
|
4681 | c /= 2
|
4682 | }
|
4683 |
|
4684 | if (e + eBias >= eMax) {
|
4685 | m = 0
|
4686 | e = eMax
|
4687 | } else if (e + eBias >= 1) {
|
4688 | m = ((value * c) - 1) * Math.pow(2, mLen)
|
4689 | e = e + eBias
|
4690 | } else {
|
4691 | m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
|
4692 | e = 0
|
4693 | }
|
4694 | }
|
4695 |
|
4696 | for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
|
4697 |
|
4698 | e = (e << mLen) | m
|
4699 | eLen += mLen
|
4700 | for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
|
4701 |
|
4702 | buffer[offset + i - d] |= s * 128
|
4703 | }
|
4704 |
|
4705 | },{}],19:[function(require,module,exports){
|
4706 | module.exports=require(3)
|
4707 | },{}],20:[function(require,module,exports){
|
4708 | 'use strict';
|
4709 |
|
4710 | var assert = require('assert');
|
4711 | var stream = require('stream');
|
4712 | var hash = require('../index');
|
4713 |
|
4714 | describe('writeToStream', function() {
|
4715 | it('should emit information about an object to a stream', function() {
|
4716 | var strm = new stream.PassThrough();
|
4717 |
|
4718 | hash.writeToStream({foo: 'bar'}, strm);
|
4719 | var result = strm.read().toString();
|
4720 | assert.strictEqual(typeof result, 'string');
|
4721 | assert.notStrictEqual(result.indexOf('foo'), -1);
|
4722 | assert.notStrictEqual(result.indexOf('bar'), -1);
|
4723 | });
|
4724 |
|
4725 | it('should leave out keys when excludeValues = true', function() {
|
4726 | var strm = new stream.PassThrough();
|
4727 |
|
4728 | hash.writeToStream({foo: 'bar'}, {excludeValues: true}, strm);
|
4729 | var result = strm.read().toString();
|
4730 | assert.strictEqual(typeof result, 'string');
|
4731 | assert.notStrictEqual(result.indexOf('foo'), -1);
|
4732 | assert. strictEqual(result.indexOf('bar'), -1);
|
4733 | });
|
4734 | });
|
4735 |
|
4736 | },{"../index":1,"assert":2,"stream":11}]},{},[20]) |
\ | No newline at end of file |