Skip to content

Commit

Permalink
util: move deprecate() to internal module
Browse files Browse the repository at this point in the history
PR-URL: #1988
Reviewed-By: Roman Reiss <[email protected]>
  • Loading branch information
brendanashworth committed Jun 16, 2015
1 parent 671e64a commit 1d79f57
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
24 changes: 24 additions & 0 deletions lib/internal/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
24 changes: 1 addition & 23 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 1d79f57

Please sign in to comment.