Skip to content

Commit 3bee87c

Browse files
prx-lmomportuga
authored andcommitted
shortened code test
1 parent bf140a6 commit 3bee87c

File tree

1 file changed

+9
-9
lines changed
  • packages/core/src/js/factories

1 file changed

+9
-9
lines changed

packages/core/src/js/factories/Grid.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ angular.module('ui.grid')
686686
* @param {string} name column name
687687
*/
688688
Grid.prototype.getColumn = function getColumn(name) {
689-
return arrayFinder(this.columns, function (column) {
689+
return rowColumnFinder(this.columns, function (column) {
690690
return column.colDef.name === name;
691691
});
692692
};
@@ -699,7 +699,7 @@ angular.module('ui.grid')
699699
* @param {string} name column.field
700700
*/
701701
Grid.prototype.getColDef = function getColDef(name) {
702-
return arrayFinder(this.options.columnDefs, function (colDef) {
702+
return rowColumnFinder(this.options.columnDefs, function (colDef) {
703703
return colDef.name === name;
704704
});
705705
};
@@ -1070,21 +1070,21 @@ angular.module('ui.grid')
10701070
return t;
10711071
};
10721072

1073-
var arrayFinder = function(array, func) {
1073+
var rowColumnFinder = function(array, func) {
10741074
if (array && array.length) {
1075-
var arr = [];
10761075
if (angular.isFunction(array.find)) {
1077-
return arr.push(array.find(func))[0] || null;
1076+
return array.find(func) || null;
10781077
}
10791078

1079+
var result = null;
10801080
array.every(function (entry) {
1081-
if ( func(entry) ) {
1082-
arr.push(entry);
1081+
if (func(entry)) {
1082+
result = entry;
10831083
return false;
10841084
}
10851085
return true;
10861086
});
1087-
return arr.length ? arr[0] : null;
1087+
return result;
10881088
}
10891089
return null;
10901090
}
@@ -1101,7 +1101,7 @@ angular.module('ui.grid')
11011101
Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
11021102
var self = this;
11031103
lookInRows = lookInRows == void 0 ? this.rows : lookInRows;
1104-
return arrayFinder(lookInRows, function (row) {
1104+
return rowColumnFinder(lookInRows, function (row) {
11051105
return self.options.rowEquality(row.entity, rowEntity);
11061106
});
11071107
};

0 commit comments

Comments
 (0)