scon-notation 1.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.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/package.json +45 -0
- package/src/decoder.js +761 -0
- package/src/encoder.js +506 -0
- package/src/minifier.js +143 -0
- package/src/schema-registry.js +204 -0
- package/src/scon.js +121 -0
- package/src/tree-hash.js +227 -0
- package/src/validator.js +131 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 QuijoteShin
|
|
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
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# scon
|
|
2
|
+
|
|
3
|
+
**SCON — Schema-Compact Object Notation for JavaScript**
|
|
4
|
+
|
|
5
|
+
Human-readable serialization with structural dedup. Smaller than JSON, optional WASM acceleration, zero config.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/scon-notation)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install scon-notation
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
WASM acceleration is included as optional dependency and loads automatically when available. To explicitly exclude it:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install scon-notation --no-optional
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```js
|
|
25
|
+
import SCON from 'scon-notation';
|
|
26
|
+
|
|
27
|
+
// Encode
|
|
28
|
+
const data = { name: 'scon', version: 1, features: { dedup: true } };
|
|
29
|
+
const sconStr = SCON.encode(data);
|
|
30
|
+
// name: scon
|
|
31
|
+
// version: 1
|
|
32
|
+
// features:
|
|
33
|
+
// dedup: true
|
|
34
|
+
|
|
35
|
+
// Decode
|
|
36
|
+
const parsed = SCON.decode(sconStr);
|
|
37
|
+
|
|
38
|
+
// JSON-style aliases
|
|
39
|
+
const str = SCON.stringify(data);
|
|
40
|
+
const obj = SCON.parse(sconStr);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features
|
|
44
|
+
|
|
45
|
+
- **WASM-accelerated**: automatically loads Rust tape decoder via WebAssembly, falls back to pure JS
|
|
46
|
+
- **Structural dedup**: xxHash128 fingerprinting detects repeated subtrees — 59-66% payload reduction on OpenAPI specs
|
|
47
|
+
- **Schema subsystem**: registry with cycle detection, deep merge, dot-notation overrides
|
|
48
|
+
- **Validation**: configurable validation modes
|
|
49
|
+
- **Minifier**: bidirectional minify/expand
|
|
50
|
+
- **JSON-compatible API**: `SCON.parse()` / `SCON.stringify()` aliases
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import SCON, { Encoder, Decoder, Minifier, Validator, SchemaRegistry, TreeHash } from 'scon-notation';
|
|
56
|
+
|
|
57
|
+
// Encode / Decode
|
|
58
|
+
SCON.encode(data)
|
|
59
|
+
SCON.encode(data, { indent: 2 })
|
|
60
|
+
SCON.encode(data, { autoExtract: true }) // structural dedup
|
|
61
|
+
SCON.decode(sconString)
|
|
62
|
+
|
|
63
|
+
// Minify / Expand
|
|
64
|
+
SCON.minify(sconString)
|
|
65
|
+
SCON.expand(minifiedString, { indent: 2 })
|
|
66
|
+
|
|
67
|
+
// Validate
|
|
68
|
+
SCON.validate(data, { mode: 'strict' })
|
|
69
|
+
|
|
70
|
+
// WASM readiness (optional — all operations work without it)
|
|
71
|
+
const hasWasm = await SCON.ready();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Performance
|
|
75
|
+
|
|
76
|
+
| Format | Bytes | Ratio | Gzip |
|
|
77
|
+
|--------|-------|-------|------|
|
|
78
|
+
| JSON | 90,886 | 1.00x | 4,632 |
|
|
79
|
+
| SCON | 26,347 | 0.29x | 3,969 |
|
|
80
|
+
| SCON (minified) | 20,211 | 0.22x | 3,818 |
|
|
81
|
+
|
|
82
|
+
OpenAPI 3.1 spec, 71 endpoints. Full methodology: [DOI 10.5281/zenodo.14733092](https://doi.org/10.5281/zenodo.14733092)
|
|
83
|
+
|
|
84
|
+
## Also available
|
|
85
|
+
|
|
86
|
+
- **Rust**: `cargo add scon` — [crates.io/crates/scon](https://crates.io/crates/scon)
|
|
87
|
+
- **PHP**: `composer require scon/scon` — [packagist.org/packages/scon/scon](https://packagist.org/packages/scon/scon)
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "scon-notation",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SCON — Schema-Compact Object Notation: human-readable serialization with structural dedup and optional WASM acceleration",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/scon.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/scon.js",
|
|
9
|
+
"./encoder": "./src/encoder.js",
|
|
10
|
+
"./decoder": "./src/decoder.js",
|
|
11
|
+
"./minifier": "./src/minifier.js",
|
|
12
|
+
"./validator": "./src/validator.js",
|
|
13
|
+
"./schema-registry": "./src/schema-registry.js",
|
|
14
|
+
"./tree-hash": "./src/tree-hash.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src/",
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"optionalDependencies": {
|
|
22
|
+
"scon-wasm": "1.0.0",
|
|
23
|
+
"hash-wasm": "^4.11.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"serialization",
|
|
27
|
+
"json-alternative",
|
|
28
|
+
"schema",
|
|
29
|
+
"dedup",
|
|
30
|
+
"parser",
|
|
31
|
+
"scon",
|
|
32
|
+
"compact",
|
|
33
|
+
"wasm"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/QuijoteShin/scon-js"
|
|
39
|
+
},
|
|
40
|
+
"homepage": "https://github.com/QuijoteShin/scon-js",
|
|
41
|
+
"author": "QuijoteShin",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|