2.0.6 • Published 2 years ago

abab v2.0.6

Weekly downloads
12,787,154
License
BSD-3-Clause
Repository
github
Last release
2 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_modbitgetjsdom-fork@olivervorasai/sliderreact-native-printer-brotherslevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscannerjsdom__no_corsstretch-rollup@mink-opn/build-tokensreact-native-slider-kfsvelte-slime@infinitebrahmanuniverse/nolb-abacclibyarntestplginexpand-react-bridgeedocu-sdksklif-ui-kitsklif-api@everything-registry/sub-chunk-1088p149-table@pmadhur/jsdomsklif-ui@hemith/react-native-tnkfilestack-js@maricode1111/date-lib@luciadias/storybook-notimation@massivepixel/use-query@simstudio/htmldiffzzzxxxyyy321123@juanaraneta/dept-central-lib-client@knooks/use-title@kontist/client@ko-developerhong/react-native-multiple-image-picker@kalkanisys/vue-select@lanz1/v-money3faraz-countries-states-cities@leo4096/strophejs@leiyulf/gantt-task-react@livecycle.io/rrweb-snapshotfenris@highmobility/auto-api-javascript@hproinformatica/functions@hint/utils-debugging-protocol-common@humanity.cash/types@hyext/ext-sdk-basic@hyext/ext-sdk-basic-ts@hyext/ext-sdk-common@hyext/ext-sdk-common-inner@hyext/ext-sdk-hy@hyext/ext-sdk-zhunxin@hyext/extsdk-dz@hyext/hyext-rn-sdk@hyext/hyliveext-rn-sdk@innodata/vue-v3-ya-metrika@inikulin/jsdom-only-external-scriptsgraphql-jinngraphql-geniegogency-test-2gogencygrids-over-polygongoogle-remake@nyanator/chrome-ext-utils@object-studio/react-native-web@nosnibor89/cdk-static-website-constructgrunt-sentry-source-maps@openpolitica/matomo-next@midwayjs/jsdom-service-worker@mazito/zkapp-contracts-add@meklitc7/date-library@meklitc7/string-library@mayuriachewad/pickupbiz-npm-package@maybejaybe/date-libfrdrk-js-semaphorefreyja
2.0.6

2 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

6 years ago

1.0.4

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

9 years ago