Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucacasonato/base64_streams
https://github.com/lucacasonato/base64_streams
Last synced: about 2 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/lucacasonato/base64_streams
- Owner: lucacasonato
- Created: 2023-09-25T05:23:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-25T06:33:46.000Z (about 1 year ago)
- Last Synced: 2024-10-25T15:48:35.329Z (18 days ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This is an implementation of a streaming Base64 encoder and decoder for
JavaScript, with the actual encoding and decoding logic being handled by
`Uint8Array.fromBase64()` and `Uint8Array.prototype.toBase64()` from the
[proposal-arraybuffer-base64](https://github.com/tc39/proposal-arraybuffer-base64).The streaming decoder supports streaming decoding and encoding. It correctly
handles padding and whitespace. There is both a WHATWG TransformStream, and a
sync-Iterator based API available.You can see the implementations for the various APIs in:
- [`Base64DecoderStream` WHATWG TransformStream](./src/whatwg/decoder.ts)
- [`Base64EncoderStream` WHATWG TransformStream](./src/whatwg/encoder.ts)
- [`decodeBase64()` sync iterator](./src/iterator/decoder.ts)
- [`encodeBase64()` sync iterator](./src/iterator/encoder.ts)To play with it:
```
$ deno repl -A --eval="import { Base64DecoderStream, Base64EncoderStream, decodeBase64, encodeBase64 } from './index.ts'"
Deno 1.37.0
exit using ctrl+d, ctrl+c, or close()
>
```To run tests, run `deno test`.