2.0.6 • Published 3 years ago

abab v2.0.6

Weekly downloads
12,787,154
License
BSD-3-Clause
Repository
github
Last release
3 years ago

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.
archetype-librarycomponennenttreact-native-bluetooth2killi8n-react-native-fast-imageticket-jsdomlive-connectspecify-importsbabel-specify-importsjsdom-exreact-native-template-rfbaseairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationreact-native-covid-sdkgql_din_modjsdom-fork@olivervorasai/sliderreact-native-printer-brotherslevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscannerjsdom__no_corsstretch-rollup@mink-opn/build-tokensreact-native-slider-kfsvelte-slime@infinitebrahmanuniverse/nolb-abacclibyarntestplginexpand-react-bridgesklif-ui-kitsklif-api@everything-registry/sub-chunk-1088p149-table@pmadhur/jsdomsklif-uitandemapptandemcodetailwind-vector-effectsyncbackbasessvelvet-customwinx-form-winxvz-parserwebdatabasetest1webdatabasetest10webchewoven-challenge-deploysuperset-plugin-chart-hello-world2supercluster-googlemaps-adapter-clonesstanikionespotify-ds-sestarbucks-jp-drinksticky-scroll-catchstp-cdktestapatestweblibapitest_track_js_clienttestlib17testnpm_lmnsvelte-component-libthreejs-miniprogram-taobaovision-camera-plugin-scan-facesvue-axios-rest@donapot/mylibtest@cryptocode99/token-lists@cubesoft/jsdom@cute-apocalypse/react-tree@corelmax/react-native-my2c2p-sdk@coveops/headless-sado@rps-engine/core@rstacruz/pnpm@pazznetwork/strophe.ts@percent/percent-api-hooks@poscredit/plugin-chart-boriscafe24api-clientgenerator-bootstrap-boilerplate-templatejitsi-meet-stepupjitsi-fmtechjulien-easy-modaljsdomprojsdomsjs-snippet-libraryjnf-accesscontrol-rnttljsbrowserjsdom-arc-extnjsdom-bypassjsdom-canvas-2jsdom-lambdajsdom-napi-rs-canvasjsdom-no-css
2.0.6

3 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

7 years ago

1.0.4

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago