class Binary
extends BSONValue
import { Binary } from "https://deno.land/x/atlas_sdk@v1.1.3/mod.ts";
A class representation of the BSON Binary type.
Constructors
new
Binary(buffer?: string | BinarySequence, subType?: number)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.
Methods
inspect(): string
length(): number
the length of the binary sequence
put(byteValue: ): void
| string
| number
| Uint8Array
| number[]
Updates this binary with byte_value.
read(position: number, length: number): BinarySequence
Reads length bytes starting at position.
toJSON(): string
toString(encoding?: ): string
| "hex"
| "base64"
| "utf8"
| "utf-8"
value(asRaw?: boolean): string | BinarySequence
Returns the value of this binary as a string.
write(sequence: string | BinarySequence, offset: number): void
Writes a buffer or string to the binary.