Skip to content

Commit 7c0f4f6

Browse files
committed
Improve code readability
1 parent 871f71c commit 7c0f4f6

5 files changed

Lines changed: 5 additions & 6 deletions

File tree

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const jsonStringify = (
3333
}
3434

3535
if (node === undefined) return;
36+
if (node === null) return "null";
3637
if (typeof node === "number") return isFinite(node) ? "" + node : "null";
3738
if (typeof node !== "object") return JSON.stringify(node);
3839

@@ -47,8 +48,6 @@ const jsonStringify = (
4748
return out + "]";
4849
}
4950

50-
if (node === null) return "null";
51-
5251
if (seen.has(node)) {
5352
if (allowCycle) return JSON.stringify("__cycle__");
5453
throw new TypeError("Converting circular structure to JSON");

test/cmp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stringify from "../dist";
1+
import stringify from "../src";
22

33
test("custom comparison function", () => {
44
const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 };

test/nested.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import stringify from "../dist";
2+
import stringify from "../src";
33

44
test("nested", function () {
55
const obj = { c: 8, b: [{ z: 6, y: 5, x: 4 }, 7], a: 3 };

test/str.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stringify from "../dist";
1+
import stringify from "../src";
22

33
test("simple object", () => {
44
const obj = { c: 6, b: [4, 5], a: 3, z: null };

test/to-json.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stringify from "../dist";
1+
import stringify from "../src";
22

33
test("toJSON function", () => {
44
const obj = {

0 commit comments

Comments
 (0)