aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/states/watch.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/states/watch.ts')
-rw-r--r--frontend/app/states/watch.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/frontend/app/states/watch.ts b/frontend/app/states/watch.ts
index 14a70b4..8c7faa7 100644
--- a/frontend/app/states/watch.ts
+++ b/frontend/app/states/watch.ts
@@ -83,3 +83,13 @@ export const setLatestGameStatesAtom = atom(
set(rawLatestGameStatesAtom, value);
},
);
+
+export function calcCodeSize(code: string): number {
+ const trimmed = code
+ .replace(/\s+/g, "")
+ .replace(/^<\?php/, "")
+ .replace(/^<\?/, "")
+ .replace(/\?>$/, "");
+ const utf8Encoded = new TextEncoder().encode(trimmed);
+ return utf8Encoded.length;
+}