@ph-itdev/ph-volume-calculator
v1.0.0
Published
Volume calculation utilities for warehouse, logistics, and shipping — unit conversions, box/container volumes, dimensional weight, tank capacity, and pallet stacking.
Maintainers
Readme
@ph-itdev/ph-volume-calculator
Volume calculation utilities for warehouse, logistics, and shipping — unit conversions, box/container volumes, dimensional weight, tank capacity, and pallet stacking.
Install
npm install @ph-itdev/ph-volume-calculatorModules
| Module | Import | Description |
|--------|--------|-------------|
| units | import { convertVolume } from '@ph-itdev/ph-volume-calculator/units' | Volume unit conversions (m³, ft³, L, gal, cm³, etc.) |
| boxes | import { boxVolume } from '@ph-itdev/ph-volume-calculator/boxes' | Box/carton volume, girth, fill rate, stacking |
| containers | import { getContainerSpec } from '@ph-itdev/ph-volume-calculator/containers' | Shipping container specs and pallet/carton loading |
| dimweight | import { dimWeight } from '@ph-itdev/ph-volume-calculator/dimweight' | Dimensional weight (FedEx, UPS, DHL, USPS) |
| tanks | import { rectangularTank } from '@ph-itdev/ph-volume-calculator/tanks' | Tank/vessel volume (rectangular, cylindrical, spherical, conical) |
| pallets | import { boxesOnPallet } from '@ph-itdev/ph-volume-calculator/pallets' | Pallet specs (Euro, US, ISO) and stacking calculations |
Or import everything from the root:
import { convertVolume, boxVolume, dimWeight, rectangularTank } from '@ph-itdev/ph-volume-calculator';Usage
Volume Unit Conversions
import { convertVolume } from '@ph-itdev/ph-volume-calculator/units';
convertVolume(1, 'ft3', 'L'); // ≈ 28.3168 liters
convertVolume(1000, 'mL', 'L'); // 1 liter
convertVolume(1, 'gal_us', 'gal_uk'); // ≈ 0.8327 UK gallons
convertVolume(100, 'cm3', 'm3'); // 0.0001 m³Box Volume & Shipping
import { boxVolume, boxGirth, lengthPlusGirth, boxesInContainer } from '@ph-itdev/ph-volume-calculator/boxes';
// Calculate volume
boxVolume({ length: 40, width: 30, height: 20, unit: 'cm' }, 'L'); // 24 L
// Carrier size check (USPS/UPS limit is 108"/130" L+G)
const box = { length: 24, width: 18, height: 12, unit: 'in' as const };
lengthPlusGirth(box); // 156 inches (over 130" UPS limit)
// How many boxes fit in a container?
const container = { length: 120, width: 80, height: 60, unit: 'cm' as const };
boxesInContainer(box, container); // { count: 64, utilization: 1.0 }Dimensional Weight
import { dimWeight, billableWeight } from '@ph-itdev/ph-volume-calculator/dimweight';
// FedEx: 60×40×30 cm → 14.4 kg dim weight
dimWeight(60, 40, 30, 'cm', 'fedex');
// Billable weight (max of actual vs dim)
billableWeight(5, 60, 40, 30, 'cm', 'fedex'); // 14.4 kg (dim wins)
billableWeight(20, 60, 40, 30, 'cm', 'fedex'); // 20 kg (actual wins)Shipping Containers
import { getContainerSpec, palletsInContainer, cartonsInContainer } from '@ph-itdev/ph-volume-calculator/containers';
const spec = getContainerSpec('40_hc');
console.log(`${spec.name}: ${spec.usableVolumeM3} m³, max ${spec.maxPayloadKg} kg`);
// How many Euro pallets fit?
palletsInContainer('40_hc'); // { count: ~24, volumeUtilization: ~0.67 }
// How many cartons?
cartonsInContainer('40_hc', 0.6, 0.4, 0.4); // { count: 288, volumeUtilization: ~0.89 }Tank Volume
import { rectangularTank, horizontalCylinderPartial, tankVolumeLiters } from '@ph-itdev/ph-volume-calculator/tanks';
// Rectangular tank: 2m × 1.5m × 1m
rectangularTank(2, 1.5, 1); // 3 m³
// Horizontal cylinder: 3m long, 0.6m radius
horizontalCylinderPartial(3, 0.6, 0.7); // ~2.6 m³ (70% full)
// Convert to liters
tankVolumeLiters(3); // 3000 LPallet Stacking
import { boxesOnPallet, stackHeight, palletVolume } from '@ph-itdev/ph-volume-calculator/pallets';
// Euro pallet with 1m load
palletVolume('euro', 1000); // ≈ 1.1 m³
// How many 40×30×25cm boxes fit on a Euro pallet?
boxesOnPallet('euro', 400, 300, 250);
// { perLayer: 8, layers: 4, total: 32, volumeUtilization: ~0.71 }
// Stack height of 3 pallets with 1m loads
stackHeight('euro', 1000, 3); // 3432 mmSupported Units
Volume: m³, cm³, mm³, ft³, in³, yd³, L, mL, US gal, UK gal, US qt, US pt
Linear: mm, cm, m, in, ft
Carriers (dim weight): FedEx, UPS, DHL, DHL Express, USPS Priority, Custom
Containers: 20' Std, 40' Std, 40' HC, 45' HC, 20' OT, 40' OT, 20' RF, 40' RF
Pallets: Euro (1200×800), US (1219×1016), ISO (1165×1165)
TypeScript
Full type definitions included. Works with ESM and CommonJS.
import type { VolumeUnit, BoxDimensions, ContainerType, DimLengthUnit } from '@ph-itdev/ph-volume-calculator';License
MIT © @ph-itdev
