Skip to content

Commit

Permalink
Reorder parsers for cleaner PR diff
Browse files Browse the repository at this point in the history
  • Loading branch information
benchristel committed Nov 23, 2024
1 parent 1c25052 commit 527be33
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,14 @@ const parseAnswerForm: Parser<PerseusExpressionAnswerForm> = object({
).parser,
});

const parseExpressionWidgetV0 = parseWidgetWithVersion(
optional(object({major: constant(0), minor: number})),
const parseExpressionWidgetLatest: Parser<ExpressionWidget> = parseWidget(
constant("expression"),
object({
answerForms: array(parseAnswerForm),
functions: array(string),
times: boolean,
visibleLabel: optional(string),
ariaLabel: optional(string),
form: boolean,
simplify: boolean,
value: string,
buttonSets: array(
enumeration(
"basic",
Expand All @@ -59,17 +56,20 @@ const parseExpressionWidgetV0 = parseWidgetWithVersion(
),
),
buttonsVisible: optional(enumeration("always", "never", "focused")),
})
}),
);

const parseExpressionWidgetLatest: Parser<ExpressionWidget> = parseWidget(
const parseExpressionWidgetV0 = parseWidgetWithVersion(
optional(object({major: constant(0), minor: number})),
constant("expression"),
object({
answerForms: array(parseAnswerForm),
functions: array(string),
times: boolean,
visibleLabel: optional(string),
ariaLabel: optional(string),
form: boolean,
simplify: boolean,
value: string,
buttonSets: array(
enumeration(
"basic",
Expand All @@ -82,8 +82,8 @@ const parseExpressionWidgetLatest: Parser<ExpressionWidget> = parseWidget(
),
),
buttonsVisible: optional(enumeration("always", "never", "focused")),
})
)
}),
);

function migrateV0ToLatest(widget: ParsedValue<typeof parseExpressionWidgetV0>, ctx: ParseContext): ParseResult<ExpressionWidget> {
const {options} = widget;
Expand Down

0 comments on commit 527be33

Please sign in to comment.