filer/dist/filer.min.js

6 lines
150 KiB
JavaScript
Raw Normal View History

2014-07-21 19:28:26 +00:00
/*! filer 0.0.19 2014-07-21 */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,s){if(!n[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(e){(function(){function r(t){var e=!1;return function(){if(e)throw Error("Callback was already called.");e=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var s=function(t,e){if(t.forEach)return t.forEach(e);for(var n=0;t.length>n;n+=1)e(t[n],n,t)},u=function(t,e){if(t.map)return t.map(e);var n=[];return s(t,function(t,r,i){n.push(e(t,r,i))}),n},f=function(t,e,n){return t.reduce?t.reduce(e,n):(s(t,function(t,r,i){n=e(n,t,r,i)}),n)},c=function(t){if(Object.keys)return Object.keys(t);var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e};void 0!==e&&e.nextTick?(a.nextTick=e.nextTick,a.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:a.nextTick):"function"==typeof setImmediate?(a.nextTick=function(t){setImmediate(t)},a.setImmediate=a.nextTick):(a.nextTick=function(t){setTimeout(t,0)},a.setImmediate=a.nextTick),a.each=function(t,e,n){if(n=n||function(){},!t.length)return n();var i=0;s(t,function(o){e(o,r(function(e){e?(n(e),n=function(){}):(i+=1,i>=t.length&&n(null))}))})},a.forEach=a.each,a.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,e,n,r){var i=l(e);i.apply(null,[t,n,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(e,n,r){if(r=r||function(){},!e.length||0>=t)return r();var i=0,o=0,a=0;(function s(){if(i>=e.length)return r();for(;t>a&&e.length>o;)o+=1,a+=1,n(e[o-1],function(t){t?(r(t),r=function(){}):(i+=1,a-=1,i>=e.length?r():s())})})()}},d=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(e))}},h=function(t,e){return function(){var n=Array.prototype.slice.call(arguments);return e.apply(null,[l(t)].concat(n))}},p=function(t){return function(){var e=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(e))}},g=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n,r){i[t.index]=r,e(n)})},function(t){r(t,i)})};a.map=d(g),a.mapSeries=p(g),a.mapLimit=function(t,e,n,r){return m(e)(t,n,r)};var m=function(t){return h(t,g)};a.reduce=function(t,e,n,r){a.eachSeries(t,function(t,r){n(e,t,function(t,n){e=n,r(t)})},function(t){r(t,e)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,e,n,r){var i=u(t,function(t){return t}).reverse();a.reduce(i,e,n,r)},a.foldr=a.reduceRight;var v=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n&&i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.filter=d(v),a.filterSeries=p(v),a.select=a.filter,a.selectSeries=a.filterSeries;var y=function(t,e,n,r){var i=[];e=u(e,function(t,e){return{index:e,value:t}}),t(e,function(t,e){n(t.value,function(n){n||i.push(t),e()})},function(){r(u(i.sort(function(t,e){return t.index-e.index}),function(t){return t.value}))})};a.reject=d(y),a.rejectSeries=p(y);var b=function(t,e,n,r){t(e,function(t,e){n(t,function(n){n?(r(t),r=function(){}):e()})},function(){r()})};a.detect=d(b),a.detectSeries=p(b),a.some=function(t,e,n){a.each(t,function(t,r){e(t,function(t){t&&(n(!0),n=function(){}),r()})},f
break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return Y(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return Y(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){Y(i>=n,"sourceEnd < sourceStart"),Y(e>=0&&t.length>e,"targetStart out of bounds"),Y(n>=0&&o.length>n,"sourceStart out of bounds"),Y(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(100>a||!r._useTypedArrays)for(var s=0;a>s;s++)t[s+e]=this[s+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=C(t,n,0),e=C(e,n,n),r._useTypedArrays)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(Y(void 0!==t&&null!==t,"missing offset"),Y(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return m(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return m(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return v(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return v(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(Y(void 0!==t&&null!==t,"missing offset"),Y(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return y(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return y(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return b(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return b(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return _(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return _(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return w(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return w(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(Y(void 0!==t&&null!==t,"missing value"),Y(void 0!==e&&null!==e,"missing offset"),Y(this.length>e,"trying to write beyond buffer length"),P(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return E(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return E(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(Y(void 0!==t&&null!==t,"missing value"),Y(void 0!==e&&null!==e,"missing offset"),Y(this.length>e,"Trying to write beyond buffer length"),V(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return x(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return x(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return A(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return A(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return k(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return k(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return S(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return S(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),Y(n>=e,"end < start"),n!==e&&0!==this.length){Y(e>=0&&this.length>e,"start out of bounds"),Y(n>=0&&this.length>=n,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=L(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return thi
}},e.exports=n},{"./nodeBufferReader":19,"./signature":21,"./stringReader":22,"./support":23,"./uint8ArrayReader":24,"./utils":25,"./zipEntry":27}],27:[function(t,e){"use strict";function n(t,e){this.options=t,this.loadOptions=e}var r=t("./stringReader"),i=t("./utils"),o=t("./compressedObject"),a=t("./object");n.prototype={isEncrypted:function(){return 1===(1&this.bitFlag)},useUTF8:function(){return 2048===(2048&this.bitFlag)},prepareCompressedContent:function(t,e,n){return function(){var r=t.index;t.setIndex(e);var i=t.readData(n);return t.setIndex(r),i}},prepareContent:function(t,e,n,r,o){return function(){var t=i.transformTo(r.uncompressInputType,this.getCompressedContent()),e=r.uncompress(t);if(e.length!==o)throw Error("Bug : uncompressed data size mismatch");return e}},readLocalPart:function(t){var e,n;if(t.skip(22),this.fileNameLength=t.readInt(2),n=t.readInt(2),this.fileName=t.readString(this.fileNameLength),t.skip(n),-1==this.compressedSize||-1==this.uncompressedSize)throw Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize == -1 || uncompressedSize == -1)");if(e=i.findCompression(this.compressionMethod),null===e)throw Error("Corrupted zip : compression "+i.pretty(this.compressionMethod)+" unknown (inner file : "+this.fileName+")");if(this.decompressed=new o,this.decompressed.compressedSize=this.compressedSize,this.decompressed.uncompressedSize=this.uncompressedSize,this.decompressed.crc32=this.crc32,this.decompressed.compressionMethod=this.compressionMethod,this.decompressed.getCompressedContent=this.prepareCompressedContent(t,t.index,this.compressedSize,e),this.decompressed.getContent=this.prepareContent(t,t.index,this.compressedSize,e,this.uncompressedSize),this.loadOptions.checkCRC32&&(this.decompressed=i.transformTo("string",this.decompressed.getContent()),a.crc32(this.decompressed)!==this.crc32))throw Error("Corrupted zip : CRC32 mismatch")},readCentralPart:function(t){if(this.versionMadeBy=t.readString(2),this.versionNeeded=t.readInt(2),this.bitFlag=t.readInt(2),this.compressionMethod=t.readString(2),this.date=t.readDate(),this.crc32=t.readInt(4),this.compressedSize=t.readInt(4),this.uncompressedSize=t.readInt(4),this.fileNameLength=t.readInt(2),this.extraFieldsLength=t.readInt(2),this.fileCommentLength=t.readInt(2),this.diskNumberStart=t.readInt(2),this.internalFileAttributes=t.readInt(2),this.externalFileAttributes=t.readInt(4),this.localHeaderOffset=t.readInt(4),this.isEncrypted())throw Error("Encrypted zip are not supported");this.fileName=t.readString(this.fileNameLength),this.readExtraFields(t),this.parseZIP64ExtraField(t),this.fileComment=t.readString(this.fileCommentLength),this.dir=16&this.externalFileAttributes?!0:!1},parseZIP64ExtraField:function(){if(this.extraFields[1]){var t=new r(this.extraFields[1].value);this.uncompressedSize===i.MAX_VALUE_32BITS&&(this.uncompressedSize=t.readInt(8)),this.compressedSize===i.MAX_VALUE_32BITS&&(this.compressedSize=t.readInt(8)),this.localHeaderOffset===i.MAX_VALUE_32BITS&&(this.localHeaderOffset=t.readInt(8)),this.diskNumberStart===i.MAX_VALUE_32BITS&&(this.diskNumberStart=t.readInt(4))}},readExtraFields:function(t){var e,n,r,i=t.index;for(this.extraFields=this.extraFields||{};t.index<i+this.extraFieldsLength;)e=t.readInt(2),n=t.readInt(2),r=t.readString(n),this.extraFields[e]={id:e,length:n,value:r}},handleUTF8:function(){if(this.useUTF8())this.fileName=a.utf8decode(this.fileName),this.fileComment=a.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();null!==t&&(this.fileName=t)}},findExtraFieldUnicodePath:function(){var t=this.extraFields[28789];if(t){var e=new r(t.value);return 1!==e.readInt(1)?null:a.crc32(this.fileName)!==e.readInt(4)?null:a.utf8decode(e.readString(t.length-5))}return null}},e.exports=n},{"./compressedObject":11,"./object":20,"./stringReader":22,"./utils":25}],28:[function(t,e){"use strict";var n=t("./lib/utils/common").assign,r=t("./lib/deflate"),i=t("./lib/inflate"),o=t("./lib/zlib/constants"),a={};n(a,r,i,o),e.exports=a},{"./lib/deflate":29,"./lib/inflate":30,".
while(Ee&&u>m);if(512&n.flags&&(n.check=b(n.check,i,m,a)),u-=m,a+=m,Ee)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=Z;case Z:if(4096&n.flags){if(0===u)break t;m=0;do Ee=i[a+m++],n.head&&Ee&&65536>n.length&&(n.head.comment+=String.fromCharCode(Ee));while(Ee&&u>m);if(512&n.flags&&(n.check=b(n.check,i,m,a)),u-=m,a+=m,Ee)break t}else n.head&&(n.head.comment=null);n.mode=Y;case Y:if(512&n.flags){for(;16>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if(d!==(65535&n.check)){t.msg="header crc mismatch",n.mode=le;break}d=0,h=0}n.head&&(n.head.hcrc=1&n.flags>>9,n.head.done=!0),t.adler=n.check=0,n.mode=W;break;case X:for(;32>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}t.adler=n.check=r(d),d=0,h=0,n.mode=H;case H:if(0===n.havedict)return t.next_out=s,t.avail_out=f,t.next_in=a,t.avail_in=u,n.hold=d,n.bits=h,C;t.adler=n.check=1,n.mode=W;case W:if(e===k||e===S)break t;case q:if(n.last){d>>>=7&h,h-=7&h,n.mode=ue;break}for(;3>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}switch(n.last=1&d,d>>>=1,h-=1,3&d){case 0:n.mode=K;break;case 1:if(c(n),n.mode=ee,e===S){d>>>=2,h-=2;break t}break;case 2:n.mode=Q;break;case 3:t.msg="invalid block type",n.mode=le}d>>>=2,h-=2;break;case K:for(d>>>=7&h,h-=7&h;32>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if((65535&d)!==(65535^d>>>16)){t.msg="invalid stored block lengths",n.mode=le;break}if(n.length=65535&d,d=0,h=0,n.mode=J,e===S)break t;case J:n.mode=G;case G:if(m=n.length){if(m>u&&(m=u),m>f&&(m=f),0===m)break t;v.arraySet(o,i,a,m,s),u-=m,a+=m,f-=m,s+=m,n.length-=m;break}n.mode=W;break;case Q:for(;14>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if(n.nlen=(31&d)+257,d>>>=5,h-=5,n.ndist=(31&d)+1,d>>>=5,h-=5,n.ncode=(15&d)+4,d>>>=4,h-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=le;break}n.have=0,n.mode=$;case $:for(;n.have<n.ncode;){for(;3>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}n.lens[Oe[n.have++]]=7&d,d>>>=3,h-=3}for(;19>n.have;)n.lens[Oe[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,xe={bits:n.lenbits},Ie=w(E,n.lens,0,19,n.lencode,0,n.work,xe),n.lenbits=xe.bits,Ie){t.msg="invalid code lengths set",n.mode=le;break}n.have=0,n.mode=te;case te:for(;n.have<n.nlen+n.ndist;){for(;ke=n.lencode[d&(1<<n.lenbits)-1],me=ke>>>24,ve=255&ke>>>16,ye=65535&ke,!(h>=me);){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if(16>ye)d>>>=me,h-=me,n.lens[n.have++]=ye;else{if(16===ye){for(Ae=me+2;Ae>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if(d>>>=me,h-=me,0===n.have){t.msg="invalid bit length repeat",n.mode=le;break}Ee=n.lens[n.have-1],m=3+(3&d),d>>>=2,h-=2}else if(17===ye){for(Ae=me+3;Ae>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}d>>>=me,h-=me,Ee=0,m=3+(7&d),d>>>=3,h-=3}else{for(Ae=me+7;Ae>h;){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}d>>>=me,h-=me,Ee=0,m=11+(127&d),d>>>=7,h-=7}if(n.have+m>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=le;break}for(;m--;)n.lens[n.have++]=Ee}}if(n.mode===le)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=le;break}if(n.lenbits=9,xe={bits:n.lenbits},Ie=w(I,n.lens,0,n.nlen,n.lencode,0,n.work,xe),n.lenbits=xe.bits,Ie){t.msg="invalid literal/lengths set",n.mode=le;break}if(n.distbits=6,n.distcode=n.distdyn,xe={bits:n.distbits},Ie=w(x,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,xe),n.distbits=xe.bits,Ie){t.msg="invalid distances set",n.mode=le;break}if(n.mode=ee,e===S)break t;case ee:n.mode=ne;case ne:if(u>=6&&f>=258){t.next_out=s,t.avail_out=f,t.next_in=a,t.avail_in=u,n.hold=d,n.bits=h,_(t,g),s=t.next_out,o=t.output,f=t.avail_out,a=t.next_in,i=t.input,u=t.avail_in,d=n.hold,h=n.bits,n.mode===W&&(n.back=-1);break}for(n.back=0;ke=n.lencode[d&(1<<n.lenbits)-1],me=ke>>>24,ve=255&ke>>>16,ye=65535&ke,!(h>=me);){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}if(ve&&0===(240&ve)){for(be=me,_e=ve,we=ye;ke=n.lencode[we+((d&(1<<be+_e)-1)>>be)],me=ke>>>24,ve=255&ke>>>16,ye=65535&ke,!(h>=be+me);){if(0===u)break t;u--,d+=i[a++]<<h,h+=8}d>>>=be,h-=be,n.back+=be}if(d>>>=me,h-=me,n.back+=me,n.length=ye,0===ve){n.mode=se;break}if(32&ve){n.back=-1,n.mode=W;break}if(64&ve){t.msg="invalid literal/length code",n.mode=le;break}n.extra=15&ve,n.mode=re;case re:if(n
o(null,u)}}o=arguments[arguments.length-1],z(n,o)&&(r=B(r),r||o(new Ue.EINVAL("flags is not valid")),d(e,n,r,a))}function F(t,e,n,r){pe(t.openFiles).has(n)?(t.releaseDescriptor(n),r(null)):r(new Ue.EBADF)}function M(t,e,n,r,i){z(n,i)&&a(e,n,r,i)}function U(t,e,n,i,o){o=arguments[arguments.length-1],z(n,o)&&c(e,n,r(o))}function P(t,e,n,i){z(n,i)&&l(e,n,r(i))}function V(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Xe(n,t.name);r(null,i)}}z(n,r)&&m(e,n,i)}function Z(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Xe(n,t.name);r(null,i)}}var o=t.openFiles[n];o?v(e,o,i):r(new Ue.EBADF)}function Y(t,e,n,i,o){z(n,o)&&z(i,o)&&b(e,n,i,r(o))}function X(t,e,n,i){z(n,i)&&_(e,n,r(i))}function H(t,e,n,i,o,a,s,u){function f(t,e){u(t,e||0,i)}o=void 0===o?0:o,a=void 0===a?i.length-o:a,u=arguments[arguments.length-1];var c=t.openFiles[n];c?pe(c.flags).contains(Te)?g(e,c,i,o,a,s,r(f)):u(new Ue.EBADF("descriptor does not permit reading")):u(new Ue.EBADF)}function W(t,e,r,i,o){if(o=arguments[arguments.length-1],i=L(i,null,"r"),z(r,o)){var a=B(i.flag||"r");a||o(new Ue.EINVAL("flags is not valid")),d(e,r,a,function(s,u){if(s)return o(s);var f=new Ve(r,u.id,a,0),c=t.allocDescriptor(f);v(e,f,function(r,a){if(r)return o(r);var s=new Xe(a,t.name),u=s.size,l=new n(u);l.fill(0),g(e,f,l,0,u,0,function(e){if(e)return o(e);t.releaseDescriptor(c);var n;n="utf8"===i.encoding?Me.decode(l):l,o(null,n)})})})}}function q(t,e,n,i,o,a,s,u){u=arguments[arguments.length-1],o=void 0===o?0:o,a=void 0===a?i.length-o:a;var f=t.openFiles[n];f?pe(f.flags).contains(Ce)?a>i.length-o?u(new Ue.EIO("intput buffer is too small")):p(e,f,i,o,a,s,r(u)):u(new Ue.EBADF("descriptor does not permit writing")):u(new Ue.EBADF)}function K(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","w"),z(n,o)){var a=B(i.flag||"w");a||o(new Ue.EINVAL("flags is not valid")),r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Me.encode(r)),d(e,n,a,function(i,s){if(i)return o(i);var u=new Ve(n,s.id,a,0),f=t.allocDescriptor(u);h(e,u,r,0,r.length,function(e){return e?o(e):(t.releaseDescriptor(f),o(null),void 0)})})}}function J(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","a"),z(n,o)){var a=B(i.flag||"a");a||o(new Ue.EINVAL("flags is not valid")),r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Me.encode(r)),d(e,n,a,function(i,s){if(i)return o(i);var u=new Ve(n,s.id,a,s.size),f=t.allocDescriptor(u);p(e,u,r,0,r.length,u.position,function(e){return e?o(e):(t.releaseDescriptor(f),o(null),void 0)})})}}function G(t,e,n,r){function i(t){r(t?!1:!0)}V(t,e,n,i)}function Q(t,e,n,i,o){z(n,o)&&C(e,n,i,r(o))}function $(t,e,n,i,o){var a=t.openFiles[n];a?R(e,a,i,r(o)):o(new Ue.EBADF)}function te(t,e,n,i,o,a,s){"function"==typeof a&&(s=a,a=null),z(n,s)&&O(e,n,i,o,a,r(s))}function ee(t,e,n,i,o,a,s){"function"==typeof a&&(s=a,a=null);var u=t.openFiles[n];u?pe(u.flags).contains(Ce)?T(e,u,i,o,a,r(s)):s(new Ue.EBADF("descriptor does not permit writing")):s(new Ue.EBADF)}function ne(t,e,n,i,o){z(n,o)&&N(e,n,i,r(o))}function re(t,e,n,i,o){var a=t.openFiles[n];a?pe(a.flags).contains(Ce)?D(e,a,i,r(o)):o(new Ue.EBADF("descriptor does not permit writing")):o(new Ue.EBADF)}function ie(t,e,n,r,i,o){function a(t,e){t?o(t):0>e.size+r?o(new Ue.EINVAL("resulting file offset would be negative")):(s.position=e.size+r,o(null,s.position))}var s=t.openFiles[n];s||o(new Ue.EBADF),"SET"===i?0>r?o(new Ue.EINVAL("resulting file offset would be negative")):(s.position=r,o(null,s.position)):"CUR"===i?0>s.position+r?o(new Ue.EINVAL("resulting file offset would be negative")):(s.position+=r,o(null,s.position)):"END"===i?v(e,s,a):o(new Ue.EINVAL("whence argument is not a proper value"))}function oe(t,e,n,i){z(n,i)&&w(e,n,r(i))}function ae(t,e,n,i,o,a){if(z(n,a)){var s=Date.now();i=i?i:s,o=o?o:s,k(e,n,i,o,r(a))}}function se(t,e,n,i,o,a){var s=Date.now();i=i?i:s,o=o?o:s;var u=t.openFiles[n];u?pe(u.flags).contains(Ce)?S(e,u,i,o,r(a)):a(new Ue.EBADF("descriptor does not permit writing")):a(new Ue.EBADF)}function ue(t,e,n,i,o){function a(t){t?o(t):_(e,n,r(o