A Base64 implementation for WebAssembly (WASM) written in ZZ that implements an Abstract Encoding interface.
$ npm install base64-wasm
$ wapm install jwerle/base64-wasm
const b64 = require('base64-wasm')
// wait for module to be ready if loading in a browser environment
b64.ready((err) => {
const message = Buffer.from('hello world')
const encoded = b64.encode(message)
console.log(encoded.toString()) // aGVsbG8gd29ybGQ=
const decoded = b64.decode(encoded)
console.log(decoded.toString()) // hello world
})
Base64 encode an input
optionally into buffer
at an optionally
specified offset
.
Base64 decode an input
optionally into buffer
at an optionally
specified offset
.
Returns a promise that resolves or rejects when the WebAssembly exports are loading. In some cases, this may happen synchronously when this module is loaded.
await b64.ready()
By default, this module allocates 2 pages of memory for the WebAssembly module.
That is 2 * 64 * 1024
bytes.
This module allows at most 256 pages of memory. That is 256 * 64 * 1024
bytes.
MIT