Merge pull request #153 from JsSucks/setting-getters

Find first setting
This commit is contained in:
Alexei Stukov 2018-03-04 23:06:21 +02:00 committed by GitHub
commit 050118f26c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -101,6 +101,17 @@ export default class SettingsSet {
return false;
}
/**
* Return the first setting that matches the id in any category
*/
findFirst(settingId) {
for (let cat of this.categories) {
const found = cat.settings.find(s => s.id === settingId);
if (found) return found;
}
return null;
}
/**
* Returns the first category where calling {function} returns true.
* @param {Function} function A function to call to filter categories