filer/dist/filer.min.js

4 lines
91 KiB
JavaScript
Raw Normal View History

2014-05-27 18:44:30 +00:00
/*! filer 0.0.6 2014-05-27 */
(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 c=n[a]={exports:{}};t[a][0].call(c.exports,function(n){var e=t[a][1][n];return i(e?e:n)},c,c.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(t,n){(function(t){(function(){function e(t){var n=!1;return function(){if(n)throw Error("Callback was already called.");n=!0,t.apply(r,arguments)}}var r,i,o={};r=this,null!=r&&(i=r.async),o.noConflict=function(){return r.async=i,o};var a=function(t,n){if(t.forEach)return t.forEach(n);for(var e=0;t.length>e;e+=1)n(t[e],e,t)},s=function(t,n){if(t.map)return t.map(n);var e=[];return a(t,function(t,r,i){e.push(n(t,r,i))}),e},u=function(t,n,e){return t.reduce?t.reduce(n,e):(a(t,function(t,r,i){e=n(e,t,r,i)}),e)},c=function(t){if(Object.keys)return Object.keys(t);var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(e);return n};void 0!==t&&t.nextTick?(o.nextTick=t.nextTick,o.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:o.nextTick):"function"==typeof setImmediate?(o.nextTick=function(t){setImmediate(t)},o.setImmediate=o.nextTick):(o.nextTick=function(t){setTimeout(t,0)},o.setImmediate=o.nextTick),o.each=function(t,n,r){if(r=r||function(){},!t.length)return r();var i=0;a(t,function(o){n(o,e(function(n){n?(r(n),r=function(){}):(i+=1,i>=t.length&&r(null))}))})},o.forEach=o.each,o.eachSeries=function(t,n,e){if(e=e||function(){},!t.length)return e();var r=0,i=function(){n(t[r],function(n){n?(e(n),e=function(){}):(r+=1,r>=t.length?e(null):i())})};i()},o.forEachSeries=o.eachSeries,o.eachLimit=function(t,n,e,r){var i=f(n);i.apply(null,[t,e,r])},o.forEachLimit=o.eachLimit;var f=function(t){return function(n,e,r){if(r=r||function(){},!n.length||0>=t)return r();var i=0,o=0,a=0;(function s(){if(i>=n.length)return r();for(;t>a&&n.length>o;)o+=1,a+=1,e(n[o-1],function(t){t?(r(t),r=function(){}):(i+=1,a-=1,i>=n.length?r():s())})})()}},l=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[o.each].concat(n))}},h=function(t,n){return function(){var e=Array.prototype.slice.call(arguments);return n.apply(null,[f(t)].concat(e))}},p=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[o.eachSeries].concat(n))}},d=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e,r){i[t.index]=r,n(e)})},function(t){r(t,i)})};o.map=l(d),o.mapSeries=p(d),o.mapLimit=function(t,n,e,r){return g(n)(t,e,r)};var g=function(t){return h(t,d)};o.reduce=function(t,n,e,r){o.eachSeries(t,function(t,r){e(n,t,function(t,e){n=e,r(t)})},function(t){r(t,n)})},o.inject=o.reduce,o.foldl=o.reduce,o.reduceRight=function(t,n,e,r){var i=s(t,function(t){return t}).reverse();o.reduce(i,n,e,r)},o.foldr=o.reduceRight;var v=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e&&i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};o.filter=l(v),o.filterSeries=p(v),o.select=o.filter,o.selectSeries=o.filterSeries;var m=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e||i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};o.reject=l(m),o.rejectSeries=p(m);var y=function(t,n,e,r){t(n,function(t,n){e(t,function(e){e?(r(t),r=function(){}):n()})},function(){r()})};o.detect=l(y),o.detectSeries=p(y),o.some=function(t,n,e){o.each(t,function(t,r){n(t,function(t){t&&(e(!0),e=function(){}),r()})},function(){e(!1)})},o.any=o.some,o.every=function(t,n,e){o.each(t,function(t,r){n(t,function(t){t||(e(!1),e=function(){}),r()})},function(){e(!0)})},o.all=o.every,o.sortBy=function(t,n,e){o.map(t,function(t,e){n(t,function(n,r){n?e(n):e(null,{value:t,criteria:r})})},function(t,n){if(t)return e(t);var
for(S=k,Y.b(1,1,m),Y.b(S,2,m),x=s(this,o),j=c(this.p,15),L=l(j),M=c(this.o,7),F=l(M),N=286;N>257&&0===j[N-1];N--);for(D=30;D>1&&0===M[D-1];D--);var q,Z,H,J,G,Q,K=N,$=D,tn=new(E?Uint32Array:Array)(K+$),nn=new(E?Uint32Array:Array)(316),en=new(E?Uint8Array:Array)(19);for(q=Z=0;K>q;q++)tn[Z++]=j[q];for(q=0;$>q;q++)tn[Z++]=M[q];if(!E)for(q=0,J=en.length;J>q;++q)en[q]=0;for(q=G=0,J=tn.length;J>q;q+=Z){for(Z=1;J>q+Z&&tn[q+Z]===tn[q];++Z);if(H=Z,0===tn[q])if(3>H)for(;H-->0;)nn[G++]=0,en[0]++;else for(;H>0;)Q=138>H?H:138,Q>H-3&&H>Q&&(Q=H-3),10>=Q?(nn[G++]=17,nn[G++]=Q-3,en[17]++):(nn[G++]=18,nn[G++]=Q-11,en[18]++),H-=Q;else if(nn[G++]=tn[q],en[tn[q]]++,H--,3>H)for(;H-->0;)nn[G++]=tn[q],en[tn[q]]++;else for(;H>0;)Q=6>H?H:6,Q>H-3&&H>Q&&(Q=H-3),nn[G++]=16,nn[G++]=Q-3,en[16]++,H-=Q}for(t=E?nn.subarray(0,G):nn.slice(0,G),U=c(en,7),B=0;19>B;B++)X[B]=U[W[B]];for(R=19;R>4&&0===X[R-1];R--);for(C=l(U),Y.b(N-257,5,m),Y.b(D-1,5,m),Y.b(R-4,4,m),B=0;R>B;B++)Y.b(X[B],3,m);for(B=0,z=t.length;z>B;B++)if(P=t[B],Y.b(C[P],U[P],m),P>=16){switch(B++,P){case 16:V=2;break;case 17:V=3;break;case 18:V=7;break;default:throw"invalid code: "+P}Y.b(t[B],V,m)}var rn,on,an,sn,un,cn,fn,ln,hn=[L,j],pn=[F,M];for(un=hn[0],cn=hn[1],fn=pn[0],ln=pn[1],rn=0,on=x.length;on>rn;++rn)if(an=x[rn],Y.b(un[an],cn[an],m),an>256)Y.b(x[++rn],x[++rn],m),sn=x[++rn],Y.b(fn[sn],ln[sn],m),Y.b(x[++rn],x[++rn],m);else if(256===an)break;this.c=Y.finish(),this.e=this.c.length;break;default:throw"invalid compression type"}return this.c};var D=function(){function t(t){switch(m){case 3===t:return[257,t-3,0];case 4===t:return[258,t-4,0];case 5===t:return[259,t-5,0];case 6===t:return[260,t-6,0];case 7===t:return[261,t-7,0];case 8===t:return[262,t-8,0];case 9===t:return[263,t-9,0];case 10===t:return[264,t-10,0];case 12>=t:return[265,t-11,1];case 14>=t:return[266,t-13,1];case 16>=t:return[267,t-15,1];case 18>=t:return[268,t-17,1];case 22>=t:return[269,t-19,2];case 26>=t:return[270,t-23,2];case 30>=t:return[271,t-27,2];case 34>=t:return[272,t-31,2];case 42>=t:return[273,t-35,3];case 50>=t:return[274,t-43,3];case 58>=t:return[275,t-51,3];case 66>=t:return[276,t-59,3];case 82>=t:return[277,t-67,4];case 98>=t:return[278,t-83,4];case 114>=t:return[279,t-99,4];case 130>=t:return[280,t-115,4];case 162>=t:return[281,t-131,5];case 194>=t:return[282,t-163,5];case 226>=t:return[283,t-195,5];case 257>=t:return[284,t-227,5];case 258===t:return[285,t-258,0];default:throw"invalid length: "+t}}var n,e,r=[];for(n=3;258>=n;n++)e=t(n),r[n]=e[2]<<24|e[1]<<16|e[0];return r}(),R=E?new Uint32Array(D):D,j=[80,75,1,2],L=[80,75,3,4],M=[80,75,5,6];h.prototype.m=function(t,n){n=n||{};var e,i=t.length,a=0;if(E&&t instanceof Array&&(t=new Uint8Array(t)),"number"!=typeof n.compressionMethod&&(n.compressionMethod=8),n.compress)switch(n.compressionMethod){case 0:break;case 8:a=r(t),t=new o(t,n.deflateOption).g(),e=m;break;default:throw Error("unknown compression method:"+n.compressionMethod)}this.files.push({buffer:t,a:n,j:e,r:!1,size:i,h:a})},h.prototype.q=function(t){this.i=t},h.prototype.g=function(){var t,n,e,i,a,s,u,c,f,l,h,g,y,w,b,A,O,T,I,S,x,N,k,_,D=this.files,R=0,F=0;for(x=0,N=D.length;N>x;++x){if(t=D[x],y=t.a.filename?t.a.filename.length:0,w=t.a.comment?t.a.comment.length:0,!t.j)switch(t.h=r(t.buffer),t.a.compressionMethod){case 0:break;case 8:t.buffer=new o(t.buffer,t.a.deflateOption).g(),t.j=m;break;default:throw Error("unknown compression method:"+t.a.compressionMethod)}if(t.a.password!==v||this.i!==v){var U=t.a.password||this.i,C=[305419896,591751049,878082192],P=v,V=v;for(E&&(C=new Uint32Array(C)),P=0,V=U.length;V>P;++P)d(C,255&U[P]);for(S=C,T=t.buffer,E?(I=new Uint8Array(T.length+12),I.set(T,12),T=I):T.unshift(0,0,0,0,0,0,0,0,0,0,0,0),k=0;12>k;++k)T[k]=p(S,11===x?255&t.h:0|256*Math.random());for(_=T.length;_>k;++k)T[k]=p(S,T[k]);t.buffer=T}R+=30+y+t.buffer.length,F+=46+y+w}for(n=new(E?Uint8Array:Array)(R+F+(46+(this.d?this.d.length:0))),e=0,i=R,a=i+F,x=0,N=D.length;N>x;++x){if(t=D[x],y=t.a.filename?t.a.filename.length:0,w=t.a.comment?t.a.comment.length:0,s=e,n[e++]=L[0],n[e++]=L[1],n[e++]=L[2],n[e++]=L[3],n[i++]
else{s=n;var r=Object.keys(s);e(null,r)}}function i(n,i){n?e(n):(a=i,t.get(a.data,r))}n=mn(n),En(n);var a,s;o(t,n,i)}function w(t,n,e,i){function a(n,e){n?i(n):(l=e,t.get(l.data,s))}function s(t,n){t?i(t):(h=n,pn(h).has(d)?i(new Vn.EEXIST):u())}function u(){p=new Wn(void 0,In),p.nlinks+=1,p.size=n.length,p.data=n,t.put(p.id,p,f)}function c(n){if(n)i(n);else{var e=Date.now();r(t,g,l,{mtime:e,ctime:e},i)}}function f(n){n?i(n):(h[d]=new Bn(p.id,In),t.put(l.data,h,c))}e=mn(e);var l,h,p,d=En(e),g=yn(e);xn==d?i(new Vn.EEXIST):o(t,g,a)}function b(t,n,e){function r(n,r){n?e(n):(s=r,t.get(s.data,i))}function i(n,r){n?e(n):(u=r,pn(u).has(c)?t.get(u[c].id,a):e(new Vn.ENOENT("a component of the path does not name an existing file")))}function a(t,n){t?e(t):n.mode!=In?e(new Vn.EINVAL("path not a symbolic link")):e(null,n.data)}n=mn(n);var s,u,c=En(n),f=yn(n);o(t,f,r)}function A(t,n,e,i){function a(n,e){n?i(n):e.mode==Tn?i(new Vn.EISDIR):(f=e,t.get(f.data,s))}function s(n,r){if(n)i(n);else{var o=new Uint8Array(e);r&&o.set(r.subarray(0,e)),t.put(f.data,o,c)}}function u(e){if(e)i(e);else{var o=Date.now();r(t,n,f,{mtime:o,ctime:o},i)}}function c(n){n?i(n):(f.size=e,f.version+=1,t.put(f.id,f,u))}n=mn(n);var f;0>e?i(new Vn.EINVAL("length cannot be negative")):o(t,n,a)}function O(t,n,e,i){function o(n,e){n?i(n):e.mode==Tn?i(new Vn.EISDIR):(c=e,t.get(c.data,a))}function a(n,r){if(n)i(n);else{var o=new Uint8Array(e);r&&o.set(r.subarray(0,e)),t.put(c.data,o,u)}}function s(e){if(e)i(e);else{var o=Date.now();r(t,n.path,c,{mtime:o,ctime:o},i)}}function u(n){n?i(n):(c.size=e,c.version+=1,t.put(c.id,c,s))}var c;0>e?i(new Vn.EINVAL("length cannot be negative")):t.get(n.id,o)}function T(t,n,e,i,a){function s(o,s){o?a(o):r(t,n,s,{atime:e,ctime:i,mtime:i},a)}n=mn(n),"number"!=typeof e||"number"!=typeof i?a(new Vn.EINVAL("atime and mtime must be number")):0>e||0>i?a(new Vn.EINVAL("atime and mtime must be positive integers")):o(t,n,s)}function I(t,n,e,i,o){function a(a,s){a?o(a):r(t,n.path,s,{atime:e,ctime:i,mtime:i},o)}"number"!=typeof e||"number"!=typeof i?o(new Vn.EINVAL("atime and mtime must be a number")):0>e||0>i?o(new Vn.EINVAL("atime and mtime must be positive integers")):t.get(n.id,a)}function S(t,n,e,r,i,o){n=mn(n),"string"!=typeof e?o(new Vn.EINVAL("attribute name must be a string")):e?null!==i&&i!==Fn&&i!==Un?o(new Vn.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):a(t,n,e,r,i,o):o(new Vn.EINVAL("attribute name cannot be an empty string"))}function x(t,n,e,r,i,o){"string"!=typeof e?o(new Vn.EINVAL("attribute name must be a string")):e?null!==i&&i!==Fn&&i!==Un?o(new Vn.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):a(t,n,e,r,i,o):o(new Vn.EINVAL("attribute name cannot be an empty string"))}function N(t,n,e,r){function i(t,n){n?n.xattrs[e]:null,t?r(t):n.xattrs.hasOwnProperty(e)?r(null,n.xattrs[e]):r(new Vn.ENOATTR)}n=mn(n),"string"!=typeof e?r(new Vn.EINVAL("attribute name must be a string")):e?o(t,n,i):r(new Vn.EINVAL("attribute name cannot be an empty string"))}function k(t,n,e,r){function i(t,n){n?n.xattrs[e]:null,t?r(t):n.xattrs.hasOwnProperty(e)?r(null,n.xattrs[e]):r(new Vn.ENOATTR)}"string"!=typeof e?r(new Vn.EINVAL):e?t.get(n.id,i):r(new Vn.EINVAL("attribute name cannot be an empty string"))}function _(t,n,e,i){function a(o,a){function s(e){e?i(e):r(t,n,a,{ctime:Date.now()},i)}var u=a?a.xattrs:null;o?i(o):u.hasOwnProperty(e)?(delete a.xattrs[e],t.put(a.id,a,s)):i(new Vn.ENOATTR)}n=mn(n),"string"!=typeof e?i(new Vn.EINVAL("attribute name must be a string")):e?o(t,n,a):i(new Vn.EINVAL("attribute name cannot be an empty string"))}function D(t,n,e,i){function o(o,a){function s(e){e?i(e):r(t,n.path,a,{ctime:Date.now()},i)}o?i(o):a.xattrs.hasOwnProperty(e)?(delete a.xattrs[e],t.put(a.id,a,s)):i(new Vn.ENOATTR)}"string"!=typeof e?i(new Vn.EINVAL("attribute name must be a string")):e?t.get(n.id,o):i(new Vn.EINVAL("attribute name cannot be an empty string"))}function R(t){return pn(Mn).has(t)?Mn[t]:null}function j(t,n,e){return t?"function"==typeof t?t={encoding:n,flag:e}:"string"==typeof t&&(t={encodin