Amount
isZero
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Checks if an amount is exactly zero by comparing the internal cents value to zero.
amount.isZero();Features
Section titled “Features”- Returns a boolean value indicating if the amount is zero
- Compares against the internal cents representation for precision
- Works with any currency
- Simple and intuitive API
- No side effects - read-only operation
- Comprehensive testing
Arguments
Section titled “Arguments”| Arg | Type | Default Value | Required |
| No arguments required | |||
From an Amount instance, use the isZero() method to check if the amount is exactly zero.
import { amount } from '@inpulse-ui/utils';
const zeroAmount = amount(0, 'USD');const result = zeroAmount.isZero();
console.log(result); // trueIt returns false for non-zero amounts:
const positiveAmount = amount(100, 'EUR');const negativeAmount = amount(-50, 'GBP');
console.log(positiveAmount.isZero()); // falseconsole.log(negativeAmount.isZero()); // falseWorks with decimal values:
const smallAmount = amount(0.01, 'USD');const zeroDecimal = amount(0.00, 'USD');
console.log(smallAmount.isZero()); // falseconsole.log(zeroDecimal.isZero()); // trueUseful for conditional logic:
const balance = amount(0, 'USD');
if (balance.isZero()) { console.log('Account has no balance');} else { console.log(`Current balance: ${balance.format()}`);}// Output: "Account has no balance"Comparison with arithmetic results:
const value = amount(100, 'USD');const same = amount(100, 'USD');const difference = value.subtract(same);
console.log(difference.isZero()); // true (100 - 100 = 0)Built with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.