|
|
@ -16,7 +16,7 @@ exports.puts = function () { |
|
|
|
|
|
|
|
|
|
|
|
exports.debug = function(x) { |
|
|
|
process.binding('stdio').writeError("DEBUG: " + x + "\n"); |
|
|
|
process.binding('stdio').writeError('DEBUG: ' + x + '\n'); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -31,7 +31,7 @@ var error = exports.error = function (x) { |
|
|
|
* 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 {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. |
|
|
@ -57,15 +57,15 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
, 'red' : [31, 39] |
|
|
|
, 'yellow' : [33, 39] |
|
|
|
}; |
|
|
|
var style = { "special": "grey" |
|
|
|
, "number": "blue" |
|
|
|
, "boolean": "blue" |
|
|
|
, "undefined": "red" |
|
|
|
, "null": "red" |
|
|
|
, "string": "green" |
|
|
|
, "date": "magenta" |
|
|
|
var style = { 'special': 'grey' |
|
|
|
, 'number': 'blue' |
|
|
|
, 'boolean': 'blue' |
|
|
|
, 'undefined': 'red' |
|
|
|
, 'null': 'red' |
|
|
|
, 'string': 'green' |
|
|
|
, 'date': 'magenta' |
|
|
|
//, "name": intentionally not styling
|
|
|
|
, "regexp": "cyan" |
|
|
|
, 'regexp': 'cyan' |
|
|
|
}[styleType]; |
|
|
|
if (style) { |
|
|
|
return '\033[' + styles[style][0] + 'm' + str + |
|
|
@ -127,17 +127,17 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
// Determine the object type
|
|
|
|
if (isArray(value)) { |
|
|
|
type = 'Array'; |
|
|
|
braces = ["[", "]"]; |
|
|
|
braces = ['[', ']']; |
|
|
|
} else { |
|
|
|
type = 'Object'; |
|
|
|
braces = ["{", "}"]; |
|
|
|
braces = ['{', '}']; |
|
|
|
} |
|
|
|
|
|
|
|
// Make functions say that they are functions
|
|
|
|
if (typeof value === 'function') { |
|
|
|
base = (isRegExp(value)) ? ' ' + value : ' [Function' + (value.name ? ': ' + value.name : '') + ']'; |
|
|
|
} else { |
|
|
|
base = ""; |
|
|
|
base = ''; |
|
|
|
} |
|
|
|
|
|
|
|
// Make dates with properties first say the date
|
|
|
@ -151,9 +151,9 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
|
|
|
|
if (recurseTimes < 0) { |
|
|
|
if (isRegExp(value)) { |
|
|
|
return stylize('' + value, "regexp"); |
|
|
|
return stylize('' + value, 'regexp'); |
|
|
|
} else { |
|
|
|
return stylize("[Object]", "special"); |
|
|
|
return stylize('[Object]', 'special'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -164,18 +164,18 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
if (value.__lookupGetter__) { |
|
|
|
if (value.__lookupGetter__(key)) { |
|
|
|
if (value.__lookupSetter__(key)) { |
|
|
|
str = stylize("[Getter/Setter]", "special"); |
|
|
|
str = stylize('[Getter/Setter]', 'special'); |
|
|
|
} else { |
|
|
|
str = stylize("[Getter]", "special"); |
|
|
|
str = stylize('[Getter]', 'special'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (value.__lookupSetter__(key)) { |
|
|
|
str = stylize("[Setter]", "special"); |
|
|
|
str = stylize('[Setter]', 'special'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (visible_keys.indexOf(key) < 0) { |
|
|
|
name = "[" + key + "]"; |
|
|
|
name = '[' + key + ']'; |
|
|
|
} |
|
|
|
if (!str) { |
|
|
|
if (seen.indexOf(value[key]) < 0) { |
|
|
@ -206,16 +206,16 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
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"); |
|
|
|
name = stylize(name, 'name'); |
|
|
|
} else { |
|
|
|
name = name.replace(/'/g, "\\'") |
|
|
|
.replace(/\\"/g, '"') |
|
|
|
.replace(/(^"|"$)/g, "'"); |
|
|
|
name = stylize(name, "string"); |
|
|
|
name = stylize(name, 'string'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return name + ": " + str; |
|
|
|
return name + ': ' + str; |
|
|
|
}); |
|
|
|
|
|
|
|
seen.pop(); |
|
|
@ -235,8 +235,8 @@ exports.inspect = function (obj, showHidden, depth, colors) { |
|
|
|
+ ' ' |
|
|
|
+ output.join(',\n ') |
|
|
|
+ ' ' |
|
|
|
+ braces[1] |
|
|
|
; |
|
|
|
+ braces[1]; |
|
|
|
|
|
|
|
} else { |
|
|
|
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; |
|
|
|
} |
|
|
@ -255,10 +255,10 @@ function isArray (ar) { |
|
|
|
|
|
|
|
|
|
|
|
function isRegExp(re) { |
|
|
|
var s = ""+re; |
|
|
|
var s = ''+ re; |
|
|
|
return re instanceof RegExp // easy case
|
|
|
|
|| typeof(re) === "function" // duck-type for context-switching evalcx case
|
|
|
|
&& re.constructor.name === "RegExp" |
|
|
|
|| typeof(re) === 'function' // duck-type for context-switching evalcx case
|
|
|
|
&& re.constructor.name === 'RegExp' |
|
|
|
&& re.compile |
|
|
|
&& re.test |
|
|
|
&& re.exec |
|
|
@ -268,7 +268,7 @@ function isRegExp (re) { |
|
|
|
|
|
|
|
function isDate(d) { |
|
|
|
if (d instanceof Date) return true; |
|
|
|
if (typeof d !== "object") return false; |
|
|
|
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); |
|
|
@ -279,7 +279,7 @@ 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"; |
|
|
|
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) { |
|
|
@ -330,39 +330,39 @@ exports.pump = function (readStream, writeStream, callback) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!readStream.pause) readStream.pause = function () {readStream.emit("pause");}; |
|
|
|
if (!readStream.resume) readStream.resume = function () {readStream.emit("resume");}; |
|
|
|
if (!readStream.pause) readStream.pause = function() {readStream.emit('pause');}; |
|
|
|
if (!readStream.resume) readStream.resume = function() {readStream.emit('resume');}; |
|
|
|
|
|
|
|
readStream.addListener("data", function (chunk) { |
|
|
|
readStream.addListener('data', function(chunk) { |
|
|
|
if (writeStream.write(chunk) === false) readStream.pause(); |
|
|
|
}); |
|
|
|
|
|
|
|
writeStream.addListener("pause", function () { |
|
|
|
writeStream.addListener('pause', function() { |
|
|
|
readStream.pause(); |
|
|
|
}); |
|
|
|
|
|
|
|
writeStream.addListener("drain", function () { |
|
|
|
writeStream.addListener('drain', function() { |
|
|
|
readStream.resume(); |
|
|
|
}); |
|
|
|
|
|
|
|
writeStream.addListener("resume", function () { |
|
|
|
writeStream.addListener('resume', function() { |
|
|
|
readStream.resume(); |
|
|
|
}); |
|
|
|
|
|
|
|
readStream.addListener("end", function () { |
|
|
|
readStream.addListener('end', function() { |
|
|
|
writeStream.end(); |
|
|
|
}); |
|
|
|
|
|
|
|
readStream.addListener("close", function () { |
|
|
|
readStream.addListener('close', function() { |
|
|
|
call(); |
|
|
|
}); |
|
|
|
|
|
|
|
readStream.addListener("error", function (err) { |
|
|
|
readStream.addListener('error', function(err) { |
|
|
|
writeStream.end(); |
|
|
|
call(err); |
|
|
|
}); |
|
|
|
|
|
|
|
writeStream.addListener("error", function (err) { |
|
|
|
writeStream.addListener('error', function(err) { |
|
|
|
readStream.destroy(); |
|
|
|
call(err); |
|
|
|
}); |
|
|
@ -378,8 +378,8 @@ exports.pump = function (readStream, writeStream, callback) { |
|
|
|
* 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 |
|
|
|
* prototype. |
|
|
|
* @param {function} superCtor Constructor function to inherit prototype from. |
|
|
|
*/ |
|
|
|
exports.inherits = function(ctor, superCtor) { |
|
|
|
ctor.super_ = superCtor; |
|
|
|