| [a762898] | 1 | import { 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 | */
|
|---|
| 19 | declare 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 | */
|
|---|
| 36 | declare function matchesProperty<T, V>(path: PropertyPath, srcValue: T): (value: V) => boolean;
|
|---|
| 37 |
|
|---|
| 38 | export { matchesProperty };
|
|---|