123ishaTest / 123ishaTest/ludiek

[Currency] Improve CurrencyPlugin to deal better with duplicate currencies

未關閉
#61 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
good first issue plugin
主要語言
TypeScript
星號
12
分支
4
PR 合併指標
30 天內沒有已合併 PR

描述

The CurrencyPlugin provides helper method that deal with lists of currencies.
However this could lead to the following odd scenario

```ts
const currency = new CurrencyPlugin([{ id: 'money' }]);
currency.gainCurrency({ id: 'money', amount: 1 });

const isPaid = currency.payCurrencies([
{ id: 'money', amount: 1 },
{ id: 'money', amount: 1 },
]);

console.log(isPaid); // true
console.log(currency.getBalance('money')); // -1
```

We could merge these lists together with a new `simplifyCurrencyList` function before checking, so it becomes
```ts
[{ id: 'money', amount: 2 }]
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。