Improve ensureArray and use it in tracing (#8785)

* Improve ensureArray and use it in tracing

* Fix typing

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
Bram Kragten
2021-04-01 22:33:47 +02:00
committed by GitHub
parent 401064d3c8
commit deca6f03ba
6 changed files with 60 additions and 55 deletions

View File

@@ -1,6 +1,8 @@
export const ensureArray = (value?: any) => {
if (!value || Array.isArray(value)) {
export function ensureArray(value: undefined): undefined;
export function ensureArray<T>(value: T | T[]): T[];
export function ensureArray(value) {
if (value === undefined || Array.isArray(value)) {
return value;
}
return [value];
};
}