Amount
getAmount
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Gets the underlying AmountType object that contains the internal representation of the amount with cents and currency properties.
amount.getAmount();Features
Section titled “Features”- Returns the internal AmountType object
- Exposes the raw _cents and _currency properties
- Useful for low-level operations and debugging
- Provides access to the exact internal state
- 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 getAmount() method to get the underlying AmountType object.
import { amount } from '@inpulse-ui/utils';
const myAmount = amount(123.45, 'USD');const result = myAmount.getAmount();
console.log(result); // { _cents: 12345, _currency: 'USD' }Access the internal properties directly:
const myAmount = amount(99.99, 'EUR');const amountData = myAmount.getAmount();
console.log(amountData._cents); // 9999console.log(amountData._currency); // 'EUR'Useful for debugging and inspection:
const amounts = [ amount(10.50, 'USD'), amount(-25.75, 'USD'), amount(0, 'USD')];
amounts.forEach((amt, index) => { const data = amt.getAmount(); console.log(`Amount ${index}:`, data);});// Amount 0: { _cents: 1050, _currency: 'USD' }// Amount 1: { _cents: -2575, _currency: 'USD' }// Amount 2: { _cents: 0, _currency: 'USD' }Interoperability with low-level functions:
import { amount } from '@inpulse-ui/utils';import { add } from '@inpulse-ui/utils/amount'; // Low-level function
const amount1 = amount(50, 'GBP');const amount2 = amount(30, 'GBP');
// Using low-level function with AmountType objectsconst result = add(amount1.getAmount(), amount2.getAmount());console.log(result); // { _cents: 8000, _currency: 'GBP' }Serialization and data transfer:
const orderAmount = amount(299.99, 'USD');const amountData = orderAmount.getAmount();
// Send to API or store in databaseconst payload = { orderId: '12345', amount: amountData, // { _cents: 29999, _currency: 'USD' } timestamp: Date.now()};
console.log(JSON.stringify(payload));Built with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.