@newdash/newdash
Version:
javascript/typescript utility library
31 lines (30 loc) • 655 B
TypeScript
/**
* Converts `value` to an integer suitable for use as the length of an
* array-like object.
*
* **Note:** This method is based on
* [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
*
* @since 5.13.0
* @category Lang
* @param value The value to convert.
* @returns Returns the converted integer.
* @example
*
* ```js
* toLength(3.2)
* // => 3
*
* toLength(Number.MIN_VALUE)
* // => 0
*
* toLength(Infinity)
* // => 4294967295
*
* toLength('3.2')
* // => 3
* ```
*/
export declare function toLength(value: number): number;
export declare function toLength(value: string): number;
export default toLength;