Browse Source

util: cleanup internalUtil.deprecate

There were two functions `deprecate` and `_deprecate`
that were really just aliases of each other. Simplify

PR-URL: https://github.com/nodejs/node/pull/11450
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
v7.x
James M Snell 8 years ago
committed by Italo A. Casas
parent
commit
237db9c497
No known key found for this signature in database GPG Key ID: 23EFEFE93C4CFFFE
  1. 10
      lib/internal/util.js
  2. 2
      lib/util.js

10
lib/internal/util.js

@ -10,12 +10,6 @@ const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol'];
// `util` module makes it accessible without having to `require('util')` there. // `util` module makes it accessible without having to `require('util')` there.
exports.customInspectSymbol = Symbol('util.inspect.custom'); exports.customInspectSymbol = Symbol('util.inspect.custom');
// All the internal deprecations have to use this function only, as this will
// prepend the prefix to the actual message.
exports.deprecate = function(fn, msg) {
return exports._deprecate(fn, msg);
};
exports.trace = function(msg) { exports.trace = function(msg) {
console.trace(`${prefix}${msg}`); console.trace(`${prefix}${msg}`);
}; };
@ -23,11 +17,11 @@ exports.trace = function(msg) {
// Mark that a method should not be used. // Mark that a method should not be used.
// Returns a modified function which warns once by default. // Returns a modified function which warns once by default.
// If --no-deprecation is set, then it is a no-op. // If --no-deprecation is set, then it is a no-op.
exports._deprecate = function(fn, msg) { exports.deprecate = function deprecate(fn, msg, code) {
// Allow for deprecating things in the process of starting up. // Allow for deprecating things in the process of starting up.
if (global.process === undefined) { if (global.process === undefined) {
return function() { return function() {
return exports._deprecate(fn, msg).apply(this, arguments); return exports.deprecate(fn, msg, code).apply(this, arguments);
}; };
} }

2
lib/util.js

@ -131,7 +131,7 @@ exports.format = function(f) {
}; };
exports.deprecate = internalUtil._deprecate; exports.deprecate = internalUtil.deprecate;
var debugs = {}; var debugs = {};

Loading…
Cancel
Save