Amount
divide
1.0.0- Dependencies:
- ∟Direct: 0
- ∟Peer: 0
- Source code ↗
- Check on NPM ↗
Hidden
Overview
Section titled “Overview”Divides an amount by a divisor.
amount.divide(/divisor/, <rounding>);Features
Section titled “Features”- Returns a single
Amountas result - Accepts fractional and whole number parts
- Excepts dividing by zero or negative numbers, with proper error handling
- Simple and intuitive API
- Comprehensive testing
Arguments
Section titled “Arguments”| Arg | Type | Default Value | Required |
parts | number | - | Yes |
rounding | math | bank | math | No |
From an initial Amount instance, use the divide() method using a number to divide the amount by that divisor.
import { amount } from '@inpulse-ui/utils';
const result = amount(100.00, 'USD').divide(2);console.log(result); // Results an AmountArray instance with value 50 USDThis method also accepts fractional divisors (e.g., 2.5 to divide the amount by 2.5).
const result = amount(100.00, 'USD').divide(2.5);console.log(result); // Results 40 USDExamples
Section titled “Examples”Use divide() when you want to:
-
Calculate unit prices.
const unitPrice = totalPrice.divide(quantity); // $127.50 ÷ 5 = $25.50 -
Reverse calculations (remove tax, etc.)
const discounted = originalPrice.divide(1.1); // Remove 10% dTax -
Perform mathematical division.
const result = amount.divide(2.5); // 100 ÷ 2.5 = 40
Please refer to the split() method whenever you need to:
- Split an amount into equal parts.
- Create equal installments.
- Distribute money among people.
- Get an array of Amount instances.
Built with by Jo Santana in Brazil.
© 2026 Inpulse. All rights reserved.