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 | 208x 49x 28x 64x 159x 75x 112x 84x | import { isArrayOfPrimitives } from "../utils";
export function normalizeArrayOfPrimitives(data: any): any {
if (Array.isArray(data)) {
if (isArrayOfPrimitives(data)) {
return data.map((value) => ({ value }));
} else {
return data.map((item) => normalizeArrayOfPrimitives(item));
}
} else if (Object(data) === data) {
return Object.fromEntries(
Object.entries(data).map(([key, value]) => [
key,
normalizeArrayOfPrimitives(value),
]),
);
} else {
return data;
}
}
|