Skip to content

Commit 24d7786

Browse files
amareshsmharish-sethuramannzakas
authored
fix: minor glitches in the right pane (#58)
Co-authored-by: Strek <[email protected]> Co-authored-by: Nicholas C. Zakas <[email protected]>
1 parent 37609c5 commit 24d7786

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/lib/render-value.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
export const renderValue = (value: unknown): string[] => {
22
if (Array.isArray(value)) {
3-
return ["Array", `[${value.length} elements]`];
3+
return [
4+
"Array",
5+
value.length
6+
? value.length === 1
7+
? `[${value.length} element]`
8+
: `[${value.length} elements]`
9+
: "[]",
10+
];
11+
}
12+
13+
if (value instanceof Object && Object.keys(value).length === 0) {
14+
return ["Object", "{}"];
415
}
516

617
if (typeof value === "object" && value !== null) {
718
const keys = Object.keys(value);
819
return [
9-
(value as { type: string })?.type,
20+
(value as { type: string })?.type ?? "Object",
1021
keys.length > 3
1122
? `{${keys.slice(0, 3).join(", ")}, ...}`
1223
: `{${keys.join(", ")}}`,

0 commit comments

Comments
 (0)