Skip to content

Commit 605556a

Browse files
authored
Merge pull request #30 from lukaswagner/fix/29-column-get-set
fix find predicate
2 parents ce61335 + 3e1917c commit 605556a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/csv-parser/src/types/column/baseColumn.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ export abstract class BaseColumn<T, C extends BC<T>> implements IColumn<T, C> {
3939
}
4040

4141
public get(index: number): T {
42-
const chunk = this._chunks.find((c) => c.offset < index && c.offset + c.length >= index);
42+
const chunk = this._chunks.find((c) => c.offset <= index && c.offset + c.length > index);
4343
if (!chunk) throw new Error('Invalid index.');
4444
return chunk.get(index - chunk.offset);
4545
}
46+
4647
public set(index: number, value: T): void {
47-
const chunk = this._chunks.find((c) => c.offset < index && c.offset + c.length >= index);
48+
const chunk = this._chunks.find((c) => c.offset <= index && c.offset + c.length > index);
4849
if (!chunk) throw new Error('Invalid index.');
4950
chunk.set(index - chunk.offset, value);
5051
}

0 commit comments

Comments
 (0)