diff options
author | Jason Smith (work) <jhs@iriscouch.com> | 2013-02-11 02:01:59 +0000 |
---|---|---|
committer | Jason Smith (work) <jhs@iriscouch.com> | 2013-02-11 02:02:07 +0000 |
commit | 7d16962dcc7851e23510cee3a76494c1e0b358fb (patch) | |
tree | fb50f3cdb05a0aa7fe540a46b6260f1d8d409ddf | |
parent | 946fe33f900e4785fac5679c5c41539bf12b7c43 (diff) | |
download | couchdb-7d16962dcc7851e23510cee3a76494c1e0b358fb.tar.gz |
Remove and fix code to be CouchDB-appropriate
-rw-r--r-- | share/server/console.js | 2 | ||||
-rw-r--r-- | share/server/nodejs_util.js | 75 |
2 files changed, 1 insertions, 76 deletions
diff --git a/share/server/console.js b/share/server/console.js index 8516cdaad..011a3d4d6 100644 --- a/share/server/console.js +++ b/share/server/console.js @@ -81,7 +81,7 @@ exports.trace = function(label) { exports.assert = function(expression) { if (!expression) { var arr = Array.prototype.slice.call(arguments, 1); - require('assert').ok(false, util.format.apply(this, arr)); + throw new Error(util.format.apply(this, arr)); } }; diff --git a/share/server/nodejs_util.js b/share/server/nodejs_util.js index c19512f1c..536f99254 100644 --- a/share/server/nodejs_util.js +++ b/share/server/nodejs_util.js @@ -62,31 +62,6 @@ 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) { - if (process.noDeprecation === true) { - return fn; - } - - var warned = false; - function deprecated() { - if (!warned) { - if (process.traceDeprecation) { - console.trace(msg); - } else { - console.error(msg); - } - warned = true; - } - return fn.apply(this, arguments); - } - - return deprecated; -}; - - exports.print = function() { for (var i = 0, len = arguments.length; i < len; ++i) { process.stdout.write(String(arguments[i])); @@ -455,13 +430,6 @@ function objectToString(o) { } -exports.p = exports.deprecate(function() { - for (var i = 0, len = arguments.length; i < len; ++i) { - error(exports.inspect(arguments[i])); - } -}, 'util.p: Use console.error() instead.'); - - function pad(n) { return n < 10 ? '0' + n.toString(10) : n.toString(10); } @@ -485,49 +453,6 @@ exports.log = function(msg) { }; -exports.exec = exports.deprecate(function() { - return require('child_process').exec.apply(this, arguments); -}, 'util.exec is now called `child_process.exec`.'); - - -exports.pump = function(readStream, writeStream, callback) { - var callbackCalled = false; - - function call(a, b, c) { - if (callback && !callbackCalled) { - callback(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); - }); -}; - - /** * Inherit the prototype methods from one constructor into another. * |