mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
perf(map): use Array.prototype.map
Replace helper functions with the native ES5 method
This commit is contained in:
committed by
Brian Ford
parent
6b05105c08
commit
a591e8b8d3
@@ -55,7 +55,6 @@
|
||||
"trim": false,
|
||||
"isElement": false,
|
||||
"makeMap": false,
|
||||
"map": false,
|
||||
"size": false,
|
||||
"includes": false,
|
||||
"arrayRemove": false,
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
trim: true,
|
||||
isElement: true,
|
||||
makeMap: true,
|
||||
map: true,
|
||||
size: true,
|
||||
includes: true,
|
||||
arrayRemove: true,
|
||||
@@ -617,15 +616,6 @@ function nodeName_(element) {
|
||||
}
|
||||
|
||||
|
||||
function map(obj, iterator, context) {
|
||||
var results = [];
|
||||
forEach(obj, function(value, index, list) {
|
||||
results.push(iterator.call(context, value, index, list));
|
||||
});
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description
|
||||
* Determines the number of elements in an array, the number of properties an object has, or
|
||||
|
||||
@@ -118,7 +118,7 @@ function orderByFilter($parse){
|
||||
if (!(isArrayLike(array))) return array;
|
||||
if (!sortPredicate) return array;
|
||||
sortPredicate = isArray(sortPredicate) ? sortPredicate: [sortPredicate];
|
||||
sortPredicate = map(sortPredicate, function(predicate){
|
||||
sortPredicate = sortPredicate.map(function(predicate){
|
||||
var descending = false, get = predicate || identity;
|
||||
if (isString(predicate)) {
|
||||
if ((predicate.charAt(0) == '+' || predicate.charAt(0) == '-')) {
|
||||
|
||||
@@ -335,7 +335,7 @@ var karmaDump = window.dump || function() {
|
||||
};
|
||||
|
||||
window.dump = function () {
|
||||
karmaDump.apply(undefined, map(arguments, function(arg) {
|
||||
karmaDump.apply(undefined, Array.prototype.map.call(arguments, function(arg) {
|
||||
return angular.mock.dump(arg);
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -147,12 +147,12 @@ describe('parser', function() {
|
||||
|
||||
it('should tokenize function invocation', function() {
|
||||
var tokens = lex("a()");
|
||||
expect(map(tokens, function(t) { return t.text;})).toEqual(['a', '(', ')']);
|
||||
expect(tokens.map(function(t) { return t.text;})).toEqual(['a', '(', ')']);
|
||||
});
|
||||
|
||||
it('should tokenize method invocation', function() {
|
||||
var tokens = lex("a.b.c (d) - e.f()");
|
||||
expect(map(tokens, function(t) { return t.text;})).
|
||||
expect(tokens.map(function(t) { return t.text;})).
|
||||
toEqual(['a.b', '.', 'c', '(', 'd', ')', '-', 'e', '.', 'f', '(', ')']);
|
||||
});
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('q', function() {
|
||||
}
|
||||
|
||||
function _argumentsToString(args) {
|
||||
return map(sliceArgs(args), _argToString).join(',');
|
||||
return sliceArgs(args).map(_argToString).join(',');
|
||||
}
|
||||
|
||||
// Help log invocation of success(), finally(), progress() and error()
|
||||
|
||||
Reference in New Issue
Block a user