-
Type:
Sub-task
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
-
None
The following is a full list of Buffer APIs used by the driver:
- .isBuffer
- Does not exist; but we'll either want to remove usages of this from the driver (we'll need to evaluate on a case-by-case basis) or use `isUint8Array`, which exists in BSON. Maybe it makes sense to export isUint8Array from BSON too.
- .concat
- We'll need to add this to ByteUtils.
- .from
- The driver uses Buffer.from to convert the following to buffers:
- utf8 strings
- number arrays
- buffers
- base64 strings
- Byte utils supports converting base64 strings and number arrays to Uint8Arrays already. converting buffers to buffers can be done using `isUint8Array` and conditionally converting the string argument to a buffer if needed. We will need to add conversion of utf8 strings -> buffers to byte utils.
- The driver uses Buffer.from to convert the following to buffers:
- .equals
- exists in ByteUtils.
- .compare
- We will need to implement .compare() for Uint8Arrays. Alternatively, this is only used for ObjectIds in the driver - we could hard-code this logic into a new method, ObjectId.compare().
- .toBase64
- exists in ByteUtils
- .allocUnsafe
- exists in ByteUtils
- .alloc
- exists in ByteUtils
- .readInt32LE
- exists in NumberUtils
Acceptance Criteria:
- Implement any missing APIs from the list above in BSON.
- Export BSON ByteUtils from the library.