From 2f8b8c87fb2062313afea7b625ccb20d1bea95b9 Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Tue, 24 May 2022 18:25:43 +0200 Subject: Initial commit --- src/helpers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/helpers.ts (limited to 'src/helpers.ts') 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('-'); -- cgit v1.3.1