npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@youngmayor/base64

v1.0.2

Published

A base64 management utility

Downloads

56

Readme

Base64 Manager

npm version install size npm downloads

A base64 management tool

Table of Contents


Features


  • Encode string to base64
  • Decode a base64 encoded string to any of the below listed formats
    • Blob
    • ObjectURL
  • Decode a base64 object to the appropriate format and download it directly in browser
  • A uniform API for managing base64 objects of Image, Text and PDF

Browser Support


Chrome | Firefox | Safari | Opera | Edge | IE | --- | --- | --- | --- | --- | --- | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ |


Installing


  • Using npm:

    $ npm install @youngmayor/base64
  • Using bower:

    $ bower install @youngmayor/base64
  • Using yarn:

    $ yarn add @youngmayor/base64

Importing


  • In a node based application, you can import the package using commonJS as shown below

    const base64 = require('@youngmayor/base64');
    
    // or 
    
    import bas64 from '@youngmayor/base64';
  • It can also be linked to using any of the below CDNs

    <script src="https://cdn.jsdelivr.net/npm/@youngmayor/base64@latest" async></script>
    
    <!-- or -->
    
    <script src="https://unpkg.com/@youngmayor/base64" async></script>
    
    
    <!-- the package can now be accessed via window.base64 -->

Usage


Encoding to base64

  • String

    base64 has a very simple API for encoding a string to base64 using the encodeString() method.

    Example

    const encoded_text = base64.encodeString('Hello World')
    console.log(encoded_text);
    
    // Result: SGVsbG8gV29ybGQ=

Managers

What are Managers?


Managers are Classes that expose you to a Unified API for handling the base64 object in it's right decode type...

base64 is inbuilted with the following managers:

Invoking Managers


Invoking a Manager is easy. Call the Manager name on the base64 object with the base64 encoded data

Example

const stringmanager = base64.managePDF(encoded_text);

Some managers require a second parameter: the type of the data. See the documentation the respective manager.

This creates a manager object for that file type. All managers extend the Base Manager class which exposes the below methods

  • toBlob(): Blob: Convert the Base64 object to a BLOB (Binary large object)

    ...
    blobData = stringmanager.toBlob();
    console.log(blobData);
       
    // Result: Blob Object
  • toObjectURL(): string: Convert the Base64 object to a URL.createObjectURL

    // ...
    url = stringmanager.toObjectURL();
    console.log(url)
    
    // Result: blob:null/8d20cde9-db64-49b2-8872-98ada802e85b
  • toDataURL(): string: Convert the encoded file to a DataURL

    // ...
    
    dataURL = stringmanager.toDataURL();
    console.log(dataURL)
    
    // Result: data:text/plain;base64,SGVsbG8gV29ybGQ=
  • download(filename): void: Download the encoded file

    PARAMETERS


    • filename: The name to save the downloaded file with
    // ...
    stringmanager.download('example-download.txt');
    // ...
  • open(): void: Open the decoded data on a new tab

    // ...
    stringmanager.open();
    // ...

Available Managers


The following Managers currently exist

Image Manager

  • Instantiation

    const base64 = require('@youngmayor/base64');
      
    const imagemanager = base64.manageImage(encoding, image_type)
    // image_type must be one of [ bmp, gif, vnd.microsofticon, jpeg, png, svg+xml, tiff, webp ]

PDF Manager

  • Instantiation

    const base64 = require('@youngmayor/base64');
    
    const pdfmanager = base64.managePDF(encoding)

String Manager

  • Instantiation

    const base64 = require('@youngmayor/base64');
    
    const stringmanager = base64.manageString(encoding, string_type)
    // string_type must be one of [ calendar, css, csv, html, javascript, plain, xml ]
  • Methods

    • decodeString(): Decode the string

          let decoded = stringmanager.decodeString(); 
          console.log(decoded)
      
          // Result: Hello World

Credits

Meyoron Aghogho (YoungMayor).