```ts
/**
 * Returns a new array with nested arrays flattened up to depth levels.
 * @param items - The array or value to flatten.
 * @param depth - The maximum depth to flatten. Defaults to Infinity.
 * @returns A new flattened array.
 */
export function flatten(items: readonly unknown[], depth: number = Infinity): unknown[] {
  if (depth < 0 || !Number.isInteger(depth)) {
    throw new Error('Depth must be a non-negative integer or Infinity');
  }

  const result: unknown[] = [];

  const flattenItems = (nestedItems: readonly unknown[], currentDepth: number) => {
    for (const item of nestedItems) {
      if (Array.isArray(item) && currentDepth > 0) {
        flattenItems(item, currentDepth - 1);
      } else if (typeof item !== 'string') {
        result.push(item);
      }
    }
  };

  flattenItems(items, depth);
  return result;
}
```