```ts
/**
 * Flattens an array up to a specified depth. Returns a new array with nested arrays flattened.
 * Strings are considered values and will not be flattened further.
 * @param items - The array to flatten.
 * @param depth - The maximum depth of nesting to flatten. Defaults to Infinity (every level).
 * @returns A new array with nested arrays flattened up to the specified depth.
 */
export function flatten(items: readonly unknown[], depth?: number): unknown[] {
    if (depth === undefined) depth = Infinity;
    if (typeof depth !== 'number' || depth < 0 && depth !== Infinity) throw Error('Depth must be a non-negative integer or Infinity');

    return items.reduce((acc, item) => {
        if (depth > 0 && Array.isArray(item)) {
            acc.push(...flatten(item, depth - 1));
        } else if (typeof item !== 'string') {
            acc.push(item);
        }
        return acc;
    }, [] as unknown[]);
}
```