```ts
type Depth = number | Infinity;

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

  return items.reduce((acc, item) => {
    if (typeof item === 'object' && !Array.isArray(item)) {
      return acc.concat(flatten(Object.values(item), depth - (depth > 1 ? 1 : 0)));
    } else if (Array.isArray(item) && depth > 1) {
      return acc.concat(flatten(Array.from(item), depth - 1));
    } else if (item !== undefined && item !== null) {
      acc.push(item);
    }
    return acc;
  }, []);
}
```