Skip to content

Commit

Permalink
remove calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo4815162342 committed Feb 27, 2024
1 parent 9e7dd66 commit e5d0dce
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/stream-writer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class BatchStreamWriter {
return bodyHeaders;
}

public async writeBatch(batch: number[][], dateFormatter?: (timestamp: number) => string) {
public async writeBatch(batch: number[][]) {
const batchWithinRange: (number | string)[][] = [];

for (let j = 0; j < batch.length; j++) {
Expand All @@ -123,16 +123,12 @@ export class BatchStreamWriter {
item.length > 0 && item[0] >= this.startDateTs && item[0] < this.endDateTs;

if (isItemInRange) {
if (dateFormatter) {
//@ts-expect-error TODO: fix this
item[0] = dateFormatter(item[0]);
}
batchWithinRange.push(item);
}
}

for (let i = 0; i < batchWithinRange.length; i++) {
let item = batchWithinRange[i];
const item = batchWithinRange[i];

const isFirstItem = i === 0;
const isLastItem = i === batchWithinRange.length - 1;
Expand All @@ -156,10 +152,6 @@ export class BatchStreamWriter {
body += ',' + (!this.isInline ? '\n' : '');
}

if (dateFormatter && (this.format === Format.json || this.format === Format.array)) {
item[0] = `"${item[0]}"`;
}

if (this.format === Format.json) {
const jsonObjectBody = item.map((val, i) => `"${this.bodyHeaders[i]}":${val}`).join(',');
body += `{${jsonObjectBody}}`;
Expand Down

0 comments on commit e5d0dce

Please sign in to comment.