Flatten an array up to a specified depth level (nesting flattened to the specified level).
Features:
- Accepts deeply nested JSON arrays of any depth
- Customizable flatten depth (1-10 levels)
- Precise control over flattening level
- Handles arrays with mixed data types
- Uses lodash _.flattenDepth for controlled flattening
Examples:
- Depth 1: [1, [2, [3, [4]]], 5] → [1, 2, [3, [4]], 5]
- Depth 2: [1, [2, [3, [4]]], 5] → [1, 2, 3, [4], 5]
- Depth 3: [1, [2, [3, [4]]], 5] → [1, 2, 3, 4, 5]
Use Cases:
- Controlled Transformation: Flatten to a specific level while preserving deeper structure
- Data Processing: Process nested arrays level by level
- Partial Flattening: Reduce nesting without losing all structure
- Progressive Operations: Apply transformations at specific nesting levels