reports/frontend/node_modules/es-toolkit/dist/array/takeWhile.d.mts
jtricerolph 1c411e402e Add settings page for managing forecasting API key and URL via UI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-07-20 14:37:36 +00:00

27 lines
No EOL
1 KiB
TypeScript

//#region src/array/takeWhile.d.ts
/**
* Returns a new array containing the leading elements of the provided array
* that satisfy the provided predicate function. It stops taking elements as soon
* as an element does not satisfy the predicate.
*
* @template T - The type of elements in the array.
* @param arr - The array to process.
* @param shouldContinueTaking - The predicate function that is called with each element, its index, and the array. Elements are included in the result as long as this function returns true.
* @returns A new array containing the leading elements that satisfy the predicate.
*
* @example
* // Returns [1, 2]
* takeWhile([1, 2, 3, 4], x => x < 3);
*
* @example
* // Returns []
* takeWhile([1, 2, 3, 4], x => x > 3);
*
* @example
* // Using index parameter
* takeWhile([10, 20, 30, 40], (x, index) => index < 2);
* // Returns: [10, 20]
*/
declare function takeWhile<T>(arr: readonly T[], shouldContinueTaking: (element: T, index: number, array: readonly T[]) => boolean): T[];
//#endregion
export { takeWhile };