Big update!Introducing GitHub Bot Commands. Learn more
Socket
BlogLoveLog in
Book a demo

abab

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Issues
File Explorer

Advanced tools

abab

WHATWG spec-compliant implementations of window.atob and window.btoa.

    2.0.6latest

Version published
Maintainers
1
Weekly downloads
18,692,146
increased by2.13%

Weekly downloads

Changelog

Source

2.0.6

  • Throw TypeError when passed zero arguments (#73), thanks to @DerekNonGeneric (19c5abd)
  • Use Yarn for development (87c89c6)
  • Dependency updates

Readme

Source

abab npm version Build Status

A JavaScript module that implements window.atob and window.btoa according the forgiving-base64 algorithm in the Infra Standard. The original code was forked from w3c/web-platform-tests.

Compatibility: Node.js version 3+ and all major browsers.

Install with npm:

npm install abab

API

btoa (base64 encode)

const { btoa } = require('abab'); btoa('Hello, world!'); // 'SGVsbG8sIHdvcmxkIQ=='

atob (base64 decode)

const { atob } = require('abab'); atob('SGVsbG8sIHdvcmxkIQ=='); // 'Hello, world!'
Valid characters

Per the spec, btoa will accept strings "containing only characters in the range U+0000 to U+00FF." If passed a string with characters above U+00FF, btoa will return null. If atob is passed a string that is not base64-valid, it will also return null. In both cases when null is returned, the spec calls for throwing a DOMException of type InvalidCharacterError.

Browsers

If you want to include just one of the methods to save bytes in your client-side code, you can require the desired module directly.

const atob = require('abab/lib/atob'); const btoa = require('abab/lib/btoa');

Development

If you're submitting a PR or deploying to npm, please use the checklists in CONTRIBUTING.md.

Remembering what atob and btoa stand for

Base64 comes from IETF RFC 4648 (2006).

  • btoa, the encoder function, stands for binary to ASCII, meaning it converts any binary input into a subset of ASCII (Base64).
  • atob, the decoder function, converts ASCII (or Base64) to its original binary format.

Keywords

FAQs

What is abab?

WHATWG spec-compliant implementations of window.atob and window.btoa.

Is abab popular?

The npm package abab receives a total of 17,984,405 weekly downloads. As such, abab popularity was classified as popular.

Is abab well maintained?

We found that abab demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.

Last updated on 17 Apr 2022
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc