util: remove pump
Remove util.pump and associated tests PR-URL: https://github.com/nodejs/node/pull/2531 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
a2c0aa84e0
commit
007cfea308
@ -493,12 +493,6 @@ Output with timestamp on `stdout`.
|
|||||||
|
|
||||||
Deprecated predecessor of `console.log`.
|
Deprecated predecessor of `console.log`.
|
||||||
|
|
||||||
## util.pump(readableStream, writableStream[, callback])
|
|
||||||
|
|
||||||
Stability: 0 - Deprecated: Use readableStream.pipe(writableStream)
|
|
||||||
|
|
||||||
Deprecated predecessor of `stream.pipe()`.
|
|
||||||
|
|
||||||
## util.puts([...])
|
## util.puts([...])
|
||||||
|
|
||||||
Stability: 0 - Deprecated: Use console.log() instead.
|
Stability: 0 - Deprecated: Use console.log() instead.
|
||||||
|
@ -611,7 +611,7 @@ function filteredOwnPropertyNames(obj) {
|
|||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
// complete('var foo = util.')
|
// complete('var foo = util.')
|
||||||
// -> [['util.print', 'util.debug', 'util.log', 'util.inspect', 'util.pump'],
|
// -> [['util.print', 'util.debug', 'util.log', 'util.inspect'],
|
||||||
// 'util.' ]
|
// 'util.' ]
|
||||||
//
|
//
|
||||||
// Warning: This eval's code like "foo.bar.baz", so it will run property
|
// Warning: This eval's code like "foo.bar.baz", so it will run property
|
||||||
|
38
lib/util.js
38
lib/util.js
@ -864,44 +864,6 @@ exports.error = internalUtil.deprecate(function(x) {
|
|||||||
}, 'util.error is deprecated. Use console.error instead.');
|
}, 'util.error is deprecated. Use console.error instead.');
|
||||||
|
|
||||||
|
|
||||||
exports.pump = internalUtil.deprecate(function(readStream, writeStream, cb) {
|
|
||||||
var callbackCalled = false;
|
|
||||||
|
|
||||||
function call(a, b, c) {
|
|
||||||
if (cb && !callbackCalled) {
|
|
||||||
cb(a, b, c);
|
|
||||||
callbackCalled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
readStream.addListener('data', function(chunk) {
|
|
||||||
if (writeStream.write(chunk) === false) readStream.pause();
|
|
||||||
});
|
|
||||||
|
|
||||||
writeStream.addListener('drain', function() {
|
|
||||||
readStream.resume();
|
|
||||||
});
|
|
||||||
|
|
||||||
readStream.addListener('end', function() {
|
|
||||||
writeStream.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
readStream.addListener('close', function() {
|
|
||||||
call();
|
|
||||||
});
|
|
||||||
|
|
||||||
readStream.addListener('error', function(err) {
|
|
||||||
writeStream.end();
|
|
||||||
call(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
writeStream.addListener('error', function(err) {
|
|
||||||
readStream.destroy();
|
|
||||||
call(err);
|
|
||||||
});
|
|
||||||
}, 'util.pump is deprecated. Use readableStream.pipe instead.');
|
|
||||||
|
|
||||||
|
|
||||||
exports._errnoException = function(err, syscall, original) {
|
exports._errnoException = function(err, syscall, original) {
|
||||||
var errname = uv.errname(err);
|
var errname = uv.errname(err);
|
||||||
var message = syscall + ' ' + errname;
|
var message = syscall + ' ' + errname;
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
var common = require('../common');
|
|
||||||
var assert = require('assert');
|
|
||||||
var net = require('net');
|
|
||||||
var fs = require('fs');
|
|
||||||
var util = require('util');
|
|
||||||
var path = require('path');
|
|
||||||
var fn = path.join(common.fixturesDir, 'does_not_exist.txt');
|
|
||||||
|
|
||||||
var got_error = false;
|
|
||||||
var conn_closed = false;
|
|
||||||
|
|
||||||
var server = net.createServer(function(stream) {
|
|
||||||
util.pump(fs.createReadStream(fn), stream, function(err) {
|
|
||||||
if (err) {
|
|
||||||
got_error = true;
|
|
||||||
} else {
|
|
||||||
// util.pump's callback fired with no error
|
|
||||||
// this shouldn't happen as the file doesn't exist...
|
|
||||||
assert.equal(true, false);
|
|
||||||
}
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
|
||||||
var conn = net.createConnection(common.PORT);
|
|
||||||
conn.setEncoding('utf8');
|
|
||||||
conn.on('data', function(chunk) {
|
|
||||||
buffer += chunk;
|
|
||||||
});
|
|
||||||
|
|
||||||
conn.on('end', function() {
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
|
|
||||||
conn.on('close', function() {
|
|
||||||
conn_closed = true;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var buffer = '';
|
|
||||||
|
|
||||||
process.on('exit', function() {
|
|
||||||
assert.equal(true, got_error);
|
|
||||||
assert.equal(true, conn_closed);
|
|
||||||
});
|
|
@ -1,38 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
var common = require('../common');
|
|
||||||
var assert = require('assert');
|
|
||||||
var net = require('net');
|
|
||||||
var fs = require('fs');
|
|
||||||
var util = require('util');
|
|
||||||
var path = require('path');
|
|
||||||
var fn = path.join(common.fixturesDir, 'elipses.txt');
|
|
||||||
|
|
||||||
var expected = fs.readFileSync(fn, 'utf8');
|
|
||||||
|
|
||||||
var server = net.createServer(function(stream) {
|
|
||||||
util.pump(fs.createReadStream(fn), stream, function() {
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
server.listen(common.PORT, function() {
|
|
||||||
var conn = net.createConnection(common.PORT);
|
|
||||||
conn.setEncoding('utf8');
|
|
||||||
conn.on('data', function(chunk) {
|
|
||||||
buffer += chunk;
|
|
||||||
});
|
|
||||||
|
|
||||||
conn.on('end', function() {
|
|
||||||
conn.end();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
var buffer = '';
|
|
||||||
var count = 0;
|
|
||||||
|
|
||||||
server.on('listening', function() {
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on('exit', function() {
|
|
||||||
assert.equal(expected, buffer);
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user