```ts
import { filter } from 'lodash';

/**
 * Flattens nested arrays up to the specified depth or fully if no depth is provided.
 *
 * @param items - The array of items to flatten. Strings are considered values and not iterable.
 * @param depth - The optional maximum depth to flatten. Negative numbers and non-integers throw an error. A depth of 0 returns a copy unchanged. Defaults to Infinity for full flattening.
 * @returns A new array with the flattened elements.
 */
export function flatten(items: readonly unknown[], depth?: number): unknown[] {
    if (depth === undefined) depth = Infinity;
    if (typeof depth !== 'number' || !Number.isInteger(depth) || depth < 0) {
        throw new Error('Depth must be a non-negative integer or Infinity.');
    }

    const flattenArray = (arr: readonly unknown[], currentDepth: number): unknown[] => {
        return arr.reduce((acc, item) => {
            if (currentDepth > 0 && Array.isArray(item)) {
                acc.push(...flattenArray(item as unknown[], currentDepth - 1));
            } else if (typeof item !== 'string') {
                acc.push(item);
            }
            return acc;
        }, [] as unknown[]);
    };

    return flattenArray(items, depth);
}
```