reactotron-core-client
Version:
Grants Reactotron clients the ability to talk to a Reactotron server.
33 lines (31 loc) • 951 B
JavaScript
;
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");
}
};
export default validate;
//# sourceMappingURL=validate.js.map