Iterate over enum values (#445)

This commit is contained in:
Matt Gibson 2021-07-30 13:57:42 -05:00 committed by GitHub
parent fdf0eb989b
commit 65c998dd0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -296,6 +296,11 @@ export class Utils {
return Object.assign(target, source); return Object.assign(target, source);
} }
static iterateEnum<O extends object, K extends keyof O = keyof O>(obj: O) {
return (Object.keys(obj).filter(k => Number.isNaN(+k)) as K[]).map(k => obj[k]);
}
static getUrl(uriString: string): URL { static getUrl(uriString: string): URL {
if (uriString == null) { if (uriString == null) {
return null; return null;