Comparing version 4.0.1 to 4.1.0
{ | ||
"name": "debug", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"repository": { | ||
@@ -26,2 +26,15 @@ "type": "git", | ||
"license": "MIT", | ||
"scripts": { | ||
"lint": "xo", | ||
"test": "npm run test:node && npm run test:browser", | ||
"test:node": "istanbul cover _mocha -- test.js", | ||
"posttest:node": "cat ./coverage/lcov.info | coveralls", | ||
"pretest:browser": "npm run build", | ||
"test:browser": "karma start --single-run", | ||
"prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .", | ||
"build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js", | ||
"build:test": "babel -d dist test.js", | ||
"build": "npm run build:debug && npm run build:test", | ||
"clean": "rimraf dist coverage" | ||
}, | ||
"dependencies": { | ||
@@ -28,0 +41,0 @@ "ms": "^2.1.1" |
@@ -320,2 +320,20 @@ # debug | ||
`disable()` | ||
Will disable all namespaces. The functions returns the namespaces currently | ||
enabled (and skipped). This can be useful if you want to disable debugging | ||
temporarily without knowing what was enabled to begin with. | ||
For example: | ||
```js | ||
let debug = require('debug'); | ||
debug.enable('foo:*,-foo:bar'); | ||
let namespaces = debug.disable(); | ||
debug.enable(namespaces); | ||
``` | ||
Note: There is no guarantee that the string will be identical to the initial | ||
enable string, but semantically they will be identical. | ||
## Checking whether a debug target is enabled | ||
@@ -322,0 +340,0 @@ |
@@ -190,6 +190,12 @@ | ||
* | ||
* @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; | ||
} | ||
@@ -228,2 +234,15 @@ | ||
/** | ||
* 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`. | ||
@@ -230,0 +249,0 @@ * |
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
80172
1424
456