ant-design/components/_util/toList.ts

6 lines
223 B
TypeScript
Raw Normal View History

export default function toList<T>(candidate: T | T[], skipEmpty = false): T[] {
if (skipEmpty && (candidate === undefined || candidate === null)) return [];
return Array.isArray(candidate) ? candidate : [candidate];
}