Skip to content

Commit d62b0f4

Browse files
committed
Fix style in sys.js
1 parent f86a214 commit d62b0f4

1 file changed

Lines changed: 34 additions & 8 deletions

File tree

lib/sys.js

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
var events = require('events');
22

3+
34
exports.print = function () {
45
for (var i = 0, len = arguments.length; i < len; ++i) {
56
process.stdout.write(arguments[i]);
67
}
78
};
89

10+
911
exports.puts = function () {
1012
for (var i = 0, len = arguments.length; i < len; ++i) {
1113
process.stdout.write(arguments[i] + '\n');
1214
}
1315
};
1416

17+
1518
exports.debug = function (x) {
1619
process.binding('stdio').writeError("DEBUG: " + x + "\n");
1720
};
1821

22+
1923
var error = exports.error = function (x) {
2024
for (var i = 0, len = arguments.length; i < len; ++i) {
2125
process.binding('stdio').writeError(arguments[i] + '\n');
2226
}
2327
};
2428

29+
2530
/**
2631
* Echos the value of a value. Trys to print the value out
2732
* in the best way possible given the different types.
2833
*
2934
* @param {Object} value The object to print out
30-
* @param {Boolean} showHidden Flag that shows hidden (not enumerable) properties of objects.
35+
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
36+
* properties of objects.
3137
*/
3238
exports.inspect = function (obj, showHidden, depth) {
3339
var seen = [];
@@ -45,7 +51,9 @@ exports.inspect = function (obj, showHidden, depth) {
4551
// Primitive types cannot have properties
4652
switch (typeof value) {
4753
case 'undefined': return 'undefined';
48-
case 'string': return JSON.stringify(value).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
54+
case 'string': return JSON.stringify(value).replace(/'/g, "\\'")
55+
.replace(/\\"/g, '"')
56+
.replace(/(^"|"$)/g, "'");
4957
case 'number': return '' + value;
5058
case 'boolean': return '' + value;
5159
}
@@ -164,7 +172,9 @@ exports.inspect = function (obj, showHidden, depth) {
164172
name = name.substr(1, name.length-2);
165173
}
166174
else {
167-
name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
175+
name = name.replace(/'/g, "\\'")
176+
.replace(/\\"/g, '"')
177+
.replace(/(^"|"$)/g, "'");
168178
}
169179
}
170180

@@ -181,7 +191,13 @@ exports.inspect = function (obj, showHidden, depth) {
181191
},0);
182192

183193
if (length > 50) {
184-
output = braces[0] + (base === '' ? '' : base + '\n ') + ' ' + output.join('\n, ') + (numLinesEst > 1 ? '\n' : ' ') + braces[1];
194+
output = braces[0]
195+
+ (base === '' ? '' : base + '\n ')
196+
+ ' '
197+
+ output.join('\n, ')
198+
+ (numLinesEst > 1 ? '\n' : ' ')
199+
+ braces[1]
200+
;
185201
}
186202
else {
187203
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
@@ -191,11 +207,15 @@ exports.inspect = function (obj, showHidden, depth) {
191207
}
192208
return format(obj, (typeof depth === 'undefined' ? 2 : depth));
193209
};
210+
211+
194212
function isArray (ar) {
195213
return ar instanceof Array
196214
|| Array.isArray(ar)
197215
|| (ar && ar !== Object.prototype && isArray(ar.__proto__));
198216
}
217+
218+
199219
function isRegExp (re) {
200220
var s = ""+re;
201221
return re instanceof RegExp // easy case
@@ -207,6 +227,8 @@ function isRegExp (re) {
207227
&& s.charAt(0) === "/"
208228
&& s.substr(-1) === "/";
209229
}
230+
231+
210232
function isDate (d) {
211233
if (d instanceof Date) return true;
212234
if (typeof d !== "object") return false;
@@ -215,6 +237,7 @@ function isDate (d) {
215237
return JSON.stringify(proto) === JSON.stringify(properties);
216238
}
217239

240+
218241
var pWarning;
219242

220243
exports.p = function () {
@@ -227,10 +250,12 @@ exports.p = function () {
227250
}
228251
};
229252

253+
230254
function pad (n) {
231255
return n < 10 ? '0' + n.toString(10) : n.toString(10);
232256
}
233257

258+
234259
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
235260

236261
// 26 Feb 16:19:34
@@ -242,9 +267,11 @@ function timestamp () {
242267
].join(' ');
243268
}
244269

270+
245271
exports.log = function (msg) {
246272
exports.puts(timestamp() + ' - ' + msg.toString());
247-
}
273+
};
274+
248275

249276
var execWarning;
250277
exports.exec = function () {
@@ -253,7 +280,8 @@ exports.exec = function () {
253280
error(execWarning);
254281
}
255282
return require('child_process').exec.apply(this, arguments);
256-
}
283+
};
284+
257285

258286
/**
259287
* Inherit the prototype methods from one constructor into another.
@@ -275,5 +303,3 @@ exports.inherits = function (ctor, superCtor) {
275303
ctor.prototype = new tempCtor();
276304
ctor.prototype.constructor = ctor;
277305
};
278-
279-

0 commit comments

Comments
 (0)