Skip to content

Commit f2983b2

Browse files
fix: version 3.3.4
Changelog: - Fix: JSONStringify denoising should support spaces and line-breaks
1 parent 746c509 commit f2983b2

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

__tests__/unit.cjs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,37 +101,45 @@ const test7Obj = [
101101
"90071992547409981111.5n",
102102
];
103103

104+
const test8Obj = { uid: BigInt("1308537228663099396") };
105+
const test8JSON = '{\n "uid": 1308537228663099396\n}';
106+
104107
assert.deepStrictEqual(JSONParse(test1JSON), test1Obj);
105-
console.log("1 test parsing passed");
108+
console.log("1 test passed");
106109
assert.deepStrictEqual(JSONStringify(JSONParse(test1JSON)), test1JSON);
107110
console.log("1 test round-trip passed");
108111

109112
assert.deepStrictEqual(JSONParse(test2JSON), test2Obj);
110-
console.log("2 test parsing passed");
113+
console.log("2 test passed");
111114
assert.deepStrictEqual(JSONStringify(JSONParse(test2JSON)), test2TersedJSON);
112115
console.log("2 test round-trip passed");
113116

114117
assert.deepStrictEqual(JSONParse(test3JSON), test3Obj);
115-
console.log("3 test parsing passed");
118+
console.log("3 test passed");
116119
assert.deepStrictEqual(JSONStringify(JSONParse(test3JSON)), test3JSON);
117120
console.log("3 test round-trip passed");
118121

119122
assert.deepStrictEqual(JSONParse(test4JSON), test4Obj);
120-
console.log("4 test parsing passed");
123+
console.log("4 test passed");
121124
assert.deepStrictEqual(JSONStringify(JSONParse(test4JSON)), test4JSON);
122125
console.log("4 test round-trip passed");
123126

124127
assert.deepStrictEqual(JSONParse(test5JSON), test5Obj);
125-
console.log("5 test parsing passed");
128+
console.log("5 test passed");
126129
assert.deepStrictEqual(JSONStringify(JSONParse(test5JSON)), test5JSON);
127130
console.log("5 test round-trip passed");
128131

129132
assert.deepStrictEqual(JSONParse(test6JSON), test6Obj);
130-
console.log("6 test parsing passed");
133+
console.log("6 test passed");
131134
assert.deepStrictEqual(JSONStringify(JSONParse(test6JSON)), test6JSON);
132135
console.log("6 test round-trip passed");
133136

134137
assert.deepStrictEqual(JSONParse(test7JSON), test7Obj);
135-
console.log("7 test parsing passed");
138+
console.log("7 test passed");
136139
assert.deepStrictEqual(JSONStringify(JSONParse(test7JSON)), test7JSON);
137140
console.log("7 test round-trip passed");
141+
142+
assert.deepStrictEqual(JSONStringify(test8Obj, null, 2), test8JSON);
143+
console.log("8 test passed");
144+
assert.deepStrictEqual(JSONParse(JSONStringify(test8Obj, null, 2)), test8Obj);
145+
console.log("8 test round-trip passed");

json-with-bigint.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const JSONStringify = (value, replacer, space) => {
2626
if (!value) return originalStringify(value, replacer, space);
2727

2828
const bigInts = /([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
29-
const noise = /([\[:])?("-?\d+n+)n("$|"[,\}\]])/g;
29+
const noise = /([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
3030
const convertedToCustomJSON = originalStringify(
3131
value,
3232
(key, value) => {

json-with-bigint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const JSONStringify = (value, replacer, space) => {
2626
if (!value) return originalStringify(value, replacer, space);
2727

2828
const bigInts = /([\[:])?"(-?\d+)n"($|([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
29-
const noise = /([\[:])?("-?\d+n+)n("$|"[,\}\]])/g;
29+
const noise = /([\[:])?("-?\d+n+)n("$|"([\\n]|\s)*(\s|[\\n])*[,\}\]])/g;
3030
const convertedToCustomJSON = originalStringify(
3131
value,
3232
(key, value) => {

json-with-bigint.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-with-bigint",
3-
"version": "3.3.3",
3+
"version": "3.3.4",
44
"description": "JS library that allows you to easily serialize and deserialize data with BigInt values",
55
"type": "module",
66
"exports": {

0 commit comments

Comments
 (0)