ToLength.js 362 B

123456789101112
  1. 'use strict';
  2. var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
  3. var ToIntegerOrInfinity = require('./ToIntegerOrInfinity');
  4. module.exports = function ToLength(argument) {
  5. var len = ToIntegerOrInfinity(argument);
  6. if (len <= 0) { return 0; } // includes converting -0 to +0
  7. if (len > MAX_SAFE_INTEGER) { return MAX_SAFE_INTEGER; }
  8. return len;
  9. };