UNPKG

arvo-core

Version:

The core Arvo package which provides application tier core primitives and contract system for building production-grade event-driven application. Provides ArvoEvent (CloudEvents-compliant), ArvoContract for type-safe service interfaces, event factories, O

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;