Click here for v1.x documentation.
Dinero.js
Dinero.js version

maximum

Dinero<TAmount>

Get the greatest of the passed Dinero objects.

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

NameTypeDescriptionRequired
dineroObjectsDinero<TAmount>[]

The Dinero objects to maximum.

Yes

Copy linkCode examples

Copy linkGet the greatest object from a set

import { dinero, maximum } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d1 = dinero({ amount: 150, currency: USD });
const d2 = dinero({ amount: 50, currency: USD });

maximum([d1, d2]); // a Dinero object with amount 150

Copy linkGet the greatest object from a set after normalization

import { dinero, maximum } from 'dinero.js';
import { USD } from '@dinero.js/currencies';

const d1 = dinero({ amount: 500, currency: USD });
const d2 = dinero({ amount: 1000, currency: USD, scale: 3 });

maximum([d1, d2]); // a Dinero object with amount 5000 and scale 3