Skip to content

Commit

Permalink
Merge pull request #30 from lukaswagner/fix/29-column-get-set
Browse files Browse the repository at this point in the history
fix find predicate
  • Loading branch information
lukaswagner authored Feb 3, 2022
2 parents ce61335 + 3e1917c commit 605556a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/csv-parser/src/types/column/baseColumn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ export abstract class BaseColumn<T, C extends BC<T>> implements IColumn<T, C> {
}

public get(index: number): T {
const chunk = this._chunks.find((c) => c.offset < index && c.offset + c.length >= index);
const chunk = this._chunks.find((c) => c.offset <= index && c.offset + c.length > index);
if (!chunk) throw new Error('Invalid index.');
return chunk.get(index - chunk.offset);
}

public set(index: number, value: T): void {
const chunk = this._chunks.find((c) => c.offset < index && c.offset + c.length >= index);
const chunk = this._chunks.find((c) => c.offset <= index && c.offset + c.length > index);
if (!chunk) throw new Error('Invalid index.');
chunk.set(index - chunk.offset, value);
}
Expand Down

0 comments on commit 605556a

Please sign in to comment.