-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up no longer needed checks for RuleElements
- Loading branch information
Showing
6 changed files
with
38 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,10 @@ | ||
import FlatModifier from "./ruleElements/flatModifier.js"; | ||
import ReplaceValue from "./ruleElements/replaceValue.js"; | ||
|
||
/** RuleElement identifier strings */ | ||
export const RULE_ELEMENT_IDS = { | ||
FLAT_MODIFIER: "WV.RuleElement.FlatModifier", | ||
REPLACE_VALUE: "WV.RuleElement.ReplaceValue" | ||
} as const; | ||
|
||
/** A union type of RuleElement ID strings */ | ||
export type RuleElementId = ValueOf<typeof RULE_ELEMENT_IDS>; | ||
|
||
/** A mapping of RuleElement IDs to RuleElement constructors. */ | ||
export const RULE_ELEMENTS = { | ||
[RULE_ELEMENT_IDS.FLAT_MODIFIER]: FlatModifier, | ||
[RULE_ELEMENT_IDS.REPLACE_VALUE]: ReplaceValue | ||
["WV.RuleElement.FlatModifier"]: FlatModifier, | ||
["WV.RuleElement.ReplaceValue"]: ReplaceValue | ||
} as const; | ||
|
||
export type MappedRuleElementId = keyof typeof RULE_ELEMENTS; | ||
|
||
/** | ||
* A custom typeguard to check whether a given RuleElement type string is one of | ||
* the mapped RuleElement types. | ||
* @param type - the type string to check | ||
* @returns whether the type string is one of the RuleElement types | ||
*/ | ||
export function isMappedRuleElementType( | ||
type?: string | ||
): type is MappedRuleElementId { | ||
if (typeof type !== "string") return false; | ||
return Object.keys(RULE_ELEMENTS).includes(type); | ||
} | ||
export type RuleElementId = keyof typeof RULE_ELEMENTS; |