mirror of https://github.com/zulip/zulip.git
Remove verbose_stacktrace function. Use console.trace instead
console.trace is available in both Firefox and Chrome and is more powerful. (imported from commit fa6e2cd5c78e7b0588b8656270d078bfa6af41fa)
This commit is contained in:
parent
d679a72952
commit
36f7e6ffd5
|
@ -25,48 +25,3 @@ function print_elapsed_time(name, fun) {
|
|||
console.log(name + ': ' + (t1 - t0) + ' ms');
|
||||
return out;
|
||||
}
|
||||
|
||||
// Javascript stack trac functionality, adapted from:
|
||||
// https://github.com/eriwen/javascript-stacktrace/blob/master/stacktrace.js
|
||||
// The first function is just a helper.
|
||||
function stringifyArguments(args) {
|
||||
var i, result = [];
|
||||
var slice = Array.prototype.slice;
|
||||
for (i = 0; i < args.length; ++i) {
|
||||
var arg = args[i];
|
||||
if (arg === undefined) {
|
||||
result[i] = 'undefined';
|
||||
} else if (arg === null) {
|
||||
result[i] = 'null';
|
||||
} else if (arg.constructor) {
|
||||
if (arg.constructor === Array) {
|
||||
if (arg.length < 3) {
|
||||
result[i] = '[' + stringifyArguments(arg) + ']';
|
||||
} else {
|
||||
result[i] = '[' + stringifyArguments(slice.call(arg, 0, 1)) + '...' + stringifyArguments(slice.call(arg, -1)) + ']';
|
||||
}
|
||||
} else if (arg.constructor === Object) {
|
||||
result[i] = '#object';
|
||||
} else if (arg.constructor === Function) {
|
||||
result[i] = '#function';
|
||||
} else if (arg.constructor === String) {
|
||||
result[i] = '"' + arg + '"';
|
||||
} else if (arg.constructor === Number) {
|
||||
result[i] = arg;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result.join(',');
|
||||
}
|
||||
|
||||
// Usage: console.log(verbose_stacktrace(arguments.callee));
|
||||
function verbose_stacktrace(curr) {
|
||||
var ANON = '{anonymous}', fnRE = /function\s*([\w\-$]+)?\s*\(/i, stack = [], fn, args, maxStackSize = 50;
|
||||
while (curr && curr['arguments'] && stack.length < maxStackSize) {
|
||||
fn = curr.toString();
|
||||
args = Array.prototype.slice.call(curr['arguments'] || []);
|
||||
stack[stack.length] = fn + '(' + stringifyArguments(args) + ')';
|
||||
curr = curr.caller;
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue