Skip to main content
Module

x/bb64/mod.ts>Base64

Easy to use Deno Base64 Encoder and Decoder for JavaScript and TypeScript
Latest
class Base64
import { Base64 } from "https://deno.land/x/bb64@1.1.0/mod.ts";

This class provides an easy interface to perform base64 encoding on strings and files.

Constructors

new
Base64(data: any)

Properties

private
bytes: Uint8Array
private
isBase64Encoded: boolean
private
mime: string

Methods

toFile(filePath: string): void

Writes the base64 string from the Base64 object to a file

toFileWithMime(filePath: string): void

Writes the base64 string from the Base64 object to a file, including the MIME type when writing to the file.

toString(): string

Returns the base64 encoded string from the Base64 object

Returns the base64 encoded string from the Base64 object, with the inclusion of the MIME type if the Base64 object was created from a file (and if not created from a file, works the same as the .toString() method)

Static Methods

fromBase64File(filePath: string): Base64

Creates a Base64 object from the contents of an already base64 encoded file

fromBase64String(encodedString: string): Base64

Creates a Base64 object from an already base64 encoded string

fromBase64Uint8Array(uint8arr: Uint8Array): Base64

Creates a Base64 object from a base64 encoded Uint8Array

fromFile(filePath: string): Base64

Creates a Base64 object from the contents of a file

fromString(unencodedString: string): Base64

Creates a Base64 object from a string

fromUint8Array(uint8arr: Uint8Array): Base64

Creates a Base64 object from a Uint8Array