@tmlmobilidade/utils
Version:
A collection of utility functions and helpers for the TML Mobilidade Go monorepo, providing common functionality for batching operations, caching, HTTP requests, object manipulation, permissions, and more.
25 lines (24 loc) • 1.13 kB
TypeScript
/**
* Utility function to convert a number to an integer,
* handling null and undefined values gracefully.
* @param value The value to convert to an integer. Can be a number, null, or undefined.
* @returns The rounded integer value if the input is a number, or null if the input is null or undefined.
* @example
* roundToInt(3.7); // returns 4
* roundToInt(-2.3); // returns -2
* roundToInt(null); // returns null
* roundToInt(undefined); // returns null
*/
export declare function roundToInt(value: null | number | string | undefined): null | number;
/**
* Utility function to convert a number to an integer,
* handling null and undefined values gracefully.
* @param value The value to convert to an integer. Can be a number, null, or undefined.
* @returns The truncated integer value if the input is a number, or null if the input is null or undefined.
* @example
* truncToInt(3.7); // returns 3
* truncToInt(-2.3); // returns -2
* truncToInt(null); // returns null
* truncToInt(undefined); // returns null
*/
export declare function truncToInt(value: null | number | string | undefined): null | number;