Skip to content

Commit 5c3ba1c

Browse files
Copilotstreamich
andcommitted
Fix TSLint errors and apply prettier formatting to BSON code
Co-authored-by: streamich <[email protected]>
1 parent bc30f0d commit 5c3ba1c

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

src/bson/BsonDecoder.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class BsonDecoder implements BinaryJsonDecoder {
5757
public readCString(): string {
5858
const reader = this.reader;
5959
const uint8 = reader.uint8;
60-
let x = reader.x;
60+
const x = reader.x;
6161
let length = 0;
6262

6363
// Find the null terminator
@@ -169,8 +169,8 @@ export class BsonDecoder implements BinaryJsonDecoder {
169169

170170
public readArray(): unknown[] {
171171
const doc = this.readDocument() as Record<string, unknown>;
172-
const keys = Object.keys(doc).sort((a, b) => parseInt(a) - parseInt(b));
173-
return keys.map(key => doc[key]);
172+
const keys = Object.keys(doc).sort((a, b) => parseInt(a, 10) - parseInt(b, 10));
173+
return keys.map((key) => doc[key]);
174174
}
175175

176176
public readBinary(): BsonBinary | Uint8Array {
@@ -195,13 +195,13 @@ export class BsonDecoder implements BinaryJsonDecoder {
195195

196196
// Timestamp (4 bytes, big-endian)
197197
const timestamp = (uint8[x] << 24) | (uint8[x + 1] << 16) | (uint8[x + 2] << 8) | uint8[x + 3];
198-
198+
199199
// Process ID (5 bytes) - first 4 bytes are little-endian, then 1 high byte
200200
const processLo = uint8[x + 4] | (uint8[x + 5] << 8) | (uint8[x + 6] << 16) | (uint8[x + 7] << 24);
201201
const processHi = uint8[x + 8];
202202
// Convert to unsigned 32-bit first, then combine with high byte
203203
const processLoUnsigned = processLo >>> 0; // Convert to unsigned
204-
const process = processLoUnsigned + (processHi * 0x100000000);
204+
const process = processLoUnsigned + processHi * 0x100000000;
205205

206206
// Counter (3 bytes, big-endian)
207207
const counter = (uint8[x + 9] << 16) | (uint8[x + 10] << 8) | uint8[x + 11];
@@ -245,4 +245,4 @@ export class BsonDecoder implements BinaryJsonDecoder {
245245
const data = reader.buf(16);
246246
return new BsonDecimal128(data);
247247
}
248-
}
248+
}

src/bson/BsonEncoder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class BsonEncoder implements BinaryJsonEncoder {
4141
}
4242

4343
public writeUndef(): void {
44-
// Not used directly in BSON - handled in writeKey
44+
// Not used directly in BSON - handled in writeKey
4545
throw new Error('Use writeKey for BSON encoding');
4646
}
4747

@@ -114,7 +114,7 @@ export class BsonEncoder implements BinaryJsonEncoder {
114114
}
115115

116116
public writeAsciiStr(str: string): void {
117-
// Use writeStr for BSON - it handles UTF-8 properly
117+
// Use writeStr for BSON - it handles UTF-8 properly
118118
this.writeStr(str);
119119
}
120120

src/bson/__tests__/BsonDecoder.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ describe('BsonDecoder', () => {
9494
});
9595

9696
test('nested array', () => {
97-
roundTrip([[1, 2], [3, 4]]);
97+
roundTrip([
98+
[1, 2],
99+
[3, 4],
100+
]);
98101
});
99102

100103
test('empty object', () => {
@@ -303,4 +306,4 @@ describe('BsonDecoder', () => {
303306
roundTrip(data);
304307
});
305308
});
306-
});
309+
});

src/bson/__tests__/automated.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ describe('Sample binary documents', () => {
3131
assertEncoder(t.json as any);
3232
});
3333
}
34-
});
34+
});

src/bson/__tests__/fuzzer.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ test('fuzzing', () => {
3131
const json = RandomJson.generate();
3232
assertEncoder(json as any);
3333
}
34-
}, 50000);
34+
}, 50000);

0 commit comments

Comments
 (0)