123ishaTest / 123ishaTest/ludiek

[Currency] Improve CurrencyPlugin to deal better with duplicate currencies

Abierto
#61 2 comentarios 1 reacción 0 asignados Ver en GitHub
good first issue plugin
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.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.