Skip to content

Commit c1ce073

Browse files
committed
Fix negative index cases for Range and take/skip
1 parent 6bc2d0d commit c1ce073

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

dist/Immutable.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ var $IndexedSequence = IndexedSequence;
684684
if (skipSeq !== seq) {
685685
skipSeq.get = function(index, notSetValue) {
686686
index = wrapIndex(this, index);
687-
return index < 0 ? notSetValue : seq.get(index + amount, notSetValue);
687+
return index >= 0 ? seq.get(index + amount, notSetValue) : notSetValue;
688688
};
689689
}
690690
return skipSeq;
@@ -705,7 +705,7 @@ var $IndexedSequence = IndexedSequence;
705705
if (takeSeq !== seq) {
706706
takeSeq.get = function(index, notSetValue) {
707707
index = wrapIndex(this, index);
708-
return index < amount ? seq.get(index, notSetValue) : notSetValue;
708+
return index >= 0 && index < amount ? seq.get(index, notSetValue) : notSetValue;
709709
};
710710
}
711711
return takeSeq;
@@ -3270,8 +3270,7 @@ var $Range = Range;
32703270
return 'Range [ ' + this._start + '...' + this._end + (this._step > 1 ? ' by ' + this._step : '') + ' ]';
32713271
},
32723272
get: function(index, notSetValue) {
3273-
index = wrapIndex(this, index);
3274-
return this.has(index) ? this._start + index * this._step : notSetValue;
3273+
return this.has(index) ? this._start + wrapIndex(this, index) * this._step : notSetValue;
32753274
},
32763275
contains: function(searchValue) {
32773276
var possibleIndex = (searchValue - this._start) / this._step;

0 commit comments

Comments
 (0)