mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-25 09:51:01 -05:00
Added enum that describes dependency kinds
This commit is contained in:
parent
59f286e65e
commit
f6c5dfd62b
1 changed files with 33 additions and 0 deletions
33
src/metadata/dependency-kind.ts
Normal file
33
src/metadata/dependency-kind.ts
Normal 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;
|
Loading…
Reference in a new issue