From 984420d181275df2dbf7a1554c6ffef4bda7aa70 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Fri, 11 Jan 2019 13:58:31 -0600 Subject: [PATCH] Convert indentation to tabs --- packages/server/src/node/evaluate.ts | 106 +++++++++++++-------------- packages/server/test/helpers.ts | 38 +++++----- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/packages/server/src/node/evaluate.ts b/packages/server/src/node/evaluate.ts index 540c4ba17..f0ad80b32 100644 --- a/packages/server/src/node/evaluate.ts +++ b/packages/server/src/node/evaluate.ts @@ -3,59 +3,59 @@ import { NewEvalMessage, TypedValue, EvalFailedMessage, EvalDoneMessage, ServerM import { SendableConnection } from "../common/connection"; export const evaluate = async (connection: SendableConnection, message: NewEvalMessage): Promise => { - const argStr: string[] = []; - message.getArgsList().forEach((value) => { - argStr.push(value); - }); - const sendResp = (resp: any): void => { - const evalDone = new EvalDoneMessage(); - evalDone.setId(message.getId()); - const tof = typeof resp; - if (tof !== "undefined") { - const tv = new TypedValue(); - let t: TypedValue.Type; - switch (tof) { - case "string": - t = TypedValue.Type.STRING; - break; - case "boolean": - t = TypedValue.Type.BOOLEAN; - break; - case "object": - t = TypedValue.Type.OBJECT; - break; - case "number": - t = TypedValue.Type.NUMBER; - break; - default: - sendErr(EvalFailedMessage.Reason.EXCEPTION, `unsupported response type ${tof}`); - return; - } - tv.setValue(tof === "string" ? resp : JSON.stringify(resp)); - tv.setType(t); - evalDone.setResponse(tv); - } + const argStr: string[] = []; + message.getArgsList().forEach((value) => { + argStr.push(value); + }); + const sendResp = (resp: any): void => { + const evalDone = new EvalDoneMessage(); + evalDone.setId(message.getId()); + const tof = typeof resp; + if (tof !== "undefined") { + const tv = new TypedValue(); + let t: TypedValue.Type; + switch (tof) { + case "string": + t = TypedValue.Type.STRING; + break; + case "boolean": + t = TypedValue.Type.BOOLEAN; + break; + case "object": + t = TypedValue.Type.OBJECT; + break; + case "number": + t = TypedValue.Type.NUMBER; + break; + default: + sendErr(EvalFailedMessage.Reason.EXCEPTION, `unsupported response type ${tof}`); + return; + } + tv.setValue(tof === "string" ? resp : JSON.stringify(resp)); + tv.setType(t); + evalDone.setResponse(tv); + } - const serverMsg = new ServerMessage(); - serverMsg.setEvalDone(evalDone); - connection.send(serverMsg.serializeBinary()); - }; - const sendErr = (reason: EvalFailedMessage.Reason, msg: string): void => { - const evalFailed = new EvalFailedMessage(); - evalFailed.setId(message.getId()); - evalFailed.setReason(reason); - evalFailed.setMessage(msg); + const serverMsg = new ServerMessage(); + serverMsg.setEvalDone(evalDone); + connection.send(serverMsg.serializeBinary()); + }; + const sendErr = (reason: EvalFailedMessage.Reason, msg: string): void => { + const evalFailed = new EvalFailedMessage(); + evalFailed.setId(message.getId()); + evalFailed.setReason(reason); + evalFailed.setMessage(msg); - const serverMsg = new ServerMessage(); - serverMsg.setEvalFailed(evalFailed); - connection.send(serverMsg.serializeBinary()); - }; - try { - const value = vm.runInNewContext(`(${message.getFunction()})(${argStr.join(",")})`, { require, setTimeout }, { - timeout: message.getTimeout() || 30000, - }); - sendResp(await value); - } catch (ex) { - sendErr(EvalFailedMessage.Reason.EXCEPTION, ex.toString()); - } + const serverMsg = new ServerMessage(); + serverMsg.setEvalFailed(evalFailed); + connection.send(serverMsg.serializeBinary()); + }; + try { + const value = vm.runInNewContext(`(${message.getFunction()})(${argStr.join(",")})`, { require, setTimeout }, { + timeout: message.getTimeout() || 30000, + }); + sendResp(await value); + } catch (ex) { + sendErr(EvalFailedMessage.Reason.EXCEPTION, ex.toString()); + } }; \ No newline at end of file diff --git a/packages/server/test/helpers.ts b/packages/server/test/helpers.ts index 47027d2cb..289e216a0 100644 --- a/packages/server/test/helpers.ts +++ b/packages/server/test/helpers.ts @@ -3,26 +3,26 @@ import { Client } from "../src/browser/client"; import { Server } from "../src/node/server"; export const createClient = (): Client => { - const s2c = new Emitter(); - const c2s = new Emitter(); + const s2c = new Emitter(); + const c2s = new Emitter(); - new Server({ - close: () => undefined, - onClose: () => undefined, - onMessage: (cb) => { - c2s.event((d) => cb(d)); - }, - send: (data) => setTimeout(() => s2c.emit(data), 0), - }); + new Server({ + close: () => undefined, + onClose: () => undefined, + onMessage: (cb) => { + c2s.event((d) => cb(d)); + }, + send: (data) => setTimeout(() => s2c.emit(data), 0), + }); - const client = new Client({ - close: () => undefined, - onClose: () => undefined, - onMessage: (cb) => { - s2c.event((d) => cb(d)); - }, - send: (data) => setTimeout(() => c2s.emit(data), 0), - }); + const client = new Client({ + close: () => undefined, + onClose: () => undefined, + onMessage: (cb) => { + s2c.event((d) => cb(d)); + }, + send: (data) => setTimeout(() => c2s.emit(data), 0), + }); - return client; + return client; };