Skip to content

Commit dc824bd

Browse files
committed
Add prepublish script so I stop forgetting to re-dist before publishing.
1 parent 6b0dd6e commit dc824bd

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ insert_final_newline = true
1414
indent_style = space
1515
indent_size = 4
1616

17+
[package.json]
18+
indent_size = 2
19+
1720
[.{jshintrc,jscsrc}]
1821
indent_style = space
1922
indent_size = 4

dist/error-stack-parser.js

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function (root, factory) {
1+
(function(root, factory) {
22
'use strict';
33
// Universal Module Definition (UMD) to support AMD, CommonJS/Node.js, Rhino, and browsers.
44

@@ -46,8 +46,9 @@
4646
return {
4747
/**
4848
* Given an Error object, extract the most information from it.
49-
* @param error {Error}
50-
* @return Array[StackFrame]
49+
*
50+
* @param {Error} error object
51+
* @return {Array} of StackFrames
5152
*/
5253
parse: function ErrorStackParser$$parse(error) {
5354
if (typeof error.stacktrace !== 'undefined' || typeof error['opera#sourceloc'] !== 'undefined') {
@@ -63,8 +64,9 @@
6364

6465
/**
6566
* Separate line and column numbers from a URL-like string.
66-
* @param urlLike String
67-
* @return Array[String]
67+
*
68+
* @param {String} urlLike
69+
* @return {Array} 3-tuple of URL, Line Number, and Column Number
6870
*/
6971
extractLocation: function ErrorStackParser$$extractLocation(urlLike) {
7072
// Fail-fast but return locations like "(native)"
@@ -84,30 +86,30 @@
8486
},
8587

8688
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
87-
var filtered = _filter(error.stack.split('\n'), function (line) {
89+
var filtered = _filter(error.stack.split('\n'), function(line) {
8890
return !!line.match(CHROME_IE_STACK_REGEXP);
8991
}, this);
9092

91-
return _map(filtered, function (line) {
93+
return _map(filtered, function(line) {
9294
if (line.indexOf('(eval ') > -1) {
9395
// Throw away eval information until we implement stacktrace.js/stackframe#8
9496
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
9597
}
9698
var tokens = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').split(/\s+/).slice(1);
9799
var locationParts = this.extractLocation(tokens.pop());
98100
var functionName = tokens.join(' ') || undefined;
99-
var fileName = locationParts[0] === 'eval' ? undefined : locationParts[0];
101+
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
100102

101103
return new StackFrame(functionName, undefined, fileName, locationParts[1], locationParts[2], line);
102104
}, this);
103105
},
104106

105107
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
106-
var filtered = _filter(error.stack.split('\n'), function (line) {
108+
var filtered = _filter(error.stack.split('\n'), function(line) {
107109
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
108110
}, this);
109111

110-
return _map(filtered, function (line) {
112+
return _map(filtered, function(line) {
111113
// Throw away eval information until we implement stacktrace.js/stackframe#8
112114
if (line.indexOf(' > eval') > -1) {
113115
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
@@ -119,8 +121,13 @@
119121
} else {
120122
var tokens = line.split('@');
121123
var locationParts = this.extractLocation(tokens.pop());
122-
var functionName = tokens.shift() || undefined;
123-
return new StackFrame(functionName, undefined, locationParts[0], locationParts[1], locationParts[2], line);
124+
var functionName = tokens.join('@') || undefined;
125+
return new StackFrame(functionName,
126+
undefined,
127+
locationParts[0],
128+
locationParts[1],
129+
locationParts[2],
130+
line);
124131
}
125132
}, this);
126133
},
@@ -159,7 +166,16 @@
159166
for (var i = 0, len = lines.length; i < len; i += 2) {
160167
var match = lineRE.exec(lines[i]);
161168
if (match) {
162-
result.push(new StackFrame(match[3] || undefined, undefined, match[2], match[1], undefined, lines[i]));
169+
result.push(
170+
new StackFrame(
171+
match[3] || undefined,
172+
undefined,
173+
match[2],
174+
match[1],
175+
undefined,
176+
lines[i]
177+
)
178+
);
163179
}
164180
}
165181

@@ -168,12 +184,11 @@
168184

169185
// Opera 10.65+ Error.stack very similar to FF/Safari
170186
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
171-
var filtered = _filter(error.stack.split('\n'), function (line) {
172-
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) &&
173-
!line.match(/^Error created at/);
187+
var filtered = _filter(error.stack.split('\n'), function(line) {
188+
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
174189
}, this);
175190

176-
return _map(filtered, function (line) {
191+
return _map(filtered, function(line) {
177192
var tokens = line.split('@');
178193
var locationParts = this.extractLocation(tokens.pop());
179194
var functionCall = (tokens.shift() || '');
@@ -184,8 +199,15 @@
184199
if (functionCall.match(/\(([^\)]*)\)/)) {
185200
argsRaw = functionCall.replace(/^[^\(]+\(([^\)]*)\)$/, '$1');
186201
}
187-
var args = (argsRaw === undefined || argsRaw === '[arguments not available]') ? undefined : argsRaw.split(',');
188-
return new StackFrame(functionName, args, locationParts[0], locationParts[1], locationParts[2], line);
202+
var args = (argsRaw === undefined || argsRaw === '[arguments not available]') ?
203+
undefined : argsRaw.split(',');
204+
return new StackFrame(
205+
functionName,
206+
args,
207+
locationParts[0],
208+
locationParts[1],
209+
locationParts[2],
210+
line);
189211
}, this);
190212
}
191213
};

dist/error-stack-parser.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)