to-positive-integer.js 323 B

12345678910
  1. var global = require('../internals/global');
  2. var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
  3. var RangeError = global.RangeError;
  4. module.exports = function (it) {
  5. var result = toIntegerOrInfinity(it);
  6. if (result < 0) throw RangeError("The argument can't be less than 0");
  7. return result;
  8. };