Amount
subtract
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Subtracts an amount from another amount.
amount.subtract(/amount/);Features
Section titled “Features”- Returns a single
Amountas result - Accepts mixed parameter types
- Automatically inherits currency from the current Amount instance
- Maintains type safety with proper error handling for currency mismatches
- Simple and intuitive API
- Comprehensive testing
Arguments
Section titled “Arguments”| Arg | Type | Default Value | Required |
amount | Amount | number | string | - | Yes |
From an initial Amount instance, use the subtract() method to subtract an Amount, number, or string value from it.
import { amount } from '@inpulse-ui/utils';
const amount1 = amount(100.00, 'USD');const amount2 = amount('50.00', 'USD'); // You can also use string valuesconst result = amount1.subtract(amount2).subtract(25);
console.log(result); // Results an Amount instance with value 25 USDIt handles negative results correctly:
const value = amount(5.25, 'USD');const result = value.subtract(10.5); // Results -5.25 USDIt will throw an error if you try to subtract an amount with a different currency:
const value = amount(100, 'USD');const result = value.subtract(50, 'EUR'); // Currency mismatch: USD vs EURBuilt with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.