Added enum that describes dependency kinds

This commit is contained in:
Kir_Antipov 2021-12-07 21:34:24 +03:00
parent 59f286e65e
commit f6c5dfd62b

View file

@ -0,0 +1,33 @@
enum DependencyKind {
Depends = 1,
Recommends,
Includes,
Suggests,
Conflicts,
Breaks,
}
namespace DependencyKind {
export function getValues(): DependencyKind[] {
return <DependencyKind[]>Object.values(DependencyKind).filter(x => typeof x === "number");
}
export function parse(kindName: string): DependencyKind | undefined {
if (typeof DependencyKind[kindName] === "number") {
return DependencyKind[kindName];
}
for (const kind of Object.values(DependencyKind)) {
if (typeof kind === "number" && kindName.localeCompare(DependencyKind[kind], undefined, { sensitivity: "accent" }) === 0) {
return kind;
}
}
return undefined;
}
export function toString(target: DependencyKind): string {
return DependencyKind[target] ?? target.toString();
}
}
export default DependencyKind;