Comparing version 1.1.2 to 2.0.0
@@ -0,1 +1,8 @@ | ||
2.0.0 / 2018-10-26 | ||
================== | ||
* Drop support for Node.js 0.6 | ||
* Replace internal `eval` usage with `Function` constructor | ||
* Use instance methods on `process` to check for listeners | ||
1.1.2 / 2018-01-11 | ||
@@ -2,0 +9,0 @@ ================== |
42
index.js
/*! | ||
* depd | ||
* Copyright(c) 2014-2017 Douglas Christopher Wilson | ||
* Copyright(c) 2014-2018 Douglas Christopher Wilson | ||
* MIT Licensed | ||
@@ -11,4 +11,2 @@ */ | ||
var callSiteToString = require('./lib/compat').callSiteToString | ||
var eventListenerCount = require('./lib/compat').eventListenerCount | ||
var relative = require('path').relative | ||
@@ -96,3 +94,3 @@ | ||
for (var i = 0; i < stack.length; i++) { | ||
str += '\n at ' + callSiteToString(stack[i]) | ||
str += '\n at ' + stack[i].toString() | ||
} | ||
@@ -134,2 +132,22 @@ | ||
/** | ||
* Determine if event emitter has listeners of a given type. | ||
* | ||
* The way to do this check is done three different ways in Node.js >= 0.8 | ||
* so this consolidates them into a minimal set using instance methods. | ||
* | ||
* @param {EventEmitter} emitter | ||
* @param {string} type | ||
* @returns {boolean} | ||
* @private | ||
*/ | ||
function eehaslisteners (emitter, type) { | ||
var count = typeof emitter.listenerCount !== 'function' | ||
? emitter.listeners(type).length | ||
: emitter.listenerCount(type) | ||
return count > 0 | ||
} | ||
/** | ||
* Determine if namespace is ignored. | ||
@@ -139,3 +157,2 @@ */ | ||
function isignored (namespace) { | ||
/* istanbul ignore next: tested in a child processs */ | ||
if (process.noDeprecation) { | ||
@@ -157,3 +174,2 @@ // --no-deprecation support | ||
function istraced (namespace) { | ||
/* istanbul ignore next: tested in a child processs */ | ||
if (process.traceDeprecation) { | ||
@@ -175,3 +191,3 @@ // --trace-deprecation support | ||
function log (message, site) { | ||
var haslisteners = eventListenerCount(process, 'deprecation') !== 0 | ||
var haslisteners = eehaslisteners(process, 'deprecation') | ||
@@ -319,3 +335,3 @@ // abort early if no destination | ||
for (var i = 0; i < stack.length; i++) { | ||
formatted += '\n at ' + callSiteToString(stack[i]) | ||
formatted += '\n at ' + stack[i].toString() | ||
} | ||
@@ -345,3 +361,3 @@ | ||
for (var i = 0; i < stack.length; i++) { | ||
formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan | ||
formatted += '\n \x1b[36mat ' + stack[i].toString() + '\x1b[39m' // cyan | ||
} | ||
@@ -411,3 +427,2 @@ | ||
var args = createArgumentsString(fn.length) | ||
var deprecate = this // eslint-disable-line no-unused-vars | ||
var stack = getStack() | ||
@@ -418,8 +433,9 @@ var site = callSiteLocation(stack[1]) | ||
// eslint-disable-next-line no-eval | ||
var deprecatedfn = eval('(function (' + args + ') {\n' + | ||
// eslint-disable-next-line no-new-func | ||
var deprecatedfn = new Function('fn', 'log', 'deprecate', 'message', 'site', | ||
'"use strict"\n' + | ||
'return function (' + args + ') {' + | ||
'log.call(deprecate, message, site)\n' + | ||
'return fn.apply(this, arguments)\n' + | ||
'})') | ||
'}')(fn, log, this, message, site) | ||
@@ -426,0 +442,0 @@ return deprecatedfn |
{ | ||
"name": "depd", | ||
"description": "Deprecate all the things", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>", | ||
@@ -16,9 +16,13 @@ "license": "MIT", | ||
"beautify-benchmark": "0.2.4", | ||
"eslint": "3.19.0", | ||
"eslint-config-standard": "7.1.0", | ||
"eslint": "5.7.0", | ||
"eslint-config-standard": "12.0.0", | ||
"eslint-plugin-import": "2.14.0", | ||
"eslint-plugin-markdown": "1.0.0-beta.7", | ||
"eslint-plugin-promise": "3.6.0", | ||
"eslint-plugin-standard": "3.0.1", | ||
"eslint-plugin-node": "7.0.1", | ||
"eslint-plugin-promise": "4.0.1", | ||
"eslint-plugin-standard": "4.0.0", | ||
"istanbul": "0.4.5", | ||
"mocha": "~1.21.5" | ||
"mocha": "5.2.0", | ||
"safe-buffer": "5.1.2", | ||
"uid-safe": "2.1.5" | ||
}, | ||
@@ -33,3 +37,3 @@ "files": [ | ||
"engines": { | ||
"node": ">= 0.6" | ||
"node": ">= 0.8" | ||
}, | ||
@@ -40,5 +44,5 @@ "scripts": { | ||
"test": "mocha --reporter spec --bail test/", | ||
"test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --no-exit test/", | ||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/" | ||
"test-ci": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter spec test/ && istanbul report lcovonly text-summary", | ||
"test-cov": "istanbul cover --print=none node_modules/mocha/bin/_mocha -- --reporter dot test/ && istanbul report lcov text-summary" | ||
} | ||
} |
@@ -270,12 +270,12 @@ # depd | ||
[npm-version-image]: https://img.shields.io/npm/v/depd.svg | ||
[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg | ||
[npm-url]: https://npmjs.org/package/depd | ||
[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd/master.svg?label=linux | ||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd | ||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/nodejs-depd/master.svg?label=windows | ||
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/nodejs-depd/master?label=windows | ||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/nodejs-depd | ||
[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd/master.svg | ||
[coveralls-image]: https://badgen.net/coveralls/c/github/dougwilson/nodejs-depd/master | ||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master | ||
[node-image]: https://img.shields.io/node/v/depd.svg | ||
[node-image]: https://badgen.net/npm/node/depd | ||
[node-url]: https://nodejs.org/en/download/ | ||
[npm-downloads-image]: https://badgen.net/npm/dm/depd | ||
[npm-url]: https://npmjs.org/package/depd | ||
[npm-version-image]: https://badgen.net/npm/v/depd | ||
[travis-image]: https://badgen.net/travis/dougwilson/nodejs-depd/master?label=linux | ||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
27117
13
6
476