boom-format 0.9.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/dist/index.js ADDED
@@ -0,0 +1,82 @@
1
+ import {
2
+ BOOM_DICTIONARY_V1,
3
+ BoomError,
4
+ BoomHeaders,
5
+ ByteReader,
6
+ ByteWriter,
7
+ DEFAULT_THRESHOLDS,
8
+ MAGIC,
9
+ StreamDecoder,
10
+ VERSION,
11
+ analyzeDictionary,
12
+ autoInit,
13
+ boomFetch,
14
+ compare,
15
+ createBoomAxios,
16
+ createBoomGraphQL,
17
+ createThresholdHeaders,
18
+ decode,
19
+ decodeFromLengthPrefixed,
20
+ decodeSmallest,
21
+ encode,
22
+ encodeSmallest,
23
+ encodeWithLength,
24
+ estimateSize,
25
+ fromJSON,
26
+ fromJSONDirect,
27
+ getBoomData,
28
+ getBoomMode,
29
+ getThresholdConfig,
30
+ index_default,
31
+ parseText,
32
+ parseThresholdHeaders,
33
+ processBoomScripts,
34
+ selectFormat,
35
+ setBoomMode,
36
+ setThresholdConfig,
37
+ stringify,
38
+ toJSON,
39
+ zigzagDecode,
40
+ zigzagEncode
41
+ } from "./chunk-5PQH6SJJ.js";
42
+ export {
43
+ BOOM_DICTIONARY_V1,
44
+ VERSION as BOOM_VERSION,
45
+ BoomError,
46
+ BoomHeaders,
47
+ ByteReader,
48
+ ByteWriter,
49
+ DEFAULT_THRESHOLDS,
50
+ MAGIC,
51
+ StreamDecoder,
52
+ analyzeDictionary,
53
+ autoInit,
54
+ boomFetch,
55
+ compare,
56
+ createBoomAxios,
57
+ createBoomGraphQL,
58
+ createThresholdHeaders,
59
+ decode,
60
+ decodeFromLengthPrefixed,
61
+ decodeSmallest,
62
+ index_default as default,
63
+ encode,
64
+ encodeSmallest,
65
+ encodeWithLength,
66
+ estimateSize,
67
+ fromJSON,
68
+ fromJSONDirect,
69
+ getBoomData,
70
+ getBoomMode,
71
+ getThresholdConfig,
72
+ parseText,
73
+ parseThresholdHeaders,
74
+ processBoomScripts,
75
+ selectFormat,
76
+ setBoomMode,
77
+ setThresholdConfig,
78
+ stringify,
79
+ toJSON,
80
+ zigzagDecode,
81
+ zigzagEncode
82
+ };
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "boom-format",
3
+ "version": "0.9.0",
4
+ "description": "Binary Object Optimised Markup - A compact binary serialisation format with readable debug mode",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.ts",
9
+ "bin": {
10
+ "boom": "./dist/cli.js"
11
+ },
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "bun": "./dist/index.js",
16
+ "deno": "./dist/index.js",
17
+ "import": "./dist/index.js",
18
+ "require": "./dist/index.cjs"
19
+ },
20
+ "./production": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/boom.min.js",
23
+ "require": "./dist/boom.min.cjs"
24
+ }
25
+ },
26
+ "files": [
27
+ "dist",
28
+ "samples",
29
+ "README.md",
30
+ "SPECIFICATION.md",
31
+ "deno.json"
32
+ ],
33
+ "scripts": {
34
+ "generate:dictionary": "node scripts/generate-dictionary.js",
35
+ "build": "npm run generate:dictionary && tsup src/index.ts src/cli.ts --format cjs,esm,iife --dts --clean --global-name Boom",
36
+ "build:prod": "npm run build && npm run minify && npm run obfuscate",
37
+ "build:browser": "tsup src/index.ts --format iife --global-name Boom --outDir docs --no-dts",
38
+ "minify": "terser dist/index.js -c -m --module -o dist/boom.min.js && terser dist/index.cjs -c -m -o dist/boom.min.cjs",
39
+ "obfuscate": "javascript-obfuscator dist/boom.min.js --output dist/boom.obf.js --compact true --control-flow-flattening true --dead-code-injection false --string-array true --string-array-encoding base64 --string-array-threshold 0.75",
40
+ "test": "node --test test/*.test.js",
41
+ "test:coverage": "node --test --experimental-test-coverage test/*.test.js",
42
+ "test:bun": "bun test test/bun.test.ts",
43
+ "test:deno": "deno test --allow-read test/deno-local.test.ts",
44
+ "benchmark": "node benchmark/bench.js",
45
+ "benchmark:bun": "bun run benchmark/bench-bun.ts",
46
+ "benchmark:deno": "deno run --allow-read benchmark/bench-deno.ts",
47
+ "benchmark:all": "npm run benchmark && echo '---' && npm run benchmark:bun && echo '---' && npm run benchmark:deno",
48
+ "benchmark:compare": "node benchmark/format-comparison.js",
49
+ "generate:og": "node docs/scripts/generate-og-images.js",
50
+ "update:year": "node docs/scripts/update-copyright-year.js",
51
+ "build:docs": "node docs/scripts/build-pages.js",
52
+ "minify:docs": "node docs/scripts/minify-docs.js",
53
+ "build:docs:prod": "npm run build:docs && npm run minify:docs",
54
+ "prepublishOnly": "npm run build:prod && npm test"
55
+ },
56
+ "keywords": [
57
+ "binary",
58
+ "serialization",
59
+ "json",
60
+ "compact",
61
+ "format",
62
+ "parser",
63
+ "encoder",
64
+ "msgpack",
65
+ "cbor",
66
+ "boom",
67
+ "llm",
68
+ "token-efficient",
69
+ "ai",
70
+ "toon",
71
+ "yaml-alternative"
72
+ ],
73
+ "author": "Tom Taylor",
74
+ "license": "SEE LICENSE IN LICENSE",
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "https://github.com/t0mtaylor/boom-format.git"
78
+ },
79
+ "homepage": "https://github.com/t0mtaylor/boom-format#readme",
80
+ "bugs": {
81
+ "url": "https://github.com/t0mtaylor/boom-format/issues"
82
+ },
83
+ "engines": {
84
+ "node": ">=18.0.0"
85
+ },
86
+ "devDependencies": {
87
+ "@types/node": "^25.0.3",
88
+ "csso": "^5.0.5",
89
+ "html-minifier-terser": "^7.2.0",
90
+ "javascript-obfuscator": "^4.1.0",
91
+ "puppeteer": "^24.34.0",
92
+ "terser": "^5.31.0",
93
+ "tsup": "^8.0.0",
94
+ "typescript": "^5.3.0"
95
+ }
96
+ }
@@ -0,0 +1,114 @@
1
+ # BOOM Sample Files
2
+
3
+ This directory contains sample files in JSON, BOOM binary, and BOOM text formats to help you understand the format.
4
+
5
+ ## Files
6
+
7
+ ### users.json / users.boom / users.boom.txt
8
+ A typical API response with an array of user objects. Demonstrates string interning with repeated keys.
9
+
10
+ | Format | Size | Savings |
11
+ |--------|------|---------|
12
+ | JSON | 540 B | - |
13
+ | BOOM binary | 256 B | **52.6%** |
14
+ | BOOM text | 331 B | **38.7%** |
15
+
16
+ ### api-response.json / api-response.boom / api-response.boom.txt
17
+ An LLM API response structure with nested objects. Shows dictionary efficiency with common API keys.
18
+
19
+ | Format | Size | Savings |
20
+ |--------|------|---------|
21
+ | JSON | 381 B | - |
22
+ | BOOM binary | 252 B | **33.9%** |
23
+ | BOOM text | 278 B | **27.0%** |
24
+
25
+ ### config.json / config.boom / config.boom.txt
26
+ Application configuration with nested settings. Good for human editing in `.boom.txt` format.
27
+
28
+ | Format | Size | Savings |
29
+ |--------|------|---------|
30
+ | JSON | 361 B | - |
31
+ | BOOM binary | 202 B | **44.0%** |
32
+ | BOOM text | 244 B | **32.4%** |
33
+
34
+ ## Using These Files
35
+
36
+ ### View BOOM Text Format
37
+ ```bash
38
+ cat users.boom.txt
39
+ ```
40
+
41
+ Output:
42
+ ```boom
43
+ {
44
+ users: [
45
+ { id: 1 name: "Alice Johnson" email: "alice@example.com" role: "admin" active: true score: 95.5 }
46
+ { id: 2 name: "Bob Smith" email: "bob@example.com" role: "user" active: true score: 88 }
47
+ { id: 3 name: "Charlie Brown" email: "charlie@example.com" role: "user" active: false score: 72.5 }
48
+ ]
49
+ total: 3
50
+ page: 1
51
+ pageSize: 10
52
+ }
53
+ ```
54
+
55
+ ### Convert Between Formats
56
+ ```bash
57
+ # JSON to BOOM binary
58
+ npx boom encode users.json
59
+
60
+ # JSON to BOOM text
61
+ npx boom encode users.json --text
62
+
63
+ # BOOM binary to JSON
64
+ npx boom decode users.boom
65
+
66
+ # BOOM text to JSON
67
+ npx boom decode users.boom.txt
68
+
69
+ # Show file info
70
+ npx boom info users.boom
71
+ ```
72
+
73
+ ### Programmatic Usage
74
+ ```javascript
75
+ import { encode, decode, stringify, parseText } from 'boom-format';
76
+ import fs from 'fs';
77
+
78
+ // Read and decode BOOM binary
79
+ const boomData = fs.readFileSync('users.boom');
80
+ const users = decode(new Uint8Array(boomData));
81
+
82
+ // Read and parse BOOM text
83
+ const textData = fs.readFileSync('users.boom.txt', 'utf-8');
84
+ const usersFromText = parseText(textData);
85
+
86
+ // Encode to BOOM binary
87
+ const encoded = encode(users);
88
+ fs.writeFileSync('output.boom', encoded);
89
+
90
+ // Convert to BOOM text
91
+ const text = stringify(users);
92
+ fs.writeFileSync('output.boom.txt', text);
93
+ ```
94
+
95
+ ## File Extensions
96
+
97
+ | Extension | Format | MIME Type |
98
+ |-----------|--------|-----------|
99
+ | `.boom` | BOOM Binary | `application/x-boom` |
100
+ | `.boom.txt` | BOOM Text | `application/x-boom-text` |
101
+ | `.json` | JSON | `application/json` |
102
+
103
+ ## BOOM Binary Header
104
+
105
+ The `.boom` files start with a 6-byte header:
106
+ - Bytes 0-3: Magic `BOOM` (0x42, 0x4F, 0x4F, 0x4D)
107
+ - Byte 4: Version (0x01)
108
+ - Byte 5: Flags
109
+
110
+ You can verify a BOOM file with:
111
+ ```bash
112
+ xxd -l 6 users.boom
113
+ # 00000000: 424f 4f4d 0101 BOOM..
114
+ ```
Binary file
@@ -0,0 +1 @@
1
+ { status: "success" data: { id: "msg_abc123" role: "assistant" content: "Hello! How can I help you today?" model: "gpt-4" created_at: "2024-01-15T10:30:00Z" usage: { prompt_tokens: 12 completion_tokens: 8 total_tokens: 20 } } meta: { request_id: "req_xyz789" latency_ms: 245 } }
@@ -0,0 +1,19 @@
1
+ {
2
+ "status": "success",
3
+ "data": {
4
+ "id": "msg_abc123",
5
+ "role": "assistant",
6
+ "content": "Hello! How can I help you today?",
7
+ "model": "gpt-4",
8
+ "created_at": "2024-01-15T10:30:00Z",
9
+ "usage": {
10
+ "prompt_tokens": 12,
11
+ "completion_tokens": 8,
12
+ "total_tokens": 20
13
+ }
14
+ },
15
+ "meta": {
16
+ "request_id": "req_xyz789",
17
+ "latency_ms": 245
18
+ }
19
+ }
Binary file
@@ -0,0 +1 @@
1
+ { app: { name: "My Application" version: "1.0.0" debug: false } database: { host: "localhost" port: 5432 name: "myapp_db" pool: { min: 2 max: 10 } } features: { darkMode: true notifications: true analytics: false } limits: [100 500 1000 5000] }
@@ -0,0 +1,22 @@
1
+ {
2
+ "app": {
3
+ "name": "My Application",
4
+ "version": "1.0.0",
5
+ "debug": false
6
+ },
7
+ "database": {
8
+ "host": "localhost",
9
+ "port": 5432,
10
+ "name": "myapp_db",
11
+ "pool": {
12
+ "min": 2,
13
+ "max": 10
14
+ }
15
+ },
16
+ "features": {
17
+ "darkMode": true,
18
+ "notifications": true,
19
+ "analytics": false
20
+ },
21
+ "limits": [100, 500, 1000, 5000]
22
+ }
Binary file
@@ -0,0 +1 @@
1
+ { users: [ { id: 1 name: "Alice Johnson" email: "alice@example.com" role: "admin" active: true score: 95.5 } { id: 2 name: "Bob Smith" email: "bob@example.com" role: "user" active: true score: 88 } { id: 3 name: "Charlie Brown" email: "charlie@example.com" role: "user" active: false score: 72.5 } ] total: 3 page: 1 pageSize: 10 }
@@ -0,0 +1,31 @@
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 1,
5
+ "name": "Alice Johnson",
6
+ "email": "alice@example.com",
7
+ "role": "admin",
8
+ "active": true,
9
+ "score": 95.5
10
+ },
11
+ {
12
+ "id": 2,
13
+ "name": "Bob Smith",
14
+ "email": "bob@example.com",
15
+ "role": "user",
16
+ "active": true,
17
+ "score": 88.0
18
+ },
19
+ {
20
+ "id": 3,
21
+ "name": "Charlie Brown",
22
+ "email": "charlie@example.com",
23
+ "role": "user",
24
+ "active": false,
25
+ "score": 72.5
26
+ }
27
+ ],
28
+ "total": 3,
29
+ "page": 1,
30
+ "pageSize": 10
31
+ }