Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Binary

A class representation of the BSON Binary type.BSON二进制类型的类表示。

Hierarchy继承层级

  • Binary

Index索引

Constructors构造函数

  • new Binary(buffer?: string | BinarySequence, subType?: number): Binary
  • 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. 此构造函数可以接受字符串作为其第一个参数。在这种情况下,这个字符串将使用ISO-8859-1编码,而不是使用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.首先使用new Binary(Buffer.from(string))将字符串转换为使用UTF-8的缓冲区。

    Parameters参数

    • Optional buffer: string | BinarySequence

      a buffer object containing the binary data.包含二进制数据的缓冲区对象。

    • Optional subType: number

      the option binary type.选项二进制类型。

    Returns 返回 Binary

Properties属性

_bsontype: "Binary"
buffer: Buffer
position: number
sub_type: number
BUFFER_SIZE: 256 = 256

Initial buffer default size初始缓冲区默认大小

SUBTYPE_BYTE_ARRAY: 2 = 2

Byte Array BSON type字节数组BSON类型

SUBTYPE_COLUMN: 7 = 7

Column BSON type列BSON类型

SUBTYPE_DEFAULT: 0 = 0

Default BSON type默认BSON类型

SUBTYPE_ENCRYPTED: 6 = 6

Encrypted BSON type加密BSON类型

SUBTYPE_FUNCTION: 1 = 1

Function BSON type功能BSON类型

SUBTYPE_MD5: 5 = 5

MD5 BSON typeMD5 BSON型

SUBTYPE_USER_DEFINED: 128 = 128

User BSON type用户BSON类型

SUBTYPE_UUID: 4 = 4

UUID BSON typeUUID BSON类型

SUBTYPE_UUID_OLD: 3 = 3

Deprecated UUID BSON type @deprecated Please use SUBTYPE_UUID不推荐的UUID BSON类型@不推荐的请使用SUBTYPE_UUID

Methods方法

  • inspect(): string
  • Returns 返回 string

  • length(): number
  • the length of the binary sequence二进制序列的长度

    Returns 返回 number

  • put(byteValue: string | number | Buffer | Uint8Array | number[]): void
  • Updates this binary with byte_value.用byte_value更新此二进制文件。

    Parameters参数

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

      a single byte we wish to write.我们希望写入的单个字节。

    Returns 返回 void

  • read(position: number, length: number): BinarySequence
  • Reads length bytes starting at position.读取从position开始的length字节。

    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(format?: string): string
  • Parameters参数

    • Optional format: string

    Returns 返回 string

  • toUUID(): UUID
  • Returns 返回 UUID

  • 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(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.要写入Binary BSON对象的字符串或缓冲区。

    • offset: number

      specify the binary of where to write the content.指定内容写入位置的二进制值。

    Returns 返回 void

Generated using TypeDoc