Comparing version 0.2.0 to 0.3.0
39
bows.js
(function() { | ||
function checkColorSupport() { | ||
var chrome = !!window.chrome, | ||
firefox = /firefox/i.test(navigator.userAgent), | ||
firebug = firefox && !!window.console.exception; | ||
return chrome || firebug; | ||
} | ||
var inNode = typeof window === 'undefined', | ||
@@ -6,6 +14,6 @@ ls = !inNode && window.localStorage, | ||
logger = require('andlog'), | ||
goldenRatio = 0.618033988749895, | ||
hue = 0, | ||
padLength = 15, | ||
noop = function() {}, | ||
colorsSupported = ls.debugColors || checkColorSupport(), | ||
yieldColor, | ||
@@ -16,2 +24,3 @@ bows, | ||
yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
@@ -22,12 +31,28 @@ hue = hue % 1; | ||
var debugRegex = debug && debug[0]==='/' && new RegExp(debug.substring(1,debug.length-1)); | ||
debugRegex = debug && debug[0]==='/' && new RegExp(debug.substring(1,debug.length-1)); | ||
bows = function(str) { | ||
var msg; | ||
msg = "%c" + (str.slice(0, padLength)); | ||
var msg, colorString, logfn; | ||
msg = (str.slice(0, padLength)); | ||
msg += Array(padLength + 3 - msg.length).join(' ') + '|'; | ||
if (debugRegex && !str.match(debugRegex)) return noop; | ||
if (!window.chrome) return logger.log.bind(logger, msg); | ||
return logger.log.bind(logger, msg, "color: hsl(" + (yieldColor()) + ",99%,40%); font-weight: bold"); | ||
if (colorsSupported) { | ||
var color = yieldColor(); | ||
msg = "%c" + msg; | ||
colorString = "color: hsl(" + (color) + ",99%,40%); font-weight: bold"; | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
}); | ||
} else { | ||
logfn = logger.log.bind(logger, msg); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
}); | ||
} | ||
return logfn; | ||
}; | ||
@@ -37,3 +62,3 @@ | ||
if (config.padLength) { | ||
return padLength = config.padLength; | ||
this.padLength = config.padLength; | ||
} | ||
@@ -40,0 +65,0 @@ }; |
@@ -1,12 +0,26 @@ | ||
(function(e){if("function"==typeof bootstrap)bootstrap("bows",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeBows=e}else"undefined"!=typeof window?window.bows=e():global.bows=e()})(function(){var define,ses,bootstrap,module,exports; | ||
return (function(e,t,n){function i(n,s){if(!t[n]){if(!e[n]){var o=typeof require=="function"&&require;if(!s&&o)return o(n,!0);if(r)return r(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var r=e[n][1][t];return i(r?r:t)},u,u.exports)}return t[n].exports}var r=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i})({1:[function(require,module,exports){ | ||
(function(window) { | ||
var logger = require('andlog'), | ||
goldenRatio = 0.618033988749895, | ||
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.bows=e():"undefined"!=typeof global?global.bows=e():"undefined"!=typeof self&&(self.bows=e())}(function(){var define,module,exports; | ||
return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
(function() { | ||
function checkColorSupport() { | ||
var chrome = !!window.chrome, | ||
firefox = /firefox/i.test(navigator.userAgent), | ||
firebug = firefox && !!window.console.exception; | ||
return chrome || firebug; | ||
} | ||
var inNode = typeof window === 'undefined', | ||
ls = !inNode && window.localStorage, | ||
debug = ls.debug, | ||
logger = require('andlog'), | ||
hue = 0, | ||
padLength = 15, | ||
noop = function() {}, | ||
colorsSupported = ls.debugColors || checkColorSupport(), | ||
yieldColor, | ||
bows; | ||
bows, | ||
debugRegex; | ||
yieldColor = function() { | ||
var goldenRatio = 0.618033988749895; | ||
hue += goldenRatio; | ||
@@ -17,8 +31,28 @@ hue = hue % 1; | ||
debugRegex = debug && debug[0]==='/' && new RegExp(debug.substring(1,debug.length-1)); | ||
bows = function(str) { | ||
var msg; | ||
msg = "%c" + (str.slice(0, padLength)); | ||
var msg, colorString, logfn; | ||
msg = (str.slice(0, padLength)); | ||
msg += Array(padLength + 3 - msg.length).join(' ') + '|'; | ||
return logger.log.bind(logger, msg, "color: hsl(" + (yieldColor()) + ",99%,40%); font-weight: bold"); | ||
if (debugRegex && !str.match(debugRegex)) return noop; | ||
if (colorsSupported) { | ||
var color = yieldColor(); | ||
msg = "%c" + msg; | ||
colorString = "color: hsl(" + (color) + ",99%,40%); font-weight: bold"; | ||
logfn = logger.log.bind(logger, msg, colorString); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg, colorString); | ||
}); | ||
} else { | ||
logfn = logger.log.bind(logger, msg); | ||
['log', 'debug', 'warn', 'error', 'info'].forEach(function (f) { | ||
logfn[f] = logger[f].bind(logger, msg); | ||
}); | ||
} | ||
return logfn; | ||
}; | ||
@@ -28,3 +62,3 @@ | ||
if (config.padLength) { | ||
return padLength = config.padLength; | ||
this.padLength = config.padLength; | ||
} | ||
@@ -38,3 +72,3 @@ }; | ||
} | ||
}).call(this); | ||
}).call(); | ||
@@ -71,4 +105,5 @@ },{"andlog":2}],2:[function(require,module,exports){ | ||
},{}]},{},[1])(1) | ||
},{}]},{},[1]) | ||
(1) | ||
}); | ||
; |
@@ -1,1 +0,1 @@ | ||
!function(e){if("function"==typeof bootstrap)bootstrap("bows",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeBows=e}else"undefined"!=typeof window?window.bows=e():global.bows=e()}(function(){return function(e,o,n){function r(n,i){if(!o[n]){if(!e[n]){var f="function"==typeof require&&require;if(!i&&f)return f(n,!0);if(t)return t(n,!0);throw new Error("Cannot find module '"+n+"'")}var u=o[n]={exports:{}};e[n][0].call(u.exports,function(o){var t=e[n][1][o];return r(t?t:o)},u,u.exports)}return o[n].exports}for(var t="function"==typeof require&&require,i=0;i<n.length;i++)r(n[i]);return r}({1:[function(e,o){!function(n){var r,t,i=e("andlog"),f=.618033988749895,u=0,d=15;r=function(){return u+=f,u%=1,360*u},t=function(e){var o;return o="%c"+e.slice(0,d),o+=Array(d+3-o.length).join(" ")+"|",i.log.bind(i,o,"color: hsl("+r()+",99%,40%); font-weight: bold")},t.config=function(e){return e.padLength?d=e.padLength:void 0},"undefined"!=typeof o?o.exports=t:n.bows=t}.call(this)},{andlog:2}],2:[function(e,o,n){!function(){var e="undefined"==typeof window,r=!e&&window.localStorage,t={};if(e)return o.exports=console,void 0;if(r&&r.debug&&window.console)t=window.console;else for(var i="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),f=i.length,u=function(){};f--;)t[i[f]]=u;"undefined"!=typeof n?o.exports=t:window.console=t}()},{}]},{},[1])(1)}); | ||
!function(n){"object"==typeof exports?module.exports=n():"function"==typeof define&&define.amd?define(n):"undefined"!=typeof window?window.bows=n():"undefined"!=typeof global?global.bows=n():"undefined"!=typeof self&&(self.bows=n())}(function(){return function n(o,e,r){function i(f,d){if(!e[f]){if(!o[f]){var u="function"==typeof require&&require;if(!d&&u)return u(f,!0);if(t)return t(f,!0);throw new Error("Cannot find module '"+f+"'")}var l=e[f]={exports:{}};o[f][0].call(l.exports,function(n){var e=o[f][1][n];return i(e?e:n)},l,l.exports,n,o,e,r)}return e[f].exports}for(var t="function"==typeof require&&require,f=0;f<r.length;f++)i(r[f]);return i}({1:[function(n,o){!function(){function e(){var n=!!window.chrome,o=/firefox/i.test(navigator.userAgent),e=o&&!!window.console.exception;return n||e}var r,i,t,f="undefined"==typeof window,d=!f&&window.localStorage,u=d.debug,l=n("andlog"),c=0,a=15,w=function(){},s=d.debugColors||e();r=function(){var n=.618033988749895;return c+=n,c%=1,360*c},t=u&&"/"===u[0]&&new RegExp(u.substring(1,u.length-1)),i=function(n){var o,e,i;if(o=n.slice(0,a),o+=Array(a+3-o.length).join(" ")+"|",t&&!n.match(t))return w;if(s){var f=r();o="%c"+o,e="color: hsl("+f+",99%,40%); font-weight: bold",i=l.log.bind(l,o,e),["log","debug","warn","error","info"].forEach(function(n){i[n]=l[n].bind(l,o,e)})}else i=l.log.bind(l,o),["log","debug","warn","error","info"].forEach(function(n){i[n]=l[n].bind(l,o)});return i},i.config=function(n){n.padLength&&(this.padLength=n.padLength)},"undefined"!=typeof o?o.exports=i:window.bows=i}.call()},{andlog:2}],2:[function(n,o,e){!function(){var n="undefined"==typeof window,r=!n&&window.localStorage,i={};if(n)return o.exports=console,void 0;if(r&&r.debug&&window.console)i=window.console;else for(var t="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),f=t.length,d=function(){};f--;)i[t[f]]=d;"undefined"!=typeof e?o.exports=i:window.console=i}()},{}]},{},[1])(1)}); |
{ | ||
"name": "bows", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Rainbowed console logs for chrome in development", | ||
@@ -5,0 +5,0 @@ "main": "bows.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73276
12
157