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

transformScale

Dinero<TAmount>

Transform a Dinero object to a new scale.

Transforming to a higher scale means that the internal amount value increases by orders of magnitude. If you're using the default Dinero.js implementation (with the number calculator), be careful not to exceed the minimum and maximum safe integers.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<TAmount>

The Dinero object to transform.

Yes
newScaleTAmount

The new scale.

Yes

Copy linkCode examples

Copy linkTransform an object to a new scale

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

const d = dinero({ amount: 500, currency: USD, scale: 2 });

transformScale(d, 4); // a Dinero object with amount 50000 and scale 4