0
0

add some helper methods to enum class

This commit is contained in:
DrMaxNix 2022-09-06 16:46:41 +02:00
parent 929d41e392
commit 3e89f10d72

View File

@ -11,4 +11,18 @@ class Juicescript_helper_enum {
yield key;
}
}
/*
HELPER: Check if ELEMENT is member of this enum
*/
has(element){
return Object.keys(this).includes(element);
}
/*
GETTER: Return name of enum with VALUE
*/
name(value){
return Object.keys(this).find(key => this[key] === value);
}
}