Skip to content

Commit

Permalink
feat: Return namespaces string when invoking disable()
Browse files Browse the repository at this point in the history
  • Loading branch information
mblarsen committed Oct 4, 2018
1 parent 4490cd9 commit b828357
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,16 @@ function setup(env) {
/**
* Disable debug output.
*
* @return {String} namespaces
* @api public
*/
function disable() {
const namespaces = [
...createDebug.names.map(toNamespace),
...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
].join(',');
createDebug.enable('');
return namespaces;
}

/**
Expand Down Expand Up @@ -223,6 +229,19 @@ function setup(env) {
return false;
}

/**
* Convert regexp to namespace
*
* @param {RegExp} regxep
* @return {String} namespace
* @api private
*/
function toNamespace(regexp) {
return regexp.toString()
.substring(2, regexp.toString().length - 2)
.replace(/\.\*\?$/, '*');
}

/**
* Coerce `val`.
*
Expand Down

0 comments on commit b828357

Please sign in to comment.