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.29 kB
TypeScript
import type { $Record } from '../object/types';
import type { Numeric } from '../types/index';
import { $BaseConverter } from './base';
import type { $TempUnit, FormatToOptions } from './types';
/**
* @class TemperatureConverter
* @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
*/
export declare class $Temperature extends $BaseConverter<$TempUnit> {
#private;
/**
* Convert temperature value to other temperature units
* @param value Number or numeric string value to convert.
* @param unit Base temperature unit for the provided value.
*/
constructor(value: Numeric, unit: $TempUnit);
/**
* @instance Converts to target temperature unit.
* @param target Target temperature unit.
*/
to(target: $TempUnit): number;
/**
* @instance Converts to all temperature units at once.
* @returns Object with all unit conversions.
*/
toAll(): $Record<$TempUnit, number>;
/**
* @instance Formats the converted value and unit.
* @param target Target unit to format to.
* @param options Formatting options.
* @returns Formatted string like "95°F", "5.25 kelvins", or "5e+3 celsius".
*/
formatTo(target: $TempUnit, options?: FormatToOptions): string;
}