UNPKG

@firebase/firestore

Version:

The Cloud Firestore component of the Firebase JS SDK.

84 lines (83 loc) 2.83 kB
/** * @license * Copyright 2020 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ByteString } from '../util/byte_string'; import { Property } from '../util/json_validation'; /** * An immutable object representing an array of bytes. */ export declare class Bytes { _byteString: ByteString; /** @hideconstructor */ constructor(byteString: ByteString); /** * Creates a new `Bytes` object from the given Base64 string, converting it to * bytes. * * @param base64 - The Base64 string used to create the `Bytes` object. */ static fromBase64String(base64: string): Bytes; /** * Creates a new `Bytes` object from the given Uint8Array. * * @param array - The Uint8Array used to create the `Bytes` object. */ static fromUint8Array(array: Uint8Array): Bytes; /** * Returns the underlying bytes as a Base64-encoded string. * * @returns The Base64-encoded string created from the `Bytes` object. */ toBase64(): string; /** * Returns the underlying bytes in a new `Uint8Array`. * * @returns The Uint8Array created from the `Bytes` object. */ toUint8Array(): Uint8Array; /** * Returns a string representation of the `Bytes` object. * * @returns A string representation of the `Bytes` object. */ toString(): string; /** * Returns true if this `Bytes` object is equal to the provided one. * * @param other - The `Bytes` object to compare against. * @returns true if this `Bytes` object is equal to the provided one. */ isEqual(other: Bytes): boolean; static _jsonSchemaVersion: string; static _jsonSchema: { type: Property<"string">; bytes: Property<"string">; }; /** * Returns a JSON-serializable representation of this `Bytes` instance. * * @returns a JSON representation of this object. */ toJSON(): object; /** * Builds a `Bytes` instance from a JSON object created by {@link Bytes.toJSON}. * * @param json a JSON object represention of a `Bytes` instance * @returns an instance of {@link Bytes} if the JSON object could be parsed. Throws a * {@link FirestoreError} if an error occurs. */ static fromJSON(json: object): Bytes; }