source: node_modules/es-toolkit/dist/compat/object/pickBy.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: 3.4 KB
Line 
1import { ValueKeyIteratee } from '../_internal/ValueKeyIteratee.mjs';
2import { ValueKeyIterateeTypeGuard } from '../_internal/ValueKeyIterateeTypeGuard.mjs';
3
4/**
5 * Creates a new object composed of the properties that satisfy the predicate function.
6 *
7 * @template T - The type of object values.
8 * @template S - The type of filtered values.
9 * @param {Record<string, T> | null | undefined} object - The source object.
10 * @param {ValueKeyIterateeTypeGuard<T, S>} predicate - The function invoked per property.
11 * @returns {Record<string, S>} Returns the new filtered object.
12 *
13 * @example
14 * const users = {
15 * 'fred': { 'user': 'fred', 'age': 40 },
16 * 'pebbles': { 'user': 'pebbles', 'age': 1 }
17 * };
18 * pickBy(users, ({ age }) => age < 40);
19 * // => { 'pebbles': { 'user': 'pebbles', 'age': 1 } }
20 */
21declare function pickBy<T, S extends T>(object: Record<string, T> | null | undefined, predicate: ValueKeyIterateeTypeGuard<T, S>): Record<string, S>;
22/**
23 * Creates a new object composed of the properties that satisfy the predicate function.
24 *
25 * @template T - The type of object values.
26 * @template S - The type of filtered values.
27 * @param {Record<number, T> | null | undefined} object - The source object.
28 * @param {ValueKeyIterateeTypeGuard<T, S>} predicate - The function invoked per property.
29 * @returns {Record<number, S>} Returns the new filtered object.
30 *
31 * @example
32 * const array = [1, 2, 3, 4];
33 * pickBy(array, (value) => value % 2 === 0);
34 * // => { 1: 2, 3: 4 }
35 */
36declare function pickBy<T, S extends T>(object: Record<number, T> | null | undefined, predicate: ValueKeyIterateeTypeGuard<T, S>): Record<number, S>;
37/**
38 * Creates a new object composed of the properties that satisfy the predicate function.
39 *
40 * @template T - The type of object values.
41 * @param {Record<string, T> | null | undefined} object - The source object.
42 * @param {ValueKeyIteratee<T>} [predicate] - The function invoked per property.
43 * @returns {Record<string, T>} Returns the new filtered object.
44 *
45 * @example
46 * const object = { 'a': 1, 'b': '2', 'c': 3 };
47 * pickBy(object, (value) => typeof value === 'string');
48 * // => { 'b': '2' }
49 */
50declare function pickBy<T>(object: Record<string, T> | null | undefined, predicate?: ValueKeyIteratee<T>): Record<string, T>;
51/**
52 * Creates a new object composed of the properties that satisfy the predicate function.
53 *
54 * @template T - The type of object values.
55 * @param {Record<number, T> | null | undefined} object - The source object.
56 * @param {ValueKeyIteratee<T>} [predicate] - The function invoked per property.
57 * @returns {Record<number, T>} Returns the new filtered object.
58 *
59 * @example
60 * const array = [1, 2, 3, 4];
61 * pickBy(array, (value) => value > 2);
62 * // => { 2: 3, 3: 4 }
63 */
64declare function pickBy<T>(object: Record<number, T> | null | undefined, predicate?: ValueKeyIteratee<T>): Record<number, T>;
65/**
66 * Creates a new object composed of the properties that satisfy the predicate function.
67 *
68 * @template T - The type of object.
69 * @param {T | null | undefined} object - The source object.
70 * @param {ValueKeyIteratee<T[keyof T]>} [predicate] - The function invoked per property.
71 * @returns {Partial<T>} Returns the new filtered object.
72 *
73 * @example
74 * const object = { 'a': 1, 'b': '2', 'c': 3 };
75 * pickBy(object, (value) => typeof value === 'string');
76 * // => { 'b': '2' }
77 */
78declare function pickBy<T extends object>(object: T | null | undefined, predicate?: ValueKeyIteratee<T[keyof T]>): Partial<T>;
79
80export { pickBy };
Note: See TracBrowser for help on using the repository browser.