示例#1
0
 Object.keys(map).forEach(function(k) {
   var it = map[k]
   if('object' == typeof it) self.mapper(k, it, ftr)
   else {
     var fel = ftr.select(k)
     var fs  = fel.createWriteStream()
     fs.end(map[k])
   }
 })
示例#2
0
function e(t,e,r){e&&!Array.isArray(e)&&"object"==typeof e&&(r=e,e=null),"string"==typeof e&&(e=[e]),Array.isArray(e)||(e=[]),this._socket=null,this.bytesReceived=0,this.readyState=null,this.supports={},Array.isArray(t)?_.apply(this,t.concat(r)):b.apply(this,[t,e,r])}function h(e,t,r){this.data=e,this.type=t,this.target=r}function w(e,t,r){this.wasClean=void 0===e||1e3==e,this.code=e,this.reason=t,this.target=r}function d(e){this.target=e}function _(i,r,n,t){t=new a({protocolVersion:l,protocol:null}).merge(t),this.protocol=t.value.protocol,this.protocolVersion=t.value.protocolVersion,this.supports.binary="hixie-76"!=this.protocolVersion,this.upgradeReq=i,this.readyState=e.CONNECTING,this._isServer=!0,"hixie-76"==t.value.protocolVersion?o.call(this,E,k,r,n):o.call(this,u,c,r,n)}function b(A,T,i){var f,S,x,k,b,q,_,C,O,h,w,s,E,d,v;if(i=new a({origin:null,protocolVersion:l,host:null,headers:null,protocol:null,agent:null,pfx:null,key:null,passphrase:null,cert:null,ca:null,ciphers:null,rejectUnauthorized:null}).merge(i),8!=i.value.protocolVersion&&13!=i.value.protocolVersion)throw Error("unsupported protocol version");if(f=m.parse(A),S="ws+unix:"===f.protocol,!f.host&&!S)throw Error("invalid url");if(x="wss:"===f.protocol||"https:"===f.protocol,k=x?g:p,b=f.port||(x?443:80),q=f.auth,this._isServer=!1,this.url=A,this.protocolVersion=i.value.protocolVersion,this.supports.binary="hixie-76"!=this.protocolVersion,_=new Buffer(i.value.protocolVersion+"-"+Date.now()).toString("base64"),C=y.createHash("sha1"),C.update(_+"258EAFA5-E914-47DA-95CA-C5AB0DC85B11"),O=C.digest("base64"),h=i.value.agent,!h&&t&&(t=!0,h=new k.Agent({host:f.hostname,port:b})),w=f.hostname,f.port&&(x&&443!=b||!x&&80!=b)&&(w=w+":"+b),s={port:b,host:f.hostname,headers:{Connection:"Upgrade",Upgrade:"websocket",Host:w,Origin:w,"Sec-WebSocket-Version":i.value.protocolVersion,"Sec-WebSocket-Key":_}},q&&(s.headers.Authorization="Basic "+new Buffer(q).toString("base64")),i.value.protocol&&(s.headers["Sec-WebSocket-Protocol"]=i.value.protocol),i.value.host&&(s.headers.Host=i.value.host),i.value.headers)for(E in i.value.headers)i.value.headers.hasOwnProperty(E)&&(s.headers[E]=i.value.headers[E]);if(i.isDefinedAndNonNull("pfx")||i.isDefinedAndNonNull("key")||i.isDefinedAndNonNull("passphrase")||i.isDefinedAndNonNull("cert")||i.isDefinedAndNonNull("ca")||i.isDefinedAndNonNull("ciphers")||i.isDefinedAndNonNull("rejectUnauthorized")){if(t)throw Error("Client side certificates are not supported on Node 0.4.x");i.isDefinedAndNonNull("pfx")&&(s.pfx=i.value.pfx),i.isDefinedAndNonNull("key")&&(s.key=i.value.key),i.isDefinedAndNonNull("passphrase")&&(s.passphrase=i.value.passphrase),i.isDefinedAndNonNull("cert")&&(s.cert=i.value.cert),i.isDefinedAndNonNull("ca")&&(s.ca=i.value.ca),i.isDefinedAndNonNull("ciphers")&&(s.ciphers=i.value.ciphers),i.isDefinedAndNonNull("rejectUnauthorized")&&(s.rejectUnauthorized=i.value.rejectUnauthorized),h||(h=new k.Agent(s))}t?s.path=(f.pathname||"/")+(f.search||""):s.path=f.path||"/",h&&(s.agent=h),S&&(s.socketPath=f.pathname),i.value.origin&&(i.value.protocolVersion<13?s.headers["Sec-WebSocket-Origin"]=i.value.origin:s.headers.Origin=i.value.origin),d=this,v=k.request(s),(t?h:v).on("error",function(e){d.emit("error",e),r.call(this,e)}),(t?h:v).once("response",function(t){var e=Error("unexpected server response ("+t.statusCode+")");d.emit("error",e),r.call(this,e)}),(t?h:v).once("upgrade",function(p,a,g){var l,r,f,s;return d.readyState==e.CLOSED?(d.emit("close"),n(d),void a.end()):(l=p.headers["sec-websocket-accept"],void 0===l||l!==O?(d.emit("error","invalid server key"),n(d),void a.end()):(r=p.headers["sec-websocket-protocol"],f=(i.value.protocol||"").split(/, */),s=null,!i.value.protocol&&r?s="server sent a subprotocol even though none requested":i.value.protocol&&!r?s="server sent no subprotocol even though requested":r&&-1===f.indexOf(r)&&(s="server responded with an invalid protocol"),s?(d.emit("error",s),n(d),void a.end()):(r&&(d.protocol=r),o.call(d,u,c,a,g),n(t?h:v),v=null,void(h=null))))}),v.end(),this.readyState=e.CONNECTING}function o(a,c,n,o){function s(r){if(t.readyState==e.OPEN){if(o&&o.length>0){t.bytesReceived+=o.length;var n=o;o=null,t._receiver.add(n)}i=u,r&&(t.bytesReceived+=r.length,t._receiver.add(r))}}function u(e){e&&(t.bytesReceived+=e.length),t._receiver.add(e)}var t,i;this._socket=n,n.setTimeout(0),n.setNoDelay(!0),t=this,this._receiver=new a,n.on("end",r.bind(this)),n.on("close",r.bind(this)),n.on("error",r.bind(this)),i=s,process.nextTick(s),t._receiver.ontext=function(r,e){e=e||{},t.emit("message",r,e)},t._receiver.onbinary=function(r,e){e=e||{},e.binary=!0,t.emit("message",r,e)},t._receiver.onping=function(r,e){e=e||{},t.pong(r,{mask:!t._isServer,binary:e.binary===!0},!0),t.emit("ping",r,e)},t._receiver.onpong=function(e,r){t.emit("pong",e,r)},t._receiver.onclose=function(r,n,e){e=e||{},t.close(r,n)},t._receiver.onerror=function(r,e){t.close(void 0!==e?e:1002,""),t.emit("error",r,e)},this._sender=new c(n),this._sender.on("error",function(e){t.close(1002,""),t.emit("error",e)}),this.readyState=e.OPEN,this.emit("open"),n.on("data",i)}function i(e){e._queue=e._queue||[]}function s(r){var e,n,t=r._queue;if(void 0!==t)for(delete r._queue,e=0,n=t.length;n>e;++e)t[e]()}function x(t,o,n,r){o.on("data",function(o){return t.readyState!=e.OPEN?void("function"==typeof r?r(Error("not opened")):(delete t._queue,t.emit("error",Error("not opened")))):(n.fin=!1,void t._sender.send(o,n))}),o.on("end",function(){return t.readyState!=e.OPEN?void("function"==typeof r?r(Error("not opened")):(delete t._queue,t.emit("error",Error("not opened")))):(n.fin=!0,t._sender.send(null,n),void("function"==typeof r&&r(null)))})}function r(o){var t,r;if(this.readyState!=e.CLOSED){if(t=this.readyState!=e.CONNECTING,this.readyState=e.CLOSED,clearTimeout(this._closeTimer),this._closeTimer=null,t&&this.emit("close",this._closeCode||1e3,this._closeMessage||""),this._socket){n(this._socket),r=this._socket,this._socket.on("error",function(){try{r.destroy()}catch(e){}});try{o?this._socket.destroy():this._socket.end()}catch(i){}this._socket=null}this._sender&&(n(this._sender),this._sender=null),this._receiver&&(this._receiver.cleanup(),this._receiver=null),n(this),this.on("error",function(){}),delete this._queue}}function n(e){t?e._events={}:e.removeAllListeners()}var f=require("util"),S=require("events"),p=require("http"),g=require("https"),y=require("crypto"),m=require("url"),v=require("fs"),a=require("options"),c=require("./Sender"),u=require("./Receiver"),k=require("./Sender.hixie"),E=require("./Receiver.hixie"),l=13,q=3e4,t=/^v0\.4/.test(process.version);f.inherits(e,S.EventEmitter),["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(t,r){e.prototype[t]=e[t]=r}),e.prototype.close=function(t,r){if(this.readyState!=e.CLOSING&&this.readyState!=e.CLOSED){if(this.readyState==e.CONNECTING)return void(this.readyState=e.CLOSED);try{this.readyState=e.CLOSING,this._closeCode=t,this._closeMessage=r;var n=!this._isServer;this._sender.close(t,r,n)}catch(o){this.emit("error",o)}finally{this.terminate()}}},e.prototype.pause=function(){if(this.readyState!=e.OPEN)throw Error("not opened");return this._socket.pause()},e.prototype.ping=function(r,t,n){if(this.readyState!=e.OPEN){if(n===!0)return;throw Error("not opened")}t=t||{},void 0===t.mask&&(t.mask=!this._isServer),this._sender.ping(r,t)},e.prototype.pong=function(r,t,n){if(this.readyState!=e.OPEN){if(n===!0)return;throw Error("not opened")}t=t||{},void 0===t.mask&&(t.mask=!this._isServer),this._sender.pong(r,t)},e.prototype.resume=function(){if(this.readyState!=e.OPEN)throw Error("not opened");return this._socket.resume()},e.prototype.send=function(t,r,n){var o;if("function"==typeof r&&(n=r,r={}),this.readyState!=e.OPEN){if("function"!=typeof n)throw Error("not opened");return void n(Error("not opened"))}return t||(t=""),this._queue?(o=this,void this._queue.push(function(){o.send(t,r,n)})):(r=r||{},r.fin=!0,void 0===r.binary&&(r.binary=t instanceof ArrayBuffer||t instanceof Buffer||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Float32Array||t instanceof Float64Array),void 0===r.mask&&(r.mask=!this._isServer),void(t instanceof v.ReadStream?(i(this),o=this,x(this,t,r,function(e){process.nextTick(function(){s(o)}),"function"==typeof n&&n(e)})):this._sender.send(t,r,n)))},e.prototype.stream=function(t,r){var n,o;if("function"==typeof t&&(r=t,t={}),n=this,"function"!=typeof r)throw Error("callback must be provided");if(this.readyState!=e.OPEN){if("function"!=typeof r)throw Error("not opened");return void r(Error("not opened"))}return this._queue?void this._queue.push(function(){n.stream(t,r)}):(t=t||{},void 0===t.mask&&(t.mask=!this._isServer),i(this),o=function(c,i){try{if(n.readyState!=e.OPEN)throw Error("not opened");t.fin=i===!0,n._sender.send(c,t),i?s(n):process.nextTick(r.bind(null,null,o))}catch(a){"function"==typeof r?r(a):(delete n._queue,n.emit("error",a))}},void process.nextTick(r.bind(null,null,o)))},e.prototype.terminate=function(){if(this.readyState!=e.CLOSED)if(this._socket){try{this._socket.end()}catch(t){return void r.call(this,!0)}this._closeTimer=setTimeout(r.bind(this,!0),q)}else this.readyState==e.CONNECTING&&r.call(this,!0)},Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=0;return this._socket&&(e=this._socket.bufferSize||0),e}}),["open","error","close","message"].forEach(function(t){Object.defineProperty(e.prototype,"on"+t,{get:function(){var e=this.listeners(t)[0];return e?e._listener?e._listener:e:void 0},set:function(e){this.removeAllListeners(t),this.addEventListener(t,e)}})}),e.prototype.addEventListener=function(t,e){function n(t,n){e.call(this,new h(t,n.binary?"Binary":"Text",r))}function o(t,n){e.call(this,new w(t,n,r))}function i(t){t.target=r,e.call(this,t)}function s(){e.call(this,new d(r))}var r=this;"function"==typeof e&&("message"===t?(n._listener=e,this.on(t,n)):"close"===t?(o._listener=e,this.on(t,o)):"error"===t?(i._listener=e,this.on(t,i)):"open"===t?(s._listener=e,this.on(t,s)):this.on(t,e))},module.exports=e;
示例#3
0
!function(n,e){"use strict";var r="undefined"==typeof window?global:window,t=e(r);module.exports=t}(this,function(){"use strict";function n(){return this}var e;e=require("atma-formatter");var r,t,o,u,i,l=100,c=75,a=50,f=25,s=0,g=-25,h={formatMessage:!0,logCaller:!0,logDate:!1,logMeta:null,color:"ascii",handleExceptions:!1},v=a;!function(){r=function(n){return Object.prototype.toString.call(n).replace("[object ","").replace("]","")},t=function(n){"function"==typeof n&&(n=n.prototype);for(var e,r,t=1,o=arguments.length;o>t;t++){e="function"==typeof arguments[t]?arguments[t].prototype:arguments[t];for(r in e)n[r]=e[r]}return n},o=function(n,e){if(null==e)return n;for(var r in e)n[r]=e[r];return n},u=function(){function n(t){if(null==t)return t;var o,u=r(t);switch(u){case"String":case"Number":case"Date":case"RegExp":case"Function":case"Error":case"Boolean":return t;case"Array":case"Arguments":o=[];for(var i=0,l=t.length;l>i;i++)o[i]=n(t[i]);return o;case"Object":case"global":if(-1!==e.indexOf(t))return"<circular>";e.push(t),o={};for(var c in t)o[c]=n(t[c]);return o;default:return console.warn("obj_dimissCircular: Unknown type",u),t}}var e;return function(r){return"object"==typeof r&&null!=r&&(e=[],r=n(r),e=null),r}}(),i=function(){function n(n){for(var e="",r=0;n>r;r++)e+="  ";return e}return function e(t,o,u){null==u&&(u=0);var i=["",0];if("undefined"==typeof t)return i[1]="<undefined>",o(i,"undefined"),i[1];if(null==t)return i[1]="<null>",o(i,"null"),i[1];var l=r(t);switch(l){case"Array":case"Arguments":for(var c,a="[",f=t,s=0,g=f.length;g>s;s++)c=f[s],"["===a&&(a+="\n"),a+=n(u+1)+e(c,o,u+1)+(g-1>s?",":"")+"\n";return a+=n(u)+"]";case"RegExp":return i[1]=t.toString(),o(i,"regexp"),i[1];case"Date":return i[1]=t.toISOString(),o(i,"date"),i[1];case"String":case"Number":case"Boolean":return i[1]=t,o(i,l.toLowerCase()),i[1];case"Function":return i[1]="<function>",o(i,l.toLowerCase()),i[1];case"Error":return t.toString().red;case"Object":case"global":var h,a="{",v=Object.keys(t);for(s=0,g=v.length;g>s;s++)h=v[s],"{"===a&&(a+="\n"),i[0]=h,i[1]=t[h],o(i),a+=n(u+1)+i[0]+": "+e(t[h],o,u+1)+(g-1>s?",":"")+"\n";return a+=n(u)+"}"}}}()}();var d;!function(){function n(n){")"===n[n.length-1]&&(n=n.substr(n.indexOf("(")+1,n.lastIndexOf(")")-1));var t=/^(.+):(\d+):(\d)/.exec(n);if(null==t)return null;var o=r.path=t[1];return r.file=o.substring(o.search(/[\/\\][^\/\\]+$/)+1),r.line=t[2],null==e&&(e=r.file),r}var e,r={path:null,file:null,line:null};d=function(r){for(var t,o=(new Error).stack.split("\n").splice(1),u=o.length,i=-1;++i<u&&(t=n(o[i]),null==t||null==e||t.file===e););return null==t||i===u?"":r.replace("P",t.path).replace("F",t.file).replace("L",t.line)}}();var p;!function(){p=function(n){return"string"!=typeof n&&(n="dd-MM hh:mm:ss"),e(new Date,n)}}();var b,y;!function(){y=function(n,e){if(h.formatMessage===!1)return h.logMeta&&n.unshift(h.logMeta(n)),n;var r=b(n);return null!=e._name&&(r=e._name.color+" "+r),h.logCaller!==!1&&(r+=d(" (F:L)",5)),"function"==typeof h.logMeta&&(r=h.logMeta(n)+" "+r),h.logDate!==!1&&(r=p(h.logDate)+" "+r),r},b=function(n){for(var e,r,t="",o=/%s|%d/,u=n.length>1&&"string"==typeof n[0]&&o.test(n[0]),i=0,l=n.length;l>i;i++)r=n[i],r instanceof String&&(r=String(r)),e="string"==typeof r?r:x.formatJSON(r),i>0&&u&&o.test(t)?t=t.replace(o,e):(""!==t&&(t+=" "),t+=e);return t}}();var m;!function(){function n(n){var r=E.error(n).getTransport();if(null!=r){if(r.flush)return void r.flush(e);if(r.flushAsync)return void r.flushAsync(e)}e()}function e(){process.exit(1)}m=function(e){process.removeListener("uncaughtException",n),e!==!1&&process.on("uncaughtException",n)}}();var w;!function(){w=function(n,e){switch(n){case"level":v=e;break;case"levels":for(var r in e)_(r,e[r]);break;case"transport":k.define(e);break;case"handleExceptions":m(e);break;case"color":x.define(e);case"logCaller":case"logDate":case"formatMessage":case"meta":h[n]=e;break;default:console.error("Logger: unknown configuration",n)}}}();var _,S;!function(){function n(e){var r=e.lastIndexOf(".");return-1===r?o:(e=e.substring(0,r),t.hasOwnProperty(e)&&t[e].strict!==!0?t[e]:n(e))}function e(n,e){var o=/\.\*$/.test(n);o&&(n=n.slice(0,-2)),t[n]={level:e,strict:o===!1},o&&r(n,e,o)}function r(n,e){var r,o=n.length;for(r in t)r.length<=o+1||0===r.indexOf(n+".")&&(t[r]={level:e})}_=function(n,r){e(n,r)},S=function(e){var r=t[e];return r===o?null:(null==r&&(r=t[e]=n(e)),r.level)};var t={},o={level:null}}();var x;!function(){function n(n){return Object.keys(n.value).forEach(function(e){try{Object.defineProperty(String.prototype,e,{get:function(){var r=this,t=n.decorator;null!=t&&r.__wrapped!==!0&&(r=t(r));var o=n.start(e)+r+n.END;return null==t?o:(o=new String(o),o.__wrapped=!0,o)},enumerable:!1,configurable:!0})}catch(r){}}),Object.defineProperty(String.prototype,"color",{get:function(){return l(this,n)},enumerable:!1,configurable:!0}),function(e){return l(e,n)}}x={init:{ascii:function(){e=n(o)},html:function(){e=n(r)},none:function(){e=n(t)}},colorize:function(n){return e(n)},formatJSON:function(n){var e=n;return void 0!==e&&"object"==typeof e&&(e=u(n)),i(e,function(n,e){e&&c[e]&&(n[1]=String(n[1])[c[e]]),n[0]&&(n[0]=n[0].bold)})},define:function(n){return x.init[n]?x.init[n]():void console.error("Invalid Color Type ",n)}};var e,r,t={END:"",value:{red:"",green:"",yellow:"",blue:"",magenta:"",cyan:"",bold:"",italic:"",underline:"",inverse:""},start:function(){return""}};!function(){r={END:"</span>",value:{red:"color:red",green:"color:green",yellow:"color:yellow",blue:"color:blue",magenta:"color:magenta",cyan:"color:cyan",bg_black:"background-color:black",bg_red:"background-color:red",bg_green:"background-color:green",bg_yellow:"background-color:yellow",bg_blue:"background-color:blue",bg_magenta:"background-color:magenta",bg_cyan:"background-color:cyan",bg_white:"background-color:white",bold:"font-weight:bold",italic:"font-style:italic",underline:"text-decoration:underline",inverse:"color:black;background:white"},start:function(n){var e='<span style="'+this.value[n]+'">';return e},decorator:function(e){return n(e)}};var n;!function(){function e(n){return r[n]}n=function(n){return n.replace(/[&"'<>\/]/g,e)};var r={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}}()}();var o={type:"ascii",START:"[",END:"",value:{red:"31m",green:"32m",yellow:"33m",blue:"34m",magenta:"35m",cyan:"36m",white:"37m",black:"30m",bg_black:"40m",bg_red:"41m",bg_green:"42m",bg_yellow:"43m",bg_blue:"44m",bg_magenta:"45m",bg_cyan:"46m",bg_white:"47m",bold:"1m",italic:"3m",underline:"4m",inverse:"7m"},start:function(n){return this.START+this.value[n]}};e=n(o);var l,c={string:"yellow",number:"cyan","boolean":"cyan",regexp:"magenta",date:"magenta","function":"magenta","null":"blue",undefined:"blue"};!function(){function n(n,e,r,t){var o=n.substring(e,r);return t.decorator?t.decorator(o):o}function e(n,e){for(var r,t=1,o=n.length,u=e;o>u;u++)if(r=n.charCodeAt(u),60===r&&t++,62===r&&t--,0===t)return u;return-1}function r(n,e,r){for(var t,o="",u=n.length,i=-1;++i<u;)t=n[i],t.end<e||(o+=r.start(t.key));return o}function t(n){if(null==n.rgx_search){var e="(";for(var r in n.value)e+="("===e?r:"|"+r;e+=")<",n.rgx_search=new RegExp(e,"g")}return n}l=function(o,u){t(u),u.rgx_search.lastIndex=0;for(var i,c,a,f,s="ascii"===u.type,g=s&&[]||null,h="",v=0;;){if(i=u.rgx_search.exec(o),null==i)break;if(c=i[1],null!=u.value[c]){var d,f,p=i.index,b=p+i[0].length;v!==p&&(h+=n(o,v,p,u)),a=e(o,b),v=a+1,-1!==a?(d=u.start(c),f=o.substring(b,a),f=l(f,u),h+=d+f+u.END+(s?r(g,a,u):""),s&&g.push({end:a,key:c}),u.rgx_search.lastIndex=a+1):h+=n(o,p,a,u)}}return v<o.length&&(h+=n(o,v,o.length,u)),h}}()}();var E,k=function(){var n,r,t={};return function(){function n(n,r){var t=e(n);""!==t&&r(n,t)}function e(n){var e=n.buffer;if(0===e.length)return"";var r=n.newLine,t=e.join(r)+r;return e.length=0,t}function t(n,e,r){n&&n(r);var t=e.length,o=-1;if(0!==t){for(;++o<t;)e[o](r);e.length=0}}r={flushAsync:function(n,r,o,u){if(n.busy)return void(null!=u&&n.listeners.push(u));var i=e(n);return""===i?void(u&&u()):(n.busy=!0,void o(n,i,function(){n.busy=!1,t(u,n.listeners),n.buffer.length>r&&n.flushAsync()}))},flush:function(e,r,t){return e.busy?void e.listeners.push(function(){n(e,r,t)}):(n(e,r),void(t&&t()))}}}(),t.http=function(){var n,e,t,o,u=0;!function(){function r(n,e,r,t,o){if(e=e.toUpperCase(),r=r||{},r["Content-Type"]||(r["Content-Type"]="text/plain"),r["Content-Length"]=Buffer.byteLength(t),"GET"===e){if(t=u(t),null==t)return void(o&&o("Encode failed"));n+=t,t=void 0}var a=c.parse(n);a.headers=r,a.method=e;var f="https:"===a.protocol?i:l,s="",g=f.request(a,function(n){n.setEncoding("utf-8"),n.on("data",function(n){s+=String(n)}).on("end",function(){o&&o(s,n)})});null!=t&&g.write(t),g.end()}function u(n){try{return encodeURIComponent(n)}catch(e){return E.error("Logger encode error",e),null}}o=function(o,u){r(n,e||"POST",t,o,u)};var i=require("https"),l=require("http"),c=require("url")}();var i;return function(){function n(n,e,r){o(e,r)}i={newLine:"\n",busy:!1,listeners:[],buffer:[],write:function(n){n=n.replace(/\n/g,"\\n"),this.buffer.push(n),this.buffer.length>u&&this.flushAsync()},flushAsync:function(e){r.flushAsync(this,u,n,e)}}}(),{write:function(n){i.write(n)},flushAsync:function(n){i.flushAsync(n)},cfg:function(r){null!=r.bufferSize&&(u=r.bufferSize),n=r.url||n,e=r.method||e,t=r.headers||t}}},t.std=function(){return{write:function(n){process.stdout.write("\n"+n)},cfg:function(){},std:!0}}(),t.stream=function(){var n;return{write:function(e){n.write(e)},cfg:function(e){var r=e.stream;if(null==r)throw Error("Transport Configuration: No `stream` property");if(null==r.write)throw Error("Transport Configuration: Invalid stream object");n=r}}}(),t.fs=function(){function n(n,e,r){l(n.path,e,r)}function t(n,e){i(n.path,e)}function o(n){try{g.appendFileSync(s.resolve(N,"logger-exceptions.txt"),b([n])+p)}catch(e){"ENOENT"===e.code&&(x(N),o(n))}}var u,i,l,c,a,f,s=require("path"),g=require("fs"),v="logs",d="txt",p=require("os").EOL,y=512e3,m=10,w=0,_=!1;!function(){{var n=require("fs");require("path")}c=function(e){try{return n.lstatSync(e).size}catch(r){return 0}},a=function(e,r){n.unlink(e,function(n){n&&o(n),r(n)})},f=function(e){try{n.unlinkSync(e)}catch(r){o(r)}},l=function(e,r,t){return r?void n.open(e,"a",function(e,u){if(null!=e)return o(e),void t(e);var i=new Buffer(r,"utf8");n.write(u,i,0,i.length,0,function(e){e&&o(e),n.close(u,t)})}):void t()},i=function(e,r){if(r)try{var t=n.openSync(e,"a");n.writeSync(t,r),n.closeSync(t)}catch(u){o(u)}}}();var S,x;!function(){S=function(n){try{return g.readdirSync(n)}catch(e){return o(e),[]}},x=function(n){if(!g.existsSync(n)){x(s.dirname(n));try{g.mkdirSync(n)}catch(e){o(e)}}}}();var E;!function(){function n(n,e){t[e]={write:n.write,end:n.end}}function e(n,e){n.write=t[e].write,n.end=t[e].end}function r(n,e){n.write=n.end=function(n){null!=n&&("string"!=typeof n&&(n=n.toString()),"stderr"===e&&(n=n.red),j.write(n))}}var t={};n(process.stdout,"stdout"),n(process.stderr,"stderr"),E=function(n){var t=n!==!1?r:e;t(process.stdout,"stdout"),t(process.stderr,"stderr")}}();var k=function(n,e){this.buffer=[],this.path=s.resolve(N,n)+"."+T,this.size=e!==!0?0:c(this.path)};k.prototype={get newLine(){return u},busy:!1,errored:!1,listeners:[],write:function(n){this.size+=n.length+u.length,this.buffer.push(n),this.buffer.length>w&&this[_?"flush":"flushAsync"](),this.size>=y&&A()},flushAsync:function(e){r.flushAsync(this,w,n,e)},flush:function(n){r.flush(this,t,n)},getBuffer_:function(){if(0===this.buffer.length)return"";var n=this.buffer.join(u)+u;return this.buffer.length=0,n}};var O,A;!function(){O=function(){u="html"===h.color?"<br/>":p,x(N);for(var n,e=S(N).sort(),r=e.length,t=/^\d+_/g;--r>-1&&(n=e[r],!t.test(n)););C=r>-1?new k(n.replace(/\.\w+$/,""),!0):A(),C.size>=y&&A(),e.length>=m&&e.slice(0,e.length-m+1).forEach(function(n){f(s.resolve(N,n))})},A=function(){null!=C&&C.flush();var r=new Date;return C=new k(r.getTime()+"_"+n++ +"_"+e(r,"dd-MM_hh"))};var n=0}();var C,N=v,T=d,j={write:function(n){null==C&&O(),C.write(n)},flush:function(n){C.flush(n)},flushAsync:function(n){C.flushAsync(n)},cfg:function(n){T=n.extension||d,N=s.resolve(s.dirname(module.parent.filename),n.directory||v),null!=n.bufferSize&&(w=n.bufferSize),n.filesCount&&(m=n.filesCount),n.fileSize&&(y=n.fileSize),null!=n.sync&&(_=n.sync),n.interceptStd&&E()},interceptStd:function(n){E(n)},exception:o};return j},n=t.std,{define:function(e){var r=e.type;if(n=t[r],null==n)throw Error("Transport type is not supported `"+r+"`");return"function"==typeof n&&(n=n()),n.cfg(e),this},write:function(e){n.write(e)},get:function(e){if(null==e)return n;var r=n[e];if(null==r)throw Error("No transport: "+e);return"function"==typeof r?r():r}}}();return function(){var e,r;!function(){e=function(e,r){var t=r,o=v;(null==e||e instanceof E==!1)&&(e=n);var u=e._scope;if(null!=u){var i=S(u);if(null!=i)return o>=i+(r-a)}return null!=e._level&&(t=e._level),o>=t?!0:!1},r=function(n,r){return function(){if(e(this,n)===!1)return this;var t=y(arguments,this);return r&&"string"==typeof t&&(t=r(t)),k.write(t),this}};var n={_parent:null,_level:null,_name:null,_scope:null}}();var t,u;!function(){t={_parent:null,_level:null,_name:null,cfg:function(n){if(0===arguments.length)return h;if("string"==typeof n)return 1===arguments.length?h[n]:(w(n,arguments[1]),this);for(var e in n)w(e,n[e]);return this},color:x,formatMessage:function(){return b(arguments)},log:r(a),warn:r(f,function(n){return n.yellow.bold}),debug:r(c),trace:r(l),error:r(s,function(n){return n.red.bold}),getTransport:function(){return k.get()},create:function(n,e){return new d(this instanceof E&&this||null,n,e)},level_LOG:a,level_WARN:f,level_TRACE:l,level_DEBUG:c,level_ERROR:s,level_EXCEPTION:g},u=o({},t),u.log=u.warn=u.debug=u.trace=u.error=n}();var i;!function(){i=function(){},i.prototype=u}();var d;!function(){d=function(n,e,r){function t(){return o.log.apply(o,arguments)}this._parent=n,this._name=e,this._level=r,null!=n&&n._name&&(this._name=n._name+"."+e),this._scope=this._name;var o=this;return t.__proto__=o,t},d.prototype=t,o(d,t)}(),E=function(n,r){return"string"==typeof n?new d(this instanceof E&&this||null,n,r):"number"==typeof n?e(null,n)?t:u:"boolean"==typeof n&&n===!0?t:u},E.prototype=t,o(E,t)}(),function(){function n(n){var e=parseInt(r[++o]);return isNaN(e)?(E.error("<atma-logger> invalid cli command --"+n+" NUMBER"),null):e}if("undefined"!=typeof process)for(var e,r=process.argv.slice(2),t=r.length,o=-1;++o<t;)switch(e=r[o].replace(/^\-+/,"")){case"no-color":E.cfg("color","none");break;case"level":var u=n("level");if(null==u)break;E.cfg("level",u);break;default:if(0===e.indexOf("level.")){var u=n("level.SCOPE_NAME");if(null==u)break;e=e.replace("level.","");var i={};i[e]=u,E.cfg("levels",i)}}}(),E});