Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit a591e8b

Browse files
realitykingbtford
authored andcommitted
perf(map): use Array.prototype.map
Replace helper functions with the native ES5 method
1 parent 6b05105 commit a591e8b

File tree

6 files changed

+5
-16
lines changed

6 files changed

+5
-16
lines changed

src/.jshintrc

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"trim": false,
5656
"isElement": false,
5757
"makeMap": false,
58-
"map": false,
5958
"size": false,
6059
"includes": false,
6160
"arrayRemove": false,

src/Angular.js

-10
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
trim: true,
5151
isElement: true,
5252
makeMap: true,
53-
map: true,
5453
size: true,
5554
includes: true,
5655
arrayRemove: true,
@@ -617,15 +616,6 @@ function nodeName_(element) {
617616
}
618617

619618

620-
function map(obj, iterator, context) {
621-
var results = [];
622-
forEach(obj, function(value, index, list) {
623-
results.push(iterator.call(context, value, index, list));
624-
});
625-
return results;
626-
}
627-
628-
629619
/**
630620
* @description
631621
* Determines the number of elements in an array, the number of properties an object has, or

src/ng/filter/orderBy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function orderByFilter($parse){
118118
if (!(isArrayLike(array))) return array;
119119
if (!sortPredicate) return array;
120120
sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate];
121-
sortPredicate = map(sortPredicate, function(predicate){
121+
sortPredicate = sortPredicate.map(function(predicate){
122122
var descending = false, get = predicate || identity;
123123
if (isString(predicate)) {
124124
if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {

test/helpers/testabilityPatch.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ var karmaDump = window.dump || function() {
335335
};
336336

337337
window.dump = function () {
338-
karmaDump.apply(undefined, map(arguments, function(arg) {
338+
karmaDump.apply(undefined, Array.prototype.map.call(arguments, function(arg) {
339339
return angular.mock.dump(arg);
340340
}));
341341
};

test/ng/parseSpec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ describe('parser', function() {
147147

148148
it('should tokenize function invocation', function() {
149149
var tokens = lex("a()");
150-
expect(map(tokens, function(t) { return t.text;})).toEqual(['a', '(', ')']);
150+
expect(tokens.map(function(t) { return t.text;})).toEqual(['a', '(', ')']);
151151
});
152152

153153
it('should tokenize method invocation', function() {
154154
var tokens = lex("a.b.c (d) - e.f()");
155-
expect(map(tokens, function(t) { return t.text;})).
155+
expect(tokens.map(function(t) { return t.text;})).
156156
toEqual(['a.b', '.', 'c', '(', 'd', ')', '-', 'e', '.', 'f', '(', ')']);
157157
});
158158

test/ng/qSpec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('q', function() {
4141
}
4242

4343
function _argumentsToString(args) {
44-
return map(sliceArgs(args), _argToString).join(',');
44+
return sliceArgs(args).map(_argToString).join(',');
4545
}
4646

4747
// Help log invocation of success(), finally(), progress() and error()

0 commit comments

Comments
 (0)