UNPKG

axe-core

Version:

Accessibility engine for automated Web UI testing

17 lines (15 loc) 543 B
/** * Iterates an array of objects looking for a property with a specific value * @method findBy * @memberof axe.utils * @instance * @param {Array} array The array of objects to iterate * @param {String} key The property name to test against * @param {Mixed} value The value to find * @return {Object} The first matching object or `undefined` if no match */ axe.utils.findBy = function (array, key, value) { if (Array.isArray(array)) { return array.find( obj => typeof obj === 'object' && obj[key] === value ); } };