Skip to content

Commit 13ac459

Browse files
committed
docs: add documentation to Binary properties
1 parent 98d255f commit 13ac459

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

src/binary.ts

+39
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,47 @@ export class Binary extends BSONValue {
6161
/** User BSON type */
6262
static readonly SUBTYPE_USER_DEFINED = 128;
6363

64+
/**
65+
* The bytes of the Binary value.
66+
*
67+
* The format of a Binary value in BSON is defined as:
68+
* ```txt
69+
* binary ::= int32 subtype (byte*)
70+
* ```
71+
*
72+
* This `buffer` is the "(byte*)" segment.
73+
*
74+
* Unless the value is subtype 2, then deserialize will read the first 4 bytes as an int32 and set this to the remaining bytes.
75+
*
76+
* ```txt
77+
* binary ::= int32 unsigned_byte(2) int32 (byte*)
78+
* ```
79+
*
80+
* @see https://bsonspec.org/spec.html
81+
*/
6482
public buffer: Uint8Array;
83+
/**
84+
* The binary subtype.
85+
*
86+
* Current defined values are:
87+
*
88+
* - `unsigned_byte(0)` Generic binary subtype
89+
* - `unsigned_byte(1)` Function
90+
* - `unsigned_byte(2)` Binary (Deprecated)
91+
* - `unsigned_byte(3)` UUID (Deprecated)
92+
* - `unsigned_byte(4)` UUID
93+
* - `unsigned_byte(5)` MD5
94+
* - `unsigned_byte(6)` Encrypted BSON value
95+
* - `unsigned_byte(7)` Compressed BSON column
96+
* - `unsigned_byte(8)` Sensitive
97+
* - `unsigned_byte(9)` Vector
98+
* - `unsigned_byte(128)` - `unsigned_byte(255)` User defined
99+
*/
65100
public sub_type: number;
101+
/**
102+
* The Binary's `buffer` can be larger than the Binary's content.
103+
* This property is used to determine where the content ends in the buffer.
104+
*/
66105
public position: number;
67106

68107
/**

0 commit comments

Comments
 (0)