Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return Object.keys(possibles).reduce((prev, key) => {
// only set the value if the value has a length of > 0
const value = typeof values[key] === 'undefined' ? [] : values[key];
if (value.length > 0) {
if (possibles[key] !== null) {
// only include possible values
prev[key] = [...setHelpers.intersection(possibles[key], new Set(value))];
} else {
// only unique values
prev[key] = [...new Set(value)];
}
}
return prev;
}, {});
};