Skip to content

Commit a5b60d7

Browse files
committed
style: format code with prettier
1 parent ea5ddf2 commit a5b60d7

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/evaluator/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,9 @@ export function evaluate(ctx: Context, node: Node, solution: Solution): number {
3131
let right: number;
3232

3333
function toNumber(value: string | number) {
34-
value = Number(value).toPrecision(
35-
ctx.preferences.precision
36-
)
34+
value = Number(value).toPrecision(ctx.preferences.precision);
3735
value = Number(value).toFixed(ctx.preferences.fractionDigits);
38-
return Number.parseFloat(value)
36+
return Number.parseFloat(value);
3937
}
4038

4139
switch (node.type) {
@@ -128,7 +126,7 @@ export function evaluate(ctx: Context, node: Node, solution: Solution): number {
128126

129127
// build solution like binary ops
130128

131-
let partial = `${node.left!.value} ${node.value} `
129+
let partial = `${node.left!.value} ${node.value} `;
132130

133131
// compute node.right
134132
right = evaluate(ctx, node.right!, solution);
@@ -142,7 +140,7 @@ export function evaluate(ctx: Context, node: Node, solution: Solution): number {
142140

143141
solution.push(partial);
144142

145-
result = right
143+
result = right;
146144
ctx.variables.set(node.left!.value, right);
147145

148146
solution.push(result);

src/lexer/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export function tokenize(ctx: Context, code: string): Token[] {
3737
const tokens: Token[] = [];
3838

3939
// remove all comments
40-
code += SYMBOL.NEWLINE
41-
code = code.replace(/\n\s*#.*\n/g, "\n\n")
42-
code = code.replace(/\s*#.*\n/g, "\n")
40+
code += SYMBOL.NEWLINE;
41+
code = code.replace(/\n\s*#.*\n/g, '\n\n');
42+
code = code.replace(/\s*#.*\n/g, '\n');
4343

4444
function isFunction(id: string) {
4545
return ctx.functions.has(id);

src/render/html.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function formatTokenValue(token: Token): string {
4242
}
4343

4444
/**
45-
* Generate HTML representation of the expression from tokens
45+
* Generate HTML representation of the expression from tokens
4646
* - _experimental_
4747
*/
4848
export function renderTokensAsHTML(
@@ -70,7 +70,7 @@ export function renderTokensAsHTML(
7070

7171
// skip EOF or implicit token
7272
if (token.type === TOKEN.EOF || token.implicit) {
73-
return ''
73+
return '';
7474
}
7575

7676
// handle special cases
@@ -81,14 +81,21 @@ export function renderTokensAsHTML(
8181
// handle exponentiation with superscript
8282
if (token.type === TOKEN.OPERATOR && token.value === SYMBOL.POW) {
8383
const nextToken = tokens[index + 1];
84-
if (nextToken && (nextToken.type === TOKEN.NUMBER || nextToken.type === TOKEN.IDENTIFIER)) {
84+
if (
85+
nextToken &&
86+
(nextToken.type === TOKEN.NUMBER ||
87+
nextToken.type === TOKEN.IDENTIFIER)
88+
) {
8589
// skip this token, let the number/identifier be rendered as superscript by the next iteration
8690
return '';
8791
}
8892
}
8993

9094
// handle superscript numbers after exponentiation
91-
if (index > 0 && (token.type === TOKEN.NUMBER || token.type === TOKEN.IDENTIFIER)) {
95+
if (
96+
index > 0 &&
97+
(token.type === TOKEN.NUMBER || token.type === TOKEN.IDENTIFIER)
98+
) {
9299
const prevToken = tokens[index - 1];
93100
if (
94101
prevToken &&

src/render/latex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function handleSpecialCases(
135135
}
136136

137137
/**
138-
* Generate LaTeX representation of the expression from tokens
138+
* Generate LaTeX representation of the expression from tokens
139139
* - _experimental_
140140
*/
141141
export function renderTokensAsLaTeX(

0 commit comments

Comments
 (0)