Skip to content

Commit

Permalink
fix(json-text): 🐛 classify null as primitive
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Oct 7, 2024
1 parent 6a87c69 commit a0ef6e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/json-text/__tests__/toTree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test('can format complex object', () => {
└─ key
├─ [0]: 1
├─ [1]: 2
├─ [2]!n
├─ [2]: !n
├─ [3]: !t
└─ [4]: !f"
`);
Expand Down
2 changes: 1 addition & 1 deletion src/json-text/toTree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {printTree} from 'tree-dump/lib/printTree';
import {stringify} from './stringify';

const isPrimitive = (value: unknown): boolean => typeof value !== 'object';
const isPrimitive = (value: unknown): boolean => typeof value !== 'object' || value === null;
const isOneLineValue = (value: unknown): boolean => {
if (isPrimitive(value)) return true;
if (value instanceof Array && !value.length) return true;
Expand Down

0 comments on commit a0ef6e7

Please sign in to comment.