Skip to content

Commit b2c56d2

Browse files
committed
Update README.md
1 parent 49a7b22 commit b2c56d2

2 files changed

Lines changed: 32 additions & 96 deletions

File tree

.github/image.png

4.54 MB
Loading

README.md

Lines changed: 32 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,66 @@
1-
# JSSC — JavaScript String Compressor
2-
**JSSC (JavaScript String Compressor)** is an open-source, **lossless string compression algorithm** designed specifically for JavaScript.
3-
4-
It operates directly on JavaScript strings (UTF-16) and produces compressed data that is also a valid JavaScript string.
5-
6-
## Key Features
7-
-**Lossless compression**
8-
- 🗜️ **High compression ratios**
9-
- up to **8:1** for numeric data
10-
- strong results for repetitive and structured text
11-
- 🌍 **Multilingual support**
12-
- English, Russian, Japanese, Chinese, Hindi, Bengali, and more
13-
- 📦 **JSON support**
14-
- JSON is converted to [JUSTC](https://just.js.org/justc) before compression
15-
- ⚙️ **String → String**
16-
- no binary buffers
17-
- no external metadata
18-
- all required information is embedded into the compressed string itself
19-
- 🧠 **Self-validating compression**
20-
- every compression mode is verified by decompression before being accepted
21-
- 🔁 **Recursive compression**
22-
- 📜 **TypeScript definitions** included
1+
![JSSC](.github/image.png)
232

24-
## Important Version Compatibility Notice
25-
⚠️ **Compressed strings produced by JSSC v1.x.x are NOT compatible with v2.x.x**
26-
27-
Reasons:
28-
- The first 16 bits (header layout) were slightly redesigned
29-
- New compression modes were added
30-
- Character encoding tables were extended
3+
# JSSC — JavaScript String Compressor
4+
JSSC is an open-source, **lossless string compression algorithm** designed specifically for JavaScript strings (UTF-16). It produces compressed data that remains a valid JS string, making it ideal for environments where binary data is difficult to handle.
315

32-
## Character Encoding
33-
JSSC operates on **JavaScript UTF-16 code units**, not on UTF-8 bytes.
6+
> **Note:** The npm package is named [`strc`](https://www.npmjs.com/package/strc). <br>
7+
> The `jssc` ("jSSC") npm package is unrelated to this project. <br>
8+
> Both names (uppercase "JSSC" and lowercase "strc") refer to the same project.
349
35-
This means:
36-
- Any character representable in a JavaScript string is supported
37-
- Compression works at the UTF-16 level
38-
- One JavaScript character = **16 bits**
39-
- Binary data must be converted to strings before compression
10+
JSSC is a complex algorithm featuring multiple internal compression modes tailored for different data structures. During compression, each mode evaluates the input; if its specific conditions are met, it produces a **candidate** string. JSSC then selects the best candidate — the one that achieves the highest compression ratio while passing a mandatory lossless decompression check. This approach results in a slower compression phase but ensures **high compression ratio** and **fast decompression**, as no brute-forcing or validation is required during recovery.
4011

41-
## Project Name vs npm Package Name
42-
The project is called **JSSC** (JavaScript String Compressor).
12+
⚠️ **Compatibility Notice:** Compressed strings from v1.x.x are **not compatible** with v2.x.x due to header and encoding changes. JSSC follows Semantic Versioning: successful decompression is guaranteed only if the decompressor version is equal to or newer than the compressor version (within the same major version).
4313

44-
The npm package is published under the name **`strc`**, because the name `jssc` is already occupied on npm by an unrelated Java-based package.
14+
## Key Features
15+
- ~**2.5:1 average compression ratio**.
16+
- **String-to-String**: No binary buffers or external metadata.
17+
- **Self-validating**: Compressed string is guaranteed to be successfully decompressed and with no data loss (if the string is not corrupted and the string was compressed by same major and not larger minor and patch version following SemVer).
18+
- **TypeScript support** and fully-typed API.
4519

46-
Both names refer to the same project.
20+
## Documentation
21+
Full documentation, API reference, and live examples are available at **[jssc.js.org](https://jssc.js.org/)**.
4722

48-
## Installation
49-
Install via npm
23+
## Quick start
5024
```
5125
npm i strc
5226
```
53-
54-
> The npm package name is `strc`, but the library itself is **JSSC**.
55-
56-
Or you can use it on your website by inserting the following HTML `script` tags.
57-
```html
58-
<script src="https://unpkg.com/justc"></script>
59-
<script src="https://unpkg.com/strc"></script>
60-
```
61-
62-
## Usage
63-
#### JavaScript
6427
```js
65-
const { compress, decompress } = require('strc');
66-
67-
const example = await compress("Hello, world!");
68-
await decompress(example);
69-
```
70-
71-
#### TypeScript
72-
```ts
7328
import { compress, decompress } from 'strc';
7429

75-
const example = await compress("Hello, world!");
76-
await decompress(example);
30+
const data = "Hello, world!";
31+
const compressed = await compress(data);
32+
const original = await decompress(compressed);
7733
```
7834

79-
#### Deno (server-side)
80-
```ts
81-
import JSSC from 'https://jssc.js.org/jssc.min.js';
82-
83-
const example = await JSSC.compress("Hello, world!");
84-
await JSSC.decompress(example);
35+
CLI:
36+
```
37+
npx jssc --help
8538
```
8639

87-
#### Browsers / Frontend (UMD)
88-
When using the UMD build via CDN, the library is exposed globally as `JSSC`.
40+
Website/Browsers:
8941
```html
9042
<script src="https://unpkg.com/justc"></script>
9143
<script src="https://unpkg.com/strc"></script>
9244
```
9345
```js
94-
const compressed = await JSSC.compress("Hello, world!");
95-
const decompressed = await JSSC.decompress(compressed);
96-
```
97-
98-
## JS API
99-
#### `compress(input: string | object | number): Promise<string>`
100-
Compresses the input and returns a compressed JavaScript string.
101-
102-
#### `decompress(input: string, stringify?: boolean): Promise<string | object | number>`
103-
Decompresses a previously compressed string/object/integer.
104-
105-
## CLI Usage
106-
```
107-
jssc --help
108-
```
109-
110-
**Compress a file/directory to JSSC Archive:**
111-
```
112-
jssc <input>
113-
```
114-
**Decompress a JSSC Archive:**
115-
```
116-
jssc <input.jssc> -d
46+
const data = "Hello, world!";
47+
const compressed = await JSSC.compress(data);
48+
const original = await JSSC.decompress(compressed);
11749
```
11850

11951
## Dependencies
12052
JSSC depends on:
12153
- <img align="top" src="https://just.js.org/justc/logo-50.svg" alt="JUSTC Logo" width="26" height="26"> [JUSTC](https://just.js.org/justc) by [JustStudio.](https://juststudio.is-a.dev/)
54+
- [lz-string](https://github.com/pieroxy/lz-string/) by [pieroxy](https://github.com/pieroxy)
12255
- [unicode-emoji-json](https://www.npmjs.com/package/unicode-emoji-json) by [Mu-An Chiou](https://github.com/muan)
56+
- [utf8.js](https://github.com/mathiasbynens/utf8.js) by [Mathias Bynens](https://mathiasbynens.be/)
12357

124-
JSSC CLI and Format Handling depends on:
58+
JSSC CLI and Format Handling (`.jssc`) depends on:
12559
- [crc-32](https://www.npmjs.com/package/crc-32) by [SheetJS](https://sheetjs.com/)
126-
- [uint8arrays](https://www.npmjs.com/package/uint8arrays) by [Alex Potsides](https://github.com/achingbrain)
12760
- [semver](https://semver.npmjs.com/) by [npm](https://www.npmjs.com/)
61+
- [uint8arrays](https://www.npmjs.com/package/uint8arrays) by [Alex Potsides](https://github.com/achingbrain)
62+
63+
> **Note:** All dependencies (except **JUSTC**) are bundled into the final build.
12864
12965
## License
13066
[MIT © 2025-2026 JustDeveloper](https://github.com/justdevw/JSSC/blob/main/LICENSE)

0 commit comments

Comments
 (0)