aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/Scripting.ts
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-04-04 01:30:01 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-04-04 01:30:01 -0400
commitdc2a998acdae1545c8e7bf9ee9f4ca98bba82ac9 (patch)
tree4f1c39d66dc9a3a653ec717c502854f60029add3 /src/client/util/Scripting.ts
parentc10b9ca57e13c8de8b35f01e6c6ce82706319e4d (diff)
Started adding linting
Diffstat (limited to 'src/client/util/Scripting.ts')
-rw-r--r--src/client/util/Scripting.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index 4e97b9401..8aef44a3a 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -26,7 +26,7 @@ export interface ExecutableScript {
}
function Compile(script: string | undefined, diagnostics: Opt<any[]>, scope: { [name: string]: any }): ExecutableScript {
- const compiled = !(diagnostics && diagnostics.some(diag => diag.category == ts.DiagnosticCategory.Error));
+ const compiled = !(diagnostics && diagnostics.some(diag => diag.category === ts.DiagnosticCategory.Error));
let func: () => Opt<Field>;
if (compiled && script) {
@@ -40,7 +40,7 @@ function Compile(script: string | undefined, diagnostics: Opt<any[]>, scope: { [
paramNames.push(prop);
params.push(scope[prop]);
}
- let thisParam = scope["this"];
+ let thisParam = scope.this;
let compiledFunction = new Function(...paramNames, script);
func = function (): Opt<Field> {
return compiledFunction.apply(thisParam, params)
@@ -49,10 +49,8 @@ function Compile(script: string | undefined, diagnostics: Opt<any[]>, scope: { [
func = () => undefined;
}
- return Object.assign(func,
- {
- compiled
- });
+ Object.assign(func, { compiled });
+ return func as ExecutableScript;
}
interface File {
@@ -125,9 +123,9 @@ export function CompileScript(script: string, scope?: { [name: string]: any }, a
}
export function ToField(data: any): Opt<Field> {
- if (typeof data == "string") {
+ if (typeof data === "string") {
return new TextField(data);
- } else if (typeof data == "number") {
+ } else if (typeof data === "number") {
return new NumberField(data);
}
return undefined;