strc 2.0.0-test → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +123 -124
  3. package/index.d.ts +121 -121
  4. package/index.js +1624 -1620
  5. package/index.min.js +38 -38
  6. package/package.json +2 -2
  7. package/test/index.js +122 -97
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025-2026 JustDeveloper <https://justdeveloper.is-a.dev/>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 JustDeveloper <https://justdeveloper.is-a.dev/>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,124 +1,123 @@
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
- JSSC is distributed as a **UMD module** and can be used in browsers, Node.js, Deno, and other JavaScript environments.
7
-
8
- ## Key Features
9
- - ✨ **Lossless compression**
10
- - 🗜️ **High compression ratios**
11
- - up to **8:1** for numeric data
12
- - strong results for repetitive and structured text
13
- - 🌍 **Multilingual support**
14
- - English, Russian, Japanese, Chinese, Hindi, Bengali, and more
15
- - 📦 **JSON support**
16
- - JSON is converted to [JUSTC](https://just.js.org/justc) before compression
17
- - ⚙️ **String → String**
18
- - no binary buffers
19
- - no external metadata
20
- - all required information is embedded into the compressed string itself
21
- - 🧠 **Self-validating compression**
22
- - every compression mode is verified by decompression before being accepted
23
- - 🔁 **Recursive optimization mode**
24
- - optional multi-pass compression (mode 31)
25
- - 📜 TypeScript definitions included
26
- - 🌐 **UMD build** for browsers and static websites
27
-
28
- ## Important Version Compatibility Notice
29
- ⚠️ **Compressed strings produced by JSSC v1.x.x are NOT compatible with v2.x.x**
30
-
31
- Reasons:
32
- - The first 16 bits (header layout) were slightly redesigned
33
- - New compression modes were added
34
- - Character encoding tables were extended
35
-
36
- ## Character Encoding
37
- JSSC operates on **JavaScript UTF-16 code units**, not on UTF-8 bytes.
38
-
39
- This means:
40
- - Any character representable in a JavaScript string is supported
41
- - Compression works at the UTF-16 level
42
- - One JavaScript character = **16 bits**
43
- - Binary data must be converted to strings before compression
44
-
45
- ## Project Name vs npm Package Name
46
- The project is called **JSSC** (JavaScript String Compressor).
47
-
48
- The npm package is published under the name **`strc`**, because the name `jssc` is already occupied on npm by an unrelated Java-based package.
49
-
50
- Both names refer to the same project.
51
-
52
- ## Installation
53
- Install via npm
54
- ```
55
- npm i strc
56
- ```
57
-
58
- > The npm package name is `strc`, but the library itself is **JSSC**.
59
-
60
- Or you can use it on your website by inserting the following HTML `script` tags.
61
- ```html
62
- <script src="https://unpkg.com/justc"></script>
63
- <script src="https://unpkg.com/strc"></script>
64
- ```
65
-
66
- ## Usage
67
- #### JavaScript
68
- ```js
69
- const { compress, decompress } = require('strc');
70
-
71
- const example = await compress("Hello, world!");
72
- await decompress(example);
73
- ```
74
-
75
- #### TypeScript
76
- ```ts
77
- import { compress, decompress } from 'strc';
78
-
79
- const example = await compress("Hello, world!");
80
- await decompress(example);
81
- ```
82
-
83
- #### Deno (server-side)
84
- ```ts
85
- import JSSC from 'https://jssc.js.org/script.js';
86
-
87
- const example = await JSSC.compress("Hello, world!");
88
- await JSSC.decompress(example);
89
- ```
90
-
91
- #### Browsers / Frontend (UMD)
92
- When using the UMD build via CDN, the library is exposed globally as `JSSC`.
93
- ```html
94
- <script src="https://unpkg.com/justc"></script>
95
- <script src="https://unpkg.com/strc"></script>
96
- ```
97
- ```js
98
- const compressed = await JSSC.compress("Hello, world!");
99
- const decompressed = await JSSC.decompress(compressed);
100
- ```
101
-
102
- ## API
103
- #### `compress(input: string | object | number): Promise<string>`
104
- Compresses the input and returns a compressed JavaScript string.
105
-
106
- #### `decompress(input: string, stringify?: boolean): Promise<string | object | number>`
107
- Decompresses a previously compressed string/object/integer.
108
-
109
- ## Dependencies
110
- JSSC depends on:
111
- - <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/)
112
-
113
- ## License
114
- [MIT © 2025-2026 JustDeveloper](https://github.com/JustDeveloper1/JSSC/blob/main/LICENSE)
115
-
116
- ---
117
- ## Minified Build
118
- For `.min.js`, I use [UglifyJS](https://github.com/mishoo/UglifyJS) by [Mihai Bazon](https://github.com/mishoo).
119
- ```bash
120
- npm i uglify-js
121
- ```
122
- ```bash
123
- uglifyjs index.js -c -m "reserved=['compress','decompress']" -o index.min.js
124
- ```
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
+ JSSC is distributed as a **UMD module** and can be used in browsers, Node.js, Deno, and other JavaScript environments.
7
+
8
+ ## Key Features
9
+ - ✨ **Lossless compression**
10
+ - 🗜️ **High compression ratios**
11
+ - up to **8:1** for numeric data
12
+ - strong results for repetitive and structured text
13
+ - 🌍 **Multilingual support**
14
+ - English, Russian, Japanese, Chinese, Hindi, Bengali, and more
15
+ - 📦 **JSON support**
16
+ - JSON is converted to [JUSTC](https://just.js.org/justc) before compression
17
+ - ⚙️ **String → String**
18
+ - no binary buffers
19
+ - no external metadata
20
+ - all required information is embedded into the compressed string itself
21
+ - 🧠 **Self-validating compression**
22
+ - every compression mode is verified by decompression before being accepted
23
+ - 🔁 **Recursive compression**
24
+ - 📜 **TypeScript definitions** included
25
+ - 🌐 **UMD build** for browsers and static websites
26
+
27
+ ## Important Version Compatibility Notice
28
+ ⚠️ **Compressed strings produced by JSSC v1.x.x are NOT compatible with v2.x.x**
29
+
30
+ Reasons:
31
+ - The first 16 bits (header layout) were slightly redesigned
32
+ - New compression modes were added
33
+ - Character encoding tables were extended
34
+
35
+ ## Character Encoding
36
+ JSSC operates on **JavaScript UTF-16 code units**, not on UTF-8 bytes.
37
+
38
+ This means:
39
+ - Any character representable in a JavaScript string is supported
40
+ - Compression works at the UTF-16 level
41
+ - One JavaScript character = **16 bits**
42
+ - Binary data must be converted to strings before compression
43
+
44
+ ## Project Name vs npm Package Name
45
+ The project is called **JSSC** (JavaScript String Compressor).
46
+
47
+ The npm package is published under the name **`strc`**, because the name `jssc` is already occupied on npm by an unrelated Java-based package.
48
+
49
+ Both names refer to the same project.
50
+
51
+ ## Installation
52
+ Install via npm
53
+ ```
54
+ npm i strc
55
+ ```
56
+
57
+ > The npm package name is `strc`, but the library itself is **JSSC**.
58
+
59
+ Or you can use it on your website by inserting the following HTML `script` tags.
60
+ ```html
61
+ <script src="https://unpkg.com/justc"></script>
62
+ <script src="https://unpkg.com/strc"></script>
63
+ ```
64
+
65
+ ## Usage
66
+ #### JavaScript
67
+ ```js
68
+ const { compress, decompress } = require('strc');
69
+
70
+ const example = await compress("Hello, world!");
71
+ await decompress(example);
72
+ ```
73
+
74
+ #### TypeScript
75
+ ```ts
76
+ import { compress, decompress } from 'strc';
77
+
78
+ const example = await compress("Hello, world!");
79
+ await decompress(example);
80
+ ```
81
+
82
+ #### Deno (server-side)
83
+ ```ts
84
+ import JSSC from 'https://jssc.js.org/jssc.min.js';
85
+
86
+ const example = await JSSC.compress("Hello, world!");
87
+ await JSSC.decompress(example);
88
+ ```
89
+
90
+ #### Browsers / Frontend (UMD)
91
+ When using the UMD build via CDN, the library is exposed globally as `JSSC`.
92
+ ```html
93
+ <script src="https://unpkg.com/justc"></script>
94
+ <script src="https://unpkg.com/strc"></script>
95
+ ```
96
+ ```js
97
+ const compressed = await JSSC.compress("Hello, world!");
98
+ const decompressed = await JSSC.decompress(compressed);
99
+ ```
100
+
101
+ ## API
102
+ #### `compress(input: string | object | number): Promise<string>`
103
+ Compresses the input and returns a compressed JavaScript string.
104
+
105
+ #### `decompress(input: string, stringify?: boolean): Promise<string | object | number>`
106
+ Decompresses a previously compressed string/object/integer.
107
+
108
+ ## Dependencies
109
+ JSSC depends on:
110
+ - <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/)
111
+
112
+ ## License
113
+ [MIT © 2025-2026 JustDeveloper](https://github.com/JustDeveloper1/JSSC/blob/main/LICENSE)
114
+
115
+ ---
116
+ ## Minified Build
117
+ For `.min.js`, I use [UglifyJS](https://github.com/mishoo/UglifyJS) by [Mihai Bazon](https://github.com/mishoo).
118
+ ```bash
119
+ npm i uglify-js
120
+ ```
121
+ ```bash
122
+ uglifyjs index.js -c -m "reserved=['compress','decompress']" -o index.min.js
123
+ ```
package/index.d.ts CHANGED
@@ -1,121 +1,121 @@
1
- /*
2
-
3
- MIT License
4
-
5
- Copyright (c) 2025-2026 JustDeveloper <https://justdeveloper.is-a.dev/>
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all
15
- copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- SOFTWARE.
24
-
25
- */
26
-
27
- /*
28
- _______________
29
- __ / / __/ __/ ___/
30
- / // /\ \_\ \/ /__
31
- \___/___/___/\___/
32
-
33
- JavaScript String Compressor
34
- https://jssc.js.org/
35
-
36
- */
37
-
38
- /**
39
- * JavaScript String Compressor - compress options
40
- * @license MIT
41
- * @copyright (c) 2025-2026 JustDeveloper <<https://justdeveloper.is-a.dev>>
42
- * @since 2.0.0
43
- */
44
- export interface compressOptions {
45
- JUSTC?: boolean,
46
- recursiveCompression?: boolean,
47
- segmentation?: boolean
48
- }
49
-
50
- /**
51
- * JavaScript String Compressor - compress function
52
- * @param str - Input string to compress
53
- * @returns Compressed string
54
- * @example
55
- * await compress('Hello, World!');
56
- * @since 1.0.0
57
- */
58
- export function compress(str: string, options?: compressOptions): Promise<string>;
59
- /**
60
- * JavaScript String Compressor - compress function
61
- * @param obj - Input object to compress
62
- * > **Note: it will `JSON.stringify()` your object so it may lose some data if your object has getters/setters/non-enumerables/etc.!**
63
- * @returns Compressed string
64
- * @example
65
- * await compress({a: "b"});
66
- * @since 2.0.0
67
- */
68
- export function compress(obj: object, options?: compressOptions): Promise<string>;
69
- /**
70
- * JavaScript String Compressor - compress function
71
- * @param int - Input integer to compress
72
- * @returns Compressed string
73
- * @example
74
- * await compress(10);
75
- * @since 2.0.0
76
- */
77
- export function compress(int: number, options?: compressOptions): Promise<string>;
78
-
79
- /**
80
- * JavaScript String Compressor - decompress function
81
- * @param str - Compressed string to decompress
82
- * @returns Decompressed string
83
- * @example
84
- * await decompress(compressedString);
85
- * @since 1.0.0
86
- */
87
- export function decompress(str: string): Promise<string>;
88
- /**
89
- * JavaScript String Compressor - decompress function
90
- * @param str - Compressed object to decompress
91
- * @param stringify - Always return string? (`JSON.stringify()` object outputs)
92
- * @returns Decompressed string
93
- * @example
94
- * await decompress(compressedString);
95
- * @since 2.0.0
96
- */
97
- export function decompress(str: string, stringify?: boolean): Promise<object|string>;
98
- /**
99
- * JavaScript String Compressor - decompress function
100
- * @param str - Compressed object to decompress
101
- * @param stringify - Always return string? (`.toString()` integer outputs)
102
- * @returns Decompressed string
103
- * @example
104
- * await decompress(compressedString);
105
- * @since 2.0.0
106
- */
107
- export function decompress(str: string, stringify?: boolean): Promise<number|string>;
108
-
109
- /**
110
- * JavaScript String Compressor
111
- * @license MIT
112
- * @copyright (c) 2025-2026 JustDeveloper <<https://justdeveloper.is-a.dev>>
113
- * @since 1.0.0
114
- */
115
- declare const JSSC: {
116
- compress: typeof compress;
117
- decompress: typeof decompress;
118
- [Symbol.toStringTag]: 'JSSC';
119
- };
120
-
121
- export default JSSC;
1
+ /*
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2025-2026 JustDeveloper <https://justdeveloper.is-a.dev/>
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+
25
+ */
26
+
27
+ /*
28
+ _______________
29
+ __ / / __/ __/ ___/
30
+ / // /\ \_\ \/ /__
31
+ \___/___/___/\___/
32
+
33
+ JavaScript String Compressor
34
+ https://jssc.js.org/
35
+
36
+ */
37
+
38
+ /**
39
+ * JavaScript String Compressor - compress options
40
+ * @license MIT
41
+ * @copyright (c) 2025-2026 JustDeveloper <<https://justdeveloper.is-a.dev>>
42
+ * @since 2.0.0
43
+ */
44
+ export interface compressOptions {
45
+ JUSTC?: boolean,
46
+ recursiveCompression?: boolean,
47
+ segmentation?: boolean
48
+ }
49
+
50
+ /**
51
+ * JavaScript String Compressor - compress function
52
+ * @param str - Input string to compress
53
+ * @returns Compressed string
54
+ * @example
55
+ * await compress('Hello, World!');
56
+ * @since 1.0.0
57
+ */
58
+ export function compress(str: string, options?: compressOptions): Promise<string>;
59
+ /**
60
+ * JavaScript String Compressor - compress function
61
+ * @param obj - Input object to compress
62
+ * > **Note: it will `JSON.stringify()` your object so it may lose some data if your object has getters/setters/non-enumerables/etc.!**
63
+ * @returns Compressed string
64
+ * @example
65
+ * await compress({a: "b"});
66
+ * @since 2.0.0
67
+ */
68
+ export function compress(obj: object, options?: compressOptions): Promise<string>;
69
+ /**
70
+ * JavaScript String Compressor - compress function
71
+ * @param int - Input integer to compress
72
+ * @returns Compressed string
73
+ * @example
74
+ * await compress(10);
75
+ * @since 2.0.0
76
+ */
77
+ export function compress(int: number, options?: compressOptions): Promise<string>;
78
+
79
+ /**
80
+ * JavaScript String Compressor - decompress function
81
+ * @param str - Compressed string to decompress
82
+ * @returns Decompressed string
83
+ * @example
84
+ * await decompress(compressedString);
85
+ * @since 1.0.0
86
+ */
87
+ export function decompress(str: string): Promise<string>;
88
+ /**
89
+ * JavaScript String Compressor - decompress function
90
+ * @param str - Compressed object to decompress
91
+ * @param stringify - Always return string? (`JSON.stringify()` object outputs)
92
+ * @returns Decompressed string
93
+ * @example
94
+ * await decompress(compressedString);
95
+ * @since 2.0.0
96
+ */
97
+ export function decompress(str: string, stringify?: boolean): Promise<object|string>;
98
+ /**
99
+ * JavaScript String Compressor - decompress function
100
+ * @param str - Compressed object to decompress
101
+ * @param stringify - Always return string? (`.toString()` integer outputs)
102
+ * @returns Decompressed string
103
+ * @example
104
+ * await decompress(compressedString);
105
+ * @since 2.0.0
106
+ */
107
+ export function decompress(str: string, stringify?: boolean): Promise<number|string>;
108
+
109
+ /**
110
+ * JavaScript String Compressor
111
+ * @license MIT
112
+ * @copyright (c) 2025-2026 JustDeveloper <<https://justdeveloper.is-a.dev>>
113
+ * @since 1.0.0
114
+ */
115
+ declare const JSSC: {
116
+ compress: typeof compress;
117
+ decompress: typeof decompress;
118
+ [Symbol.toStringTag]: 'JSSC';
119
+ };
120
+
121
+ export default JSSC;