Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Binary

A class representation of the BSON Binary type.

Hierarchy

Index

Constructors

  • Create a new Binary instance.

    This constructor can accept a string as its first argument. In this case, this string will be encoded using ISO-8859-1, not using UTF-8. This is almost certainly not what you want. Use new Binary(Buffer.from(string)) instead to convert the string to a Buffer using UTF-8 first.

    Parameters

    • Optional buffer: string | BinarySequence

      a buffer object containing the binary data.

    • Optional subType: number

      the option binary type.

    Returns Binary

Properties

buffer: Uint8Array
position: number
sub_type: number
BUFFER_SIZE: 256 = 256

Initial buffer default size

SUBTYPE_BYTE_ARRAY: 2 = 2

Byte Array BSON type

SUBTYPE_COLUMN: 7 = 7

Column BSON type

SUBTYPE_DEFAULT: 0 = 0

Default BSON type

SUBTYPE_ENCRYPTED: 6 = 6

Encrypted BSON type

SUBTYPE_FUNCTION: 1 = 1

Function BSON type

SUBTYPE_MD5: 5 = 5

MD5 BSON type

SUBTYPE_USER_DEFINED: 128 = 128

User BSON type

SUBTYPE_UUID: 4 = 4

UUID BSON type

SUBTYPE_UUID_OLD: 3 = 3

Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID

Accessors

  • get _bsontype(): "Binary"
  • Returns "Binary"

Methods

  • inspect(): string
  • Returns string

  • length(): number
  • the length of the binary sequence

    Returns number

  • put(byteValue: string | number | Uint8Array | number[]): void
  • Updates this binary with byte_value.

    Parameters

    • byteValue: string | number | Uint8Array | number[]

      a single byte we wish to write.

    Returns void

  • Reads length bytes starting at position.

    Parameters

    • position: number

      read from the given position in the Binary.

    • length: number

      the number of bytes to read.

    Returns BinarySequence

  • toJSON(): string
  • Returns string

  • toString(encoding?: "base64" | "hex" | "utf8" | "utf-8"): string
  • Parameters

    • Optional encoding: "base64" | "hex" | "utf8" | "utf-8"

    Returns string

  • Returns UUID

  • Returns the value of this binary as a string.

    remarks

    This is handy when calling this function conditionally for some key value pairs and not others

    Parameters

    • Optional asRaw: boolean

      Will skip converting to a string

    Returns string | BinarySequence

  • Writes a buffer or string to the binary.

    Parameters

    • sequence: string | BinarySequence

      a string or buffer to be written to the Binary BSON object.

    • offset: number

      specify the binary of where to write the content.

    Returns void

Generated using TypeDoc