source: node_modules/es-toolkit/dist/compat/predicate/matchesProperty.d.mts

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.7 KB
Line 
1import { PropertyPath } from '../_internal/PropertyPath.mjs';
2
3/**
4 * Creates a function that checks if a given target object matches a specific property value.
5 *
6 * @template T
7 * @template V
8 * @param {PropertyPath} path - The property path to check within the target object.
9 * @param {T} srcValue - The value to compare against the property value in the target object.
10 * @returns {(value: any) => boolean} Returns a function that takes a target object and returns
11 * `true` if the property value at the given path in the target object matches the provided value,
12 * otherwise returns `false`.
13 *
14 * @example
15 * const checkName = matchesProperty('name', 'Alice');
16 * console.log(checkName({ name: 'Alice' })); // true
17 * console.log(checkName({ name: 'Bob' })); // false
18 */
19declare function matchesProperty<T>(path: PropertyPath, srcValue: T): (value: any) => boolean;
20/**
21 * Creates a function that checks if a given target object matches a specific property value.
22 *
23 * @template T
24 * @template V
25 * @param {PropertyPath} path - The property path to check within the target object.
26 * @param {T} srcValue - The value to compare against the property value in the target object.
27 * @returns {(value: V) => boolean} Returns a function that takes a target object and returns
28 * `true` if the property value at the given path in the target object matches the provided value,
29 * otherwise returns `false`.
30 *
31 * @example
32 * const checkNested = matchesProperty(['address', 'city'], 'New York');
33 * console.log(checkNested({ address: { city: 'New York' } })); // true
34 * console.log(checkNested({ address: { city: 'Los Angeles' } })); // false
35 */
36declare function matchesProperty<T, V>(path: PropertyPath, srcValue: T): (value: V) => boolean;
37
38export { matchesProperty };
Note: See TracBrowser for help on using the repository browser.