ToolPouch

Calculators

Perform calculations: financial, unit conversion, and percentage math.

Install the SDK

npm install @toolpouch/sdkView on npm →

Import from this module

import { functionName } from '@toolpouch/sdk/calculators'

tipCalculator

Signature

tipCalculator(bill: number, tipPercent: number, people?: number): { tip: number; total: number; perPerson: number }

Calculate tip amount, total, and per-person split.

Example

import { tipCalculator } from '@toolpouch/sdk/calculators';
const result = tipCalculator(100, 20, 2);
// { tip: 20, total: 120, perPerson: 60 }

Returns

Object with tip, total, and perPerson amounts

discountCalculator

Signature

discountCalculator(price: number, discountPercent: number): { savings: number; finalPrice: number }

Calculate discount amount and final price.

Example

import { discountCalculator } from '@toolpouch/sdk/calculators';
const result = discountCalculator(100, 20);
// { savings: 20, finalPrice: 80 }

Returns

Object with savings and finalPrice

compoundInterest

Signature

compoundInterest(principal: number, rate: number, years: number, compoundsPerYear?: number): number

Calculate compound interest on an investment.

Example

import { compoundInterest } from '@toolpouch/sdk/calculators';
const amount = compoundInterest(1000, 5, 10, 12);
// 1644.72

Returns

Final amount as number

loanPayment

Signature

loanPayment(principal: number, rate: number, years: number): { monthly: number; totalInterest: number }

Calculate monthly payment and total interest on a loan.

Example

import { loanPayment } from '@toolpouch/sdk/calculators';
const result = loanPayment(200000, 4, 30);
// { monthly: 954.83, totalInterest: 143739.9 }

Returns

Object with monthly payment and totalInterest

percentageChange

Signature

percentageChange(oldValue: number, newValue: number): number

Calculate percentage change from old value to new value.

Example

import { percentageChange } from '@toolpouch/sdk/calculators';
const pct = percentageChange(100, 120);
// 20

Returns

Percentage change as number

unitConvert

Signature

unitConvert(value: number, from: string, to: string): number

Convert between units: length, weight, temperature, volume.

Example

import { unitConvert } from '@toolpouch/sdk/calculators';
const meters = unitConvert(1, 'mile', 'm');
// 1609.34

Returns

Converted value as number