From 007cfea30829ec10a9ba690dd8f28d7afe1462a7 Mon Sep 17 00:00:00 2001 From: Wyatt Preul Date: Mon, 24 Aug 2015 16:53:46 -0500 Subject: [PATCH] util: remove pump Remove util.pump and associated tests PR-URL: https://github.com/nodejs/node/pull/2531 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/util.markdown | 6 --- lib/repl.js | 2 +- lib/util.js | 38 --------------- test/sequential/test-pump-file2tcp-noexist.js | 47 ------------------- test/sequential/test-pump-file2tcp.js | 38 --------------- 5 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 test/sequential/test-pump-file2tcp-noexist.js delete mode 100644 test/sequential/test-pump-file2tcp.js diff --git a/doc/api/util.markdown b/doc/api/util.markdown index b1ab10a81e094f..eb1090dfc1e4f9 100644 --- a/doc/api/util.markdown +++ b/doc/api/util.markdown @@ -493,12 +493,6 @@ Output with timestamp on `stdout`. Deprecated predecessor of `console.log`. -## util.pump(readableStream, writableStream[, callback]) - - Stability: 0 - Deprecated: Use readableStream.pipe(writableStream) - -Deprecated predecessor of `stream.pipe()`. - ## util.puts([...]) Stability: 0 - Deprecated: Use console.log() instead. diff --git a/lib/repl.js b/lib/repl.js index 87014b5d5d2a90..4485b4016b1363 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -611,7 +611,7 @@ function filteredOwnPropertyNames(obj) { // // Example: // complete('var foo = util.') -// -> [['util.print', 'util.debug', 'util.log', 'util.inspect', 'util.pump'], +// -> [['util.print', 'util.debug', 'util.log', 'util.inspect'], // 'util.' ] // // Warning: This eval's code like "foo.bar.baz", so it will run property diff --git a/lib/util.js b/lib/util.js index eeeb42a9489821..0666300d68e809 100644 --- a/lib/util.js +++ b/lib/util.js @@ -864,44 +864,6 @@ exports.error = internalUtil.deprecate(function(x) { }, '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) { var errname = uv.errname(err); var message = syscall + ' ' + errname; diff --git a/test/sequential/test-pump-file2tcp-noexist.js b/test/sequential/test-pump-file2tcp-noexist.js deleted file mode 100644 index 66d1e1119ff6e2..00000000000000 --- a/test/sequential/test-pump-file2tcp-noexist.js +++ /dev/null @@ -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); -}); diff --git a/test/sequential/test-pump-file2tcp.js b/test/sequential/test-pump-file2tcp.js deleted file mode 100644 index f5949085e0aec3..00000000000000 --- a/test/sequential/test-pump-file2tcp.js +++ /dev/null @@ -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); -});