Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 876ff26

Browse files
committedJun 4, 2015
lib: Deprecating with internal/util's deprecate
Since internal/util's deprecate prepends `(node)` to the messages, all the deprecations in the code base has to use it only.
1 parent 660fc96 commit 876ff26

13 files changed

+53
-36
lines changed
 

‎lib/_http_outgoing.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const assert = require('assert').ok;
44
const Stream = require('stream');
55
const timers = require('timers');
66
const util = require('util');
7+
const internalUtil = require('internal/util');
78
const common = require('_http_common');
89

910
const CRLF = common.CRLF;
@@ -643,6 +644,6 @@ OutgoingMessage.prototype.flushHeaders = function() {
643644
this._send('');
644645
};
645646

646-
OutgoingMessage.prototype.flush = util.deprecate(function() {
647+
OutgoingMessage.prototype.flush = internalUtil.deprecate(function() {
647648
this.flushHeaders();
648-
}, 'flush is deprecated. Use flushHeaders instead.');
649+
}, 'OutgoingMessage.flush is deprecated. Use flushHeaders instead.');

‎lib/_stream_writable.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = Writable;
88
Writable.WritableState = WritableState;
99

1010
const util = require('util');
11+
const internalUtil = require('internal/util');
1112
const Stream = require('stream');
1213

1314
util.inherits(Writable, Stream);
@@ -119,10 +120,10 @@ WritableState.prototype.getBuffer = function writableStateGetBuffer() {
119120
};
120121

121122
Object.defineProperty(WritableState.prototype, 'buffer', {
122-
get: util.deprecate(function() {
123+
get: internalUtil.deprecate(function() {
123124
return this.getBuffer();
124-
}, '_writableState.buffer is deprecated. Use ' +
125-
'_writableState.getBuffer() instead.')
125+
}, '_writableState.buffer is deprecated. Use _writableState.getBuffer() ' +
126+
'instead.')
126127
});
127128

128129
function Writable(options) {

‎lib/buffer.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -456,28 +456,28 @@ Buffer.prototype.fill = function fill(val, start, end) {
456456

457457

458458
// XXX remove in v0.13
459-
Buffer.prototype.get = util.deprecate(function get(offset) {
459+
Buffer.prototype.get = internalUtil.deprecate(function get(offset) {
460460
offset = ~~offset;
461461
if (offset < 0 || offset >= this.length)
462462
throw new RangeError('index out of range');
463463
return this[offset];
464-
}, '.get() is deprecated. Access using array indexes instead.');
464+
}, 'Buffer.get() is deprecated. Access using array indexes instead.');
465465

466466

467467
// XXX remove in v0.13
468-
Buffer.prototype.set = util.deprecate(function set(offset, v) {
468+
Buffer.prototype.set = internalUtil.deprecate(function set(offset, v) {
469469
offset = ~~offset;
470470
if (offset < 0 || offset >= this.length)
471471
throw new RangeError('index out of range');
472472
return this[offset] = v;
473-
}, '.set() is deprecated. Set using array indexes instead.');
473+
}, 'Buffer.set() is deprecated. Set using array indexes instead.');
474474

475475

476476
// TODO(trevnorris): fix these checks to follow new standard
477477
// write(string, offset = 0, length = buffer.length, encoding = 'utf8')
478478
var writeWarned = false;
479-
const writeMsg = '.write(string, encoding, offset, length) is deprecated.' +
480-
' Use write(string[, offset[, length]][, encoding]) instead.';
479+
const writeMsg = 'Buffer.write(string, encoding, offset, length) is deprecated.'
480+
+ ' Use write(string[, offset[, length]][, encoding]) instead.';
481481
Buffer.prototype.write = function(string, offset, length, encoding) {
482482
// Buffer#write(string);
483483
if (offset === undefined) {
@@ -505,7 +505,7 @@ Buffer.prototype.write = function(string, offset, length, encoding) {
505505

506506
// XXX legacy write(string, encoding, offset, length) - remove in v0.13
507507
} else {
508-
writeWarned = internalUtil.printDeprecationMessage(writeMsg, writeWarned);
508+
writeWarned = internalUtil.deprecate(writeMsg, writeWarned);
509509
var swap = encoding;
510510
encoding = offset;
511511
offset = length >>> 0;

‎lib/child_process.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const util = require('util');
4+
const internalUtil = require('internal/util');
45
const debug = util.debuglog('child_process');
56
const constants = require('constants');
67

@@ -268,11 +269,11 @@ exports.execFile = function(file /* args, options, callback */) {
268269
return child;
269270
};
270271

271-
var _deprecatedCustomFds = util.deprecate(function(options) {
272+
var _deprecatedCustomFds = internalUtil.deprecate(function(options) {
272273
options.stdio = options.customFds.map(function(fd) {
273274
return fd === -1 ? 'pipe' : fd;
274275
});
275-
}, 'child_process: customFds option is deprecated, use stdio instead.');
276+
}, 'child_process.customFds option is deprecated, use stdio instead.');
276277

277278
function _convertCustomFds(options) {
278279
if (options && options.customFds && !options.stdio) {

‎lib/crypto.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ try {
1717
const constants = require('constants');
1818
const stream = require('stream');
1919
const util = require('util');
20+
const internalUtil = require('internal/util');
2021

2122
const DH_GENERATOR = 2;
2223

@@ -679,10 +680,13 @@ function filterDuplicates(names) {
679680
}
680681

681682
// Legacy API
682-
exports.__defineGetter__('createCredentials', util.deprecate(function() {
683-
return require('tls').createSecureContext;
684-
}, 'createCredentials() is deprecated, use tls.createSecureContext instead'));
683+
exports.__defineGetter__('createCredentials',
684+
internalUtil.deprecate(function() {
685+
return require('tls').createSecureContext;
686+
}, 'crypto.createCredentials() is deprecated, ' +
687+
'use tls.createSecureContext instead'));
685688

686-
exports.__defineGetter__('Credentials', util.deprecate(function() {
689+
exports.__defineGetter__('Credentials', internalUtil.deprecate(function() {
687690
return require('tls').SecureContext;
688-
}, 'Credentials is deprecated, use tls.createSecureContext instead'));
691+
}, 'crypto.Credentials is deprecated, ' +
692+
'use tls.createSecureContext instead'));

‎lib/http.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const util = require('util');
4+
const internalUtil = require('internal/util');
45
const EventEmitter = require('events').EventEmitter;
56

67

@@ -91,9 +92,9 @@ Client.prototype.request = function(method, path, headers) {
9192
return c;
9293
};
9394

94-
exports.Client = util.deprecate(Client,
95+
exports.Client = internalUtil.deprecate(Client,
9596
'http.Client will be removed soon. Do not use it.');
9697

97-
exports.createClient = util.deprecate(function(port, host) {
98+
exports.createClient = internalUtil.deprecate(function(port, host) {
9899
return new Client(port, host);
99100
}, 'http.createClient is deprecated. Use `http.request` instead.');

‎lib/module.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const NativeModule = require('native_module');
44
const util = require('util');
5+
const internalUtil = require('internal/util');
56
const runInThisContext = require('vm').runInThisContext;
67
const assert = require('assert').ok;
78
const fs = require('fs');
@@ -121,7 +122,7 @@ function tryExtensions(p, exts) {
121122
}
122123

123124

124-
const noopDeprecateRequireDot = util.deprecate(function() {},
125+
const noopDeprecateRequireDot = internalUtil.deprecate(function() {},
125126
'warning: require(\'.\') resolved outside the package directory. ' +
126127
'This functionality is deprecated and will be removed soon.');
127128

‎lib/net.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const events = require('events');
44
const stream = require('stream');
55
const timers = require('timers');
66
const util = require('util');
7+
const internalUtil = require('internal/util');
78
const assert = require('assert');
89
const cares = process.binding('cares_wrap');
910
const uv = process.binding('uv');
@@ -1075,16 +1076,17 @@ function Server(options, connectionListener) {
10751076
this._connections = 0;
10761077

10771078
Object.defineProperty(this, 'connections', {
1078-
get: util.deprecate(function() {
1079+
get: internalUtil.deprecate(function() {
10791080

10801081
if (self._usingSlaves) {
10811082
return null;
10821083
}
10831084
return self._connections;
1084-
}, 'connections property is deprecated. Use getConnections() method'),
1085-
set: util.deprecate(function(val) {
1085+
}, 'Server.connections property is deprecated. ' +
1086+
'Use Server.getConnections() method'),
1087+
set: internalUtil.deprecate(function(val) {
10861088
return (self._connections = val);
1087-
}, 'connections property is deprecated. Use getConnections() method'),
1089+
}, 'Server.connections property is deprecated.'),
10881090
configurable: true, enumerable: false
10891091
});
10901092

@@ -1496,9 +1498,9 @@ function emitCloseNT(self) {
14961498
}
14971499

14981500

1499-
Server.prototype.listenFD = util.deprecate(function(fd, type) {
1501+
Server.prototype.listenFD = internalUtil.deprecate(function(fd, type) {
15001502
return this.listen({ fd: fd });
1501-
}, 'listenFD is deprecated. Use listen({fd: <number>}).');
1503+
}, 'Server.listenFD is deprecated. Use Server.listen({fd: <number>}).');
15021504

15031505
Server.prototype._setupSlave = function(socketList) {
15041506
this._usingSlaves = true;

‎lib/os.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const binding = process.binding('os');
44
const util = require('util');
5+
const internalUtil = require('internal/util');
56
const isWindows = process.platform === 'win32';
67

78
exports.hostname = binding.getHostname;
@@ -44,9 +45,10 @@ exports.tmpdir = function() {
4445

4546
exports.tmpDir = exports.tmpdir;
4647

47-
exports.getNetworkInterfaces = util.deprecate(function() {
48+
exports.getNetworkInterfaces = internalUtil.deprecate(function() {
4849
return exports.networkInterfaces();
49-
}, 'getNetworkInterfaces is now called `os.networkInterfaces`.');
50+
}, 'os.getNetworkInterfaces is deprecated. ' +
51+
'Use `os.networkInterfaces` instead.');
5052

5153
exports.EOL = isWindows ? '\r\n' : '\n';
5254

‎lib/readline.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
const kHistorySize = 30;
1010

1111
const util = require('util');
12+
const internalUtil = require('internal/util');
1213
const inherits = util.inherits;
1314
const EventEmitter = require('events').EventEmitter;
1415

@@ -1417,8 +1418,9 @@ function codePointAt(str, index) {
14171418
}
14181419
return code;
14191420
}
1420-
exports.codePointAt = util.deprecate(codePointAt,
1421-
'codePointAt() is deprecated. Use String.prototype.codePointAt');
1421+
exports.codePointAt = internalUtil.deprecate(codePointAt,
1422+
'readline.codePointAt is deprecated. ' +
1423+
'Use String.prototype.codePointAt instead');
14221424

14231425

14241426
/**

‎lib/smalloc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
const util = require('internal/util');
44

55
module.exports = require('internal/smalloc');
6-
util.printDeprecationMessage('smalloc is deprecated.');
6+
util.deprecate('smalloc is deprecated. Use typed arrays.');

‎lib/sys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ const util = require('internal/util');
77
// sys is deprecated and shouldn't be used
88

99
module.exports = require('util');
10-
util.printDeprecationMessage('sys is deprecated. Use util instead.');
10+
util.deprecate('sys is deprecated. Use util instead.');

‎lib/tty.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const util = require('util');
4+
const internalUtil = require('internal/util');
45
const net = require('net');
56
const TTY = process.binding('tty_wrap').TTY;
67
const isTTY = process.binding('tty_wrap').isTTY;
@@ -14,12 +15,13 @@ exports.isatty = function(fd) {
1415

1516

1617
// backwards-compat
17-
exports.setRawMode = util.deprecate(function(flag) {
18+
exports.setRawMode = internalUtil.deprecate(function(flag) {
1819
if (!process.stdin.isTTY) {
1920
throw new Error('can\'t set raw mode on non-tty');
2021
}
2122
process.stdin.setRawMode(flag);
22-
}, 'tty.setRawMode: Use `process.stdin.setRawMode()` instead.');
23+
}, 'tty.setRawMode is deprecated. ' +
24+
'Use `process.stdin.setRawMode()` instead.');
2325

2426

2527
function ReadStream(fd, options) {

0 commit comments

Comments
 (0)
Please sign in to comment.