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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@loxjs/node-base64

v2.0.3

Published

A Node.js module that provides URL-safe Base64 encoding and decoding.

Downloads

5

Readme

@loxjs/node-base64

@loxjs/node-base64 is a Node.js module that provides URL-safe Base64 encoding and decoding. It follows the RFC 4648 Spec for Base64 encoding, where '+' is encoded as '-' and '/' is encoded as '_'. Additionally, it can remove padding characters '=' for a more compact representation.

Installation

npm install @loxjs/node-base64

Or with yarn:

yarn add @loxjs/node-base64

Usage

This module exports three main functions: encode, decode, and validate. You can use these functions to handle URL-safe Base64 strings within your Node.js applications.

Encoding to URL Safe Base64

const base64 = require('@loxjs/node-base64');

// Encode a string to Base64
const encodedString = base64.encode('Hello World!');
console.log(encodedString); // Output: SGVsbG8gV29ybGQh (without padding '=' characters)

Encoding with Padding Characters

const base64 = require('@loxjs/node-base64');

// Encode a string to Base64 and keep padding '=' characters
const encodedStringWithEq = base64.encode('Hello World!', true);
console.log(encodedStringWithEq); // Output: SGVsbG8gV29ybGQh== (with padding '=' characters)

Decoding from URL Safe Base64

const base64 = require('@loxjs/node-base64');

// Decode a URL Safe Base64 string
const decodedString = base64.decode('SGVsbG8gV29ybGQh');
console.log(decodedString); // Output: Hello World!

Validating a URL Safe Base64 String

const base64 = require('@loxjs/node-base64');

// Validate a URL Safe Base64 string
const isValid = base64.validate('SGVsbG8gV29ybGQh');
console.log(isValid); // Output: true

API

encode(str, [witheq])

Encodes a buffer or string to URL Safe Base64.

  • str (String|Buffer): The string or buffer to encode.
  • witheq (Boolean): Optional. If true, retains padding '=' characters. Defaults to false.

decode(str)

Decodes a URL Safe Base64 string to its original representation.

  • str (String): The URL Safe Base64 string to decode.

validate(str)

Validates whether a string is a URL Safe Base64 encoded string.

  • str (String): The string to validate.

Contributing

Contributions to @loxjs/node-base64 are welcome! Please ensure that your contributions adhere to the following guidelines:

  • Write clear, readable, and maintainable code.
  • Follow existing coding styles and practices.
  • Write meaningful commit messages.
  • Update the documentation accordingly.

For more detailed information, please read the contributing guide.

Enjoy using @loxjs/node-base64!