source: node_modules/es-toolkit/dist/compat/array/reject.d.ts

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

Added visualizations

  • Property mode set to 100644
File size: 2.3 KB
Line 
1import { ListIterateeCustom } from '../_internal/ListIterateeCustom.js';
2import { ObjectIterateeCustom } from '../_internal/ObjectIteratee.js';
3import { StringIterator } from '../_internal/StringIterator.js';
4
5/**
6 * Iterates over the collection and rejects elements based on the given predicate.
7 * If a function is provided, it is invoked for each element in the collection.
8 *
9 * @param {string | null | undefined} collection The string to iterate over
10 * @param {StringIterator<boolean>} [predicate] The function invoked per iteration
11 * @returns {string[]} Returns a new array of characters that do not satisfy the predicate
12 * @example
13 * reject('abc', char => char === 'b')
14 * // => ['a', 'c']
15 */
16declare function reject(collection: string | null | undefined, predicate?: StringIterator<boolean>): string[];
17/**
18 * Iterates over the collection and rejects elements based on the given predicate.
19 * If a function is provided, it is invoked for each element in the collection.
20 *
21 * @template T
22 * @param {ArrayLike<T> | null | undefined} collection The array-like to iterate over
23 * @param {ListIterateeCustom<T, boolean>} [predicate] The function invoked per iteration
24 * @returns {T[]} Returns a new array of elements that do not satisfy the predicate
25 * @example
26 * reject([1, 2, 3], num => num % 2 === 0)
27 * // => [1, 3]
28 *
29 * reject([{ a: 1 }, { a: 2 }, { b: 1 }], 'a')
30 * // => [{ b: 1 }]
31 */
32declare function reject<T>(collection: ArrayLike<T> | null | undefined, predicate?: ListIterateeCustom<T, boolean>): T[];
33/**
34 * Iterates over the collection and rejects elements based on the given predicate.
35 * If a function is provided, it is invoked for each element in the collection.
36 *
37 * @template T
38 * @param {T | null | undefined} collection The object to iterate over
39 * @param {ObjectIterateeCustom<T, boolean>} [predicate] The function invoked per iteration
40 * @returns {Array<T[keyof T]>} Returns a new array of elements that do not satisfy the predicate
41 * @example
42 * reject({ a: 1, b: 2, c: 3 }, value => value % 2 === 0)
43 * // => [1, 3]
44 *
45 * reject({ item1: { a: 0, b: true }, item2: { a: 1, b: true }, item3: { a: 2, b: false }}, { b: false })
46 * // => [{ a: 0, b: true }, { a: 1, b: true }]
47 */
48declare function reject<T extends object>(collection: T | null | undefined, predicate?: ObjectIterateeCustom<T, boolean>): Array<T[keyof T]>;
49
50export { reject };
Note: See TracBrowser for help on using the repository browser.