UNPKG

reactotron-core-client

Version:

Grants Reactotron clients the ability to talk to a Reactotron server.

37 lines (35 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; const isCreateSocketValid = createSocket => typeof createSocket !== "undefined" && createSocket !== null; const isHostValid = host => typeof host === "string" && host && host !== ""; const isPortValid = port => typeof port === "number" && port >= 1 && port <= 65535; const onCommandValid = fn => typeof fn === "function"; /** * Ensures the options are sane to run this baby. Throw if not. These * are basically sanity checks. */ const validate = options => { const { createSocket, host, port, onCommand } = options; if (!isCreateSocketValid(createSocket)) { throw new Error("invalid createSocket function"); } if (!isHostValid(host)) { throw new Error("invalid host"); } if (!isPortValid(port)) { throw new Error("invalid port"); } if (!onCommandValid(onCommand)) { throw new Error("invalid onCommand handler"); } }; var _default = exports.default = validate; //# sourceMappingURL=validate.js.map