Check whether the value of a Dinero object is greater than or equal another.
You can only compare objects that share the same currency. The function also normalizes objects to the same scale (the highest) before comparing them.
Copy linkParameters
Name | Type | Description | Required |
---|---|---|---|
dineroObject | Dinero<TAmount> | The first Dinero object to compare. | Yes |
comparator | Dinero<TAmount> | The second Dinero object to compare. | Yes |
Copy linkCode examples
Copy linkCompare two objects
import { dinero, greaterThanOrEqual } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d1 = dinero({ amount: 500, currency: USD });
const d2 = dinero({ amount: 800, currency: USD });
greaterThanOrEqual(d1, d2); // false
Copy linkCompare two identical objects
import { dinero, greaterThanOrEqual } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d1 = dinero({ amount: 500, currency: USD });
const d2 = dinero({ amount: 500, currency: USD });
greaterThanOrEqual(d1, d2); // true
Copy linkCompare two objects after normalization
import { dinero, greaterThanOrEqual } from 'dinero.js';
import { USD } from '@dinero.js/currencies';
const d1 = dinero({ amount: 800, currency: USD });
const d2 = dinero({ amount: 5000, currency: USD, scale: 3 });
greaterThanOrEqual(d1, d2); // true