aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers.ts
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2022-05-24 18:25:43 +0200
committerMaksymilian Jopek <maks@jopek.eu>2022-05-24 18:25:43 +0200
commit2f8b8c87fb2062313afea7b625ccb20d1bea95b9 (patch)
tree973e20986e4b9279b9322a9fd140e6f989eaf492 /src/helpers.ts
download1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.gz
1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.tar.zst
1942-2f8b8c87fb2062313afea7b625ccb20d1bea95b9.zip
Initial commit
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/helpers.ts b/src/helpers.ts
new file mode 100644
index 0000000..8a17555
--- /dev/null
+++ b/src/helpers.ts
@@ -0,0 +1,8 @@
+import { canvas, ctx } from "./consts";
+
+export const sleep = (ms: number) => new Promise(res => setTimeout(res, ms));
+export const clearCtx = () => ctx.clearRect(0, 0, canvas.width, canvas.height)
+export const toKebabCase = (str: string) => str
+ .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
+ ?.map(x => x.toLowerCase())
+ .join('-');