API reference › @evolu/common › Types › PredicateWithIndex
type PredicateWithIndex<T> = (value: T, index: number) => boolean;
Defined in: packages/common/src/Types.ts:99
Checks a condition on a value at a given index and returns a boolean.
Useful for callbacks that need both the element and its position.
Filtering by position
import type { PredicateWithIndex } from "@evolu/common";
const isEvenIndex: PredicateWithIndex<string> = (value, index) =>
index % 2 === 0;
expect(["a", "b", "c", "d"].filter(isEvenIndex)).toEqual(["a", "c"]);