Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

to-absolute-index.js 485B

12345678910111213
  1. 'use strict';
  2. var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
  3. var max = Math.max;
  4. var min = Math.min;
  5. // Helper for a popular repeating case of the spec:
  6. // Let integer be ? ToInteger(index).
  7. // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
  8. module.exports = function (index, length) {
  9. var integer = toIntegerOrInfinity(index);
  10. return integer < 0 ? max(integer + length, 0) : min(integer, length);
  11. };