UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

35 lines (34 loc) 1.25 kB
import type { $Record } from '../object/types'; import type { Numeric } from '../types/index'; import { $BaseConverter } from './base'; import type { $VolumeUnit, FormatToOptions } from './types'; /** * @class VolumeConverter * @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`. */ export declare class $Volume extends $BaseConverter<$VolumeUnit> { #private; /** * Convert volume value to other volume units * @param value Number or numeric string value to convert. * @param unit Base volume unit for the provided value. */ constructor(value: Numeric, unit: $VolumeUnit); /** * @instance Converts to target volume unit. * @param target Target volume unit. */ to(target: $VolumeUnit): number; /** * @instance Converts to target volume unit. * @param target Target volume unit. */ toAll(): $Record<$VolumeUnit, number>; /** * @instance Formats the converted value and unit. * @param target Target unit to format to. * @param options Formatting options. * @returns Formatted string like "5m³", "5.25 cubic-meters", or "5e+3 meter". */ formatTo(target: $VolumeUnit, options?: FormatToOptions): string; }