Amount
abs
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Returns the absolute value of an amount, removing any negative sign.
amount.abs();Features
Section titled “Features”- Returns a new
Amountinstance with absolute value - Preserves the original currency
- Maintains immutability - original instance remains unchanged
- Handles both positive and negative values
- Simple and intuitive API
- Comprehensive testing
Arguments
Section titled “Arguments”| Arg | Type | Default Value | Required |
| No arguments required | |||
From an Amount instance, use the abs() method to get the absolute value of the amount.
import { amount } from '@inpulse-ui/utils';
const negativeAmount = amount(-100.50, 'USD');const result = negativeAmount.abs();
console.log(result); // Results in Amount instance with value 100.50 USDconsole.log(negativeAmount); // Original remains -100.50 USD (immutable)It works with positive values as well (returns the same value):
const positiveAmount = amount(75.25, 'EUR');const result = positiveAmount.abs();
console.log(result); // Results in Amount instance with value 75.25 EURIt handles zero values correctly:
const zeroAmount = amount(0, 'GBP');const result = zeroAmount.abs();
console.log(result); // Results in Amount instance with value 0 GBPBuilt with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.