Skip to content

Commit a0ef6e7

Browse files
committed
fix(json-text): 🐛 classify null as primitive
1 parent 6a87c69 commit a0ef6e7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/json-text/__tests__/toTree.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test('can format complex object', () => {
4949
└─ key
5050
├─ [0]: 1
5151
├─ [1]: 2
52-
├─ [2]!n
52+
├─ [2]: !n
5353
├─ [3]: !t
5454
└─ [4]: !f"
5555
`);

src/json-text/toTree.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {printTree} from 'tree-dump/lib/printTree';
22
import {stringify} from './stringify';
33

4-
const isPrimitive = (value: unknown): boolean => typeof value !== 'object';
4+
const isPrimitive = (value: unknown): boolean => typeof value !== 'object' || value === null;
55
const isOneLineValue = (value: unknown): boolean => {
66
if (isPrimitive(value)) return true;
77
if (value instanceof Array && !value.length) return true;

0 commit comments

Comments
 (0)