Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Binary

A class representation of the BSON Binary type.

Hierarchy

  • Binary

Index

Constructors

constructor

  • new Binary(buffer?: string | BinarySequence, subType?: number): Binary
  • Parameters

    • Optional buffer: string | BinarySequence

      a buffer object containing the binary data.

    • Optional subType: number

      the option binary type.

    Returns Binary

Properties

_bsontype

_bsontype: "Binary"

buffer

buffer: Buffer

position

position: number

sub_type

sub_type: number

Static Readonly BUFFER_SIZE

BUFFER_SIZE: 256 = 256

Initial buffer default size

Static Readonly SUBTYPE_BYTE_ARRAY

SUBTYPE_BYTE_ARRAY: 2 = 2

Byte Array BSON type

Static Readonly SUBTYPE_COLUMN

SUBTYPE_COLUMN: 7 = 7

Column BSON type

Static Readonly SUBTYPE_DEFAULT

SUBTYPE_DEFAULT: 0 = 0

Default BSON type

Static Readonly SUBTYPE_ENCRYPTED

SUBTYPE_ENCRYPTED: 6 = 6

Encrypted BSON type

Static Readonly SUBTYPE_FUNCTION

SUBTYPE_FUNCTION: 1 = 1

Function BSON type

Static Readonly SUBTYPE_MD5

SUBTYPE_MD5: 5 = 5

MD5 BSON type

Static Readonly SUBTYPE_USER_DEFINED

SUBTYPE_USER_DEFINED: 128 = 128

User BSON type

Static Readonly SUBTYPE_UUID

SUBTYPE_UUID: 4 = 4

UUID BSON type

Static Readonly SUBTYPE_UUID_OLD

SUBTYPE_UUID_OLD: 3 = 3

Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID

Methods

inspect

  • inspect(): string
  • Returns string

length

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

    Returns number

put

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

    Parameters

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

      a single byte we wish to write.

    Returns void

read

  • read(position: number, length: number): BinarySequence
  • 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

  • toJSON(): string
  • Returns string

toString

  • toString(format?: string): string
  • Parameters

    • Optional format: string

    Returns string

toUUID

  • toUUID(): UUID
  • Returns UUID

value

  • value(asRaw?: boolean): string | BinarySequence
  • 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

write

  • write(sequence: string | BinarySequence, offset: number): void
  • 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