mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
13 lines
439 B
JavaScript
13 lines
439 B
JavaScript
|
var toInteger = require('../internals/to-integer');
|
||
|
|
||
|
var max = Math.max;
|
||
|
var min = Math.min;
|
||
|
|
||
|
// Helper for a popular repeating case of the spec:
|
||
|
// Let integer be ? ToInteger(index).
|
||
|
// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
|
||
|
module.exports = function (index, length) {
|
||
|
var integer = toInteger(index);
|
||
|
return integer < 0 ? max(integer + length, 0) : min(integer, length);
|
||
|
};
|