diff --git a/lib/internal/util.js b/lib/internal/util.js index 76576331adb..8019260e0c7 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -16,3 +16,27 @@ exports.printDeprecationMessage = function(msg, warned) { return true; }; + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + // Allow for deprecating things in the process of starting up. + if (global.process === undefined) { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + if (process.noDeprecation === true) { + return fn; + } + + var warned = false; + function deprecated() { + warned = exports.printDeprecationMessage(msg, warned); + return fn.apply(this, arguments); + } + + return deprecated; +}; diff --git a/lib/util.js b/lib/util.js index 177cf454eec..afddf439cf8 100644 --- a/lib/util.js +++ b/lib/util.js @@ -48,29 +48,7 @@ exports.format = function(f) { }; -// Mark that a method should not be used. -// Returns a modified function which warns once by default. -// If --no-deprecation is set, then it is a no-op. -exports.deprecate = function(fn, msg) { - // Allow for deprecating things in the process of starting up. - if (global.process === undefined) { - return function() { - return exports.deprecate(fn, msg).apply(this, arguments); - }; - } - - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - warned = internalUtil.printDeprecationMessage(msg, warned); - return fn.apply(this, arguments); - } - - return deprecated; -}; +exports.deprecate = internalUtil.deprecate; var debugs = {};