Add missing APIs into ByteUtils and export it from BSON

XMLWordPrintableJSON

    • Type: Sub-task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 0
    • None
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • 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.
      • .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.

            Assignee:
            Bailey Pearson
            Reporter:
            Sergey Zelenov
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: