This commit is contained in:
Kim Ravn Hansen
2025-10-17 12:33:41 +02:00
parent d7ff5b432b
commit 0265f78b6d
3 changed files with 80 additions and 55 deletions

View File

@@ -16,7 +16,7 @@ export class Orientation {
/**
* @param {string} str
* @returns {Orientation}
* @returns {Orientation|undefined}
*/
static fromString(str) {
if (typeof str !== "string") {
@@ -35,14 +35,16 @@ export class Orientation {
/**
* @param {string|number} val
* @returns {Orientation}
* @returns {Orientation|undefined}
*/
static normalize(val) {
if (typeof val === "string") {
return Orientation.fromString(val);
}
return val % 4;
if ((val | 0) === val) {
return (val | 0) % 4;
}
}
}