diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-11 21:40:54 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-11 21:50:20 +0530 |
| commit | 845d503bb16cb5046a4fec6d046b7b527a080187 (patch) | |
| tree | a9f8fdf4510ad4d61e8d105065be9071946e2bdf /src/eval.ts | |
| parent | 5a9942fde65787b35d4eb8e3441af6fe68819612 (diff) | |
| download | css-everything-845d503bb16cb5046a4fec6d046b7b527a080187.tar.gz css-everything-845d503bb16cb5046a4fec6d046b7b527a080187.zip | |
chore: adds prettier
Diffstat (limited to 'src/eval.ts')
| -rw-r--r-- | src/eval.ts | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/eval.ts b/src/eval.ts index 191a76b..5e99282 100644 --- a/src/eval.ts +++ b/src/eval.ts @@ -12,7 +12,11 @@ export type EvalActions = { setAttribute(name: string, value: string): Promise<void> withEvent(fn: (e: any) => void): Promise<void> getFormData(): Promise<FormData | undefined> - sendRequest(_: { method: string, url: string, data: FormData | undefined }): Promise<void> + sendRequest(_: { + method: string + url: string + data: FormData | undefined + }): Promise<void> // calculate ?? } @@ -20,19 +24,19 @@ type EvalValue = string | undefined | void export const evalExpr = async ( expr: Expr, - actions: EvalActions + actions: EvalActions, ): Promise<EvalValue> => match<Promise<EvalValue>, Expr>(expr, { Call: async ({ name, args }) => getFunctions(name, args, actions), - LiteralString: async (s) => s, + LiteralString: async s => s, LiteralNumber: async ({ value, unit }) => matchString<number, CSSUnit>(unit, { s: () => value * 1000, _: () => value, }).toString(), - Identifier: async (s) => s, - VarIdentifier: async (s) => s, - _: async (_) => undefined, + Identifier: async s => s, + VarIdentifier: async s => s, + _: async _ => undefined, }) const getFunctions = (name: string, args: Expr[], actions: EvalActions) => @@ -93,9 +97,11 @@ const getFunctions = (name: string, args: Expr[], actions: EvalActions) => }, 'prevent-default': async () => actions.withEvent(e => e.preventDefault()), - 'request': async () => { + request: async () => { const url = await evalExpr(args[0], actions) - const method = args[1] ? (await evalExpr(args[1], actions) ?? 'post') : 'post' + const method = args[1] + ? (await evalExpr(args[1], actions)) ?? 'post' + : 'post' if (url) { const data = await actions.getFormData() |
