haveSameCurrency
Check whether a set of Dinero objects have the same currency.
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
dineroObjects | Dinero<TAmount>[] | The Dinero object to check. | Yes |
Code examples
Compare two objects with the same currency
js
import { dinero, haveSameCurrency } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d1 = dinero({ amount: 2000, currency: USD });
const d2 = dinero({ amount: 1000, currency: USD });
haveSameCurrency([d1, d2]); // trueCompare two objects with different currencies
js
import { dinero, haveSameAmount } from 'dinero.js';
import { USD, EUR } from '@dinero.js/currencies';
const d1 = dinero({ amount: 1000, currency: USD });
const d2 = dinero({ amount: 1000, currency: EUR });
haveSameAmount([d1, d2]); // false