123ishaTest / 123ishaTest/ludiek
[Currency] Improve CurrencyPlugin to deal better with duplicate currencies
- Lenguaje dominante
- TypeScript
- Estrellas
- 12
- Forks
- 4
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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 }]
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.