@newdash/newdash
Version:
javascript/typescript utility library
28 lines (27 loc) • 587 B
TypeScript
/**
* Converts `value` to a safe integer. A safe integer can be compared and
* represented correctly.
*
* @since 5.7.0
* @category Lang
* @param value The value to convert.
* @returns Returns the converted integer.
* @example
*
* ```js
* toSafeInteger(3.2)
* // => 3
*
* toSafeInteger(Number.MIN_VALUE)
* // => 0
*
* toSafeInteger(Infinity)
* // => 9007199254740991
*
* toSafeInteger('3.2')
* // => 3
* ```
*/
export declare function toSafeInteger(value: string): number;
export declare function toSafeInteger(value: number): number;
export default toSafeInteger;