parse x and y position from moveTo param

This commit is contained in:
Hanusiak Piotr
2022-02-09 10:52:44 +01:00
parent fe570c9117
commit b565080312
2 changed files with 22 additions and 4 deletions
+12
View File
@@ -0,0 +1,12 @@
export class StringUtils {
public static parsePointFromParam(param: string, separator: string = ","): { x: number; y: number } | undefined {
const values = param.split(separator).map((val) => parseInt(val));
if (values.length !== 2) {
return;
}
if (isNaN(values[0]) || isNaN(values[1])) {
return;
}
return { x: values[0], y: values[1] };
}
}