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.23 kB
TypeScript
import type { $Record } from '../object/types';
import type { Numeric } from '../types/index';
import { $BaseConverter } from './base';
import type { $AreaUnit, FormatToOptions } from './types';
/**
* @class AreaConverter
* @description Handles conversions with smart `.to()`, `.toAll()`, and `.formatTo()`.
*/
export declare class $Area extends $BaseConverter<$AreaUnit> {
#private;
/**
* Convert area value to other area units
* @param value Number or numeric string value to convert.
* @param unit Base area unit for the provided value.
*/
constructor(value: Numeric, unit: $AreaUnit);
/**
* @instance Converts to target area unit.
* @param target Target area unit.
*/
to(target: $AreaUnit): number;
/**
* @instance Converts to all area units.
* @returns Object with all unit conversions.
*/
toAll(): $Record<$AreaUnit, number>;
/**
* @instance Formats the converted value and unit.
* @param target Target unit to format to.
* @param options Formatting options.
* @returns Formatted string like "5km²", "5.02 square-miles", or "5e+3 meter".
*/
formatTo(target: $AreaUnit, options?: FormatToOptions): string;
}