1 // Taken from: https://github.com/paulmillr/es6-shim/
5 var toInteger = require('../../../number/to-integer')
6 , toPosInt = require('../../../number/to-pos-integer')
7 , validValue = require('../../../object/valid-value')
9 , hasOwnProperty = Object.prototype.hasOwnProperty
10 , max = Math.max, min = Math.min;
12 module.exports = function (target, start/*, end*/) {
13 var o = validValue(this), end = arguments[2], l = toPosInt(o.length)
14 , to, from, fin, count, direction;
16 target = toInteger(target);
17 start = toInteger(start);
18 end = (end === undefined) ? l : toInteger(end);
20 to = target < 0 ? max(l + target, 0) : min(target, l);
21 from = start < 0 ? max(l + start, 0) : min(start, l);
22 fin = end < 0 ? max(l + end, 0) : min(end, l);
23 count = min(fin - from, l - to);
26 if ((from < to) && (to < (from + count))) {
32 if (hasOwnProperty.call(o, from)) o[to] = o[from];