autobench 0.0.1alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +16 -0
- data/README.md +123 -0
- data/bin/autobench +180 -0
- data/bin/autobench-config +162 -0
- data/lib/autobench.rb +28 -0
- data/lib/autobench/client.rb +78 -0
- data/lib/autobench/common.rb +49 -0
- data/lib/autobench/config.rb +62 -0
- data/lib/autobench/render.rb +102 -0
- data/lib/autobench/version.rb +3 -0
- data/lib/autobench/yslow.rb +75 -0
- data/lib/phantomas/README.md +296 -0
- data/lib/phantomas/core/formatter.js +65 -0
- data/lib/phantomas/core/helper.js +64 -0
- data/lib/phantomas/core/modules/requestsMonitor/requestsMonitor.js +214 -0
- data/lib/phantomas/core/pads.js +16 -0
- data/lib/phantomas/core/phantomas.js +418 -0
- data/lib/phantomas/lib/args.js +27 -0
- data/lib/phantomas/lib/modules/_coffee-script.js +2 -0
- data/lib/phantomas/lib/modules/assert.js +326 -0
- data/lib/phantomas/lib/modules/events.js +216 -0
- data/lib/phantomas/lib/modules/http.js +55 -0
- data/lib/phantomas/lib/modules/path.js +441 -0
- data/lib/phantomas/lib/modules/punycode.js +510 -0
- data/lib/phantomas/lib/modules/querystring.js +214 -0
- data/lib/phantomas/lib/modules/tty.js +7 -0
- data/lib/phantomas/lib/modules/url.js +625 -0
- data/lib/phantomas/lib/modules/util.js +520 -0
- data/lib/phantomas/modules/ajaxRequests/ajaxRequests.js +15 -0
- data/lib/phantomas/modules/assetsTypes/assetsTypes.js +21 -0
- data/lib/phantomas/modules/cacheHits/cacheHits.js +28 -0
- data/lib/phantomas/modules/caching/caching.js +66 -0
- data/lib/phantomas/modules/cookies/cookies.js +54 -0
- data/lib/phantomas/modules/domComplexity/domComplexity.js +130 -0
- data/lib/phantomas/modules/domQueries/domQueries.js +148 -0
- data/lib/phantomas/modules/domains/domains.js +49 -0
- data/lib/phantomas/modules/globalVariables/globalVariables.js +44 -0
- data/lib/phantomas/modules/headers/headers.js +48 -0
- data/lib/phantomas/modules/localStorage/localStorage.js +14 -0
- data/lib/phantomas/modules/requestsStats/requestsStats.js +71 -0
- data/lib/phantomas/modules/staticAssets/staticAssets.js +40 -0
- data/lib/phantomas/modules/waterfall/waterfall.js +62 -0
- data/lib/phantomas/modules/windowPerformance/windowPerformance.js +36 -0
- data/lib/phantomas/package.json +27 -0
- data/lib/phantomas/phantomas.js +35 -0
- data/lib/phantomas/run-multiple.js +177 -0
- data/lib/yslow.js +5 -0
- metadata +135 -0
@@ -0,0 +1,520 @@
|
|
1
|
+
// Copyright Joyent, Inc. and other Node contributors.
|
2
|
+
//
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
// copy of this software and associated documentation files (the
|
5
|
+
// "Software"), to deal in the Software without restriction, including
|
6
|
+
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
+
// persons to whom the Software is furnished to do so, subject to the
|
9
|
+
// following conditions:
|
10
|
+
//
|
11
|
+
// The above copyright notice and this permission notice shall be included
|
12
|
+
// in all copies or substantial portions of the Software.
|
13
|
+
//
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
17
|
+
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
+
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
19
|
+
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
20
|
+
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
var formatRegExp = /%[sdj%]/g;
|
23
|
+
exports.format = function(f) {
|
24
|
+
if (typeof f !== 'string') {
|
25
|
+
var objects = [];
|
26
|
+
for (var i = 0; i < arguments.length; i++) {
|
27
|
+
objects.push(inspect(arguments[i]));
|
28
|
+
}
|
29
|
+
return objects.join(' ');
|
30
|
+
}
|
31
|
+
|
32
|
+
var i = 1;
|
33
|
+
var args = arguments;
|
34
|
+
var len = args.length;
|
35
|
+
var str = String(f).replace(formatRegExp, function(x) {
|
36
|
+
if (i >= len) return x;
|
37
|
+
switch (x) {
|
38
|
+
case '%s': return String(args[i++]);
|
39
|
+
case '%d': return Number(args[i++]);
|
40
|
+
case '%j': return JSON.stringify(args[i++]);
|
41
|
+
case '%%': return '%';
|
42
|
+
default:
|
43
|
+
return x;
|
44
|
+
}
|
45
|
+
});
|
46
|
+
for (var x = args[i]; i < len; x = args[++i]) {
|
47
|
+
if (x === null || typeof x !== 'object') {
|
48
|
+
str += ' ' + x;
|
49
|
+
} else {
|
50
|
+
str += ' ' + inspect(x);
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return str;
|
54
|
+
};
|
55
|
+
|
56
|
+
|
57
|
+
exports.print = function() {
|
58
|
+
for (var i = 0, len = arguments.length; i < len; ++i) {
|
59
|
+
process.stdout.write(String(arguments[i]));
|
60
|
+
}
|
61
|
+
};
|
62
|
+
|
63
|
+
|
64
|
+
exports.puts = function() {
|
65
|
+
for (var i = 0, len = arguments.length; i < len; ++i) {
|
66
|
+
process.stdout.write(arguments[i] + '\n');
|
67
|
+
}
|
68
|
+
};
|
69
|
+
|
70
|
+
|
71
|
+
exports.debug = function(x) {
|
72
|
+
process.stderr.write('DEBUG: ' + x + '\n');
|
73
|
+
};
|
74
|
+
|
75
|
+
|
76
|
+
var error = exports.error = function(x) {
|
77
|
+
for (var i = 0, len = arguments.length; i < len; ++i) {
|
78
|
+
process.stderr.write(arguments[i] + '\n');
|
79
|
+
}
|
80
|
+
};
|
81
|
+
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Echos the value of a value. Trys to print the value out
|
85
|
+
* in the best way possible given the different types.
|
86
|
+
*
|
87
|
+
* @param {Object} obj The object to print out.
|
88
|
+
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
|
89
|
+
* properties of objects.
|
90
|
+
* @param {Number} depth Depth in which to descend in object. Default is 2.
|
91
|
+
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
|
92
|
+
* output. Default is false (no coloring).
|
93
|
+
*/
|
94
|
+
function inspect(obj, showHidden, depth, colors) {
|
95
|
+
var ctx = {
|
96
|
+
showHidden: showHidden,
|
97
|
+
seen: [],
|
98
|
+
stylize: colors ? stylizeWithColor : stylizeNoColor
|
99
|
+
};
|
100
|
+
return formatValue(ctx, obj, (typeof depth === 'undefined' ? 2 : depth));
|
101
|
+
}
|
102
|
+
exports.inspect = inspect;
|
103
|
+
|
104
|
+
|
105
|
+
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
106
|
+
var colors = {
|
107
|
+
'bold' : [1, 22],
|
108
|
+
'italic' : [3, 23],
|
109
|
+
'underline' : [4, 24],
|
110
|
+
'inverse' : [7, 27],
|
111
|
+
'white' : [37, 39],
|
112
|
+
'grey' : [90, 39],
|
113
|
+
'black' : [30, 39],
|
114
|
+
'blue' : [34, 39],
|
115
|
+
'cyan' : [36, 39],
|
116
|
+
'green' : [32, 39],
|
117
|
+
'magenta' : [35, 39],
|
118
|
+
'red' : [31, 39],
|
119
|
+
'yellow' : [33, 39]
|
120
|
+
};
|
121
|
+
|
122
|
+
// Don't use 'blue' not visible on cmd.exe
|
123
|
+
var styles = {
|
124
|
+
'special': 'cyan',
|
125
|
+
'number': 'yellow',
|
126
|
+
'boolean': 'yellow',
|
127
|
+
'undefined': 'grey',
|
128
|
+
'null': 'bold',
|
129
|
+
'string': 'green',
|
130
|
+
'date': 'magenta',
|
131
|
+
// "name": intentionally not styling
|
132
|
+
'regexp': 'red'
|
133
|
+
};
|
134
|
+
|
135
|
+
|
136
|
+
function stylizeWithColor(str, styleType) {
|
137
|
+
var style = styles[styleType];
|
138
|
+
|
139
|
+
if (style) {
|
140
|
+
return '\033[' + colors[style][0] + 'm' + str +
|
141
|
+
'\033[' + colors[style][1] + 'm';
|
142
|
+
} else {
|
143
|
+
return str;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
function stylizeNoColor(str, styleType) {
|
149
|
+
return str;
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
function formatValue(ctx, value, recurseTimes) {
|
154
|
+
// Provide a hook for user-specified inspect functions.
|
155
|
+
// Check that value is an object with an inspect function on it
|
156
|
+
if (value && typeof value.inspect === 'function' &&
|
157
|
+
// Filter out the util module, it's inspect function is special
|
158
|
+
value !== exports &&
|
159
|
+
// Also filter out any prototype objects using the circular check.
|
160
|
+
!(value.constructor && value.constructor.prototype === value)) {
|
161
|
+
return value.inspect(recurseTimes);
|
162
|
+
}
|
163
|
+
|
164
|
+
// Primitive types cannot have properties
|
165
|
+
var primitive = formatPrimitive(ctx, value);
|
166
|
+
if (primitive) {
|
167
|
+
return primitive;
|
168
|
+
}
|
169
|
+
|
170
|
+
// Look up the keys of the object.
|
171
|
+
var visibleKeys = Object.keys(value);
|
172
|
+
var keys = ctx.showHidden ? Object.getOwnPropertyNames(value) : visibleKeys;
|
173
|
+
|
174
|
+
// Some type of object without properties can be shortcutted.
|
175
|
+
if (keys.length === 0) {
|
176
|
+
if (typeof value === 'function') {
|
177
|
+
var name = value.name ? ': ' + value.name : '';
|
178
|
+
return ctx.stylize('[Function' + name + ']', 'special');
|
179
|
+
}
|
180
|
+
if (isRegExp(value)) {
|
181
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
182
|
+
}
|
183
|
+
if (isDate(value)) {
|
184
|
+
return ctx.stylize(Date.prototype.toUTCString.call(value), 'date');
|
185
|
+
}
|
186
|
+
if (isError(value)) {
|
187
|
+
return formatError(value);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
var base = '', array = false, braces = ['{', '}'];
|
192
|
+
|
193
|
+
// Make Array say that they are Array
|
194
|
+
if (isArray(value)) {
|
195
|
+
array = true;
|
196
|
+
braces = ['[', ']'];
|
197
|
+
}
|
198
|
+
|
199
|
+
// Make functions say that they are functions
|
200
|
+
if (typeof value === 'function') {
|
201
|
+
var n = value.name ? ': ' + value.name : '';
|
202
|
+
base = ' [Function' + n + ']';
|
203
|
+
}
|
204
|
+
|
205
|
+
// Make RegExps say that they are RegExps
|
206
|
+
if (isRegExp(value)) {
|
207
|
+
base = ' ' + RegExp.prototype.toString.call(value);
|
208
|
+
}
|
209
|
+
|
210
|
+
// Make dates with properties first say the date
|
211
|
+
if (isDate(value)) {
|
212
|
+
base = ' ' + Date.prototype.toUTCString.call(value);
|
213
|
+
}
|
214
|
+
|
215
|
+
// Make error with message first say the error
|
216
|
+
if (isError(value)) {
|
217
|
+
base = ' ' + formatError(value);
|
218
|
+
}
|
219
|
+
|
220
|
+
if (keys.length === 0 && (!array || value.length == 0)) {
|
221
|
+
return braces[0] + base + braces[1];
|
222
|
+
}
|
223
|
+
|
224
|
+
if (recurseTimes < 0) {
|
225
|
+
if (isRegExp(value)) {
|
226
|
+
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
227
|
+
} else {
|
228
|
+
return ctx.stylize('[Object]', 'special');
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
ctx.seen.push(value);
|
233
|
+
|
234
|
+
var output;
|
235
|
+
if (array) {
|
236
|
+
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
237
|
+
} else {
|
238
|
+
output = keys.map(function(key) {
|
239
|
+
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
240
|
+
});
|
241
|
+
}
|
242
|
+
|
243
|
+
ctx.seen.pop();
|
244
|
+
|
245
|
+
return reduceToSingleString(output, base, braces);
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
function formatPrimitive(ctx, value) {
|
250
|
+
switch (typeof value) {
|
251
|
+
case 'undefined':
|
252
|
+
return ctx.stylize('undefined', 'undefined');
|
253
|
+
|
254
|
+
case 'string':
|
255
|
+
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
256
|
+
.replace(/'/g, "\\'")
|
257
|
+
.replace(/\\"/g, '"') + '\'';
|
258
|
+
return ctx.stylize(simple, 'string');
|
259
|
+
|
260
|
+
case 'number':
|
261
|
+
return ctx.stylize('' + value, 'number');
|
262
|
+
|
263
|
+
case 'boolean':
|
264
|
+
return ctx.stylize('' + value, 'boolean');
|
265
|
+
}
|
266
|
+
// For some reason typeof null is "object", so special case here.
|
267
|
+
if (value === null) {
|
268
|
+
return ctx.stylize('null', 'null');
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
function formatError(value) {
|
274
|
+
return '[' + Error.prototype.toString.call(value) + ']';
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
279
|
+
var output = [];
|
280
|
+
for (var i = 0, l = value.length; i < l; ++i) {
|
281
|
+
if (Object.prototype.hasOwnProperty.call(value, String(i))) {
|
282
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
283
|
+
String(i), true));
|
284
|
+
} else {
|
285
|
+
output.push('');
|
286
|
+
}
|
287
|
+
}
|
288
|
+
keys.forEach(function(key) {
|
289
|
+
if (!key.match(/^\d+$/)) {
|
290
|
+
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
291
|
+
key, true));
|
292
|
+
}
|
293
|
+
});
|
294
|
+
return output;
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
299
|
+
var name, str;
|
300
|
+
if (value.__lookupGetter__) {
|
301
|
+
if (value.__lookupGetter__(key)) {
|
302
|
+
if (value.__lookupSetter__(key)) {
|
303
|
+
str = ctx.stylize('[Getter/Setter]', 'special');
|
304
|
+
} else {
|
305
|
+
str = ctx.stylize('[Getter]', 'special');
|
306
|
+
}
|
307
|
+
} else {
|
308
|
+
if (value.__lookupSetter__(key)) {
|
309
|
+
str = ctx.stylize('[Setter]', 'special');
|
310
|
+
}
|
311
|
+
}
|
312
|
+
}
|
313
|
+
if (visibleKeys.indexOf(key) < 0) {
|
314
|
+
name = '[' + key + ']';
|
315
|
+
}
|
316
|
+
if (!str) {
|
317
|
+
if (ctx.seen.indexOf(value[key]) < 0) {
|
318
|
+
if (recurseTimes === null) {
|
319
|
+
str = formatValue(ctx, value[key], null);
|
320
|
+
} else {
|
321
|
+
str = formatValue(ctx, value[key], recurseTimes - 1);
|
322
|
+
}
|
323
|
+
if (str.indexOf('\n') > -1) {
|
324
|
+
if (array) {
|
325
|
+
str = str.split('\n').map(function(line) {
|
326
|
+
return ' ' + line;
|
327
|
+
}).join('\n').substr(2);
|
328
|
+
} else {
|
329
|
+
str = '\n' + str.split('\n').map(function(line) {
|
330
|
+
return ' ' + line;
|
331
|
+
}).join('\n');
|
332
|
+
}
|
333
|
+
}
|
334
|
+
} else {
|
335
|
+
str = ctx.stylize('[Circular]', 'special');
|
336
|
+
}
|
337
|
+
}
|
338
|
+
if (typeof name === 'undefined') {
|
339
|
+
if (array && key.match(/^\d+$/)) {
|
340
|
+
return str;
|
341
|
+
}
|
342
|
+
name = JSON.stringify('' + key);
|
343
|
+
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
344
|
+
name = name.substr(1, name.length - 2);
|
345
|
+
name = ctx.stylize(name, 'name');
|
346
|
+
} else {
|
347
|
+
name = name.replace(/'/g, "\\'")
|
348
|
+
.replace(/\\"/g, '"')
|
349
|
+
.replace(/(^"|"$)/g, "'");
|
350
|
+
name = ctx.stylize(name, 'string');
|
351
|
+
}
|
352
|
+
}
|
353
|
+
|
354
|
+
return name + ': ' + str;
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
function reduceToSingleString(output, base, braces) {
|
359
|
+
var numLinesEst = 0;
|
360
|
+
var length = output.reduce(function(prev, cur) {
|
361
|
+
numLinesEst++;
|
362
|
+
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
363
|
+
return prev + cur.length + 1;
|
364
|
+
}, 0);
|
365
|
+
|
366
|
+
if (length > 60) {
|
367
|
+
return braces[0] +
|
368
|
+
(base === '' ? '' : base + '\n ') +
|
369
|
+
' ' +
|
370
|
+
output.join(',\n ') +
|
371
|
+
' ' +
|
372
|
+
braces[1];
|
373
|
+
}
|
374
|
+
|
375
|
+
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
// NOTE: These type checking functions intentionally don't use `instanceof`
|
380
|
+
// because it is fragile and can be easily faked with `Object.create()`.
|
381
|
+
function isArray(ar) {
|
382
|
+
return Array.isArray(ar) ||
|
383
|
+
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
384
|
+
}
|
385
|
+
exports.isArray = isArray;
|
386
|
+
|
387
|
+
|
388
|
+
function isRegExp(re) {
|
389
|
+
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
390
|
+
}
|
391
|
+
exports.isRegExp = isRegExp;
|
392
|
+
|
393
|
+
|
394
|
+
function isDate(d) {
|
395
|
+
return typeof d === 'object' && objectToString(d) === '[object Date]';
|
396
|
+
}
|
397
|
+
exports.isDate = isDate;
|
398
|
+
|
399
|
+
|
400
|
+
function isError(e) {
|
401
|
+
return typeof e === 'object' && objectToString(e) === '[object Error]';
|
402
|
+
}
|
403
|
+
exports.isError = isError;
|
404
|
+
|
405
|
+
|
406
|
+
function objectToString(o) {
|
407
|
+
return Object.prototype.toString.call(o);
|
408
|
+
}
|
409
|
+
|
410
|
+
|
411
|
+
var pWarning;
|
412
|
+
|
413
|
+
exports.p = function() {
|
414
|
+
if (!pWarning) {
|
415
|
+
pWarning = 'util.p will be removed in future versions of Node. ' +
|
416
|
+
'Use util.puts(util.inspect()) instead.\n';
|
417
|
+
exports.error(pWarning);
|
418
|
+
}
|
419
|
+
for (var i = 0, len = arguments.length; i < len; ++i) {
|
420
|
+
error(exports.inspect(arguments[i]));
|
421
|
+
}
|
422
|
+
};
|
423
|
+
|
424
|
+
|
425
|
+
function pad(n) {
|
426
|
+
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
427
|
+
}
|
428
|
+
|
429
|
+
|
430
|
+
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
431
|
+
'Oct', 'Nov', 'Dec'];
|
432
|
+
|
433
|
+
// 26 Feb 16:19:34
|
434
|
+
function timestamp() {
|
435
|
+
var d = new Date();
|
436
|
+
var time = [pad(d.getHours()),
|
437
|
+
pad(d.getMinutes()),
|
438
|
+
pad(d.getSeconds())].join(':');
|
439
|
+
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
440
|
+
}
|
441
|
+
|
442
|
+
|
443
|
+
exports.log = function(msg) {
|
444
|
+
exports.puts(timestamp() + ' - ' + msg.toString());
|
445
|
+
};
|
446
|
+
|
447
|
+
|
448
|
+
var execWarning;
|
449
|
+
exports.exec = function() {
|
450
|
+
if (!execWarning) {
|
451
|
+
execWarning = 'util.exec has moved to the "child_process" module.' +
|
452
|
+
' Please update your source code.';
|
453
|
+
error(execWarning);
|
454
|
+
}
|
455
|
+
return require('child_process').exec.apply(this, arguments);
|
456
|
+
};
|
457
|
+
|
458
|
+
|
459
|
+
exports.pump = function(readStream, writeStream, callback) {
|
460
|
+
var callbackCalled = false;
|
461
|
+
|
462
|
+
function call(a, b, c) {
|
463
|
+
if (callback && !callbackCalled) {
|
464
|
+
callback(a, b, c);
|
465
|
+
callbackCalled = true;
|
466
|
+
}
|
467
|
+
}
|
468
|
+
|
469
|
+
readStream.addListener('data', function(chunk) {
|
470
|
+
if (writeStream.write(chunk) === false) readStream.pause();
|
471
|
+
});
|
472
|
+
|
473
|
+
writeStream.addListener('drain', function() {
|
474
|
+
readStream.resume();
|
475
|
+
});
|
476
|
+
|
477
|
+
readStream.addListener('end', function() {
|
478
|
+
writeStream.end();
|
479
|
+
});
|
480
|
+
|
481
|
+
readStream.addListener('close', function() {
|
482
|
+
call();
|
483
|
+
});
|
484
|
+
|
485
|
+
readStream.addListener('error', function(err) {
|
486
|
+
writeStream.end();
|
487
|
+
call(err);
|
488
|
+
});
|
489
|
+
|
490
|
+
writeStream.addListener('error', function(err) {
|
491
|
+
readStream.destroy();
|
492
|
+
call(err);
|
493
|
+
});
|
494
|
+
};
|
495
|
+
|
496
|
+
|
497
|
+
/**
|
498
|
+
* Inherit the prototype methods from one constructor into another.
|
499
|
+
*
|
500
|
+
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
501
|
+
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
502
|
+
* during bootstrapping this function needs to be revritten using some native
|
503
|
+
* functions as prototype setup using normal JavaScript does not work as
|
504
|
+
* expected during bootstrapping (see mirror.js in r114903).
|
505
|
+
*
|
506
|
+
* @param {function} ctor Constructor function which needs to inherit the
|
507
|
+
* prototype.
|
508
|
+
* @param {function} superCtor Constructor function to inherit prototype from.
|
509
|
+
*/
|
510
|
+
exports.inherits = function(ctor, superCtor) {
|
511
|
+
ctor.super_ = superCtor;
|
512
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
513
|
+
constructor: {
|
514
|
+
value: ctor,
|
515
|
+
enumerable: false,
|
516
|
+
writable: true,
|
517
|
+
configurable: true
|
518
|
+
}
|
519
|
+
});
|
520
|
+
};
|