8000 Remove Array polyfills. They must now be provided for unsupported env… · stacktracejs/error-stack-parser@4ea1f3f · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ea1f3f

Browse files
committed
Remove Array polyfills. They must now be provided for unsupported environments
1 parent 58bf933 commit 4ea1f3f

4 files changed

+16
-94
lines changed

dist/error-stack-parser.js

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,45 +17,6 @@
1717
var CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+\:\d+|\(native\))/m;
1818
var SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code\])?$/;
1919

20-
function _map(array, fn, thisArg) {
21-
if (typeof Array.prototype.map === 'function') {
22-
return array.map(fn, thisArg);
23-
} else {
24-
var output = new Array(array.length);
25-
for (var i = 0; i < array.length; i++) {
26-
output[i] = fn.call(thisArg, array[i]);
27-
}
28-
return output;
29-
}
30-
}
31-
32-
function _filter(array, fn, thisArg) {
33-
if (typeof Array.prototype.filter === 'function') {
34-
return array.filter(fn, thisArg);
35-
} else {
36-
var output = [];
37-
for (var i = 0; i < array.length; i++) {
38-
if (fn.call(thisArg, array[i])) {
39-
output.push(array[i]);
40-
}
41-
}
42-
return output;
43-
}
44-
}
45-
46-
function _indexOf(array, target) {
47-
if (typeof Array.prototype.indexOf === 'function') {
48-
return array.indexOf(target);
49-
} else {
50-
for (var i = 0; i < array.length; i++) {
51-
if (array[i] === target) {
52-
return i;
53-
}
54-
}
55-
return -1;
56-
}
57-
}
58-
5920
return {
6021
/**
6122
* Given an Error object, extract the most information from it.
@@ -88,19 +49,19 @@
8849
},
8950

9051
parseV8OrIE: function ErrorStackParser$$parseV8OrIE(error) {
91-
var filtered = _filter(error.stack.split('\n'), function(line) {
52+
var filtered = error.stack.split('\n').filter(function(line) {
9253
return !!line.match(CHROME_IE_STACK_REGEXP);
9354
}, this);
9455

95-
return _map(filtered, function(line) {
56+
return filtered.map(function(line) {
9657
if (line.indexOf('(eval ') > -1) {
9758
// Throw away eval information until we implement stacktrace.js/stackframe#8
9859
line = line.replace(/eval code/g, 'eval').replace(/(\(eval at [^\()]*)|(\)\,.*$)/g, '');
9960
}
10061
var tokens = line.replace(/^\s+/, '').replace(/\(eval code/g, '(').split(/\s+/).slice(1);
10162
var locationParts = this.extractLocation(tokens.pop());
10263
var functionName = tokens.join(' ') || undefined;
103-
var fileName = _indexOf(['eval', '<anonymous>'], locationParts[0]) > -1 ? undefined : locationParts[0];
64+
var fileName = ['eval', '<anonymous>'].indexOf(locationParts[0]) > -1 ? undefined : locationParts[0];
10465

10566
return new StackFrame({
10667
functionName: functionName,
@@ -113,11 +74,11 @@
11374
},
11475

11576
parseFFOrSafari: function ErrorStackParser$$parseFFOrSafari(error) {
116-
var filtered = _filter(error.stack.split('\n'), function(line) {
77+
var filtered = error.stack.split('\n').filter(function(line) {
11778
return !line.match(SAFARI_NATIVE_CODE_REGEXP);
11879
}, this);
11980

120-
return _map(filtered, function(line) {
81+
return filtered.map(function(line) {
12182
// Throw away eval information until we implement stacktrace.js/stackframe#8
12283
if (line.indexOf(' > eval') > -1) {
12384
line = line.replace(/ line (\d+)(?: > eval line \d+)* > eval\:\d+\:\d+/g, ':$1');
@@ -198,11 +159,11 @@
198159

199160
// Opera 10.65+ Error.stack very similar to FF/Safari
200161
parseOpera11: function ErrorStackParser$$parseOpera11(error) {
201-
var filtered = _filter(error.stack.split('\n'), function(line) {
162+
var filtered = error.stack.split('\n').filter(function(line) {
202163
return !!line.match(FIREFOX_SAFARI_STACK_REGEXP) && !line.match(/^Error created at/);
203164
}, this);
204165

205-
return _map(filtered, function(line) {
166+
return filtered.map(function(line) {
206167
var tokens = line.split('@');
207168
var locationParts = this.extractLocation(tokens.pop());
208169
var functionCall = (tokens.shift() || '');

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)
0