Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 7x 7x 5x 7x 7x 2x 5x 5x 1x 4x 4x 4x 4x 5x 2x 7x | const objectPath = require('object-path');
const prepForComparison = require('./prep-for-comparison');
function executeRulePathEqual(input, rule, values) {
const firstMatch = values.find((value) => {
const property = value[rule.property];
if (property === undefined || typeof property !== 'object') {
return;
}
const keys = Object.keys(property);
if (keys.length !== 1) {
return;
}
const path = keys[0];
let pathValue = property[path];
pathValue = prepForComparison(pathValue, rule);
return objectPath.get(input, path) === pathValue;
});
if (firstMatch) {
return firstMatch.value;
}
}
module.exports = executeRulePathEqual;
|