```ts
export function flatten(items: readonly unknown[], depth?: number): unknown[] {
  if (depth === undefined) {
    depth = Infinity;
  }
  if (!Number.isInteger(depth) || depth < 0) {
    throw new Error('Depth must be a non-negative integer or Infinity');
  }

  const result: unknown[] = [];
  const stack: { item: unknown; currentDepth: number }[] = [...items.map(item => ({ item, currentDepth: 1 }))];

  while (stack.length > 0) {
    const { item, currentDepth } = stack.pop()!;
    if (Array.isArray(item)) {
      if (currentDepth < depth) {
        stack.push(...item.map(subItem => ({ item: subItem, currentDepth: currentDepth + 1 })));
      } else {
        result.unshift(...item);
      }
    } else if (typeof item !== 'string') {
      result.unshift(item);
    }
  }

  return result;
}
```