Back to Firebase Js Sdk

Bytes class

docs-devsite/firestore_.bytes.md

12.12.14.4 KB
Original Source

Project: /docs/reference/js/_project.yaml Book: /docs/reference/_book.yaml page_type: reference

{% comment %} DO NOT EDIT THIS FILE! This is generated by the JS SDK team, and any local changes will be overwritten. Changes should be made in the source code at https://github.com/firebase/firebase-js-sdk {% endcomment %}

Bytes class

An immutable object representing an array of bytes.

<b>Signature:</b>

typescript
export declare class Bytes 

Methods

MethodModifiersDescription
fromBase64String(base64)<code>static</code>Creates a new <code>Bytes</code> object from the given Base64 string, converting it to bytes.
fromJSON(json)<code>static</code>Builds a <code>Bytes</code> instance from a JSON object created by Bytes.toJSON()<!-- -->.
fromUint8Array(array)<code>static</code>Creates a new <code>Bytes</code> object from the given Uint8Array.
isEqual(other)Returns true if this <code>Bytes</code> object is equal to the provided one.
toBase64()Returns the underlying bytes as a Base64-encoded string.
toJSON()Returns a JSON-serializable representation of this <code>Bytes</code> instance.
toString()Returns a string representation of the <code>Bytes</code> object.
toUint8Array()Returns the underlying bytes in a new <code>Uint8Array</code>.

Bytes.fromBase64String()

Creates a new Bytes object from the given Base64 string, converting it to bytes.

<b>Signature:</b>

typescript
static fromBase64String(base64: string): Bytes;

Parameters

ParameterTypeDescription
base64stringThe Base64 string used to create the <code>Bytes</code> object.

<b>Returns:</b>

Bytes

Bytes.fromJSON()

Builds a Bytes instance from a JSON object created by Bytes.toJSON()<!-- -->.

<b>Signature:</b>

typescript
static fromJSON(json: object): Bytes;

Parameters

ParameterTypeDescription
jsonobjecta JSON object represention of a <code>Bytes</code> instance

<b>Returns:</b>

Bytes

an instance of Bytes if the JSON object could be parsed. Throws a FirestoreError if an error occurs.

Bytes.fromUint8Array()

Creates a new Bytes object from the given Uint8Array.

<b>Signature:</b>

typescript
static fromUint8Array(array: Uint8Array): Bytes;

Parameters

ParameterTypeDescription
arrayUint8ArrayThe Uint8Array used to create the <code>Bytes</code> object.

<b>Returns:</b>

Bytes

Bytes.isEqual()

Returns true if this Bytes object is equal to the provided one.

<b>Signature:</b>

typescript
isEqual(other: Bytes): boolean;

Parameters

ParameterTypeDescription
otherBytesThe <code>Bytes</code> object to compare against.

<b>Returns:</b>

boolean

true if this Bytes object is equal to the provided one.

Bytes.toBase64()

Returns the underlying bytes as a Base64-encoded string.

<b>Signature:</b>

typescript
toBase64(): string;

<b>Returns:</b>

string

The Base64-encoded string created from the Bytes object.

Bytes.toJSON()

Returns a JSON-serializable representation of this Bytes instance.

<b>Signature:</b>

typescript
toJSON(): object;

<b>Returns:</b>

object

a JSON representation of this object.

Bytes.toString()

Returns a string representation of the Bytes object.

<b>Signature:</b>

typescript
toString(): string;

<b>Returns:</b>

string

A string representation of the Bytes object.

Bytes.toUint8Array()

Returns the underlying bytes in a new Uint8Array<!-- -->.

<b>Signature:</b>

typescript
toUint8Array(): Uint8Array;

<b>Returns:</b>

Uint8Array

The Uint8Array created from the Bytes object.