29 lines
610 B
JavaScript
29 lines
610 B
JavaScript
"use strict";
|
|
|
|
const sortCollectionBy = (collection, key) => {
|
|
collection.sort((a, b) => {
|
|
a = a[key].toLowerCase();
|
|
b = b[key].toLowerCase();
|
|
if (a < b) return -1;
|
|
if (a > b) return 1;
|
|
return 0;
|
|
});
|
|
return collection;
|
|
};
|
|
|
|
const playerArrayContains = (arr, item) => {
|
|
let i = 0, count = arr.length, matchFound = false;
|
|
|
|
for(; i < count; i++) {
|
|
if (arr[i].name === item.name && arr[i].fraction === item.fraction) {
|
|
matchFound = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return matchFound;
|
|
};
|
|
|
|
exports.sortCollection = sortCollectionBy;
|
|
exports.arrayContains = playerArrayContains;
|