Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 264x 49x 2x 90x 215x 103x 140x 112x | import { isArrayOfArrays } from "../utils";
export function normalizePrimitiveArrays(data: any): any {
if (Array.isArray(data)) {
if (isArrayOfArrays(data)) {
return data.map((items) => ({ items: normalizePrimitiveArrays(items) }));
} else {
return data.map((item) => normalizePrimitiveArrays(item));
}
} else if (Object(data) === data) {
return Object.fromEntries(
Object.entries(data).map(([key, value]) => [
key,
normalizePrimitiveArrays(value),
]),
);
} else {
return data;
}
}
|