File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed
Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change 1010 cpc = mod ;
1111 });
1212
13- let input = $state (" " );
14- let output = $derived .by (() => {
13+ function wasm_eval(input : string ) {
14+ if (! cpc || input .trim ().length === 0 ) {
15+ return " " ;
16+ }
1517 try {
16- if (! cpc || input .trim ().length === 0 ) {
17- return " " ;
18- }
1918 return cpc .wasm_eval (input );
2019 } catch (e ) {
2120 return " " ;
2221 }
23- });
22+ }
23+
24+ let input = $state (" " );
25+ let output = $derived (wasm_eval (input ));
2426 let saved_queries: { id: number ; in: string ; out: string }[] = $state ([]);
2527 </script >
2628
6264 type =" text"
6365 class =" border border-gray-500/50 w-full rounded-lg px-3 py-2 outline-none"
6466 bind:value ={input }
65- onkeydown ={(e ) => {
67+ onkeydown ={async (e ) => {
68+ const input_el = e .currentTarget ;
69+ const input = e .currentTarget .value ;
6670 if (check_shortcut (e , " Enter" )) {
67- const input = e .currentTarget .value ;
68- let out;
69- try {
70- out = wasm_eval (e .currentTarget .value );
71- } catch (e ) {
72- out = " " ;
73- }
71+ const out = wasm_eval (input )
7472 console .log (out );
7573 saved_queries .unshift ({
7674 id: saved_queries .length ,
7775 in: input ,
7876 out ,
7977 });
80- e . currentTarget .value = " " ;
78+ input_el .value = " " ;
8179 output = " " ;
8280 }
8381 }}
You can’t perform that action at this time.
0 commit comments