Skip to content

Commit 1d79f57

Browse files
util: move deprecate() to internal module
PR-URL: #1988 Reviewed-By: Roman Reiss <[email protected]>
1 parent 671e64a commit 1d79f57

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

lib/internal/util.js

+24
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,27 @@ exports.printDeprecationMessage = function(msg, warned) {
1616

1717
return true;
1818
};
19+
20+
// Mark that a method should not be used.
21+
// Returns a modified function which warns once by default.
22+
// If --no-deprecation is set, then it is a no-op.
23+
exports.deprecate = function(fn, msg) {
24+
// Allow for deprecating things in the process of starting up.
25+
if (global.process === undefined) {
26+
return function() {
27+
return exports.deprecate(fn, msg).apply(this, arguments);
28+
};
29+
}
30+
31+
if (process.noDeprecation === true) {
32+
return fn;
33+
}
34+
35+
var warned = false;
36+
function deprecated() {
37+
warned = exports.printDeprecationMessage(msg, warned);
38+
return fn.apply(this, arguments);
39+
}
40+
41+
return deprecated;
42+
};

lib/util.js

+1-23
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,7 @@ exports.format = function(f) {
4848
};
4949

5050

51-
// Mark that a method should not be used.
52-
// Returns a modified function which warns once by default.
53-
// If --no-deprecation is set, then it is a no-op.
54-
exports.deprecate = function(fn, msg) {
55-
// Allow for deprecating things in the process of starting up.
56-
if (global.process === undefined) {
57-
return function() {
58-
return exports.deprecate(fn, msg).apply(this, arguments);
59-
};
60-
}
61-
62-
if (process.noDeprecation === true) {
63-
return fn;
64-
}
65-
66-
var warned = false;
67-
function deprecated() {
68-
warned = internalUtil.printDeprecationMessage(msg, warned);
69-
return fn.apply(this, arguments);
70-
}
71-
72-
return deprecated;
73-
};
51+
exports.deprecate = internalUtil.deprecate;
7452

7553

7654
var debugs = {};

0 commit comments

Comments
 (0)