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

trimScale

Dinero<TAmount>

Trim a Dinero object's scale as much as possible, down to the currency exponent.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<TAmount>

The Dinero object to trim.

Yes

Copy linkCode examples

Copy linkTrim an object down to its currency exponent's scale

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

const d = dinero({ amount: 500000, currency: USD, scale: 5 });

trimScale(d); // a Dinero object with amount 500 and scale 2

Copy linkTrim an object down to the safest possible scale

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

const d = dinero({ amount: 99950, currency: USD, scale: 4 });

trimScale(d); // a Dinero object with amount 9995 and scale 3