Security update for permissions_by_term
[yaffs-website] / node_modules / uncss / node_modules / lodash / toLength.js
1 var baseClamp = require('./internal/baseClamp'),
2     toInteger = require('./toInteger');
3
4 /** Used as references for the maximum length and index of an array. */
5 var MAX_ARRAY_LENGTH = 4294967295;
6
7 /**
8  * Converts `value` to an integer suitable for use as the length of an
9  * array-like object.
10  *
11  * **Note:** This method is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
12  *
13  * @static
14  * @memberOf _
15  * @category Lang
16  * @param {*} value The value to convert.
17  * @returns {number} Returns the converted integer.
18  * @example
19  *
20  * _.toLength(3);
21  * // => 3
22  *
23  * _.toLength(Number.MIN_VALUE);
24  * // => 0
25  *
26  * _.toLength(Infinity);
27  * // => 4294967295
28  *
29  * _.toLength('3');
30  * // => 3
31  */
32 function toLength(value) {
33   return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
34 }
35
36 module.exports = toLength;