Skip to content

Commit 3715819

Browse files
committed
Merge pull request immutable-js#132 from briandipalma/master
fix(Sequence.skip): returned collection was set to incorrect offset inde...
2 parents f3cb429 + 3a8e95b commit 3715819

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

__tests__/IndexedSequence.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
///<reference path='../resources/jest.d.ts'/>
2+
///<reference path='../dist/Immutable.d.ts'/>
3+
jest.autoMockOff();
4+
5+
import jasmineCheck = require('jasmine-check');
6+
jasmineCheck.install();
7+
8+
import Immutable = require('immutable');
9+
10+
describe('IndexedSequence', () => {
11+
12+
it('maintains skipped offset', () => {
13+
var seq = Immutable.Sequence(['A', 'B', 'C', 'D', 'E']);
14+
15+
// This is what we expect for IndexedSequences
16+
var operated = seq.skip(1);
17+
expect(operated.entrySeq().toArray()).toEqual([
18+
[0, 'B'],
19+
[1, 'C'],
20+
[2, 'D'],
21+
[3, 'E']
22+
]);
23+
24+
expect(operated.first()).toEqual('B');
25+
});
26+
27+
});

dist/Immutable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ var $IndexedSequence = IndexedSequence;
683683
var skipSeq = skipFactory(this, amount, false);
684684
if (skipSeq !== this) {
685685
skipSeq.get = (function(index, notSetValue) {
686-
return $__0.get(index - amount, notSetValue);
686+
return $__0.get(index + amount, notSetValue);
687687
});
688688
}
689689
return skipSeq;

0 commit comments

Comments
 (0)