import type Bicoder from "./Bicoder"; import globals from "./globals"; const JSON = { stringify: function (_bicoder: Bicoder, value: T): string { return globals.JSON.stringify(value); }, parse: function (bicoder: Bicoder, jsonString: string): T { const parsed = globals.JSON.parse(jsonString); if (!bicoder.test(parsed)) { throw new Error("JSON does not match type"); } return parsed; }, }; export default JSON;