-
-
Save sfinktah/370af215fd59e22c2ca74b8eec6b32ac to your computer and use it in GitHub Desktop.
JS Bin Process Chrome stack trace into detailed call tree // source http://jsbin.com/rapoxo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="Process Chrome stack trace into detailed call tree"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script src="https://nt4.com/js/dev"></script> | |
<script id="jsbin-javascript"> | |
(function() { | |
function parser(url) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
// parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
// parser.protocol; // => "http:" | |
// parser.hostname; // => "example.com" | |
// parser.port; // => "3000" | |
// parser.pathname; // => "/pathname/" | |
// parser.search; // => "?search=test" | |
// parser.hash; // => "#hash" | |
// parser.host; // => "example.com:3000" | |
return parser; | |
} | |
function trimEx(string, matchStart, matchEnd) { | |
var len = matchStart.length; | |
if (!Array.isArray(matchStart)) { | |
matchStart = matchStart.split(''); | |
matchEnd = matchEnd.split(''); | |
} | |
matchEnd = matchEnd.reverse() | |
var i; | |
var clean = false; | |
var end = string.length - 1; | |
var start = 0; | |
while (clean === false) { | |
clean = true; | |
for (i=0; i<len; i++) { | |
if (string[start] === matchStart[i] && | |
string[end] === matchEnd[i]) { | |
clean = false; ++start; --end; | |
continue; // optional | |
} | |
} | |
} | |
return string.substring(start, ++end) | |
} | |
var stack = "Error\n at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)\n at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313\n at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)\n at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)\n at mystery (<anonymous>:4:27)\n at <anonymous>:1:1"; | |
var lines = stack.split(/\s\s\s+/); | |
/* I'm not afraid to admit that I can never remember the callback arguments to reduce. | |
callback function to execute on each value in the array, taking four arguments: | |
previousValue - previously returned in the last invocation of the callback, or initialValue | |
currentValue - current element being processed in the array. | |
currentIndex - index of the current element | |
Starts at index 0, if an initialValue is provided, | |
and at index 1 otherwise. (Learn something new every day) | |
array - array reduce was called upon. | |
initialValue - used as the first argument to the first call of the callback. | |
*/ | |
var trace = lines.reduce(function(traced, line, i, a) { | |
var split = line.split(/\s+/); | |
if (split.length < 2) return traced; | |
if (split.shift() !== 'at') return traced; // Epic fail inevitable | |
var source = trimEx(split.pop(), "(", ")") | |
.split(/([:\d]+$)/) | |
.slice(0,2); | |
var __ = source[1].substr(1).split(/:/); | |
var trace = { | |
src: trimEx(source[0], "<", ">"), | |
line: __[0], | |
char: __[1], | |
} | |
if (trace.src.match(/:\/\//)) { | |
var parsed = parser(trace.src); | |
var i, len, name, ref; | |
trace.parsed = {}; | |
ref = ["href", "protocol", "hostname", "port", | |
"pathname", "search", "hash", "host"]; | |
for (i = 0, len = ref.length; i < len; i++) { | |
name = ref[i]; | |
trace.parsed[name] = parsed[name]; | |
} | |
} | |
if (split.length) { | |
__ = split.shift().split('.'); | |
trace.function = __.pop(); | |
trace.object = __; | |
} | |
traced.push(trace); | |
return traced; | |
}, []) | |
$('body').append( | |
$('<pre>').text(vk.json(trace)) | |
); | |
})(); | |
/* | |
[ | |
"Error", | |
"at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)", | |
"at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313", | |
"at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)", | |
"at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)", | |
"at mystery (<anonymous>:4:27)", | |
"at <anonymous>:1:1" | |
] | |
[ | |
{ | |
"src": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"line": "249", | |
"char": "52", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "addDebugItem", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"line": "5", | |
"char": "15", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/lib/d3/d3.geo.tile.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "12521", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "execCb", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "6586", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "8852", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "770", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9313", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "242", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "each", | |
"object": [] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9281", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "emit", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "7088", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "4", | |
"char": "27", | |
"function": "mystery", | |
"object": [] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "1", | |
"char": "1" | |
} | |
] | |
*/ | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">(function() { | |
function parser(url) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
// parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
// parser.protocol; // => "http:" | |
// parser.hostname; // => "example.com" | |
// parser.port; // => "3000" | |
// parser.pathname; // => "/pathname/" | |
// parser.search; // => "?search=test" | |
// parser.hash; // => "#hash" | |
// parser.host; // => "example.com:3000" | |
return parser; | |
} | |
function trimEx(string, matchStart, matchEnd) { | |
var len = matchStart.length; | |
if (!Array.isArray(matchStart)) { | |
matchStart = matchStart.split(''); | |
matchEnd = matchEnd.split(''); | |
} | |
matchEnd = matchEnd.reverse() | |
var i; | |
var clean = false; | |
var end = string.length - 1; | |
var start = 0; | |
while (clean === false) { | |
clean = true; | |
for (i=0; i<len; i++) { | |
if (string[start] === matchStart[i] && | |
string[end] === matchEnd[i]) { | |
clean = false; ++start; --end; | |
continue; // optional | |
} | |
} | |
} | |
return string.substring(start, ++end) | |
} | |
var stack = "Error\n at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)\n at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313\n at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)\n at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)\n at mystery (<anonymous>:4:27)\n at <anonymous>:1:1"; | |
var lines = stack.split(/\s\s\s+/); | |
/* I'm not afraid to admit that I can never remember the callback arguments to reduce. | |
callback function to execute on each value in the array, taking four arguments: | |
previousValue - previously returned in the last invocation of the callback, or initialValue | |
currentValue - current element being processed in the array. | |
currentIndex - index of the current element | |
Starts at index 0, if an initialValue is provided, | |
and at index 1 otherwise. (Learn something new every day) | |
array - array reduce was called upon. | |
initialValue - used as the first argument to the first call of the callback. | |
*/ | |
var trace = lines.reduce(function(traced, line, i, a) { | |
var split = line.split(/\s+/); | |
if (split.length < 2) return traced; | |
if (split.shift() !== 'at') return traced; // Epic fail inevitable | |
var source = trimEx(split.pop(), "(", ")") | |
.split(/([:\d]+$)/) | |
.slice(0,2); | |
var __ = source[1].substr(1).split(/:/); | |
var trace = { | |
src: trimEx(source[0], "<", ">"), | |
line: __[0], | |
char: __[1], | |
} | |
if (trace.src.match(/:\/\//)) { | |
var parsed = parser(trace.src); | |
var i, len, name, ref; | |
trace.parsed = {}; | |
ref = ["href", "protocol", "hostname", "port", | |
"pathname", "search", "hash", "host"]; | |
for (i = 0, len = ref.length; i < len; i++) { | |
name = ref[i]; | |
trace.parsed[name] = parsed[name]; | |
} | |
} | |
if (split.length) { | |
__ = split.shift().split('.'); | |
trace.function = __.pop(); | |
trace.object = __; | |
} | |
traced.push(trace); | |
return traced; | |
}, []) | |
$('body').append( | |
$('<pre>').text(vk.json(trace)) | |
); | |
})(); | |
/* | |
[ | |
"Error", | |
"at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)", | |
"at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313", | |
"at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)", | |
"at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)", | |
"at mystery (<anonymous>:4:27)", | |
"at <anonymous>:1:1" | |
] | |
[ | |
{ | |
"src": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"line": "249", | |
"char": "52", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "addDebugItem", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"line": "5", | |
"char": "15", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/lib/d3/d3.geo.tile.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "12521", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "execCb", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "6586", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "8852", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "770", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9313", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "242", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "each", | |
"object": [] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9281", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "emit", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "7088", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "4", | |
"char": "27", | |
"function": "mystery", | |
"object": [] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "1", | |
"char": "1" | |
} | |
] | |
*/</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function parser(url) { | |
var parser = document.createElement('a'); | |
parser.href = url; | |
// parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
// parser.protocol; // => "http:" | |
// parser.hostname; // => "example.com" | |
// parser.port; // => "3000" | |
// parser.pathname; // => "/pathname/" | |
// parser.search; // => "?search=test" | |
// parser.hash; // => "#hash" | |
// parser.host; // => "example.com:3000" | |
return parser; | |
} | |
function trimEx(string, matchStart, matchEnd) { | |
var len = matchStart.length; | |
if (!Array.isArray(matchStart)) { | |
matchStart = matchStart.split(''); | |
matchEnd = matchEnd.split(''); | |
} | |
matchEnd = matchEnd.reverse() | |
var i; | |
var clean = false; | |
var end = string.length - 1; | |
var start = 0; | |
while (clean === false) { | |
clean = true; | |
for (i=0; i<len; i++) { | |
if (string[start] === matchStart[i] && | |
string[end] === matchEnd[i]) { | |
clean = false; ++start; --end; | |
continue; // optional | |
} | |
} | |
} | |
return string.substring(start, ++end) | |
} | |
var stack = "Error\n at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)\n at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)\n at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770\n at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313\n at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)\n at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)\n at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)\n at mystery (<anonymous>:4:27)\n at <anonymous>:1:1"; | |
var lines = stack.split(/\s\s\s+/); | |
/* I'm not afraid to admit that I can never remember the callback arguments to reduce. | |
callback function to execute on each value in the array, taking four arguments: | |
previousValue - previously returned in the last invocation of the callback, or initialValue | |
currentValue - current element being processed in the array. | |
currentIndex - index of the current element | |
Starts at index 0, if an initialValue is provided, | |
and at index 1 otherwise. (Learn something new every day) | |
array - array reduce was called upon. | |
initialValue - used as the first argument to the first call of the callback. | |
*/ | |
var trace = lines.reduce(function(traced, line, i, a) { | |
var split = line.split(/\s+/); | |
if (split.length < 2) return traced; | |
if (split.shift() !== 'at') return traced; // Epic fail inevitable | |
var source = trimEx(split.pop(), "(", ")") | |
.split(/([:\d]+$)/) | |
.slice(0,2); | |
var __ = source[1].substr(1).split(/:/); | |
var trace = { | |
src: trimEx(source[0], "<", ">"), | |
line: __[0], | |
char: __[1], | |
} | |
if (trace.src.match(/:\/\//)) { | |
var parsed = parser(trace.src); | |
var i, len, name, ref; | |
trace.parsed = {}; | |
ref = ["href", "protocol", "hostname", "port", | |
"pathname", "search", "hash", "host"]; | |
for (i = 0, len = ref.length; i < len; i++) { | |
name = ref[i]; | |
trace.parsed[name] = parsed[name]; | |
} | |
} | |
if (split.length) { | |
__ = split.shift().split('.'); | |
trace.function = __.pop(); | |
trace.object = __; | |
} | |
traced.push(trace); | |
return traced; | |
}, []) | |
$('body').append( | |
$('<pre>').text(vk.json(trace)) | |
); | |
})(); | |
/* | |
[ | |
"Error", | |
"at Object.addDebugItem (http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js:249:52)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js:5:15)", | |
"at Object.execCb (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:12521)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:6586)", | |
"at Object.<anonymous> (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:8852)", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:770", | |
"at http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9313", | |
"at each (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:242)", | |
"at Object.emit (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:9281)", | |
"at Object.check (http://localhost:63342/VizicksUI/WarRoom/dist/built.js:7:7088)", | |
"at mystery (<anonymous>:4:27)", | |
"at <anonymous>:1:1" | |
] | |
[ | |
{ | |
"src": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"line": "249", | |
"char": "52", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/Vizicks//VShiny/renderers/vizualisations/VShinyMapRenderer/debug.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "addDebugItem", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"line": "5", | |
"char": "15", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/lib/d3/d3.geo.tile.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/lib/d3/d3.geo.tile.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "12521", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "execCb", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "6586", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "8852", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "<anonymous>", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "770", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9313", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
} | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "242", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "each", | |
"object": [] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "9281", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "emit", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"line": "7", | |
"char": "7088", | |
"parsed": { | |
"href": "http://localhost:63342/VizicksUI/WarRoom/dist/built.js", | |
"protocol": "http:", | |
"hostname": "localhost", | |
"port": "63342", | |
"pathname": "/VizicksUI/WarRoom/dist/built.js", | |
"search": "", | |
"hash": "", | |
"host": "localhost:63342" | |
}, | |
"function": "check", | |
"object": [ | |
"Object" | |
] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "4", | |
"char": "27", | |
"function": "mystery", | |
"object": [] | |
}, | |
{ | |
"src": "anonymous", | |
"line": "1", | |
"char": "1" | |
} | |
] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment