Showing with 439 additions and 389 deletions.
  1. +10 −10 lib/_debugger.js
  2. +1 −1 lib/_http_agent.js
  3. +5 −5 lib/_http_client.js
  4. +4 −4 lib/_http_incoming.js
  5. +8 −8 lib/_http_outgoing.js
  6. +5 −5 lib/_http_server.js
  7. +10 −10 lib/_stream_readable.js
  8. +3 −3 lib/_stream_transform.js
  9. +13 −11 lib/_stream_writable.js
  10. +7 −7 lib/_tls_legacy.js
  11. +9 −9 lib/_tls_wrap.js
  12. +10 −10 lib/assert.js
  13. +17 −17 lib/buffer.js
  14. +23 −23 lib/child_process.js
  15. +10 −10 lib/cluster.js
  16. +1 −1 lib/console.js
  17. +5 −5 lib/crypto.js
  18. +9 −9 lib/dgram.js
  19. +3 −3 lib/dns.js
  20. +1 −1 lib/domain.js
  21. +19 −17 lib/events.js
  22. +72 −72 lib/fs.js
  23. +6 −6 lib/https.js
  24. +3 −2 lib/module.js
  25. +29 −29 lib/net.js
  26. +5 −5 lib/path.js
  27. +10 −9 lib/querystring.js
  28. +12 −12 lib/readline.js
  29. +14 −13 lib/repl.js
  30. +4 −3 lib/smalloc.js
  31. +1 −1 lib/stream.js
  32. +4 −4 lib/tls.js
  33. +11 −8 lib/url.js
  34. +81 −26 lib/util.js
  35. +2 −1 lib/vm.js
  36. +12 −12 lib/zlib.js
  37. +0 −1 node.gyp
  38. +0 −16 src/macros.py
@@ -182,7 +182,7 @@ exports.Client = Client;


Client.prototype._addHandle = function(desc) {
if (!IS_OBJECT(desc) || !IS_NUMBER(desc.handle)) {
if (!util.isObject(desc) || !util.isNumber(desc.handle)) {
return;
}

@@ -296,7 +296,7 @@ Client.prototype.reqLookup = function(refs, cb) {
this.req(req, function(err, res) {
if (err) return cb(err);
for (var ref in res) {
if (IS_OBJECT(res[ref])) {
if (util.isObject(res[ref])) {
self._addHandle(res[ref]);
}
}
@@ -559,7 +559,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
}


if (IS_ARRAY(mirror) && !IS_NUMBER(prop.name)) {
if (util.isArray(mirror) && !util.isNumber(prop.name)) {
// Skip the 'length' property.
return;
}
@@ -592,7 +592,7 @@ Client.prototype.mirrorObject = function(handle, depth, cb) {
val = function() {};
} else if (handle.type === 'null') {
val = null;
} else if (!IS_UNDEFINED(handle.value)) {
} else if (!util.isUndefined(handle.value)) {
val = handle.value;
} else if (handle.type === 'undefined') {
val = undefined;
@@ -891,7 +891,7 @@ Interface.prototype.print = function(text, oneline) {
if (this.killed) return;
this.clearline();

this.stdout.write(IS_STRING(text) ? text : util.inspect(text));
this.stdout.write(util.isString(text) ? text : util.inspect(text));

if (oneline !== true) {
this.stdout.write('\n');
@@ -1213,7 +1213,7 @@ Interface.prototype.scripts = function() {
this.pause();
for (var id in client.scripts) {
var script = client.scripts[id];
if (IS_OBJECT(script) && script.name) {
if (util.isObject(script) && script.name) {
if (displayNatives ||
script.name == client.currentScript ||
!script.isNative) {
@@ -1350,13 +1350,13 @@ Interface.prototype.setBreakpoint = function(script, line,
ambiguous;

// setBreakpoint() should insert breakpoint on current line
if (IS_UNDEFINED(script)) {
if (util.isUndefined(script)) {
script = this.client.currentScript;
line = this.client.currentSourceLine + 1;
}

// setBreakpoint(line-number) should insert breakpoint in current script
if (IS_UNDEFINED(line) && IS_NUMBER(script)) {
if (util.isUndefined(line) && util.isNumber(script)) {
line = script;
script = this.client.currentScript;
}
@@ -1451,7 +1451,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {
if (bp.scriptId === script ||
bp.scriptReq === script ||
(bp.script && bp.script.indexOf(script) !== -1)) {
if (!IS_UNDEFINED(index)) {
if (!util.isUndefined(index)) {
ambiguous = true;
}
if (bp.line === line) {
@@ -1464,7 +1464,7 @@ Interface.prototype.clearBreakpoint = function(script, line) {

if (ambiguous) return this.error('Script name is ambiguous');

if (IS_UNDEFINED(breakpoint)) {
if (util.isUndefined(breakpoint)) {
return this.error('Script : ' + script + ' not found');
}

@@ -246,7 +246,7 @@ Agent.prototype.destroy = function() {
};

Agent.prototype.request = function(options, cb) {
if (IS_STRING(options)) {
if (util.isString(options)) {
options = url.parse(options);
}
// don't try to do dns lookups of foo.com:8080, just foo.com
@@ -44,14 +44,14 @@ function ClientRequest(options, cb) {
var self = this;
OutgoingMessage.call(self);

self.agent = IS_UNDEFINED(options.agent) ? globalAgent : options.agent;
self.agent = util.isUndefined(options.agent) ? globalAgent : options.agent;

var defaultPort = options.defaultPort || 80;

var port = options.port || defaultPort;
var host = options.hostname || options.host || 'localhost';

if (IS_UNDEFINED(options.setHost)) {
if (util.isUndefined(options.setHost)) {
var setHost = true;
}

@@ -63,7 +63,7 @@ function ClientRequest(options, cb) {
self.once('response', cb);
}

if (!IS_ARRAY(options.headers)) {
if (!util.isArray(options.headers)) {
if (options.headers) {
var keys = Object.keys(options.headers);
for (var i = 0, l = keys.length; i < l; i++) {
@@ -92,7 +92,7 @@ function ClientRequest(options, cb) {
self.useChunkedEncodingByDefault = true;
}

if (IS_ARRAY(options.headers)) {
if (util.isArray(options.headers)) {
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n',
options.headers);
} else if (self.getHeader('expect')) {
@@ -413,7 +413,7 @@ ClientRequest.prototype.onSocket = function(socket) {
httpSocketSetup(socket);

// Propagate headers limit from request object to parser
if (IS_NUMBER(req.maxHeadersCount)) {
if (util.isNumber(req.maxHeadersCount)) {
parser.maxHeaderPairs = req.maxHeadersCount << 1;
} else {
// Set default value because parser may be reused from FreeList
@@ -125,7 +125,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) {
switch (field) {
// Array headers:
case 'set-cookie':
if (!IS_UNDEFINED(dest[field])) {
if (!util.isUndefined(dest[field])) {
dest[field].push(value);
} else {
dest[field] = [value];
@@ -145,7 +145,7 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) {
case 'proxy-authenticate':
case 'sec-websocket-extensions':
case 'sec-websocket-protocol':
if (!IS_UNDEFINED(dest[field])) {
if (!util.isUndefined(dest[field])) {
dest[field] += ', ' + value;
} else {
dest[field] = value;
@@ -156,14 +156,14 @@ IncomingMessage.prototype._addHeaderLine = function(field, value) {
default:
if (field.slice(0, 2) == 'x-') {
// except for x-
if (!IS_UNDEFINED(dest[field])) {
if (!util.isUndefined(dest[field])) {
dest[field] += ', ' + value;
} else {
dest[field] = value;
}
} else {
// drop duplicates
if (IS_UNDEFINED(dest[field])) dest[field] = value;
if (util.isUndefined(dest[field])) dest[field] = value;
}
break;
}
@@ -115,7 +115,7 @@ OutgoingMessage.prototype._send = function(data, encoding) {
// the same packet. Future versions of Node are going to take care of
// this at a lower level and in a more general way.
if (!this._headerSent) {
if (IS_STRING(data)) {
if (util.isString(data)) {
data = this._header + data;
} else {
this.output.unshift(this._header);
@@ -166,7 +166,7 @@ OutgoingMessage.prototype._buffer = function(data, encoding) {

var length = this.output.length;

if (length === 0 || !IS_STRING(data)) {
if (length === 0 || !util.isString(data)) {
this.output.push(data);
this.outputEncodings.push(encoding);
return false;
@@ -205,7 +205,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {

if (headers) {
var keys = Object.keys(headers);
var isArray = IS_ARRAY(headers);
var isArray = util.isArray(headers);
var field, value;

for (var i = 0, l = keys.length; i < l; i++) {
@@ -218,7 +218,7 @@ OutgoingMessage.prototype._storeHeader = function(firstLine, headers) {
value = headers[key];
}

if (IS_ARRAY(value)) {
if (util.isArray(value)) {
for (var j = 0; j < value.length; j++) {
storeHeader(this, state, field, value[j]);
}
@@ -401,7 +401,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) {
return true;
}

if (!IS_STRING(chunk) && !IS_BUFFER(chunk)) {
if (!util.isString(chunk) && !util.isBuffer(chunk)) {
throw new TypeError('first argument must be a string or Buffer');
}

@@ -412,7 +412,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) {

var len, ret;
if (this.chunkedEncoding) {
if (IS_STRING(chunk) &&
if (util.isString(chunk) &&
encoding !== 'hex' &&
encoding !== 'base64' &&
encoding !== 'binary') {
@@ -444,7 +444,7 @@ OutgoingMessage.prototype.write = function(chunk, encoding) {
OutgoingMessage.prototype.addTrailers = function(headers) {
this._trailer = '';
var keys = Object.keys(headers);
var isArray = IS_ARRAY(headers);
var isArray = util.isArray(headers);
var field, value;
for (var i = 0, l = keys.length; i < l; i++) {
var key = keys[i];
@@ -466,7 +466,7 @@ var crlf_buf = new Buffer('\r\n');


OutgoingMessage.prototype.end = function(data, encoding) {
if (data && !IS_STRING(data) && !IS_BUFFER(data)) {
if (data && !util.isString(data) && !util.isBuffer(data)) {
throw new TypeError('first argument must be a string or Buffer');
}

@@ -173,7 +173,7 @@ ServerResponse.prototype._implicitHeader = function() {
ServerResponse.prototype.writeHead = function(statusCode) {
var reasonPhrase, headers, headerIndex;

if (IS_STRING(arguments[1])) {
if (util.isString(arguments[1])) {
reasonPhrase = arguments[1];
headerIndex = 2;
} else {
@@ -188,13 +188,13 @@ ServerResponse.prototype.writeHead = function(statusCode) {
// Slow-case: when progressive API and header fields are passed.
headers = this._renderHeaders();

if (IS_ARRAY(obj)) {
if (util.isArray(obj)) {
// handle array case
// TODO: remove when array is no longer accepted
var field;
for (var i = 0, len = obj.length; i < len; ++i) {
field = obj[i][0];
if (!IS_UNDEFINED(headers[field])) {
if (!util.isUndefined(headers[field])) {
obj.push([field, headers[field]]);
}
}
@@ -332,7 +332,7 @@ function connectionListener(socket) {
parser.incoming = null;

// Propagate headers limit from server instance to parser
if (IS_NUMBER(this.maxHeadersCount)) {
if (util.isNumber(this.maxHeadersCount)) {
parser.maxHeaderPairs = this.maxHeadersCount << 1;
} else {
// Set default value because parser may be reused from FreeList
@@ -442,7 +442,7 @@ function connectionListener(socket) {
}
});

if (!IS_UNDEFINED(req.headers.expect) &&
if (!util.isUndefined(req.headers.expect) &&
(req.httpVersionMajor == 1 && req.httpVersionMinor == 1) &&
continueExpression.test(req.headers['expect'])) {
res._expect_continue = true;
@@ -111,7 +111,7 @@ function Readable(options) {
Readable.prototype.push = function(chunk, encoding) {
var state = this._readableState;

if (IS_STRING(chunk) && !state.objectMode) {
if (util.isString(chunk) && !state.objectMode) {
encoding = encoding || state.defaultEncoding;
if (encoding !== state.encoding) {
chunk = new Buffer(chunk, encoding);
@@ -132,7 +132,7 @@ function readableAddChunk(stream, state, chunk, encoding, addToFront) {
var er = chunkInvalid(state, chunk);
if (er) {
stream.emit('error', er);
} else if (IS_NULL_OR_UNDEFINED(chunk)) {
} else if (util.isNullOrUndefined(chunk)) {
state.reading = false;
if (!state.ended)
onEofChunk(stream, state);
@@ -213,7 +213,7 @@ function howMuchToRead(n, state) {
if (state.objectMode)
return n === 0 ? 0 : 1;

if (isNaN(n) || IS_NULL(n)) {
if (isNaN(n) || util.isNull(n)) {
// only flow one buffer at a time
if (state.flowing && state.buffer.length)
return state.buffer[0].length;
@@ -249,7 +249,7 @@ Readable.prototype.read = function(n) {
var state = this._readableState;
var nOrig = n;

if (!IS_NUMBER(n) || n > 0)
if (!util.isNumber(n) || n > 0)
state.emittedReadable = false;

// if we're doing read(0) to trigger a readable event, but we
@@ -337,7 +337,7 @@ Readable.prototype.read = function(n) {
else
ret = null;

if (IS_NULL(ret)) {
if (util.isNull(ret)) {
state.needReadable = true;
n = 0;
}
@@ -353,17 +353,17 @@ Readable.prototype.read = function(n) {
if (nOrig !== n && state.ended && state.length === 0)
endReadable(this);

if (!IS_NULL(ret))
if (!util.isNull(ret))
this.emit('data', ret);

return ret;
};

function chunkInvalid(state, chunk) {
var er = null;
if (!IS_BUFFER(chunk) &&
!IS_STRING(chunk) &&
!IS_NULL_OR_UNDEFINED(chunk) &&
if (!util.isBuffer(chunk) &&
!util.isString(chunk) &&
!util.isNullOrUndefined(chunk) &&
!state.objectMode &&
!er) {
er = new TypeError('Invalid non-string/buffer chunk');
@@ -761,7 +761,7 @@ Readable.prototype.wrap = function(stream) {
// proxy all the other methods.
// important when wrapping filters and duplexes.
for (var i in stream) {
if (IS_FUNCTION(stream[i]) && IS_UNDEFINED(this[i])) {
if (util.isFunction(stream[i]) && util.isUndefined(this[i])) {
this[i] = function(method) { return function() {
return stream[method].apply(stream, arguments);
}}(i);
@@ -92,7 +92,7 @@ function afterTransform(stream, er, data) {
ts.writechunk = null;
ts.writecb = null;

if (!IS_NULL_OR_UNDEFINED(data))
if (!util.isNullOrUndefined(data))
stream.push(data);

if (cb)
@@ -126,7 +126,7 @@ function Transform(options) {
this._readableState.sync = false;

this.once('prefinish', function() {
if (IS_FUNCTION(this._flush))
if (util.isFunction(this._flush))
this._flush(function(er) {
done(stream, er);
});
@@ -174,7 +174,7 @@ Transform.prototype._write = function(chunk, encoding, cb) {
Transform.prototype._read = function(n) {
var ts = this._transformState;

if (!IS_NULL(ts.writechunk) && ts.writecb && !ts.transforming) {
if (!util.isNull(ts.writechunk) && ts.writecb && !ts.transforming) {
ts.transforming = true;
this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
} else {