mirror of
https://github.com/debug-js/debug.git
synced 2026-01-18 16:12:38 +00:00
refactor
This commit is contained in:
parent
bb0b7bb026
commit
db73b661fd
20
lib/debug.js
20
lib/debug.js
@ -138,19 +138,21 @@ function coerce(val) {
|
||||
/**
|
||||
* Enable specified `namespaces` for debugging.
|
||||
*/
|
||||
|
||||
debug.enable = function(namespaces) {
|
||||
namespaces.split(/[\s,]+/)
|
||||
.forEach(function(name){
|
||||
name = name.replace('*', '.*?');
|
||||
if (name[0] === '-') {
|
||||
skips.push(new RegExp('^' + name.substr(1) + '$'));
|
||||
} else {
|
||||
names.push(new RegExp('^' + name + '$'));
|
||||
}
|
||||
})
|
||||
.forEach(function(name){
|
||||
name = name.replace('*', '.*?');
|
||||
if (name[0] == '-') {
|
||||
skips.push(new RegExp('^' + name.substr(1) + '$'));
|
||||
} else {
|
||||
names.push(new RegExp('^' + name + '$'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `process.env.DEBUG` initially.
|
||||
*/
|
||||
debug.enable(process.env.DEBUG || '');
|
||||
|
||||
debug.enable(process.env.DEBUG || '');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user