Comparing version 1.3.1 to 1.4.0
/** | ||
* logdown - Debug utility with markdown support that runs on browser and server | ||
* | ||
* @version v1.3.1 | ||
* @version v1.4.0 | ||
* @link https://github.com/caiogondim/logdown | ||
@@ -9,2 +9,2 @@ * @author Caio Gondim <me@caiogondim.com> (http://caiogondim.com) | ||
*/ | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown||r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function l(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function p(e){return"string"==typeof e?e.replace(/%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(u())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); | ||
!function(){"use strict";function e(o){if(!(this instanceof e))return new e(o);o=o||{};var n=void 0===o.prefix?"":o.prefix;return n=a(n),n&&c(n,g)?p(n,g):(this.alignOuput=Boolean(o.alignOuput),this.markdown=void 0===o.markdown||o.markdown,this.prefix=n,g.push(this),r(g),d()?(this.prefixColor=m[h%m.length],h+=1):f()&&(this.prefixColor=E()),this)}function r(e){var r=e.sort(function(e,r){return r.prefix.length-e.prefix.length})[0];e.forEach(function(e){if(e.alignOuput){var o=new Array(Math.max(r.prefix.length-e.prefix.length+1,0)).join(" ");e.prefix=e.prefix+o}})}function o(e){for(var r=[],o=n(e);o;)e=e.replace(o.rule.regexp,o.rule.replacer),d()&&(r.push(o.rule.style),r.push("color:inherit;")),o=n(e);return{text:e,styles:r}}function n(e){var r=[],o=[];return d()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:f()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function t(e,r){var n,t,i,s;return"string"==typeof e?r.markdown&&u()?(n=o(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),r.prefix&&(u()?(t="%c"+r.prefix+"%c "+t,i.unshift("color:"+r.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+r.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function i(e,r){var n,t="";return r.prefix&&(t=u()?"["+r.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+r.prefix+"["+b.modifiers.bold[1]+"m["+r.prefixColor[1]+"m ":"["+r.prefix+"] "),"string"==typeof e?t+=r.markdown?o(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function s(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===y.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return y.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function l(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function p(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function a(e){return"string"==typeof e?e.replace(/%c/g,""):e}function u(){if(d()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(f())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function f(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function d(){return"undefined"!=typeof window}function x(e){return e}var g=[],h=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},y=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=l(r);"*"===r?y=[]:y.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=l(r);"*"===r?y=[{type:"disable",regExp:o}]:y.push({type:"disable",regExp:o})})};var v=["debug","log","info","warn","error"];v.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!s(this)){var n=Array.prototype.slice.call(arguments,0).join(" ");d()?(n=a(n),e=t(n,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):f()&&(n=x(n),e=i(n,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var E=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();f()?module.exports=e:d()&&(window.Logdown=e)}(); |
/** | ||
* logdown - Debug utility with markdown support that runs on browser and server | ||
* | ||
* @version v1.3.1 | ||
* @version v1.4.0 | ||
* @link https://github.com/caiogondim/logdown | ||
@@ -9,2 +9,2 @@ * @author Caio Gondim <me@caiogondim.com> (http://caiogondim.com) | ||
*/ | ||
!function(){"use strict";function e(r){if(!(this instanceof e))return new e(r);r=r||{};var o=void 0===r.prefix?"":r.prefix;return o=p(o),o&&c(o,x)?l(o,x):(this.markdown=void 0===r.markdown||r.markdown,this.prefix=o,x.push(this),f()?(this.prefixColor=m[g%m.length],g+=1):u()&&(this.prefixColor=v()),this)}function r(e){for(var r=[],n=o(e);n;)e=e.replace(n.rule.regexp,n.rule.replacer),f()&&(r.push(n.rule.style),r.push("color:inherit;")),n=o(e);return{text:e,styles:r}}function o(e){var r=[],o=[];return f()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:u()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function n(e,o){var n,t,i,s;return"string"==typeof e?o.markdown&&a()?(n=r(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),o.prefix&&(a()?(t="%c"+o.prefix+"%c "+t,i.unshift("color:"+o.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+o.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function t(e,o){var n,t="";return o.prefix&&(t=a()?"["+o.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+o.prefix+"["+b.modifiers.bold[1]+"m["+o.prefixColor[1]+"m ":"["+o.prefix+"] "),"string"==typeof e?t+=o.markdown?r(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function i(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===h.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return h.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function s(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function l(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function p(e){return"string"==typeof e?e.replace(/%c/g,""):e}function a(){if(f()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(u())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function f(){return"undefined"!=typeof window}function d(e){return e}var x=[],g=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},h=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=s(r);"*"===r?h=[]:h.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=s(r);"*"===r?h=[{type:"disable",regExp:o}]:h.push({type:"disable",regExp:o})})};var y=["debug","log","info","warn","error"];y.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!i(this)){var s=Array.prototype.slice.call(arguments,0).join(" ");f()?(s=p(s),e=n(s,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):u()&&(s=d(s),e=t(s,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var v=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();u()?module.exports=e:f()&&(window.Logdown=e)}(); | ||
!function(){"use strict";function e(o){if(!(this instanceof e))return new e(o);o=o||{};var n=void 0===o.prefix?"":o.prefix;return n=a(n),n&&c(n,g)?p(n,g):(this.alignOuput=Boolean(o.alignOuput),this.markdown=void 0===o.markdown||o.markdown,this.prefix=n,g.push(this),r(g),d()?(this.prefixColor=m[h%m.length],h+=1):f()&&(this.prefixColor=E()),this)}function r(e){var r=e.sort(function(e,r){return r.prefix.length-e.prefix.length})[0];e.forEach(function(e){if(e.alignOuput){var o=new Array(Math.max(r.prefix.length-e.prefix.length+1,0)).join(" ");e.prefix=e.prefix+o}})}function o(e){for(var r=[],o=n(e);o;)e=e.replace(o.rule.regexp,o.rule.replacer),d()&&(r.push(o.rule.style),r.push("color:inherit;")),o=n(e);return{text:e,styles:r}}function n(e){var r=[],o=[];return d()?o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-weight:bold;"},{regexp:/_([^_]+)_/,replacer:function(e,r){return"%c"+r+"%c"},style:"font-style:italic;"},{regexp:/`([^`]+)`/,replacer:function(e,r){return"%c"+r+"%c"},style:"background:#FDF6E3; color:#586E75; padding:1px 5px; border-radius:4px;"}]:f()&&(o=[{regexp:/\*([^\*]+)\*/,replacer:function(e,r){return"["+b.modifiers.bold[0]+"m"+r+"["+b.modifiers.bold[1]+"m"}},{regexp:/_([^_]+)_/,replacer:function(e,r){return"["+b.modifiers.italic[0]+"m"+r+"["+b.modifiers.italic[1]+"m"}},{regexp:/`([^`]+)`/,replacer:function(e,r){return"["+b.bgColors.bgYellow[0]+"m["+b.colors.black[0]+"m "+r+" ["+b.colors.black[1]+"m["+b.bgColors.bgYellow[1]+"m"}}]),o.forEach(function(o){var n=e.match(o.regexp);n&&r.push({rule:o,match:n})}),0===r.length?null:(r.sort(function(e,r){return e.match.index-r.match.index}),r[0])}function t(e,r){var n,t,i,s;return"string"==typeof e?r.markdown&&u()?(n=o(e),t=n.text,i=n.styles):(t=e,i=[]):(t=t||"",i=i||[],s=e),r.prefix&&(u()?(t="%c"+r.prefix+"%c "+t,i.unshift("color:"+r.prefixColor+"; font-weight:bold;","color:inherit;")):t="["+r.prefix+"] "+t),{parsedText:t,styles:i,notText:s}}function i(e,r){var n,t="";return r.prefix&&(t=u()?"["+r.prefixColor[0]+"m["+b.modifiers.bold[0]+"m"+r.prefix+"["+b.modifiers.bold[1]+"m["+r.prefixColor[1]+"m ":"["+r.prefix+"] "),"string"==typeof e?t+=r.markdown?o(e).text:e:n=e,{parsedText:t,styles:[],notText:n}}function s(r){var o=null;"undefined"!=typeof process&&void 0!==process.env&&0===y.length&&(void 0!==process.env.NODE_DEBUG&&""!==process.env.NODE_DEBUG?o="NODE_DEBUG":void 0!==process.env.DEBUG&&""!==process.env.DEBUG&&(o="DEBUG"),o&&(e.disable("*"),process.env[o].split(",").forEach(function(r){e.enable(r)})));var n=!1;return y.forEach(function(e){"enable"===e.type&&e.regExp.test(r.prefix)?n=!1:"disable"===e.type&&e.regExp.test(r.prefix)&&(n=!0)}),n}function l(e){return new RegExp("^"+e.replace(/\*/g,".*?")+"$")}function c(e,r){var o=!1;return r.forEach(function(r){if(r.prefix===e)return void(o=!0)}),o}function p(e,r){var o;return r.forEach(function(r){if(r.prefix===e)return void(o=r)}),o}function a(e){return"string"==typeof e?e.replace(/%c/g,""):e}function u(){if(d()){var e="WebkitAppearance"in document.documentElement.style,r=window.console&&(console.firebug||console.exception&&console.table),o=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31;return e||r||o}if(f())return!(process.stdout&&!process.stdout.isTTY)&&("win32"===process.platform||("COLORTERM"in process.env||"dumb"!==process.env.TERM&&!!/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)))}function f(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function d(){return"undefined"!=typeof window}function x(e){return e}var g=[],h=0,m=["#B58900","#CB4B16","#DC322F","#D33682","#6C71C4","#268BD2","#2AA198","#859900"],b={modifiers:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},colors:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39]},bgColors:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49]}},y=[];e.enable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.disable(r.substr(1));var o=l(r);"*"===r?y=[]:y.push({type:"enable",regExp:o})})},e.disable=function(){Array.prototype.forEach.call(arguments,function(r){"-"===r[0]&&e.enable(r.substr(1));var o=l(r);"*"===r?y=[{type:"disable",regExp:o}]:y.push({type:"disable",regExp:o})})};var v=["debug","log","info","warn","error"];v.forEach(function(r){e.prototype[r]=function(){var e,o=[];if(!s(this)){var n=Array.prototype.slice.call(arguments,0).join(" ");d()?(n=a(n),e=t(n,this),Function.prototype.apply.call(console[r]||console.log,console,[e.parsedText].concat(e.styles,"undefined"!=typeof e.notText?[e.notText]:""))):f()&&(n=x(n),e=i(n,this),"warn"===r?e.parsedText="["+b.colors.yellow[0]+"m⚠["+b.colors.yellow[1]+"m "+e.parsedText:"error"===r?e.parsedText="["+b.colors.red[0]+"m✖["+b.colors.red[1]+"m "+e.parsedText:"info"===r?e.parsedText="["+b.colors.blue[0]+"mℹ["+b.colors.blue[1]+"m "+e.parsedText:"debug"===r&&(e.parsedText="["+b.colors.gray[0]+"m🐛["+b.colors.gray[1]+"m "+e.parsedText),o.push(e.parsedText),e.notText&&o.push(e.notText),(console[r]||console.log).apply(console,o))}}});var E=function(){var e=0,r=[[31,39],[32,39],[33,39],[34,39],[35,39],[36,39]];return function(){return r[(e+=1)%r.length]}}();f()?module.exports=e:d()&&(window.Logdown=e)}(); |
{ | ||
"name": "logdown", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Debug utility with markdown support that runs on browser and server", | ||
@@ -55,3 +55,2 @@ "main": "dist/index.js", | ||
"karma-mocha": "^1.0.0", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-sinon": "^1.0.5", | ||
@@ -61,3 +60,4 @@ "mocha": "^2.5.3", | ||
"standard": "^8.0.0" | ||
} | ||
}, | ||
"dependencies": {} | ||
} |
@@ -71,2 +71,3 @@ /* global console, module, window, document, navigator, process */ | ||
// | ||
this.alignOuput = Boolean(opts.alignOuput) | ||
this.markdown = opts.markdown === undefined ? true : opts.markdown | ||
@@ -77,2 +78,3 @@ this.prefix = prefix | ||
instances.push(this) | ||
alignPrefixes(instances) | ||
@@ -214,2 +216,15 @@ if (isBrowser()) { | ||
function alignPrefixes (instances) { | ||
var longest = instances.sort(function (a, b) { | ||
return b.prefix.length - a.prefix.length | ||
})[0] | ||
instances.forEach(function (instance) { | ||
if (instance.alignOuput) { | ||
var padding = new Array(Math.max(longest.prefix.length - instance.prefix.length + 1, 0)).join(' ') | ||
instance.prefix = instance.prefix + padding | ||
} | ||
}) | ||
} | ||
function parseMarkdown (text) { | ||
@@ -216,0 +231,0 @@ var styles = [] |
@@ -149,2 +149,20 @@ /* global describe, afterEach, beforeEach, console, it, require, window, | ||
it('can add whitespace to align logger output', function () { | ||
try { | ||
var abc = new Logdown({prefix: 'abc'}) | ||
var demo = new Logdown({prefix: 'demo', alignOuput: true}) | ||
var longDemo = new Logdown({prefix: 'longDemo', alignOuput: true}) | ||
var longerDemo = new Logdown({prefix: 'longerDemo', alignOuput: true}) | ||
assert.equal(abc.prefix.length, 3, 'Skipping \'alignOuput\' will not add whitespace characters') | ||
assert.equal(demo.prefix.length, 10, 'Padding will be added to make short names as long as the longest') | ||
assert.equal(longDemo.prefix.length, 10, 'Padding will be added to make long names as long as the longest') | ||
assert.equal(longerDemo.prefix.length, 10, 'The longest name will set the width for every other logger name') | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
// https://github.com/caiogondim/logdown/issues/14 | ||
@@ -151,0 +169,0 @@ xit('should print not-string arguments as is', function () { |
@@ -53,3 +53,3 @@ /* global module */ | ||
// launcher | ||
browsers: ['Chrome', 'Firefox', 'Safari'], | ||
browsers: ['Chrome', 'Firefox'], | ||
@@ -56,0 +56,0 @@ // Continuous Integration mode |
@@ -258,2 +258,20 @@ /* global describe, it, beforeEach, afterEach, xit */ | ||
it('can add whitespace to align logger output', function () { | ||
try { | ||
var abc = new Logdown({prefix: 'abc'}) | ||
var demo = new Logdown({prefix: 'demo', alignOuput: true}) | ||
var longDemo = new Logdown({prefix: 'longDemo', alignOuput: true}) | ||
var longerDemo = new Logdown({prefix: 'longerDemo', alignOuput: true}) | ||
assert.equal(abc.prefix.length, 3, 'Skipping \'alignOuput\' will not add whitespace characters') | ||
assert.equal(demo.prefix.length, 10, 'Padding will be added to make short names as long as the longest') | ||
assert.equal(longDemo.prefix.length, 10, 'Padding will be added to make long names as long as the longest') | ||
assert.equal(longerDemo.prefix.length, 10, 'The longest name will set the width for every other logger name') | ||
} catch (error) { | ||
sandbox.restore() | ||
throw error | ||
} | ||
sandbox.restore() | ||
}) | ||
// https://github.com/caiogondim/logdown/issues/14 | ||
@@ -260,0 +278,0 @@ xit('should print not-string arguments as is', function () { |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
129788
18
35
2419
1