ant-design/components/_util/toList.ts
二货爱吃白萝卜 3b8ea07a8a
fix: Typography copyable support array children (#50813)
* test: test driven

* test: test driven

* fix: test case
2024-09-11 20:01:10 +08:00

6 lines
223 B
TypeScript

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