Comparing version 0.2.0 to 0.3.0
@@ -0,1 +1,6 @@ | ||
0.3.0 / 2014-06-16 | ||
================== | ||
* Add `NO_DEPRECATION` environment variable | ||
0.2.0 / 2014-06-15 | ||
@@ -2,0 +7,0 @@ ================== |
32
index.js
@@ -107,2 +107,3 @@ /*! | ||
deprecate._file = file | ||
deprecate._ignored = isignored(namespace) | ||
deprecate._namespace = namespace | ||
@@ -118,2 +119,24 @@ deprecate._warned = Object.create(null) | ||
/** | ||
* Determine if namespace is ignored. | ||
*/ | ||
function isignored(namespace) { | ||
var str = process.env.NO_DEPRECATION || '' | ||
var val = str.split(/[ ,]+/) | ||
namespace = String(namespace).toLowerCase() | ||
for (var i = 0 ; i < val.length; i++) { | ||
if (!(str = val[i])) continue; | ||
// namespace ignored | ||
if (str === '*' || str.toLowerCase() === namespace) { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
/** | ||
* Display deprecation message. | ||
@@ -123,2 +146,9 @@ */ | ||
function log(message, site) { | ||
var haslisteners = eventListenerCount(process, 'deprecation') !== 0 | ||
// abort early if no destination | ||
if (!haslisteners && this._ignored) { | ||
return | ||
} | ||
var caller | ||
@@ -173,3 +203,3 @@ var callSite | ||
// emit deprecation if listeners exist | ||
if (eventListenerCount(process, 'deprecation') !== 0) { | ||
if (haslisteners) { | ||
var err = DeprecationError(this._namespace, message, stack.slice(i)) | ||
@@ -176,0 +206,0 @@ process.emit('deprecation', err) |
{ | ||
"name": "depd", | ||
"description": "Deprecate all the things", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -103,4 +103,23 @@ # depd | ||
### process.env.NO_DEPRECATION | ||
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION` | ||
is provided as a quick solution to silencing deprecation warnings from being | ||
output. The format of this is similar to that of `DEBUG`: | ||
```sh | ||
$ NO_DEPRECATION=my-module,othermod node app.js | ||
``` | ||
This will suppress deprecations from being output for "my-module" and "othermod". | ||
The value is a list of comma-separated namespaces. To suppress every warning | ||
across all namespaces, use the value `*` for a namespace. | ||
**NOTE** This will not suppress the deperecations given to any "deprecation" | ||
event listeners, just the output to STDERR. | ||
## Display | ||
![message](files/message.png) | ||
When a user calls a function in your library that you mark deprecated, they | ||
@@ -107,0 +126,0 @@ will see the following written to STDERR (in the given colors, similar colors |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
20262
345
250
2