Browse Source

Soft migration of sys -> util, Removal of deprecated utils module.

v0.7.4-release
Micheil Smith 14 years ago
committed by Ryan Dahl
parent
commit
e38eb0c5a4
  1. 4
      benchmark/io.js
  2. 4
      benchmark/process_loop.js
  3. 4
      benchmark/run.js
  4. 66
      doc/api.markdown
  5. 4
      lib/assert.js
  6. 4
      lib/child_process.js
  7. 1
      lib/crypto.js
  8. 4
      lib/dgram.js
  9. 12
      lib/fs.js
  10. 22
      lib/http.js
  11. 10
      lib/net.js
  12. 4
      lib/readline.js
  13. 14
      lib/repl.js
  14. 4
      lib/stream.js
  15. 402
      lib/sys.js
  16. 390
      lib/util.js
  17. 1
      lib/utils.js
  18. 2
      src/node.cc
  19. 8
      src/node.js
  20. 4
      test/common.js
  21. 3
      test/disabled/test-dns.js
  22. 2
      test/disabled/test-fs-sendfile.js
  23. 2
      test/disabled/test-http-big-proxy-responses.js
  24. 2
      test/disabled/test-http-head-request.js
  25. 4
      test/disabled/test-remote-module-loading.js
  26. 2
      test/disabled/tls_client.js
  27. 2
      test/disabled/tls_server.js
  28. 3
      test/fixtures/child_process_should_emit_error.js
  29. 1
      test/fixtures/print-10-lines.js
  30. 1
      test/fixtures/recvfd.js
  31. 2
      test/fixtures/stdio-filter.js
  32. 2
      test/message/2100bytes.js
  33. 2
      test/pummel/test-http-client-reconnect-bug.js
  34. 1
      test/simple/test-child-process-custom-fds.js
  35. 3
      test/simple/test-child-process-exec-env.js
  36. 1
      test/simple/test-crypto.js
  37. 6
      test/simple/test-dgram-multicast.js
  38. 2
      test/simple/test-http-expect-continue.js
  39. 2
      test/simple/test-http-head-request.js
  40. 2
      test/simple/test-http-keep-alive-close-on-header.js
  41. 2
      test/simple/test-http-keep-alive.js
  42. 1
      test/simple/test-http-tls.js
  43. 4
      test/simple/test-http-upgrade-server.js
  44. 1
      test/simple/test-net-tls.js
  45. 2
      test/simple/test-next-tick-ordering.js
  46. 8
      test/simple/test-pump-file2tcp-noexist.js
  47. 4
      test/simple/test-pump-file2tcp.js
  48. 2
      test/simple/test-regression-object-prototype.js
  49. 3
      test/simple/test-repl.js
  50. 1
      test/simple/test-sendfd.js
  51. 2
      test/simple/test-signal-unregister.js
  52. 2
      test/simple/test-url.js
  53. 17
      tools/ronnjs/bin/ronn.js
  54. 18
      tools/ronnjs/lib/ext/opts.js
  55. 8
      tools/ronnjs/lib/ronn.js

4
benchmark/io.js

@ -1,5 +1,5 @@
var fs = require('fs');
var sys = require('sys');
var util = require('util');
var Buffer = require('buffer').Buffer;
var path = "/tmp/wt.dat";
@ -43,7 +43,7 @@ function writetest(size, bsize) {
s.on('drain', function () {
dowrite();
if (c++ % 2000 == 0) sys.print(".");
if (c++ % 2000 == 0) util.print(".");
});
dowrite();

4
benchmark/process_loop.js

@ -1,4 +1,4 @@
var sys = require("sys"),
var util = require("util"),
childProcess = require("child_process");
function next (i) {
@ -7,7 +7,7 @@ function next (i) {
var child = childProcess.spawn("echo", ["hello"]);
child.stdout.addListener("data", function (chunk) {
sys.print(chunk);
util.print(chunk);
});
child.addListener("exit", function (code) {

4
benchmark/run.js

@ -1,5 +1,5 @@
var path = require("path");
var sys = require("sys");
var util = require("util");
var childProcess = require("child_process");
var benchmarks = [ "timers.js"
, "process_loop.js"
@ -19,7 +19,7 @@ function exec (script, callback) {
function runNext (i) {
if (i >= benchmarks.length) return;
sys.print(benchmarks[i] + ": ");
util.print(benchmarks[i] + ": ");
exec(benchmarks[i], function (elapsed, code) {
if (code != 0) {
console.log("ERROR ");

66
doc/api.markdown

@ -34,7 +34,7 @@ variable with the same name as the module.
Example:
var sys = require('sys');
var util = require('util');
It is possible to extend node with other modules. See `'Modules'`
@ -271,7 +271,7 @@ manipulated, e.g. to remove listeners.
server.on('stream', function (stream) {
console.log('someone connected!');
});
console.log(sys.inspect(server.listeners('stream'));
console.log(util.inspect(server.listeners('stream'));
// [ [Function] ]
@ -766,9 +766,9 @@ What platform you're running on. `'linux2'`, `'darwin'`, etc.
Returns an object describing the memory usage of the Node process.
var sys = require('sys');
var util = require('util');
console.log(sys.inspect(process.memoryUsage()));
console.log(util.inspect(process.memoryUsage()));
This will generate:
@ -806,35 +806,35 @@ given, otherwise returns the current mask.
## sys
## util
These functions are in the module `'sys'`. Use `require('sys')` to access
These functions are in the module `'util'`. Use `require('util')` to access
them.
### sys.print(string)
### util.print(string)
Like `console.log()` but without the trailing newline.
require('sys').print('String with no newline');
require('util').print('String with no newline');
### sys.debug(string)
### util.debug(string)
A synchronous output function. Will block the process and
output `string` immediately to `stderr`.
require('sys').debug('message on stderr');
require('util').debug('message on stderr');
### sys.log(string)
### util.log(string)
Output with timestamp on `stdout`.
require('sys').log('Timestmaped message.');
require('util').log('Timestmaped message.');
### sys.inspect(object, showHidden=false, depth=2)
### util.inspect(object, showHidden=false, depth=2)
Return a string representation of `object`, which is useful for debugging.
@ -847,14 +847,14 @@ formatting the object. This is useful for inspecting large complicated objects.
The default is to only recurse twice. To make it recurse indefinitely, pass
in `null` for `depth`.
Example of inspecting all properties of the `sys` object:
Example of inspecting all properties of the `util` object:
var sys = require('sys');
var util = require('util');
console.log(sys.inspect(sys, true, null));
console.log(util.inspect(util, true, null));
### sys.pump(readableStream, writeableStream, [callback])
### util.pump(readableStream, writeableStream, [callback])
Experimental
@ -962,16 +962,16 @@ existing streams; `-1` means that a new stream should be created.
Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the exit code:
var sys = require('sys'),
var util = require('util'),
spawn = require('child_process').spawn,
ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', function (data) {
sys.print('stdout: ' + data);
util.print('stdout: ' + data);
});
ls.stderr.on('data', function (data) {
sys.print('stderr: ' + data);
util.print('stderr: ' + data);
});
ls.on('exit', function (code) {
@ -981,7 +981,7 @@ Example of running `ls -lh /usr`, capturing `stdout`, `stderr`, and the exit cod
Example: A very elaborate way to run 'ps ax | grep ssh'
var sys = require('sys'),
var util = require('util'),
spawn = require('child_process').spawn,
ps = spawn('ps', ['ax']),
grep = spawn('grep', ['ssh']);
@ -991,7 +991,7 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
});
ps.stderr.on('data', function (data) {
sys.print('ps stderr: ' + data);
util.print('ps stderr: ' + data);
});
ps.on('exit', function (code) {
@ -1002,11 +1002,11 @@ Example: A very elaborate way to run 'ps ax | grep ssh'
});
grep.stdout.on('data', function (data) {
sys.print(data);
util.print(data);
});
grep.stderr.on('data', function (data) {
sys.print('grep stderr: ' + data);
util.print('grep stderr: ' + data);
});
grep.on('exit', function (code) {
@ -1035,14 +1035,14 @@ See also: `child_process.exec()`
High-level way to execute a command as a child process, buffer the
output, and return it all in a callback.
var sys = require('sys'),
var util = require('util'),
exec = require('child_process').exec,
child;
child = exec('cat *.js bad_file | wc -l',
function (error, stdout, stderr) {
sys.print('stdout: ' + stdout);
sys.print('stderr: ' + stderr);
util.print('stdout: ' + stdout);
util.print('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
@ -1140,7 +1140,7 @@ the object `sandbox` will be used as the global object for `code`.
Example: compile and execute code that increments a global variable and sets a new one.
These globals are contained in the sandbox.
var sys = require('sys'),
var util = require('util'),
Script = process.binding('evals').Script,
sandbox = {
animal: 'cat',
@ -1149,7 +1149,7 @@ These globals are contained in the sandbox.
Script.runInNewContext(
'count += 1; name = "kitty"', sandbox, 'myfile.js');
console.log(sys.inspect(sandbox));
console.log(util.inspect(sandbox));
// { animal: 'cat', count: 3, name: 'kitty' }
@ -1207,7 +1207,7 @@ Running code does not have access to local scope. `sandbox` is optional.
Example: compile code that increments a global variable and sets one, then execute this code multiple times.
These globals are contained in the sandbox.
var sys = require('sys'),
var util = require('util'),
Script = process.binding('evals').Script,
scriptObj, i,
sandbox = {
@ -1222,7 +1222,7 @@ These globals are contained in the sandbox.
scriptObj.runInNewContext(sandbox);
}
console.log(sys.inspect(sandbox));
console.log(util.inspect(sandbox));
// { animal: 'cat', count: 12, name: 'kitty' }
@ -2963,7 +2963,7 @@ the first character, then it returns an empty string. Examples:
Test whether or not the given path exists. Then, call the `callback` argument with either true or false. Example:
path.exists('/etc/passwd', function (exists) {
sys.debug(exists ? "it's there" : "no passwd!");
util.debug(exists ? "it's there" : "no passwd!");
});
@ -3214,7 +3214,7 @@ The module `circle.js` has exported the functions `area()` and
`circumference()`. To export an object, add to the special `exports`
object. (Alternatively, one can use `this` instead of `exports`.) Variables
local to the module will be private. In this example the variable `PI` is
private to `circle.js`. The function `puts()` comes from the module `'sys'`,
private to `circle.js`. The function `puts()` comes from the module `'util'`,
which is a built-in module. Modules which are not prefixed by `'./'` are
built-in module--more about this later.

4
lib/assert.js

@ -23,7 +23,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// UTILITY
var inherits = require('sys').inherits;
var util = require('util');
var pSlice = Array.prototype.slice;
// 1. The assert module provides functions that throw
@ -47,7 +47,7 @@ assert.AssertionError = function AssertionError (options) {
Error.captureStackTrace(this, stackStartFunction);
}
};
inherits(assert.AssertionError, Error);
util.inherits(assert.AssertionError, Error);
assert.AssertionError.prototype.toString = function() {
if (this.message) {

4
lib/child_process.js

@ -1,4 +1,4 @@
var inherits = require('sys').inherits;
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var Stream = require('net').Stream;
var InternalChildProcess = process.binding('child_process').ChildProcess;
@ -155,7 +155,7 @@ function ChildProcess () {
this.__defineGetter__('pid', function () { return internal.pid; });
}
inherits(ChildProcess, EventEmitter);
util.inherits(ChildProcess, EventEmitter);
ChildProcess.prototype.kill = function (sig) {

1
lib/crypto.js

@ -3582,7 +3582,6 @@ var RootCaCerts = [
+"-----END CERTIFICATE-----\n"
];
var sys = require("sys");
try {
var binding = process.binding('crypto');
var SecureContext = binding.SecureContext;

4
lib/dgram.js

@ -1,4 +1,4 @@
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var events = require("events");
var dns = require('dns');
@ -72,7 +72,7 @@ function Socket (type, listener) {
}
}
sys.inherits(Socket, events.EventEmitter);
util.inherits(Socket, events.EventEmitter);
exports.Socket = Socket;
exports.createSocket = function (type, listener) {

12
lib/fs.js

@ -1,4 +1,4 @@
var sys = require('sys');
var util = require('util');
var events = require('events');
var binding = process.binding('fs');
@ -666,7 +666,7 @@ var ReadStream = fs.ReadStream = function(path, options) {
self._read();
});
};
sys.inherits(ReadStream, events.EventEmitter);
util.inherits(ReadStream, events.EventEmitter);
fs.FileReadStream = fs.ReadStream; // support the legacy name
@ -761,7 +761,7 @@ var readStreamForceCloseWarning;
ReadStream.prototype.forceClose = function (cb) {
if (!readStreamForceCloseWarning) {
readStreamForceCloseWarning = "ReadStream.prototype.forceClose renamed to destroy()";
sys.error(readStreamForceCloseWarning);
util.error(readStreamForceCloseWarning);
}
return this.destroy(cb);
};
@ -844,7 +844,7 @@ var WriteStream = fs.WriteStream = function(path, options) {
this.flush();
}
};
sys.inherits(WriteStream, events.EventEmitter);
util.inherits(WriteStream, events.EventEmitter);
fs.FileWriteStream = fs.WriteStream; // support the legacy name
@ -940,7 +940,7 @@ var writeStreamCloseWarning;
WriteStream.prototype.close = function (cb) {
if (!writeStreamCloseWarning) {
writeStreamCloseWarning = "WriteStream.prototype.close renamed to end()";
sys.error(writeStreamCloseWarning);
util.error(writeStreamCloseWarning);
}
return this.end(cb);
};
@ -958,7 +958,7 @@ var writeStreamForceCloseWarning;
WriteStream.prototype.forceClose = function (cb) {
if (!writeStreamForceCloseWarning) {
writeStreamForceCloseWarning = "WriteStream.prototype.forceClose renamed to destroy()";
sys.error(writeStreamForceCloseWarning);
util.error(writeStreamForceCloseWarning);
}
return this.destroy(cb);
};

22
lib/http.js

@ -1,9 +1,9 @@
var sys = require('sys');
var util = require('util');
var debug;
var debugLevel = parseInt(process.env.NODE_DEBUG, 16);
if (debugLevel & 0x4) {
debug = function (x) { sys.error('HTTP: ' + x); };
debug = function (x) { util.error('HTTP: ' + x); };
} else {
debug = function () { };
}
@ -207,7 +207,7 @@ function IncomingMessage (socket) {
this.statusCode = null;
this.client = this.socket;
}
sys.inherits(IncomingMessage, stream.Stream);
util.inherits(IncomingMessage, stream.Stream);
exports.IncomingMessage = IncomingMessage;
IncomingMessage.prototype._parseQueryString = function () {
@ -305,7 +305,7 @@ function OutgoingMessage (socket) {
this.finished = false;
}
sys.inherits(OutgoingMessage, stream.Stream);
util.inherits(OutgoingMessage, stream.Stream);
exports.OutgoingMessage = OutgoingMessage;
// This abstract either writing directly to the socket or buffering it.
@ -499,7 +499,7 @@ OutgoingMessage.prototype.write = function (chunk, encoding) {
if (typeof(chunk) === 'string') {
len = Buffer.byteLength(chunk, encoding);
var chunk = len.toString(16) + CRLF + chunk + CRLF;
debug('string chunk = ' + sys.inspect(chunk));
debug('string chunk = ' + util.inspect(chunk));
ret = this._send(chunk, encoding);
} else {
// buffer
@ -605,7 +605,7 @@ function ServerResponse (req) {
this.shouldKeepAlive = false;
}
}
sys.inherits(ServerResponse, OutgoingMessage);
util.inherits(ServerResponse, OutgoingMessage);
exports.ServerResponse = ServerResponse;
ServerResponse.prototype.writeContinue = function () {
@ -678,7 +678,7 @@ function ClientRequest (socket, method, url, headers) {
this._storeHeader(method + " " + url + " HTTP/1.1\r\n", headers);
}
sys.inherits(ClientRequest, OutgoingMessage);
util.inherits(ClientRequest, OutgoingMessage);
exports.ClientRequest = ClientRequest;
ClientRequest.prototype.finish = function () {
@ -769,7 +769,7 @@ function Server (requestListener) {
this.addListener("connection", connectionListener);
}
sys.inherits(Server, net.Server);
util.inherits(Server, net.Server);
Server.prototype.setSecure = function (credentials) {
this.secure = true;
@ -934,14 +934,14 @@ function Client ( ) {
this.setSecure(this.credentials);
} else {
self._initParser();
debug('requests: ' + sys.inspect(self._outgoing));
debug('requests: ' + util.inspect(self._outgoing));
outgoingFlush(self);
}
});
self.addListener("secure", function () {
self._initParser();
debug('requests: ' + sys.inspect(self._outgoing));
debug('requests: ' + util.inspect(self._outgoing));
outgoingFlush(self);
});
@ -968,7 +968,7 @@ function Client ( ) {
}
});
};
sys.inherits(Client, net.Stream);
util.inherits(Client, net.Stream);
exports.Client = Client;

10
lib/net.js

@ -1,4 +1,4 @@
var sys = require("sys");
var util = require("util");
var fs = require("fs");
var events = require("events");
var stream = require("stream");
@ -9,7 +9,7 @@ var kPoolSize = 40*1024;
var debugLevel = parseInt(process.env.NODE_DEBUG, 16);
function debug () {
if (debugLevel & 0x2) sys.error.apply(this, arguments);
if (debugLevel & 0x2) util.error.apply(this, arguments);
}
var binding = process.binding('net');
@ -532,7 +532,7 @@ function Stream (fd, type) {
setImplmentationMethods(this);
}
};
sys.inherits(Stream, stream.Stream);
util.inherits(Stream, stream.Stream);
exports.Stream = Stream;
@ -783,7 +783,7 @@ Stream.prototype._writeOut = function (data, encoding, fd) {
var leftOver = buffer.slice(off + bytesWritten, off + len);
leftOver.used = leftOver.length; // used the whole thing...
// sys.error('data.used = ' + data.used);
// util.error('data.used = ' + data.used);
//if (!this._writeQueue) initWriteStream(this);
// data should be the next thing to write.
@ -1093,7 +1093,7 @@ function Server (listener) {
}
};
}
sys.inherits(Server, events.EventEmitter);
util.inherits(Server, events.EventEmitter);
exports.Server = Server;

4
lib/readline.js

@ -7,8 +7,8 @@
var kHistorySize = 30;
var kBufSize = 10*1024;
var sys = require('sys');
var inherits = require('sys').inherits;
var util = require('util');
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
var stdio = process.binding('stdio');

14
lib/repl.js

@ -12,7 +12,7 @@
// repl.start("node > ").context.foo = "stdin is fun"; // expose foo to repl context
var sys = require('sys');
var util = require('util');
var Script = process.binding('evals').Script;
var evalcx = Script.runInContext;
var path = require("path");
@ -41,7 +41,7 @@ function resetContext() {
// Can overridden with custom print functions, such as `probe` or `eyes.js`
exports.writer = sys.inspect;
exports.writer = util.inspect;
function REPLServer(prompt, stream) {
var self = this;
@ -59,7 +59,7 @@ function REPLServer(prompt, stream) {
if (rli.enabled && !disableColors) {
// Turn on ANSI coloring.
exports.writer = function(obj, showHidden, depth) {
return sys.inspect(obj, showHidden, depth, true);
return util.inspect(obj, showHidden, depth, true);
};
}
@ -167,9 +167,9 @@ REPLServer.prototype.readline = function (cmd) {
* (2) the leading text completed.
*
* Example:
* complete('var foo = sys.')
* -> [['sys.print', 'sys.debug', 'sys.log', 'sys.inspect', 'sys.pump'],
* 'sys.' ]
* complete('var foo = util.')
* -> [['util.print', 'util.debug', 'util.log', 'util.inspect', 'util.pump'],
* 'util.' ]
*
* Warning: This eval's code like "foo.bar.baz", so it will run property
* getter code.
@ -253,7 +253,7 @@ REPLServer.prototype.complete = function (line) {
// Intentionally excluding moved modules: posix, utils.
var builtinLibs = ['assert', 'buffer', 'child_process', 'crypto', 'dgram',
'dns', 'events', 'file', 'freelist', 'fs', 'http', 'net', 'path',
'querystring', 'readline', 'repl', 'string_decoder', 'sys', 'tcp', 'url'];
'querystring', 'readline', 'repl', 'string_decoder', 'util', 'tcp', 'url'];
completionGroups.push(builtinLibs);
}
}

4
lib/stream.js

@ -1,10 +1,10 @@
var events = require('events');
var inherits = require('sys').inherits;
var util = require('util');
function Stream () {
events.EventEmitter.call(this);
}
inherits(Stream, events.EventEmitter);
util.inherits(Stream, events.EventEmitter);
exports.Stream = Stream;
Stream.prototype.pipe = function (dest, options) {

402
lib/sys.js

@ -1,390 +1,18 @@
var events = require('events');
var util = require("util");
exports.print = function () {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.stdout.write(String(arguments[i]));
}
};
exports.puts = function () {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.stdout.write(arguments[i] + '\n');
}
};
exports.debug = function (x) {
process.binding('stdio').writeError("DEBUG: " + x + "\n");
};
var error = exports.error = function (x) {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.binding('stdio').writeError(arguments[i] + '\n');
}
};
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} value The object to print out
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
* properties of objects.
* @param {Number} depth Depth in which to descend in object. Default is 2.
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
* output. Default is false (no coloring).
*/
exports.inspect = function (obj, showHidden, depth, colors) {
var seen = [];
var stylize = function (str, styleType) {
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
var styles = { 'bold' : [1, 22]
, 'italic' : [3, 23]
, 'underline' : [4, 24]
, 'inverse' : [7, 27]
, 'white' : [37, 39]
, 'grey' : [90, 39]
, 'black' : [30, 39]
, 'blue' : [34, 39]
, 'cyan' : [36, 39]
, 'green' : [32, 39]
, 'magenta' : [35, 39]
, 'red' : [31, 39]
, 'yellow' : [33, 39]
};
var style = { "special": "grey"
, "number": "blue"
, "boolean": "blue"
, "undefined": "red"
, "null": "red"
, "string": "green"
, "date": "magenta"
//, "name": intentionally not styling
, "regexp": "cyan"
}[styleType];
if (style) {
return '\033[' + styles[style][0] + 'm' + str +
'\033[' + styles[style][1] + 'm';
} else {
return str;
}
};
if (! colors) {
stylize = function(str, styleType) { return str; };
}
function format(value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the sys module, it's inspect function is special
value !== exports &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
}
// Primitive types cannot have properties
switch (typeof value) {
case 'undefined': return stylize('undefined', 'undefined');
case 'string': return stylize(
JSON.stringify(value).replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'"),
'string');
case 'number': return stylize('' + value, 'number');
case 'boolean': return stylize('' + value, 'boolean');
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
return stylize('null', 'null');
}
// Look up the keys of the object.
var visible_keys = Object.keys(value);
var keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
// Functions without properties can be shortcutted.
if (typeof value === 'function' && keys.length === 0) {
if (isRegExp(value)) {
return stylize('' + value, 'regexp');
} else {
return stylize('[Function'+ (value.name ? ': '+ value.name : '')+ ']', 'special');
}
}
// Dates without properties can be shortcutted
if (isDate(value) && keys.length === 0) {
return stylize(value.toUTCString(), 'date');
}
var base, type, braces;
// Determine the object type
if (isArray(value)) {
type = 'Array';
braces = ["[", "]"];
} else {
type = 'Object';
braces = ["{", "}"];
}
// Make functions say that they are functions
if (typeof value === 'function') {
base = (isRegExp(value)) ? ' ' + value : ' [Function'+ (value.name ? ': '+ value.name : '')+ ']';
} else {
base = "";
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + value.toUTCString();
}
seen.push(value);
if (keys.length === 0) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return stylize('' + value, "regexp");
} else {
return stylize("[Object]", "special");
}
}
var output = keys.map(function (key) {
var name, str;
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
str = stylize("[Getter/Setter]", "special");
} else {
str = stylize("[Getter]", "special");
}
} else {
if (value.__lookupSetter__(key)) {
str = stylize("[Setter]", "special");
}
}
}
if (visible_keys.indexOf(key) < 0) {
name = "[" + key + "]";
}
if (!str) {
if (seen.indexOf(value[key]) < 0) {
if ( recurseTimes === null) {
str = format(value[key]);
} else {
str = format(value[key], recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (isArray(value)) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = stylize('[Circular]', 'special');
}
}
if (typeof name === 'undefined') {
if (type === 'Array' && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length-2);
name = stylize(name, "name");
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = stylize(name, "string");
}
}
return name + ": " + str;
});
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if( cur.indexOf('\n') >= 0 ) {
numLinesEst++;
}
return prev + cur.length + 1;
},0);
if (length > (require('readline').columns || 50)) {
output = braces[0]
+ (base === '' ? '' : base + '\n ')
+ ' '
+ output.join(',\n ')
+ ' '
+ braces[1]
;
} else {
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
return output;
}
return format(obj, (typeof depth === 'undefined' ? 2 : depth));
};
function isArray (ar) {
return ar instanceof Array
|| Array.isArray(ar)
|| (ar && ar !== Object.prototype && isArray(ar.__proto__));
}
function isRegExp (re) {
var s = ""+re;
return re instanceof RegExp // easy case
|| typeof(re) === "function" // duck-type for context-switching evalcx case
&& re.constructor.name === "RegExp"
&& re.compile
&& re.test
&& re.exec
&& s.match(/^\/.*\/[gim]{0,3}$/);
}
function isDate (d) {
if (d instanceof Date) return true;
if (typeof d !== "object") return false;
var properties = Date.prototype && Object.getOwnPropertyNames(Date.prototype);
var proto = d.__proto__ && Object.getOwnPropertyNames(d.__proto__);
return JSON.stringify(proto) === JSON.stringify(properties);
var sysWarning;
if (!sysWarning) {
sysWarning = "The 'sys' module is now called 'util'. It should have a similar interface.";
util.error(sysWarning);
}
var pWarning;
exports.p = function () {
if (!pWarning) {
pWarning = "sys.p will be removed in future versions of Node. Use sys.puts(sys.inspect()) instead.\n";
exports.error(pWarning);
}
for (var i = 0, len = arguments.length; i < len; ++i) {
error(exports.inspect(arguments[i]));
}
};
function pad (n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp () {
var d = new Date();
return [ d.getDate()
, months[d.getMonth()]
, [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':')
].join(' ');
}
exports.log = function (msg) {
exports.puts(timestamp() + ' - ' + msg.toString());
};
var execWarning;
exports.exec = function () {
if (!execWarning) {
execWarning = 'sys.exec has moved to the "child_process" module. Please update your source code.';
error(execWarning);
}
return require('child_process').exec.apply(this, arguments);
};
exports.pump = function (readStream, writeStream, callback) {
var callbackCalled = false;
function call (a, b, c) {
if (callback && !callbackCalled) {
callback(a, b, c);
callbackCalled = true;
}
}
if (!readStream.pause) readStream.pause = function () {readStream.emit("pause");};
if (!readStream.resume) readStream.resume = function () {readStream.emit("resume");};
readStream.addListener("data", function (chunk) {
if (writeStream.write(chunk) === false) readStream.pause();
});
writeStream.addListener("pause", function () {
readStream.pause();
});
writeStream.addListener("drain", function () {
readStream.resume();
});
writeStream.addListener("resume", 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.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be revritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype
* @param {function} superCtor Constructor function to inherit prototype from
*/
exports.inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false
}
});
};
exports.print = util.print;
exports.puts = util.puts;
exports.debug = util.debug;
exports.error = util.error;
exports.inspect = util.inspect;
exports.p = util.p;
exports.log = util.log;
exports.exec = util.exec;
exports.pump = util.pump;
exports.inherits = util.inherits;

390
lib/util.js

@ -0,0 +1,390 @@
var events = require('events');
exports.print = function () {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.stdout.write(String(arguments[i]));
}
};
exports.puts = function () {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.stdout.write(arguments[i] + '\n');
}
};
exports.debug = function (x) {
process.binding('stdio').writeError("DEBUG: " + x + "\n");
};
var error = exports.error = function (x) {
for (var i = 0, len = arguments.length; i < len; ++i) {
process.binding('stdio').writeError(arguments[i] + '\n');
}
};
/**
* Echos the value of a value. Trys to print the value out
* in the best way possible given the different types.
*
* @param {Object} value The object to print out
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
* properties of objects.
* @param {Number} depth Depth in which to descend in object. Default is 2.
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
* output. Default is false (no coloring).
*/
exports.inspect = function (obj, showHidden, depth, colors) {
var seen = [];
var stylize = function (str, styleType) {
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
var styles = { 'bold' : [1, 22]
, 'italic' : [3, 23]
, 'underline' : [4, 24]
, 'inverse' : [7, 27]
, 'white' : [37, 39]
, 'grey' : [90, 39]
, 'black' : [30, 39]
, 'blue' : [34, 39]
, 'cyan' : [36, 39]
, 'green' : [32, 39]
, 'magenta' : [35, 39]
, 'red' : [31, 39]
, 'yellow' : [33, 39]
};
var style = { "special": "grey"
, "number": "blue"
, "boolean": "blue"
, "undefined": "red"
, "null": "red"
, "string": "green"
, "date": "magenta"
//, "name": intentionally not styling
, "regexp": "cyan"
}[styleType];
if (style) {
return '\033[' + styles[style][0] + 'm' + str +
'\033[' + styles[style][1] + 'm';
} else {
return str;
}
};
if (! colors) {
stylize = function(str, styleType) { return str; };
}
function format(value, recurseTimes) {
// Provide a hook for user-specified inspect functions.
// Check that value is an object with an inspect function on it
if (value && typeof value.inspect === 'function' &&
// Filter out the util module, it's inspect function is special
value !== exports &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
return value.inspect(recurseTimes);
}
// Primitive types cannot have properties
switch (typeof value) {
case 'undefined': return stylize('undefined', 'undefined');
case 'string': return stylize(
JSON.stringify(value).replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'"),
'string');
case 'number': return stylize('' + value, 'number');
case 'boolean': return stylize('' + value, 'boolean');
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
return stylize('null', 'null');
}
// Look up the keys of the object.
var visible_keys = Object.keys(value);
var keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
// Functions without properties can be shortcutted.
if (typeof value === 'function' && keys.length === 0) {
if (isRegExp(value)) {
return stylize('' + value, 'regexp');
} else {
return stylize('[Function'+ (value.name ? ': '+ value.name : '')+ ']', 'special');
}
}
// Dates without properties can be shortcutted
if (isDate(value) && keys.length === 0) {
return stylize(value.toUTCString(), 'date');
}
var base, type, braces;
// Determine the object type
if (isArray(value)) {
type = 'Array';
braces = ["[", "]"];
} else {
type = 'Object';
braces = ["{", "}"];
}
// Make functions say that they are functions
if (typeof value === 'function') {
base = (isRegExp(value)) ? ' ' + value : ' [Function'+ (value.name ? ': '+ value.name : '')+ ']';
} else {
base = "";
}
// Make dates with properties first say the date
if (isDate(value)) {
base = ' ' + value.toUTCString();
}
seen.push(value);
if (keys.length === 0) {
return braces[0] + base + braces[1];
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
return stylize('' + value, "regexp");
} else {
return stylize("[Object]", "special");
}
}
var output = keys.map(function (key) {
var name, str;
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
str = stylize("[Getter/Setter]", "special");
} else {
str = stylize("[Getter]", "special");
}
} else {
if (value.__lookupSetter__(key)) {
str = stylize("[Setter]", "special");
}
}
}
if (visible_keys.indexOf(key) < 0) {
name = "[" + key + "]";
}
if (!str) {
if (seen.indexOf(value[key]) < 0) {
if ( recurseTimes === null) {
str = format(value[key]);
} else {
str = format(value[key], recurseTimes - 1);
}
if (str.indexOf('\n') > -1) {
if (isArray(value)) {
str = str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n').substr(2);
} else {
str = '\n' + str.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
}
}
} else {
str = stylize('[Circular]', 'special');
}
}
if (typeof name === 'undefined') {
if (type === 'Array' && key.match(/^\d+$/)) {
return str;
}
name = JSON.stringify('' + key);
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
name = name.substr(1, name.length-2);
name = stylize(name, "name");
} else {
name = name.replace(/'/g, "\\'")
.replace(/\\"/g, '"')
.replace(/(^"|"$)/g, "'");
name = stylize(name, "string");
}
}
return name + ": " + str;
});
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if( cur.indexOf('\n') >= 0 ) {
numLinesEst++;
}
return prev + cur.length + 1;
},0);
if (length > (require('readline').columns || 50)) {
output = braces[0]
+ (base === '' ? '' : base + '\n ')
+ ' '
+ output.join(',\n ')
+ ' '
+ braces[1]
;
} else {
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
}
return output;
}
return format(obj, (typeof depth === 'undefined' ? 2 : depth));
};
function isArray (ar) {
return ar instanceof Array
|| Array.isArray(ar)
|| (ar && ar !== Object.prototype && isArray(ar.__proto__));
}
function isRegExp (re) {
var s = ""+re;
return re instanceof RegExp // easy case
|| typeof(re) === "function" // duck-type for context-switching evalcx case
&& re.constructor.name === "RegExp"
&& re.compile
&& re.test
&& re.exec
&& s.match(/^\/.*\/[gim]{0,3}$/);
}
function isDate (d) {
if (d instanceof Date) return true;
if (typeof d !== "object") return false;
var properties = Date.prototype && Object.getOwnPropertyNames(Date.prototype);
var proto = d.__proto__ && Object.getOwnPropertyNames(d.__proto__);
return JSON.stringify(proto) === JSON.stringify(properties);
}
var pWarning;
exports.p = function () {
if (!pWarning) {
pWarning = "util.p will be removed in future versions of Node. Use util.puts(util.inspect()) instead.\n";
exports.error(pWarning);
}
for (var i = 0, len = arguments.length; i < len; ++i) {
error(exports.inspect(arguments[i]));
}
};
function pad (n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
// 26 Feb 16:19:34
function timestamp () {
var d = new Date();
return [ d.getDate()
, months[d.getMonth()]
, [pad(d.getHours()), pad(d.getMinutes()), pad(d.getSeconds())].join(':')
].join(' ');
}
exports.log = function (msg) {
exports.puts(timestamp() + ' - ' + msg.toString());
};
var execWarning;
exports.exec = function () {
if (!execWarning) {
execWarning = 'util.exec has moved to the "child_process" module. Please update your source code.';
error(execWarning);
}
return require('child_process').exec.apply(this, arguments);
};
exports.pump = function (readStream, writeStream, callback) {
var callbackCalled = false;
function call (a, b, c) {
if (callback && !callbackCalled) {
callback(a, b, c);
callbackCalled = true;
}
}
if (!readStream.pause) readStream.pause = function () {readStream.emit("pause");};
if (!readStream.resume) readStream.resume = function () {readStream.emit("resume");};
readStream.addListener("data", function (chunk) {
if (writeStream.write(chunk) === false) readStream.pause();
});
writeStream.addListener("pause", function () {
readStream.pause();
});
writeStream.addListener("drain", function () {
readStream.resume();
});
writeStream.addListener("resume", 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.
*
* The Function.prototype.inherits from lang.js rewritten as a standalone
* function (not on Function.prototype). NOTE: If this file is to be loaded
* during bootstrapping this function needs to be revritten using some native
* functions as prototype setup using normal JavaScript does not work as
* expected during bootstrapping (see mirror.js in r114903).
*
* @param {function} ctor Constructor function which needs to inherit the
* prototype
* @param {function} superCtor Constructor function to inherit prototype from
*/
exports.inherits = function (ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false
}
});
};

1
lib/utils.js

@ -1 +0,0 @@
sys.js

2
src/node.cc

@ -1520,7 +1520,7 @@ static Handle<Value> Binding(const Arguments& args) {
exports->Set(String::New("readline"), String::New(native_readline));
exports->Set(String::New("sys"), String::New(native_sys));
exports->Set(String::New("url"), String::New(native_url));
exports->Set(String::New("utils"), String::New(native_utils));
exports->Set(String::New("util"), String::New(native_util));
exports->Set(String::New("path"), String::New(native_path));
exports->Set(String::New("string_decoder"), String::New(native_string_decoder));
exports->Set(String::New("stream"), String::New(native_stream));

8
src/node.js

@ -483,9 +483,9 @@ process.openStdin = function () {
var formatRegExp = /%[sdj]/g;
function format (f) {
if (typeof f !== 'string') {
var objects = [], sys = module.requireNative('sys');
var objects = [], util = module.requireNative('util');
for (var i = 0; i < arguments.length; i++) {
objects.push(sys.inspect(arguments[i]));
objects.push(util.inspect(arguments[i]));
}
return objects.join(' ');
}
@ -523,8 +523,8 @@ global.console.warn = function () {
global.console.error = global.console.warn;
global.console.dir = function(object){
var sys = module.requireNative('sys');
process.stdout.write(sys.inspect(object) + '\n');
var util = module.requireNative('util');
process.stdout.write(util.inspect(object) + '\n');
};
var times = {};

4
test/common.js

@ -8,8 +8,8 @@ exports.PORT = 12346;
exports.assert = require('assert');
var sys = require("sys");
for (var i in sys) exports[i] = sys[i];
var util = require("util");
for (var i in util) exports[i] = util[i];
//for (var i in exports) global[i] = exports[i];
function protoCtrChain (o) {

3
test/disabled/test-dns.js

@ -2,8 +2,7 @@ common = require("../common");
assert = common.assert;
var dns = require("dns"),
child_process = require("child_process"),
sys = require("sys");
child_process = require("child_process");
// Try resolution without callback

2
test/disabled/test-fs-sendfile.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert;
tcp = require("tcp");
sys = require("sys");
util = require("util");
var x = path.join(common.fixturesDir, "x.txt");
var expected = "xyz";

2
test/disabled/test-http-big-proxy-responses.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert;
var sys = require("sys"),
var util = require("util"),
fs = require("fs"),
http = require("http"),
url = require("url");

2
test/disabled/test-http-head-request.js

@ -3,7 +3,7 @@ assert = common.assert;
var assert = require("assert");
var http = require("http");
var sys = require("sys");
var util = require("util");
var body = "hello world";

4
test/disabled/test-remote-module-loading.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert;
var http = require('http');
var sys = require('sys');
var util = require('util');
var url = require("url");
var modulesLoaded = 0;
@ -26,7 +26,7 @@ assert.throws(function () {
var nodeBinary = process.ARGV[0];
var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+common.PORT+'/moduleB.js';
sys.exec(cmd, function (err, stdout, stderr) {
util.exec(cmd, function (err, stdout, stderr) {
if (err) throw err;
console.log('success!');
modulesLoaded++;

2
test/disabled/tls_client.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert;
var sys=require('sys');
var util=require('util');
var net=require('net');
var fs=require('fs');
var crypto=require('crypto');

2
test/disabled/tls_server.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert;
var sys=require('sys');
var util=require('util');
var net=require('net');
var fs=require('fs');
var crypto=require('crypto');

3
test/fixtures/child_process_should_emit_error.js

@ -1,5 +1,4 @@
var exec = require('child_process').exec,
puts = require('sys').puts;
var exec = require('child_process').exec;
[0, 1].forEach(function(i) {
exec('ls', function(err, stdout, stderr) {

1
test/fixtures/print-10-lines.js

@ -1,4 +1,3 @@
puts = require('sys').puts;
for (var i = 0; i < 10; i++) {
console.log('count ' + i);
}

1
test/fixtures/recvfd.js

@ -2,7 +2,6 @@
// script is doing and how it fits into the test as a whole.
var net = require('net');
var sys = require('sys');
var receivedData = [];
var receivedFDs = [];

2
test/fixtures/stdio-filter.js

@ -1,4 +1,4 @@
sys = require('sys');
var util = require('util');
var regexIn = process.argv[2];
var replacement = process.argv[3];

2
test/message/2100bytes.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
sys = require('sys');
util = require('util');
console.log([
'_______________________________________________50',
'______________________________________________100',

2
test/pummel/test-http-client-reconnect-bug.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert
var net = require("net"),
sys = require("sys"),
util = require("util"),
http = require("http");
var errorCount = 0;

1
test/simple/test-child-process-custom-fds.js

@ -5,7 +5,6 @@ var assert = require('assert');
var spawn = require('child_process').spawn;
var path = require('path');
var fs = require('fs');
var sys = require('sys');
function fixtPath(p) {
return path.join(common.fixturesDir, p);

3
test/simple/test-child-process-exec-env.js

@ -1,7 +1,6 @@
common = require('../common');
assert = common.assert;
var exec = require('child_process').exec,
sys = require('sys');
var exec = require('child_process').exec;
success_count = 0;
error_count = 0;
response = "";

1
test/simple/test-crypto.js

@ -9,7 +9,6 @@ try {
}
var fs = require('fs');
var sys = require('sys');
var path = require('path');
// Test Certificates

6
test/simple/test-dgram-multicast.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert
var dgram = require("dgram"),
sys = require('sys'),
util = require('util'),
assert = require('assert'),
Buffer = require("buffer").Buffer;
var LOCAL_BROADCAST_HOST = '224.0.0.1';
@ -35,7 +35,7 @@ sendSocket.sendNext = function () {
sendSocket.send(buf, 0, buf.length, common.PORT, LOCAL_BROADCAST_HOST, function (err) {
if (err) throw err;
console.error('sent %s to %s', sys.inspect(buf.toString()),
console.error('sent %s to %s', util.inspect(buf.toString()),
LOCAL_BROADCAST_HOST+common.PORT);
process.nextTick(sendSocket.sendNext);
});
@ -48,7 +48,7 @@ function mkListener() {
var listenSocket = dgram.createSocket('udp4')
listenSocket.on('message', function(buf, rinfo) {
console.error('received %s from %j', sys.inspect(buf.toString()), rinfo);
console.error('received %s from %j', util.inspect(buf.toString()), rinfo);
receivedMessages.push(buf);
if (receivedMessages.length == sendMessages.length) {

2
test/simple/test-http-expect-continue.js

@ -1,6 +1,5 @@
var common = require("../common");
var assert = common.assert;
var sys = require("sys");
var http = require("http");
var outstanding_reqs = 0;
@ -55,7 +54,6 @@ server.addListener("listening", function() {
res.addListener('end', function () {
common.debug("Got full response.");
assert.equal(body, test_res_body, "Response body doesn't match.");
// common.debug(sys.inspect(res.headers));
assert.ok("abcd" in res.headers, "Response headers missing.");
outstanding_reqs--;
if (outstanding_reqs == 0) {

2
test/simple/test-http-head-request.js

@ -3,7 +3,7 @@ assert = common.assert
assert = require("assert");
http = require("http");
sys = require("sys");
util = require("util");
body = "hello world\n";

2
test/simple/test-http-keep-alive-close-on-header.js

@ -3,7 +3,7 @@ assert = common.assert
assert = require("assert");
http = require("http");
sys = require("sys");
util = require("util");
body = "hello world\n";
headers = {'connection':'keep-alive'}

2
test/simple/test-http-keep-alive.js

@ -3,7 +3,7 @@ assert = common.assert
assert = require("assert");
http = require("http");
sys = require("sys");
util = require("util");
body = "hello world\n";
headers = {'connection':'keep-alive'}

1
test/simple/test-http-tls.js

@ -5,7 +5,6 @@ http = require("http");
url = require("url");
qs = require("querystring");
var fs = require('fs');
var sys = require('sys');
var have_openssl;
try {

4
test/simple/test-http-upgrade-server.js

@ -1,7 +1,7 @@
common = require("../common");
assert = common.assert
var sys = require("sys");
var util = require("util");
var net = require("net");
var http = require("http");
@ -48,7 +48,7 @@ function testServer(){
});
};
sys.inherits(testServer, http.Server);
util.inherits(testServer, http.Server);
function writeReq(socket, data, encoding){

1
test/simple/test-net-tls.js

@ -1,7 +1,6 @@
common = require("../common");
assert = common.assert
var fs = require('fs');
var sys = require('sys');
var net = require('net');
var have_openssl;

2
test/simple/test-next-tick-ordering.js

@ -1,6 +1,6 @@
common = require("../common");
assert = common.assert
var sys = require('sys'), i;
var i;
var N = 30;
var done = [];

8
test/simple/test-pump-file2tcp-noexist.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert
net = require("net");
fs = require("fs");
sys = require("sys");
util = require("util");
path = require("path");
fn = path.join(common.fixturesDir, 'does_not_exist.txt');
@ -11,12 +11,12 @@ var conn_closed = false;
server = net.createServer(function (stream) {
common.error('pump!');
sys.pump(fs.createReadStream(fn), stream, function (err) {
common.error("sys.pump's callback fired");
util.pump(fs.createReadStream(fn), stream, function (err) {
common.error("util.pump's callback fired");
if (err) {
got_error = true;
} else {
common.debug("sys.pump's callback fired with no error");
common.debug("util.pump's callback fired with no error");
common.debug("this shouldn't happen as the file doesn't exist...");
assert.equal(true, false);
}

4
test/simple/test-pump-file2tcp.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert
net = require("net");
fs = require("fs");
sys = require("sys");
util = require("util");
path = require("path");
fn = path.join(common.fixturesDir, 'elipses.txt');
@ -10,7 +10,7 @@ expected = fs.readFileSync(fn, 'utf8');
server = net.createServer(function (stream) {
common.error('pump!');
sys.pump(fs.createReadStream(fn), stream, function () {
util.pump(fs.createReadStream(fn), stream, function () {
common.error('server stream close');
common.error('server close');
server.close();

2
test/simple/test-regression-object-prototype.js

@ -1,5 +1,3 @@
var sys = require('sys');
//console.log('puts before');
Object.prototype.xadsadsdasasdxx = function () {

3
test/simple/test-repl.js

@ -1,8 +1,7 @@
common = require("../common");
assert = common.assert
var sys = require("sys"),
net = require("net"),
var net = require("net"),
repl = require("repl"),
message = "Read, Eval, Print Loop",
unix_socket_path = "/tmp/node-repl-sock",

1
test/simple/test-sendfd.js

@ -34,7 +34,6 @@ var fs = require('fs');
var net = require('net');
var netBinding = process.binding('net');
var path = require('path');
var sys = require('sys');
var DATA = {
'ppid' : process.pid,

2
test/simple/test-signal-unregister.js

@ -3,7 +3,7 @@ assert = common.assert
var childKilled = false, done = false,
spawn = require('child_process').spawn,
sys = require("sys"),
util = require("util"),
child;
var join = require('path').join;

2
test/simple/test-url.js

@ -2,7 +2,7 @@ common = require("../common");
assert = common.assert
var url = require("url"),
sys = require("sys");
util = require("util");
// URLs to parse, and expected data
// { url : parsed }

17
tools/ronnjs/bin/ronn.js

@ -3,10 +3,12 @@
var opts = require(__dirname + '/../lib/ext/opts');
var ronn = require(__dirname + '/../lib/ronn');
var util = require("util");
var options = [
{ short : 'V'
, description : 'Show version and exit'
, callback : function () { sys.puts('0.1'); process.exit(1); }
, callback : function () { util.puts('0.1'); process.exit(1); }
},
{ short : 'b'
, long : 'build'
@ -50,7 +52,6 @@ var arguments = [
opts.parse(options, arguments, true);
var sys = require('sys');
var fs = require('fs');
var path = require('path');
@ -64,10 +65,10 @@ if (opts.get("man") && !opts.get("build")) {
var spawn = require('child_process').spawn;
var man = spawn('man', ['--warnings', '-E UTF-8', '-l', '-'], {"LANG":"C"});
man.stdout.addListener('data', function (data) {
sys.puts(data);
util.puts(data);
});
man.stderr.addListener('data', function (data) {
sys.puts(data);
util.puts(data);
});
man.addListener('exit', function() {
process.exit(0);
@ -84,7 +85,7 @@ if (opts.get("man") && !opts.get("build")) {
if (opts.get("html")) fHtml = ronn.html();
if (opts.get("fragment")) {
if (opts.get("html")) {
sys.debug("Can't use both --fragment and --html");
util.debug("Can't use both --fragment and --html");
process.exit(-1);
}
fFrag = ronn.fragment();
@ -95,8 +96,8 @@ if (opts.get("man") && !opts.get("build")) {
if (fHtml) fs.writeFileSync(fBase + ".html", fHtml, 'utf8');
if (fFrag) fs.writeFileSync(fBase + ".fragment", fFrag, 'utf8');
} else {
if (fRoff) sys.puts(fRoff);
if (fHtml) sys.puts(fHtml);
if (fFrag) sys.puts(fFrag);
if (fRoff) util.puts(fRoff);
if (fHtml) util.puts(fHtml);
if (fFrag) util.puts(fFrag);
}
}

18
tools/ronnjs/lib/ext/opts.js

@ -34,7 +34,7 @@ of the authors and should not be interpreted as representing official policies,
either expressed or implied, of Joey Mazzarelli.
***************************************************************************/
var puts = require('sys').puts
var util = require('util')
, values = {}
, args = {}
, argv = []
@ -133,8 +133,8 @@ exports.parse = function (options, params, help) {
}
}
} else {
puts('Conflicting flags: ' + prefix + name + '\n');
puts(helpString());
util.puts('Conflicting flags: ' + prefix + name + '\n');
util.puts(helpString());
process.exit(1);
}
}
@ -173,8 +173,8 @@ exports.parse = function (options, params, help) {
// No match. If it starts with a dash, show an error. Otherwise
// add it to the extra params.
if (inp[0] == '-') {
puts('Unknown option: ' + inp);
if (opts['--help']) puts('Try --help');
util.puts('Unknown option: ' + inp);
if (opts['--help']) util.puts('Try --help');
process.exit(1);
} else {
argv.push(inp);
@ -198,8 +198,8 @@ exports.parse = function (options, params, help) {
}
}
if (errors.length) {
for (var i=0; i<errors.length; i++) puts(errors[i]);
puts('\n' + helpString());
for (var i=0; i<errors.length; i++) util.puts(errors[i]);
util.puts('\n' + helpString());
process.exit(1);
}
};
@ -226,7 +226,7 @@ exports.args = function () {
* @return string Value of arg
*/
exports.arg = function (name) {
//puts(require('sys').inspect(arguments));
//util.puts(require('util').inspect(arguments));
return args[name];
};
@ -234,7 +234,7 @@ exports.arg = function (name) {
* Print the help message and exit
*/
exports.help = function () {
puts(helpString());
util.puts(helpString());
process.exit(0);
};

8
tools/ronnjs/lib/ronn.js

@ -4,7 +4,7 @@
*/
var md = require(__dirname + '/ext/markdown');
var sys = require('sys');
var util = require('util');
/* exports Ronn class
* usage :
@ -36,7 +36,7 @@ exports.Ronn = function(text, version, manual, date) {
function blockFilter(out, node, context) {
if (typeof node == "string") {
if (!node.match(/^\s*$/m)) sys.debug("unexpected text: " + node);
if (!node.match(/^\s*$/m)) util.debug("unexpected text: " + node);
return out;
}
var tag = node.shift();
@ -150,7 +150,7 @@ exports.Ronn = function(text, version, manual, date) {
out += "\n";
break;
default:
sys.debug("unrecognized block tag: " + tag);
util.debug("unrecognized block tag: " + tag);
break;
}
context.parent = fParent;
@ -235,7 +235,7 @@ exports.Ronn = function(text, version, manual, date) {
}
break;
default:
sys.debug("unrecognized inline tag: " + tag);
util.debug("unrecognized inline tag: " + tag);
break;
}
context.parent = fParent;

Loading…
Cancel
Save