diff options
author | Brandon Benvie <brandon@bbenvie.com> | 2012-01-28 23:13:42 -0500 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-30 00:27:07 +0100 |
commit | 5403a8ce4cce83a13569b09ee5b2ba3d1ad8c176 (patch) | |
tree | fec6c0c58f9e75ebf4b161d8cfc1fb7626f00192 /lib/util.js | |
parent | e3c0c86b280854e4ad8db9bd5f6c645ffe9e9966 (diff) | |
download | node-new-5403a8ce4cce83a13569b09ee5b2ba3d1ad8c176.tar.gz |
core: add `NativeModule.prototype.deprecate`
Formalize and cleanup handling of deprecated core methods.
Diffstat (limited to 'lib/util.js')
-rw-r--r-- | lib/util.js | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/util.js b/lib/util.js index d3b13066f8..5750159e82 100644 --- a/lib/util.js +++ b/lib/util.js @@ -407,18 +407,12 @@ function objectToString(o) { } -var pWarning; - exports.p = function() { - if (!pWarning) { - pWarning = 'util.p will be removed in future versions of Node. ' + - 'Use util.puts(util.inspect()) instead.\n'; - exports.error(pWarning); - } for (var i = 0, len = arguments.length; i < len; ++i) { error(exports.inspect(arguments[i])); } }; +module.deprecate('p', 'Use `util.puts(util.inspect())` instead.'); function pad(n) { @@ -444,15 +438,10 @@ exports.log = function(msg) { }; -var execWarning; exports.exec = function() { - if (!execWarning) { - execWarning = 'util.exec has moved to the "child_process" module.' + - ' Please update your source code.'; - error(execWarning); - } return require('child_process').exec.apply(this, arguments); }; +module.deprecate('exec', 'It is now called `child_process.exec`.'); exports.pump = function(readStream, writeStream, callback) { @@ -517,19 +506,3 @@ exports.inherits = function(ctor, superCtor) { } }); }; - -var deprecationWarnings; - -exports._deprecationWarning = function(moduleId, message) { - if (!deprecationWarnings) - deprecationWarnings = {}; - else if (message in deprecationWarnings) - return; - - deprecationWarnings[message] = true; - - if ((new RegExp('\\b' + moduleId + '\\b')).test(process.env.NODE_DEBUG)) - console.trace(message); - else - console.error(message); -}; |