1.1.0 • Published 6 months ago

base64plus v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Base64Plus

Build Status License npm version Total Downloads Latest Release

Base64Plus is a modern, Unicode-safe Base64 encoding and decoding library. It supports Node.js, ES Modules, Browsers, and TypeScript with a built-in polyfill for Node.js environments.

  • Handles Unicode strings properly: Native atob/btoa fail with multi-byte characters like emojis or non-Latin scripts.
  • Works in both Node.js & Browsers: Node.js lacks atob/btoa, but Base64Plus provides a seamless polyfill.
  • Supports ES Modules & TypeScript: Fully typed for modern JavaScript projects.
  • Encodes and decodes Buffers: Unlike atob, which only works with plain strings.
  • No dependencies & lightweight: Small package size with no external dependencies.

Table Of Contents

  1. Installation
  2. Usage
  3. API Reference
  4. Development & Contribution
  5. Changelog
  6. License

1. Installation

  • Option 1: Install via NPM

    npm install base64plus
  • Option 2: Use via CDN

    Include the UMD version directly in your HTML file:

<script src="https://github.com/nassiry/base64plus/releases/latest/download/base64Plus.umd.js"></script>
<script>
  console.log(Base64Plus.encode("Hello, World!"));
</script>

2. Usage

  • Node.js (CommonJS)

    const Base64Plus = require("base64plus");
    
    const encoded = Base64Plus.encode("Hello, World!");
    console.log(encoded); // Base64 string
    
    const decoded = Base64Plus.decode(encoded);
    console.log(decoded); // Hello, World!
  • ES Modules

    import Base64Plus from "base64plus";
    
    const encoded = Base64Plus.encode("Base64 Encoding");
    console.log(encoded); // Base64 string
    
    const decoded = Base64Plus.decode(encoded);
    console.log(decoded); // Base64 Encoding
  • TypeScript Usage

    For TypeScript, just import Base64Plus and enjoy the full type support!

    import Base64Plus from "base64plus";
    
    const encoded: string = Base64Plus.encode("Hello, TypeScript!");
    console.log(encoded); // Base64 string
    
    const decoded: string = Base64Plus.decode(encoded);
    console.log(decoded); // Hello, TypeScript!

2. API Reference

  • Base64Plus.encode(input: string): string Encodes a string to Base64 while supporting full Unicode characters.
  • Base64Plus.decode(base64String: string): string Decodes a Base64 string back to a Unicode string.
  • Base64Plus.isValid(base64String: string): boolean Checks if a string is a valid Base64 string.

    Deprecated: Base64Plus.isValidBase64(base64String: string): boolean Use Base64Plus.isValid instead.

3. Development & Contribution

Clone the Repository & install the dependencies.

git clone https://github.com/nassiry/base64plus.git
cd base64plus
npm install
  • Build the Project

    npm run build
  • Run Tests

    ```bash
    npm test
    ```
    For more details on contributing, see CONTRIBUTING.

Changelog

See CHANGELOG for release details.

License

This package is open-source software licensed under the MIT license.

1.1.0

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.1

6 months ago

1.0.0

7 months ago