Skip to content

Commit befdc47

Browse files
committed
update comments
1 parent 31f941e commit befdc47

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/mongo_logger.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,22 +481,19 @@ export function stringifyWithMaxLen(
481481
} else if (value != null && typeof value === 'object' && '_bsontype' in value) {
482482
const v = value as BSONObject;
483483
if (v._bsontype === 'Binary') {
484-
// This is an estimate based on the fact that the base64 is approximately 1.3x the length of
485-
// the actual binary sequence
486-
// Also accounting for stringified fields before the binary sequence and the fields after
487-
// the binary sequence
488-
currentLength += (value.position + value.position * 0.3 + 22 + 17) | 0;
484+
// '{"$binary":{"base64":"<base64 string>","subType":"XX"}}'
485+
// This is an estimate based on the fact that the base64 is approximately 1.33x the length of
486+
// the actual binary sequence https://en.wikipedia.org/wiki/Base64
487+
currentLength += (22 + value.position + value.position * 0.33 + 18) | 0;
489488
} else if (v._bsontype === 'Code') {
490489
// '{"$code":"<code>"}' or '{"$code":"<code>","$scope":<scope>}'
491-
// TODO: Account for scope?
492490
if (v.scope == null) {
493491
currentLength += v.code.length + 10 + 2;
494492
} else {
495493
// Ignoring actual scope object
496494
currentLength += v.code.length + 10 + 11;
497495
}
498496
} else if (v._bsontype === 'Decimal128') {
499-
// TODO: Is this worth doing here?
500497
currentLength += value.toExtendedJSON().length;
501498
} else if (v._bsontype === 'Double') {
502499
// Doesn't account for representing integers as <value>.0

0 commit comments

Comments
 (0)