Add getService helper function

This commit is contained in:
Haidang666
2021-09-13 14:49:17 +07:00
parent 1e05c04a39
commit 93c69248d9
7 changed files with 55 additions and 17 deletions

16
src/utils/getService.ts Normal file
View File

@@ -0,0 +1,16 @@
import { Service } from "../types/segments.model";
export function getService<T extends string>(...value: T[]): Service {
for (const name of value) {
if (name) {
const service = Object.values(Service).find(
(val) => val.toLowerCase() === name.trim().toLowerCase()
);
if (service) {
return service;
}
}
}
return Service.YouTube;
}