mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
extract updateItems
This commit is contained in:
parent
796f5e7764
commit
b45e9b7cf2
@ -18,14 +18,19 @@ export class GildedRose {
|
||||
}
|
||||
|
||||
updateQuality() {
|
||||
this.items = this.items
|
||||
.map((item) => ({ ...item, quality: updateItemQuality(item) }))
|
||||
.map((item) => ({ ...item, sellIn: updateItemSellIn(item) }))
|
||||
.map(item => ({ ...item, quality: sellInBelow0(item) }))
|
||||
this.items = updateItems(this.items)
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateItems(items: Item[]): Item[] {
|
||||
return items
|
||||
.map((item) => ({ ...item, quality: updateItemQuality(item) }))
|
||||
.map((item) => ({ ...item, sellIn: updateItemSellIn(item) }))
|
||||
.map(item => ({ ...item, quality: sellInBelow0(item) }))
|
||||
}
|
||||
|
||||
function updateItemSellIn({name, sellIn}: Item) {
|
||||
if (name == 'Sulfuras, Hand of Ragnaros') return sellIn
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user