feat(smartjson): Implement stableOneWayStringify: deterministic, cycle-safe JSON for hashing/comparisons; update docs and tests

This commit is contained in:
2025-09-12 20:43:03 +00:00
parent 374a8e411a
commit bd67581b75
5 changed files with 122 additions and 3 deletions

View File

@@ -104,4 +104,15 @@ tap.test('should respect simpleOrderArray comparator', async () => {
expect(ordered.indexOf('"a"')).toBeLessThan(ordered.indexOf('"c"'));
});
tap.test('stableOneWayStringify should handle circular references without throwing', async () => {
const a: any = { name: 'x' };
a.self = a;
const b: any = { name: 'x' };
b.self = b;
const s1 = smartjson.stableOneWayStringify(a);
const s2 = smartjson.stableOneWayStringify(b);
expect(typeof s1).toEqual('string');
expect(s1).toEqual(s2);
});
tap.start();