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

hasSubUnits

boolean

Check whether a Dinero object has minor currency units.

Copy linkParameters

NameTypeDescriptionRequired
dineroObjectDinero<TAmount>

The Dinero object to check.

Yes

Copy linkCode examples

Copy linkCheck an object with sub-units

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

const d = dinero({ amount: 1150, currency: USD });

hasSubUnits(d); // true

Copy linkCheck an object without sub-units

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

const d = dinero({ amount: 1100, currency: USD });

hasSubUnits(d); // false

Copy linkCheck an object with sub-units based on the scale

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

const d = dinero({ amount: 1100, currency: USD, scale: 3 });

hasSubUnits(d); // true