diff --git a/src/common.js b/src/common.js index dab9e480..0b6d0b64 100644 --- a/src/common.js +++ b/src/common.js @@ -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; } /** @@ -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`. *