@terminus/ngx-tools
Version:
[![CircleCI][circle-badge]][circle-link] [![codecov][codecov-badge]][codecov-project] [![semantic-release][semantic-release-badge]][semantic-release] [![MIT License][license-image]][license-url] <br> [![NPM version][npm-version-image]][npm-url] [![Github
15 lines (14 loc) • 570 B
TypeScript
/**
* Determine if an object exists in an array
*
* @param object - The object to look for in the array
* @param array - The array to search through
* @param comparator - The function to determine what object values to compare
* @returns True if a match was found
*
* @example
* const arr = [{id: 1}, {id: 2}, {id: 3}];
* const comparator = (v) => v.id;
* arrayContainsObject({id: 2}, array, comparator); // Returns: true
*/
export declare function arrayContainsObject(object: Record<string, any>, array: any[], comparator: (value: any) => string): boolean;