main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
485 bytes
|
Rev | Line | |
---|
[79a0317] | 1 | 'use strict';
|
---|
| 2 | var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');
|
---|
| 3 |
|
---|
| 4 | var max = Math.max;
|
---|
| 5 | var min = Math.min;
|
---|
| 6 |
|
---|
| 7 | // Helper for a popular repeating case of the spec:
|
---|
| 8 | // Let integer be ? ToInteger(index).
|
---|
| 9 | // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
---|
| 10 | module.exports = function (index, length) {
|
---|
| 11 | var integer = toIntegerOrInfinity(index);
|
---|
| 12 | return integer < 0 ? max(integer + length, 0) : min(integer, length);
|
---|
| 13 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.