UNPKG

@boringnode/bus

Version:

A simple and lean driver-based service bus implementation

34 lines (32 loc) 778 B
// src/encoders/json_encoder.ts var JsonEncoder = class { encode(message) { return JSON.stringify(message); } decode(data) { return JSON.parse(data.toString()); } }; // src/transport_message.ts function isTransportMessage(value) { return typeof value === "object" && value !== null && !Array.isArray(value) && typeof Reflect.get(value, "busId") === "string" && Object.hasOwn(value, "payload"); } function tryDecodeTransportMessage(encoder, data) { try { const message = encoder.decode(data); return isTransportMessage(message) ? message : null; } catch { return null; } } export { JsonEncoder, tryDecodeTransportMessage }; /** * @boringnode/bus * * @license MIT * @copyright BoringNode */ //# sourceMappingURL=chunk-DZUPXJD3.js.map