UNPKG

@ecomplus/utils

Version:

JS utility functions to E-Com Plus (not only) related apps

24 lines 844 B
export default findByProperty; /** * @method * @memberof ecomUtils * @name findByProperty * @description Find object from list by some property value. * @param {Array} list - List of nested objects * @param {string} prop - Property name * @param {number|string} value - Property value to be matched * @returns {Object.<string, *>|undefined} * * @example * // Find on list of generic objects * ecomUtils.findByProperty([ { a: 1, b: 1 }, { a: 2 } ], 'a', 1) * // => { a: 1, b: 1 } * ecomUtils.findByProperty([ { a: 1 }, { a: 1, b: 1 }, { a: 0 } ], 'a', 1) * // => { a: 1 } * ecomUtils.findByProperty([ { a: 0, b: 0 }, { a: 1 } ], 'a', 3) * // => undefined */ declare function findByProperty(list: any[], prop: string, value: number | string): { [x: string]: any; } | undefined; //# sourceMappingURL=find-by-property.d.ts.map