UNPKG

ut2

Version:

一个现代 JavaScript 实用工具库。[点击查看在线文档]。

21 lines (17 loc) 387 B
'use strict'; var native = require('./internals/native.js'); var toInteger = require('./toInteger.js'); function toLength(value) { value = toInteger(value); if (!value) { return 0; } if (value < 0) { return 0; } if (value > native.MAX_ARRAY_LENGTH) { return native.MAX_ARRAY_LENGTH; } return value; } module.exports = toLength;