v4
This commit is contained in:
@@ -3,11 +3,14 @@ export function numericPrice(price: string): number {
|
||||
return Number.isFinite(value) ? value : Number.POSITIVE_INFINITY;
|
||||
}
|
||||
|
||||
export function decoratePlans<T extends { price: string }>(plans: T[]) {
|
||||
const sorted = [...plans]
|
||||
.map((plan, index) => ({ plan, index, value: numericPrice(plan.price) }))
|
||||
.sort((a, b) => a.value - b.value || a.index - b.index);
|
||||
export function decoratePlans<T extends { price: string; period: string }>(plans: T[]) {
|
||||
const enriched = plans.map((plan, index) => ({
|
||||
plan,
|
||||
index,
|
||||
value: numericPrice(plan.price)
|
||||
}));
|
||||
|
||||
const sorted = [...enriched].sort((a, b) => a.value - b.value || a.index - b.index);
|
||||
const cheapestIndex = sorted[0]?.index ?? -1;
|
||||
const mobileOrder = new Map(sorted.map((entry, order) => [entry.index, order]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user