UNPKG

arvo-core

Version:

This core package contains all the core classes and components of the Arvo Event Driven System

25 lines (24 loc) 776 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isJSONSerializable = void 0; /** * Checks if an object is JSON serializable. * * @param obj - The object to check for JSON serializability. * @returns A boolean indicating whether the object is JSON serializable. * @throws {Error} If the object is not JSON serializable. */ var isJSONSerializable = function (obj) { try { var serialized = JSON.stringify(obj); if (serialized === '{}' && Object.keys(obj).length > 0) { return false; } var parsed = JSON.parse(serialized); return JSON.stringify(obj) === JSON.stringify(parsed); } catch (_a) { return false; } }; exports.isJSONSerializable = isJSONSerializable;