node-simple-ipc
Version:
A Node.Js module for local Inter Process Communication
48 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isIpcEvent = exports.isIpcOutput = exports.isIpcInput = exports.assertValidIpcHandler = exports.assertValidIpcName = void 0;
function assertValidIpcName(name) {
if (typeof name === 'string' && name.length > 0) {
return true;
}
throw new Error('IPC name must be a not empty string.');
}
exports.assertValidIpcName = assertValidIpcName;
function assertValidIpcHandler(handlerFn) {
if (typeof handlerFn === 'function') {
return true;
}
throw new Error('IPC handler must be a function.');
}
exports.assertValidIpcHandler = assertValidIpcHandler;
function isIpcInput(data) {
if (typeof data !== 'object') {
return false;
}
const input = data;
return ('correlationId' in input &&
'name' in input &&
'type' in input &&
input.type === "I" /* Input */);
}
exports.isIpcInput = isIpcInput;
function isIpcOutput(data) {
if (typeof data !== 'object') {
return false;
}
const output = data;
return ('correlationId' in output &&
'name' in output &&
'type' in output &&
output.type === "O" /* Output */);
}
exports.isIpcOutput = isIpcOutput;
function isIpcEvent(data) {
if (typeof data !== 'object') {
return false;
}
const event = data;
return 'name' in event && 'type' in event && event.type === "E" /* Event */;
}
exports.isIpcEvent = isIpcEvent;
//# sourceMappingURL=validation.js.map