Skip to content

Commit a9c1b3f

Browse files
removed promoteUUIds
1 parent 15a746c commit a9c1b3f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/parser/deserializer.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ export interface DeserializeOptions {
3535
promoteBuffers?: boolean;
3636
/** when deserializing will promote BSON values to their Node.js closest equivalent types. */
3737
promoteValues?: boolean;
38-
/** when deserializing will return UUID type, if promoteBuffers is also true then promoteUUIDs will take precedence and a buffer will not be returned */
39-
promoteUUIDs?: boolean;
4038
/** allow to specify if there what fields we wish to return as unserialized raw buffer. */
4139
fieldsAsRaw?: Document;
4240
/** return BSON regular expressions as BSONRegExp instances. */
@@ -137,7 +135,6 @@ function deserializeObject(
137135
const promoteBuffers = options['promoteBuffers'] == null ? false : options['promoteBuffers'];
138136
const promoteLongs = options['promoteLongs'] == null ? true : options['promoteLongs'];
139137
const promoteValues = options['promoteValues'] == null ? true : options['promoteValues'];
140-
const promoteUUIDs = options.promoteUUIDs == null ? false : options.promoteUUIDs;
141138

142139
// Ensures default validation option if none given
143140
const validation = options.validation == null ? { utf8: true } : options.validation;
@@ -416,9 +413,7 @@ function deserializeObject(
416413
throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
417414
}
418415

419-
if (promoteUUIDs && subType === 4) {
420-
value = new Binary(buffer.slice(index, index + binarySize), subType).toUUID();
421-
} else if (promoteBuffers && promoteValues) {
416+
if (promoteBuffers && promoteValues) {
422417
value = buffer.slice(index, index + binarySize);
423418
} else {
424419
value = new Binary(buffer.slice(index, index + binarySize), subType);
@@ -448,12 +443,14 @@ function deserializeObject(
448443
_buffer[i] = buffer[index + i];
449444
}
450445

451-
if (promoteUUIDs && subType === 4) {
452-
value = new Binary(_buffer, subType).toUUID();
453-
} else if (promoteBuffers && promoteValues) {
446+
if (promoteBuffers && promoteValues) {
454447
value = _buffer;
455448
} else {
456449
value = new Binary(_buffer, subType);
450+
value = new Binary(buffer.slice(index, index + binarySize), subType);
451+
if (subType === constants.BSON_BINARY_SUBTYPE_UUID_NEW) {
452+
value = value.toUUID();
453+
}
457454
}
458455
}
459456

0 commit comments

Comments
 (0)