
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
base64-encoding
Advanced tools
Fast Base64 encoding and decoding powered by WebAssembly.
Fast Base64 encoding and decoding powered by WebAssembly.
This library is modeled after the WHATWG TextEncoder
and TextDecoder
API,
providing a Base64Encoder
and Base64Decoder
class.
The C implementation was chosen based on benchmarks provided by gaspardpetit/base64
.
const encoder = await new Base64Encoder().optimize();
encoder.encode(new TextEncoder().encode('foobar')) // => Zm9vYmFy
const decoder = await new Base64Decoder().optimize();
new TextDecoder().decode(decoder.decode("Zm9vYmFy")) // => foobar
For one-shot usage, you can use the JS implementation without instantiating a WASM instance:
new Base64Encoder().encode(new TextEncoder().encode('foobar')) // => Zm9vYmFy
new TextDecoder().decode(new Base64Decoder().decode("Zm9vYmFy")) // => foobar
This implementation also supports a URL-friendly variant of Base64, where
'+'
are mapped to '-'
'/'
are mapped to '_'
'='
are omittedTo use this variant, provide the url
setting when creating the encoder.
const encoder = await new Base64Encoder({ url: true }).optimize();
For decoding URL-friendly Base64 no extra steps are required.
TBD
Currently only the encoder provides a significant performance improvement over the pure JS implementation.
This module is published on npm under the base64-encoding
tag.
The package contains the following:
The root folder (Browse) exports ES modules in ES2018 syntax. All internal module paths are fully qualified, so they can be imported in Deno or the browser directly:
import * as b64 from 'https://unpkg.com/base64-encoding?module';
The module
folder (Browse) contains a rolled-up version of the above.
import * as b64 from 'https://unpkg.com/base64-encoding/module';
The cjs
folder (Browse) exports CommonJS modules in ES2015 syntax for use in node.
require('base64-encoding')
The src
folder (Browse) contains the TypeScript source code.
The root and cjs
folder include type declarations and source maps, so that IntelliSense works out of the box in VSCode.
The package.json
properly sets the main
, module
, type
and exports
keys, so that package.json-
based tools will pick the right version.
TBD
Currently the C code is licensed under an ancient Apache 1.0 license that comes with some pretty old-school requirements, such as including the following in all promotional materials:
This product includes software developed by the Apache Group for use in the Apache HTTP server project (http://www.apache.org/).
It is very likely that ap_base64.c
has been shipped under a Apache-2.0 license somewhere.
Once I locate it, this requirement will go away.
FAQs
Fast Base64 encoding and decoding powered by WebAssembly.
The npm package base64-encoding receives a total of 111 weekly downloads. As such, base64-encoding popularity was classified as not popular.
We found that base64-encoding demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.