@foxy.io/sdk
Version:
Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.
20 lines (19 loc) • 926 B
TypeScript
/**
* Instances of this error are thrown by `getTimeFromFrequency` when
* provided with unsupported frequency.
*/
export declare class InvalidFrequencyError extends Error {
constructor(frequency: string);
}
/**
* Gives a rough estimate for a number of milliseconds in the given frequency.
*
* IMPORTANT: this function SHOULD NOT be used to calculate precise dates
* as it doesn't account for leap years, months of variable length, etc. It works
* best for broad estimates and comparing frequencies.
*
* @param frequency Frequency as positive integer + units (y, m, w, d for years, months, weeks and days respectively). You can use .5m for twice a month. Example: 1m (1 month), 4y (4 years).
* @throws InvalidFrequencyError when provided with unsupported frequency.
* @returns Estimated number of milliseconds in the given frequency.
*/
export declare function getTimeFromFrequency(frequency: string): number;