metric-to-light
Version:
A utility to convert metric distances to the time it takes for light to travel that distance.
31 lines (30 loc) • 946 B
TypeScript
export declare const SPEED_OF_LIGHT_MS = 299792458;
interface DistanceUnit {
name: string;
symbol: string;
factor: number;
}
interface TimeUnit {
name: string;
factor: number;
singular: string;
plural: string;
}
interface LightTimeResult {
value: number;
unit: string;
}
interface LightTimeError {
error: string;
}
export declare const distanceUnits: DistanceUnit[];
export declare const timeUnits: TimeUnit[];
/**
* The "Light Time Algo"
* Calculates the time it takes for light to travel a given distance.
* @param {number} distance - The numerical value of the distance.
* @param {number} distanceFactor - The conversion factor of the input distance unit to meters.
* @returns {{value: number, unit: string}|{error: string}} The result object or an error object.
*/
export declare function calculateLightTime(distance: number, distanceFactor: number): LightTimeResult | LightTimeError;
export {};