UNPKG

ws-rmi

Version:

A Remote Method Invocation implementation written in JavaScript utilising the WebSocket protocol

18 lines (17 loc) 869 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateRMIRemoteResult = exports.createRMIRemoteResult = void 0; const RMIMessage_1 = require("./RMIMessage"); const JSONValidation_1 = require("../JSONValidation"); /** * Creates an object adhering to the RMI Remote Result schema. * * @param id The ID of the request that was used from the client. * @param result The result of the function invocation. */ const createRMIRemoteResult = (id, result) => (0, RMIMessage_1.createRMIMessage)(id, "RESPONSE_RESULT", { result }); exports.createRMIRemoteResult = createRMIRemoteResult; /** * Validates that the given message is an RMI Remote Result. */ exports.validateRMIRemoteResult = (0, RMIMessage_1.createRMIMessageValidator)((data) => (0, JSONValidation_1.isObject)(data) && (0, JSONValidation_1.hasProperty)(data, "result"));