Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: appengine/config_service/ui/bower_components/stacky/lib/parsing.js

Issue 2923973003: Added base template for config ui. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /**
2 * @license
3 * Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
4 *
5 * This code may only be used under the BSD style license found at polymer.githu b.io/LICENSE.txt
6 * The complete set of authors may be found at polymer.github.io/AUTHORS.txt
7 * The complete set of contributors may be found at polymer.github.io/CONTRIBUTO RS.txt
8 * Code distributed by Google as part of the polymer project is also subject to
9 * an additional IP rights grant found at polymer.github.io/PATENTS.txt
10 */
11 (function(scope) {
12 'use strict';
13
14 function parse(stack) {
15 var rawLines = stack.split('\n');
16
17 var stackyLines = compact(rawLines.map(parseStackyLine));
18 if (stackyLines.length === rawLines.length) return stackyLines;
19
20 var v8Lines = compact(rawLines.map(parseV8Line));
21 if (v8Lines.length > 0) return v8Lines;
22
23 var geckoLines = compact(rawLines.map(parseGeckoLine));
24 if (geckoLines.length > 0) return geckoLines;
25
26 throw new Error('Unknown stack format: ' + stack);
27 }
28
29 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Obje cts/Error/Stack
30 var GECKO_LINE = /^(?:([^@]*)@)?(.*?):(\d+)(?::(\d+))?$/;
31
32 function parseGeckoLine(line) {
33 var match = line.match(GECKO_LINE);
34 if (!match) return null;
35 return {
36 method: match[1] || '',
37 location: match[2] || '',
38 line: parseInt(match[3]) || 0,
39 column: parseInt(match[4]) || 0,
40 };
41 }
42
43 // https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
44 var V8_OUTER1 = /^\s*(eval )?at (.*) \((.*)\)$/;
45 var V8_OUTER2 = /^\s*at()() (\S+)$/;
46 var V8_INNER = /^\(?([^\(]+):(\d+):(\d+)\)?$/;
47
48 function parseV8Line(line) {
49 var outer = line.match(V8_OUTER1) || line.match(V8_OUTER2);
50 if (!outer) return null;
51 var inner = outer[3].match(V8_INNER);
52 if (!inner) return null;
53
54 var method = outer[2] || '';
55 if (outer[1]) method = 'eval at ' + method;
56 return {
57 method: method,
58 location: inner[1] || '',
59 line: parseInt(inner[2]) || 0,
60 column: parseInt(inner[3]) || 0,
61 };
62 }
63
64 // Stacky.formatting.pretty
65
66 var STACKY_LINE = /^\s*(.+) at (.+):(\d+):(\d+)$/;
67
68 function parseStackyLine(line) {
69 var match = line.match(STACKY_LINE);
70 if (!match) return null;
71 return {
72 method: match[1] || '',
73 location: match[2] || '',
74 line: parseInt(match[3]) || 0,
75 column: parseInt(match[4]) || 0,
76 };
77 }
78
79 // Helpers
80
81 function compact(array) {
82 var result = [];
83 array.forEach(function(value) {
84 if (value) {
85 result.push(value);
86 }
87 });
88 return result;
89 }
90
91 scope.parse = parse;
92 scope.parseGeckoLine = parseGeckoLine;
93 scope.parseV8Line = parseV8Line;
94 scope.parseStackyLine = parseStackyLine;
95 })(typeof module !== 'undefined' ? module.exports : (this.Stacky = this.Stacky | | {}));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698