Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/skywa04885/llibencoding
Simple Encoding & Decoding Streaming Library
https://github.com/skywa04885/llibencoding
Last synced: 19 days ago
JSON representation
Simple Encoding & Decoding Streaming Library
- Host: GitHub
- URL: https://github.com/skywa04885/llibencoding
- Owner: skywa04885
- Created: 2022-03-28T09:11:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-05T10:35:57.000Z (over 2 years ago)
- Last Synced: 2024-12-12T08:51:32.309Z (about 2 months ago)
- Language: TypeScript
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# llibencoding (Luke's Encoding Library)
#### Introduction
Luke's encoding library contains many stream implementations for specific types of encoding, most libraries these days
only have one type of encoding, or don't use streams so I decided to create one myself because I need it for some of my
projects.#### Supported formats
1. Line (Wraps the data into lines, used by other formats)
2. Base64
3. Hex
4. QuotedPrintable
5. Dot Escaping (SMTP/POP3)#### Usage Example
The following example usage is the same for all other encoders / decoders.
```ts
import {Readable} from 'stream';
import {Base64EncoderStream} from "llibencoding/dist/Base64EncoderStream";
import {Base64DecoderStream} from "llibencoding/dist/Base64DecoderStream";const message: string = 'Hello World! A simple multi-line message, with quite some data so it will wrap for sure!';
const encoder: Base64EncoderStream = new Base64EncoderStream();
const decoder: Base64DecoderStream = new Base64DecoderStream();let encoded: string = '';
let decoded: string = '';encoder.on('data', (chunk: Buffer): void => {
encoded += chunk.toString('utf-8');
});decoder.on('data', (chunk: Buffer): void => {
decoded += chunk.toString('utf-8');
});encoder.pipe(decoder); // Decodes everything that get's encoded.
const readable: Readable = Readable.from(Buffer.from(message, 'utf-8'));
readable.pipe(encoder);```