Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orbitturner/orbit-encoder
A versatile library that efficiently encodes and compresses diverse data inputs into concise strings.
https://github.com/orbitturner/orbit-encoder
compression encoder-decoder
Last synced: 5 days ago
JSON representation
A versatile library that efficiently encodes and compresses diverse data inputs into concise strings.
- Host: GitHub
- URL: https://github.com/orbitturner/orbit-encoder
- Owner: orbitturner
- License: gpl-3.0
- Created: 2022-04-12T11:47:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-23T17:39:29.000Z (about 1 year ago)
- Last Synced: 2024-04-24T19:03:12.517Z (10 months ago)
- Topics: compression, encoder-decoder
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/orbit-encoder
- Size: 1.45 MB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# ๐ข ORBIT ENCODER โ๏ธ๐๏ธ
[![Compatible Status](https://img.shields.io/badge/works%20with-PS1-blue)](https://github.com/orbitturner/ORBIT-ENCODER)
[![Code Size Status](https://img.shields.io/github/languages/code-size/orbitturner/ORBIT-ENCODER)](https://github.com/orbitturner/ORBIT-ENCODER)
[![Commit Status](https://img.shields.io/github/commit-activity/m/orbitturner/ORBIT-ENCODER?color=red)](https://github.com/orbitturner/ORBIT-ENCODER)
[![Issues Status](https://img.shields.io/github/issues/orbitturner/ORBIT-ENCODER)](https://github.com/orbitturner/ORBIT-ENCODER)
[![npm version](https://img.shields.io/npm/v/ORBIT-ENCODER.svg)](https://github.com/orbitturner/ORBIT-ENCODER) [![license](https://img.shields.io/npm/l/ORBIT-ENCODER.svg)](https://github.com/orbitturner/ORBIT-ENCODER)**ORBIT-ENCODER** is an utility library for Data Compression and Encoding. It can take whatever object you give him as argument and returns a compressed encoded string. It provides a decoding method too. It uses a modified version of [*LZString*](https://www.npmjs.com/package/lz-string) for UTF16 Compression.
INSTALLATION
___
## ๐ Table Of Contents ๐
- [๐ข ORBIT ENCODER โ๏ธ๐๏ธ](#orbit-encoder)
* [๐ Table Of Contents ๐](#table-of-contents)
* [๐จ What is this Library for? ๐ค](#what-is-this-library-for)
* [โจ Key Features ๐ฏ](#key-features---)
* [๐ฅ HOW TO RUN IT ? ๐ฐ](#how-to-run-it)
* [๐ค HOW IT WORKS ? ๐ค](#how-it-works)
+ [โค Encode & Decode Given Data ๐ข](#encode---decode-given-data)
* [Configuration Options](#configuration-options)
* [Contributing โค](#contributing--)
* [Issue Reporting](#issue-reporting)
* [GREETINGS](#greetings)
* [Author](#author)
* [License](#license)___
## ๐จ What is this Library for? ๐ค
**ORBIT-ENCODER** is a small library that is useful for Encoding Objects [`String, Arrays, JSON, Anything...`] to a `Compressed UTF16` String. You can also Decode that string back using The exposed **Decode** method.
> **Note:** This library can only be used with JS or TS but you already know that ๐คฆ๐ฟโโ๏ธ.
## โจ Key Features ๐ฏ
* Use it **without `instantiation`** because all the methods are `Static`.
* **Fast and High Performance Compression** of big Complex Data.
* โ TOO EASY TO USE !! ๐ฅณ๐ฅณ___
## ๐ฅ HOW TO RUN IT ? ๐ฐ
```bash
# installation with npm
npm install array-querier# or you may prefer
npm i --save array-querier# installation with yarn
yarn add array-querier
```**This SCRIPT relies on NOTHING SO YOU DON'T NEED ADDITIONNAL PACKAGES.**
___
## ๐ค HOW IT WORKS ? ๐คYou only need to Import the ***OrbitEncoder*** Class from the Package and start using it !
### โค Encode & Decode Given Data ๐ข
If you have a User object as follows ->
```json
const User = {
"name": "Orbit",
"age": 21,
"planet": {
"id": 4,
"codename" : "Shadow-Coders",
"galaxyName" : "Turner"
}
}
```
๐๐พ Let's Encode and Decode an Objects :- **ECMAScript Modules and Typescript**
```typescript
import {OrbitEncoder} from 'orbit-encoder/lib/OrbitEncoder';// Then Encode whatever you want
const encodedData = OrbitEncoder.encode(User);console.log(encodedData);
/**
* ๐๐พ Output: ๐๐พ
*
* แขใฐดไ ผเง็คใฆๆฉร฿แ แฃแฃกไฆTษใฆโไฐ แกใขใชๅ ใฒชโ ็ฅถfฤเขโธวธอเฃฃแโตMไผไปไปไใๆแขธแฃทๅฐเงฃไนฉๅไบฐรฆแฉไฉดยธๆคฎเ ขๆคๆชๆไๅกๆฌ็โไคฃ&ใPฦไ
*
* /
```
```typescript
...
const decodedData = OrbitEncoder.decode(encodedData);console.log(decodedData);
/**
* ๐๐พ Output: ๐๐พ
*
* {
name: 'Orbit',
age: 21,
planet: { id: 4, codename: 'Shadow-Coders', galaxyName: 'Turner' }
}
*
* /
```
**๐ ANGULAR & FRONTEND USERS โข๏ธ**
> **Note:** If you are using this in your frontend application you'll need to add the folowing line in your `index.html` ๐๐พ:.
```html
if (global === undefined) { var global = window; }
```
> **FIX COMING:** We are working on Future updates that will try to fix this error [*Uncaught ReferenceError: global is not defined*].- **CommonJs and Vanilla JS**
```javascript
const orbit = require("orbit-encoder").OrbitEncoder;const data = orbit.encode('Bodio Bodio Yei !!');
console.log(data); // ๐ Output :แ ขๆฑวเข็ ็ผๆฉชๆขธๆ<าฐแก โข เญ
console.log(orbit.decode(data));
```
> **โ Note: โ ** * You can do that : const orbit = require("orbit-encoder"); And use orbit.OrbitEncoder.encode() everywhere but for a more clean approach I did the code above.### โค Encode & Decode Data Passed on URI ๐ข
Sometimes you may want to pass some heavy and complex data or datastructure in a URL, so you can use the `encodeWithURIsafe` method. It produces ASCII strings representing the original string encoded in Base64 with a few tweaks to make these URI safe. Hence, you can send them to the server without thinking about URL encoding them.
This saves bandwidth and CPU.- **ECMAScript Modules and Typescript**
```typescript
import {OrbitEncoder} from 'orbit-encoder/lib/OrbitEncoder';const data = [['2021-03-02','2021-06-02'],['2022-05-05','2021-07-01']];
// Then Encode whatever you want
const encodedData = OrbitEncoder.encodeWithURIsafe(data);console.log(dataForURI);
/**
* ๐๐พ Output: ๐๐พ
*
* OoRgzglgsgVgggTygZQAwHcoI1CBJMPGPTGAUQBcoARATSurwgA1kAPAIyJNjwYFUBEADIBhPEkZthAFTgBmWXDZ4ANiAAmQA
*
* /
```
```typescript
...
const decodedData = OrbitEncoder.decodeURIsafe(encodedData);console.log(decodedData);
/**
* ๐๐พ Output: ๐๐พ
*
* [ [ '2021-03-02', '2021-06-02' ], [ '2022-05-05', '2021-07-01' ] ]
*
* /
```
- **CommonJs and Vanilla JS**
```javascript
const orbit = require("orbit-encoder").OrbitEncoder;const dataForURI = orbit.encodeWithURIsafe([['2021-03-02','2021-06-02'],['2022-05-05','2021-07-01']]);
console.log(dataForURI) // ๐ Output : OoRgzglgsgVgggTygZQAwHcoI1CBJMPGPTGAUQBcoARATSurwgA1kAPAIyJNjwYFUBEADIBhPEkZthAFTgBmWXDZ4ANiAAmQA
console.log(orbit.decodeURIsafe(dataForURI))
```___
## Configuration Options*Coming Soon !*
___
## Contributing โค๐๐พ Pull requests are welcome!
___## Issue Reporting
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](mailto:[email protected]) details the procedure for disclosing security issues.
___## GREETINGS
___
## Author[Orbit Turner](https://orbitturner.com)
___
## LicenseThis project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
______________________________________________________
**โค MADE WITH LOVE โค**![Image of OT](https://raw.githubusercontent.com/orbitturner/orbitturner/master/LOGO-OT.png)
![]()