Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

depd

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

depd - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

9

History.md

@@ -0,1 +1,10 @@

0.4.0 / 2014-07-19
==================
* Add `TRACE_DEPRECATION` environment variable
* Remove non-standard grey color from color output
* Support `--no-deprecation` argument
* Support `--trace-deprecation` argument
* Support `deprecate.property(fn, prop, message)`
0.3.0 / 2014-06-16

@@ -2,0 +11,0 @@ ==================

80

index.js

@@ -35,2 +35,23 @@ /*!

/**
* Determine if namespace is contained in the string.
*/
function containsNamespace(str, namespace) {
var val = str.split(/[ ,]+/)
namespace = String(namespace).toLowerCase()
for (var i = 0 ; i < val.length; i++) {
if (!(str = val[i])) continue;
// namespace contained
if (str === '*' || str.toLowerCase() === namespace) {
return true
}
}
return false
}
/**
* Convert a data descriptor to accessor descriptor.

@@ -110,2 +131,3 @@ */

deprecate._namespace = namespace
deprecate._traced = istraced(namespace)
deprecate._warned = Object.create(null)

@@ -124,17 +146,29 @@

function isignored(namespace) {
/* istanbul ignore next: tested in a child processs */
if (process.noDeprecation) {
// --no-deprecation support
return true
}
var str = process.env.NO_DEPRECATION || ''
var val = str.split(/[ ,]+/)
namespace = String(namespace).toLowerCase()
// namespace ignored
return containsNamespace(str, namespace)
}
for (var i = 0 ; i < val.length; i++) {
if (!(str = val[i])) continue;
/**
* Determine if namespace is traced.
*/
// namespace ignored
if (str === '*' || str.toLowerCase() === namespace) {
return true
}
function istraced(namespace) {
/* istanbul ignore next: tested in a child processs */
if (process.traceDeprecation) {
// --trace-deprecation support
return true
}
return false
var str = process.env.TRACE_DEPRECATION || ''
// namespace traced
return containsNamespace(str, namespace)
}

@@ -213,3 +247,3 @@

: formatPlain
var msg = format.call(this, message, caller)
var msg = format.call(this, message, caller, stack.slice(i))
process.stderr.write(msg + '\n', 'utf8')

@@ -263,3 +297,3 @@

function formatPlain(msg, caller) {
function formatPlain(msg, caller, stack) {
var timestamp = new Date().toUTCString()

@@ -271,2 +305,11 @@

// add stack trace
if (this._traced) {
for (var i = 0; i < stack.length; i++) {
formatted += '\n at ' + stack[i].toString()
}
return formatted
}
if (caller) {

@@ -283,7 +326,16 @@ formatted += ' at ' + formatLocation(caller)

function formatColor(msg, caller) {
function formatColor(msg, caller, stack) {
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' // bold cyan
+ ' \x1b[33;1mdeprecated\x1b[22;39m' // bold yellow
+ ' \x1b[90m' + msg + '\x1b[39m' // grey
+ ' \x1b[0m' + msg + '\x1b[39m' // reset
// add stack trace
if (this._traced) {
for (var i = 0; i < stack.length; i++) {
formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan
}
return formatted
}
if (caller) {

@@ -361,3 +413,3 @@ formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan

function wrapproperty(obj, prop, message) {
if (!obj || typeof obj !== 'object') {
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
throw new TypeError('argument obj must be object')

@@ -364,0 +416,0 @@ }

4

package.json
{
"name": "depd",
"description": "Deprecate all the things",
"version": "0.3.0",
"version": "0.4.0",
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",

@@ -13,3 +13,3 @@ "license": "MIT",

"devDependencies": {
"istanbul": "0.2.10",
"istanbul": "0.3.0",
"mocha": "~1.20.1",

@@ -16,0 +16,0 @@ "should": "~4.0.4"

@@ -20,4 +20,3 @@ # depd

```js
var depd = require('depd')
var deprecate = depd('my-module')
var deprecate = require('depd')('my-module')
```

@@ -118,5 +117,28 @@

Providing the argument `--no-deprecation` to the `node` executable will suppress
all deprecations.
**NOTE** This will not suppress the deperecations given to any "deprecation"
event listeners, just the output to STDERR.
### process.env.TRACE_DEPRECATION
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
is provided as a solution to getting more detailed location information in deprecation
warnings by including the entire stack trace. The format of this is the same as
`NO_DEPRECATION`:
```sh
$ TRACE_DEPRECATION=my-module,othermod node app.js
```
This will include stack traces for deprecations being output for "my-module" and
"othermod". The value is a list of comma-separated namespaces. To trace every
warning across all namespaces, use the value `*` for a namespace.
Providing the argument `--trace-deprecation` to the `node` executable will trace
all deprecations.
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
## Display

@@ -132,3 +154,3 @@

bright cyan bright yellow
| | grey cyan
| | reset cyan
| | | |

@@ -135,0 +157,0 @@ ▼ ▼ ▼ ▼

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc