filer/dist/filer.min.js

4 lines
79 KiB
JavaScript
Raw Normal View History

2014-09-02 19:48:54 +00:00
/*! filer 0.0.27 2014-09-02 */
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Filer=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=e[a]={exports:{}};t[a][0].call(c.exports,function(n){var e=t[a][1][n];return i(e?e:n)},c,c.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(n,e){(function(n){(function(){function r(t){var n=!1;return function(){if(n)throw Error("Callback was already called.");n=!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 u=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 u(t,function(t,r,i){e.push(n(t,r,i))}),e},c=function(t,n,e){return t.reduce?t.reduce(n,e):(u(t,function(t,r,i){e=n(e,t,r,i)}),e)},f=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!==n&&n.nextTick?(a.nextTick=n.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,n,e){if(e=e||function(){},!t.length)return e();var i=0;u(t,function(o){n(o,r(function(n){n?(e(n),e=function(){}):(i+=1,i>=t.length&&e(null))}))})},a.forEach=a.each,a.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()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,n,e,r){var i=l(n);i.apply(null,[t,e,r])},a.forEachLimit=a.eachLimit;var l=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 u(){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():u())})})()}},d=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(n))}},p=function(t,n){return function(){var e=Array.prototype.slice.call(arguments);return n.apply(null,[l(t)].concat(e))}},h=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(n))}},g=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)})};a.map=d(g),a.mapSeries=h(g),a.mapLimit=function(t,n,e,r){return v(n)(t,e,r)};var v=function(t){return p(t,g)};a.reduce=function(t,n,e,r){a.eachSeries(t,function(t,r){e(n,t,function(t,e){n=e,r(t)})},function(t){r(t,n)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,n,e,r){var i=s(t,function(t){return t}).reverse();a.reduce(i,n,e,r)},a.foldr=a.reduceRight;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}))})};a.filter=d(m),a.filterSeries=h(m),a.select=a.filter,a.selectSeries=a.filterSeries;var y=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}))})};a.reject=d(y),a.rejectSeries=h(y);var E=function(t,n,e,r){t(n,function(t,n){e(t,function(e){e?(r(t),r=function(){}):n()})},function(){r()})};a.detect=d(E),a.detectSeries=h(E),a.some=function(t,n,e){a.each(t,function(t,r){n(t,function(t){t&&(e(!0),e=function(){}),r()})},f
e?(e=Number(e),e>l&&(e=l)):e=l,r=((r||"utf8")+"").toLowerCase();var d;switch(r){case"hex":d=i(this,t,n,e);break;case"utf8":case"utf-8":d=o(this,t,n,e);break;case"ascii":d=a(this,t,n,e);break;case"binary":d=u(this,t,n,e);break;case"base64":d=s(this,t,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":d=c(this,t,n,e);break;default:throw Error("Unknown encoding")}return d},r.prototype.toString=function(t,n,e){var r=this;if(t=((t||"utf8")+"").toLowerCase(),n=Number(n)||0,e=void 0===e?r.length:Number(e),e===n)return"";var i;switch(t){case"hex":i=h(r,n,e);break;case"utf8":case"utf-8":i=l(r,n,e);break;case"ascii":i=d(r,n,e);break;case"binary":i=p(r,n,e);break;case"base64":i=f(r,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,n,e);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 z(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,n,e,i){var o=this;if(e||(e=0),i||0===i||(i=this.length),n||(n=0),i!==e&&0!==t.length&&0!==o.length){z(i>=e,"sourceEnd < sourceStart"),z(n>=0&&t.length>n,"targetStart out of bounds"),z(e>=0&&o.length>e,"sourceStart out of bounds"),z(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-e>t.length-n&&(i=t.length-n+e);var a=i-e;if(100>a||!r._useTypedArrays)for(var u=0;a>u;u++)t[u+n]=this[u+e];else t._set(this.subarray(e,e+a),n)}},r.prototype.slice=function(t,n){var e=this.length;if(t=D(t,e,0),n=D(n,e,e),r._useTypedArrays)return r._augment(this.subarray(t,n));for(var i=n-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,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,n)},r.prototype.readUInt8=function(t,n){return n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,n){return v(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return v(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return m(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return m(this,t,!1,n)},r.prototype.readInt8=function(t,n){if(n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var e=128&this[t];return e?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,n){return y(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return E(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return E(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return b(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return b(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return w(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return w(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"trying to write beyond buffer length"),V(t,255)),n>=this.length?void 0:(this[n]=t,n+1)},r.prototype.writeUInt16LE=function(t,n,e){return I(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){return I(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){return O(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){return O(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"Trying to write beyond buffer length"),Y(t,127,-128)),n>=this.length?void 0:(t>=0?this.writeUInt8(t,n,e):this.writeUInt8(255+t+1,n,e),n+1)},r.prototype.writeInt16LE=function(t,n,e){return A(this,t,n,!0,e)},r.prototype.writeInt16BE=functi
"function"==typeof n&&(e=n,n={}),n=n||{},e=e||a;var r=new m;return r.start(t,!1,n.recursive),r.on("change",e),r},T.open(function(t){function i(t){function i(t){var n=T[t]();return n.flags=g,n.changes=[],n.guid=r(n),n.close=function(){var t=n.changes;u(t),t.length=0},n}N.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext")}},N.readyState=t?d:f,e(),n(t,N)}if(t)return i(t);var o=T.getReadWriteContext();o.guid=r(o),x?o.clear(function(t){return t?i(t):(A.ensureRootDirectory(o,i),void 0)}):A.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,u=t("../constants.js"),s=u.FILE_SYSTEM_NAME,c=u.FS_FORMAT,f=u.FS_READY,l=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,h=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),y=t("../errors.js"),E=t("../shared.js").guid,b=u.STDIN,w=u.STDOUT,I=u.STDERR,O=u.FIRST_DESCRIPTOR,A=t("./implementation.js");r.providers=h,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var n=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=e(r[i]),u=n.queueOrRun(function(){function e(){u.close(),a.apply(n,arguments)}var u=n.provider.openReadWriteContext();if(d===n.readyState){var s=new y.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(n,s)}o?r.push(e):r[i]=e;var c=[n,u].concat(r);A[t].apply(null,c)});u&&a(u)}}),r.prototype.Shell=function(t){return new g(this,t)},n.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":12,"../errors.js":15,"../fs-watcher.js":18,"../path.js":22,"../providers/index.js":23,"../shared.js":27,"../shell/shell.js":30,"./implementation.js":16}],18:[function(t,n){function e(){function t(t){(e===t||u&&0===t.indexOf(n))&&a.trigger("change","change",t)}r.call(this);var n,e,a=this,u=!1;a.start=function(r,a,s){if(!e){if(i.isNull(r))throw Error("Path must be a string without null bytes.");e=i.normalize(r),u=s===!0,u&&(n="/"===e?"/":e+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var n=o.getInstance();n.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");e.prototype=new r,e.prototype.constructor=e,n.exports=e},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":22}],19:[function(t,n){n.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js")}},{"./buffer.js":11,"./errors.js":15,"./filesystem/interface.js":17,"./path.js":22}],20:[function(t,n){function e(t){var n=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||n,this.ctime=t.ctime||n,this.mtime=t.mtime||n,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,n,e){t[n]?e(null):t.guid(function(r,i){t[n]=i,e(r)})}var i=t("./constants.js").MODE_FILE;e.create=function(t,n){r(t,"id",function(i){return i?(n(i),void 0):(r(t,"data",function(r){return r?(n(r),void 0):(n(null,new e(t)),void 0)}),void 0)})},n.exports=e},{"./constants.js":12}],21:[function(t,n){n.exports=function(t,n,e,r){this.path=t,this.id=n,this.flags=e,this.position=r}},{}],22:[function(t,n,e){function r(t,n){for(var e=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),e++):e&&(t.splice(r,1),e--)}if(n)for(;e--;e)t.unshift("..");return t}function i(){for(var t="",n=!1,e=arguments.length-1;e>=-1&&!n;e--){var i=e>=0?arguments[e]:"/";"string"==typeof i&&i&&(t=i+"/"+t,n="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!n).join("/"),(n?"/":"")+t||"."}function o(