Find first setting

This commit is contained in:
Jiiks 2018-03-04 23:03:38 +02:00
parent 1b6a846102
commit 43bc873bcb
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