use includes instead of indexOf

use _.uniq instead of filter&indexOf
This commit is contained in:
Barış Soner Uşaklı
2018-10-20 14:40:48 -04:00
parent a6c70412db
commit 26d4e0852f
57 changed files with 156 additions and 208 deletions

View File

@@ -19,7 +19,7 @@ module.exports = function (Groups) {
});
var ephemeralIdx = groupNames.reduce(function (memo, cur, idx) {
if (Groups.ephemeralGroups.indexOf(cur) !== -1) {
if (Groups.ephemeralGroups.includes(cur)) {
memo.push(idx);
}
return memo;

View File

@@ -265,14 +265,14 @@ module.exports = function (Groups) {
},
function (groupNames, next) {
groupNames = Groups.removeEphemeralGroups(groupNames);
if (groupNames.length === 0) {
if (!groupNames.length) {
return callback(null, false);
}
Groups.isMemberOfGroups(uid, groupNames, next);
},
function (isMembers, next) {
next(null, isMembers.indexOf(true) !== -1);
next(null, isMembers.includes(true));
},
], callback);
};

View File

@@ -18,7 +18,7 @@ module.exports = function (Groups) {
// Ephemeral groups and the registered-users groups are searchable
groupNames = Groups.ephemeralGroups.concat(groupNames).concat('registered-users');
groupNames = groupNames.filter(function (name) {
return name.toLowerCase().indexOf(query) !== -1 && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
return name.toLowerCase().includes(query) && name !== 'administrators' && !Groups.isPrivilegeGroup(name);
});
groupNames = groupNames.slice(0, 100);
Groups.getGroupsData(groupNames, next);