ToLength.js 332 B

123456789101112
  1. 'use strict';
  2. var MAX_SAFE_INTEGER = require('../helpers/maxSafeInteger');
  3. var ToInteger = require('./ToInteger');
  4. module.exports = function ToLength(argument) {
  5. var len = ToInteger(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. };