everyutil
Version:
A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.
11 lines (10 loc) • 526 B
TypeScript
/**
* Flattens an array until the provided depth function returns false for an element.
* @author @dailker
* @template T
* @param {any[]} array - The input array.
* @param {(item: any, depth: number) => boolean} depthFn - Function to determine if an item should be further flattened.
* @param {number} [depth=0] - Current depth (for recursion).
* @returns {T[]} - Flattened array.
*/
export declare function flattenUntil<T>(array: any[], depthFn: (item: any, depth: number) => boolean, depth?: number): T[];