1.1.0 • Published 10 months ago
@victorenator/base64 v1.1.0
Base64 Encoder/Decoder Stream
Install
npm install @victorenator/base64
Examples
Decode Base64-data from network
const res = await fetch('/base64data');
res.body
.pipeThrough(createBase64DecoderStream())
.pipeTo(...)
Encode Base64-data to network
const stream = new ReadableStream({
start(controller) {
controller.enqueue('ABC 123');
controller.stop();
}
})
.pipeThrough(new TextEncoderStream())
.pipeThrough(createBase64EncoderStream());
await fetch('/base64data', {
method: 'PUT',
body: stream,
});