mirror of
https://github.com/debug-js/debug.git
synced 2026-01-18 16:12:38 +00:00
Merge pull request #15 from TooTallNate/enabled
debug: add an `enabled` flag to the returned debug function
This commit is contained in:
commit
e7b895446c
@ -105,17 +105,20 @@ function humanize(ms) {
|
||||
*/
|
||||
|
||||
function debug(name) {
|
||||
function disabled(){}
|
||||
disabled.enabled = false;
|
||||
|
||||
var match = skips.some(function(re){
|
||||
return re.test(name);
|
||||
});
|
||||
|
||||
if (match) return function(){};
|
||||
if (match) return disabled;
|
||||
|
||||
match = names.some(function(re){
|
||||
return re.test(name);
|
||||
});
|
||||
|
||||
if (!match) return function(){};
|
||||
if (!match) return disabled;
|
||||
var c = color();
|
||||
|
||||
function colored(fmt) {
|
||||
@ -137,6 +140,8 @@ function debug(name) {
|
||||
console.error.apply(this, arguments);
|
||||
}
|
||||
|
||||
colored.enabled = plain.enabled = true;
|
||||
|
||||
return isatty
|
||||
? colored
|
||||
: plain;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user