mirror of https://gitgud.io/fatchan/jschan.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
781 B
36 lines
781 B
'use strict';
|
|
|
|
const { isDeepStrictEqual } = require('util')
|
|
|
|
function getDotProp(obj, prop) {
|
|
return prop
|
|
.split('.')
|
|
.reduce((a, b) => a[b], obj);
|
|
}
|
|
|
|
function includeChildren(template, prop, tasks) {
|
|
Object.keys(getDotProp(template, prop))
|
|
.reduce((a, x) => {
|
|
a[`${prop}.${x}`] = tasks;
|
|
return a;
|
|
}, {});
|
|
}
|
|
|
|
function compareSettings(entries, oldObject, newObject, maxSetSize) {
|
|
const resultSet = new Set();
|
|
entries.every(entry => {
|
|
const oldValue = getDotProp(oldObject, entry[0]);
|
|
const newValue = getDotProp(newObject, entry[0]);
|
|
if (!isDeepStrictEqual(oldValue, newValue)) {
|
|
entry[1].forEach(t => resultSet.add(t));
|
|
}
|
|
return resultSet.size < maxSetSize;
|
|
});
|
|
return resultSet;
|
|
}
|
|
|
|
module.exports = {
|
|
getDotProp,
|
|
includeChildren,
|
|
compareSettings,
|
|
}
|
|
|