@rfanth/tjson 0.4.2 → 0.5.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/README.md +27 -16
- package/package.json +1 -1
- package/tjson.d.ts +7 -5
- package/tjson.js +1 -1
- package/tjson_bg.js +52 -52
- package/tjson_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -23,10 +23,10 @@ TJSON represents the same data model as JSON but renders it in a way that feels
|
|
|
23
23
|
|
|
24
24
|
**TJSON output**
|
|
25
25
|
```
|
|
26
|
-
name: Alice
|
|
26
|
+
name: Alice age:30 active:true
|
|
27
27
|
bio: ``
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
| She is a developer.
|
|
29
|
+
| She loves Rust.
|
|
30
30
|
``
|
|
31
31
|
scores: 90, 85, 92
|
|
32
32
|
tags: rust, wasm, json, serialization
|
|
@@ -81,7 +81,7 @@ All four functions throw an `Error` on invalid input.
|
|
|
81
81
|
|
|
82
82
|
Options use **camelCase** in JavaScript. The underlying library's Rust API uses snake_case and idiomatic Rust, but exposes the same options.
|
|
83
83
|
|
|
84
|
-
Key options
|
|
84
|
+
**Key options:**
|
|
85
85
|
|
|
86
86
|
| Option | Default | Description |
|
|
87
87
|
|---|---|---|
|
|
@@ -89,20 +89,24 @@ Key options at a glance:
|
|
|
89
89
|
| `wrapWidth` | `80` | Column wrap limit; `0` for unlimited |
|
|
90
90
|
| `tables` | `true` | Render arrays-of-objects as pipe tables |
|
|
91
91
|
| `multilineStrings` | `true` | Use `\`\`` blocks for strings containing newlines |
|
|
92
|
-
| `bareStrings` | `"prefer"` | Use bare (unquoted) string values when spec permits |
|
|
93
|
-
| `bareKeys` | `"prefer"` | Use bare (unquoted) object keys when spec permits |
|
|
94
92
|
| `inlineObjects` | `true` | Pack multiple key-value pairs onto one line |
|
|
95
93
|
| `inlineArrays` | `true` | Pack multiple array items onto one line |
|
|
96
94
|
| `stringArrayStyle` | `"preferComma"` | How to pack all-string arrays |
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
|
101
|
-
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
95
|
+
|
|
96
|
+
**Advanced options:**
|
|
97
|
+
|
|
98
|
+
| Option | Default | Description |
|
|
99
|
+
|---|---|---|
|
|
100
|
+
| `bareStrings` | `"prefer"` | Use bare (unquoted) string values when spec permits |
|
|
101
|
+
| `bareKeys` | `"prefer"` | Use bare (unquoted) object keys when spec permits |
|
|
102
|
+
| `forceMarkers` | `false` | Force explicit `[` / `{` indent markers on single-step indents |
|
|
103
|
+
| `multilineStyle` | `"bold"` | Multiline block style (`"bold"`, `"floating"`, `"light"`, etc.) |
|
|
104
|
+
| `multilineMinLines` | `1` | Min newlines in a string before using a multiline block |
|
|
105
|
+
| `indentGlyphStyle` | `"auto"` | When to wrap deeply nested content in `/<` `/>` glyphs |
|
|
106
|
+
| `indentGlyphMarkerStyle` | `"compact"` | Where to place the opening `/<` glyph |
|
|
107
|
+
| `tableUnindentStyle` | `"auto"` | How to reposition wide tables toward the left margin |
|
|
104
108
|
| `tableMinRows` | `3` | Min rows required to render a table |
|
|
105
|
-
| `
|
|
109
|
+
| `tableMinColumns` | `3` | Min columns required to render a table |
|
|
106
110
|
| `tableMinSimilarity` | `0.8` | Min fraction of rows sharing a column |
|
|
107
111
|
| `tableColumnMaxWidth` | `40` | Bail on table if any column exceeds this width |
|
|
108
112
|
| `fold` | — | Set all four fold styles at once; more specific options override |
|
|
@@ -110,9 +114,16 @@ Key options at a glance:
|
|
|
110
114
|
| `stringBareFoldStyle` | `"auto"` | How to fold long bare strings |
|
|
111
115
|
| `stringQuotedFoldStyle` | `"auto"` | How to fold long quoted strings |
|
|
112
116
|
| `stringMultilineFoldStyle` | `"none"` | How to fold multiline block continuation lines |
|
|
113
|
-
| `indentGlyphMarkerStyle` | `"compact"` | Where to place the opening `/<` glyph |
|
|
114
117
|
|
|
115
|
-
|
|
118
|
+
**Experimental options** (may change or be removed in a future version):
|
|
119
|
+
|
|
120
|
+
| Option | Default | Description |
|
|
121
|
+
|---|---|---|
|
|
122
|
+
| `kvPackMultiple` | `2` | Spacing multiplier between packed key-value pairs (1–4; spaces = value × 2) |
|
|
123
|
+
| `multilineMaxLines` | `10` | Max lines in a `"floating"` block before falling back to `"bold"` |
|
|
124
|
+
| `tableFold` | `false` | Fold long table rows across continuation lines |
|
|
125
|
+
|
|
126
|
+
Full option reference with inline documentation is in the TypeScript types bundled with the package.
|
|
116
127
|
|
|
117
128
|
## Resources
|
|
118
129
|
|
package/package.json
CHANGED
package/tjson.d.ts
CHANGED
|
@@ -30,18 +30,18 @@ export interface StringifyOptions {
|
|
|
30
30
|
multilineStyle?: MultilineStyle;
|
|
31
31
|
/** Minimum number of lines before a multiline block is used. Default: `1`. */
|
|
32
32
|
multilineMinLines?: number;
|
|
33
|
-
/** Maximum number of lines in a multiline block before falling back. Default: `10`. */
|
|
33
|
+
/** @experimental Maximum number of lines in a minimal (`) multiline block before falling back to a bold style multiline block (``), applies with multilineStyle: "floating" only. The idea is that we want to reserve a minimal style multiline for short multilines only for "floating". "light" has a similar look with no max line fallback. Default: `10`. */
|
|
34
34
|
multilineMaxLines?: number;
|
|
35
35
|
/** Enable table rendering for uniform arrays-of-objects. Default: `true`. */
|
|
36
36
|
tables?: boolean;
|
|
37
|
-
/** Allow folding long table rows across continuation lines. Default: `false`. */
|
|
37
|
+
/** @experimental Allow folding long table rows across continuation lines. (Not currently implemented. It is probably best to avoid this option for now as it may change.) Default: `false`. */
|
|
38
38
|
tableFold?: boolean;
|
|
39
|
-
/**
|
|
39
|
+
/** Whether to push wide tables toward the left margin. Independent of `indentGlyphStyle`. Default: `"auto"`. */
|
|
40
40
|
tableUnindentStyle?: TableUnindentStyle;
|
|
41
41
|
/** Minimum rows required to render a table. Default: `3`. */
|
|
42
42
|
tableMinRows?: number;
|
|
43
43
|
/** Minimum columns required to render a table. Default: `3`. */
|
|
44
|
-
|
|
44
|
+
tableMinColumns?: number;
|
|
45
45
|
/** Minimum fraction [0–1] of rows sharing a column before it's included. Default: `0.8`. */
|
|
46
46
|
tableMinSimilarity?: number;
|
|
47
47
|
/** If any column's content width (including the leading space on bare string values) exceeds this value, the table is abandoned and falls back to block layout. `0` means no limit. Default: `40`. */
|
|
@@ -58,10 +58,12 @@ export interface StringifyOptions {
|
|
|
58
58
|
stringQuotedFoldStyle?: FoldStyle;
|
|
59
59
|
/** How to fold multiline string continuation lines. Default: `"none"`. */
|
|
60
60
|
stringMultilineFoldStyle?: FoldStyle;
|
|
61
|
-
/**
|
|
61
|
+
/** Whether to wrap deeply-nested objects and arrays in `/<` `/>` glyphs to reduce visual depth. Independent of `tableUnindentStyle`. Default: `"auto"`. */
|
|
62
62
|
indentGlyphStyle?: IndentGlyphStyle;
|
|
63
63
|
/** Where to place the opening `/<` glyph. Default: `"compact"`. */
|
|
64
64
|
indentGlyphMarkerStyle?: IndentGlyphMarkerStyle;
|
|
65
|
+
/** @experimental Spacing multiplier between packed key-value pairs. Valid values: 1–4 (clamped); actual spaces = value × 2. Default: `2` (4 spaces). May be changed or removed in a future version. */
|
|
66
|
+
kvPackMultiple?: number;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
/** Parse a TJSON string and return a JSON string. */
|
package/tjson.js
CHANGED
package/tjson_bg.js
CHANGED
|
@@ -128,7 +128,7 @@ export function toJson(input) {
|
|
|
128
128
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
export function
|
|
131
|
+
export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
|
|
132
132
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
133
133
|
return ret;
|
|
134
134
|
}
|
|
@@ -139,68 +139,68 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
139
139
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
140
140
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
141
141
|
}
|
|
142
|
-
export function
|
|
142
|
+
export function __wbg___wbindgen_bigint_get_as_i64_3d3aba5d616c6a51(arg0, arg1) {
|
|
143
143
|
const v = arg1;
|
|
144
144
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
145
145
|
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
146
146
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
147
147
|
}
|
|
148
|
-
export function
|
|
148
|
+
export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
|
|
149
149
|
const v = arg0;
|
|
150
150
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
151
151
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
152
152
|
}
|
|
153
|
-
export function
|
|
153
|
+
export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
|
|
154
154
|
const ret = debugString(arg1);
|
|
155
155
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
156
156
|
const len1 = WASM_VECTOR_LEN;
|
|
157
157
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
158
158
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
159
159
|
}
|
|
160
|
-
export function
|
|
160
|
+
export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
|
|
161
161
|
const ret = arg0 in arg1;
|
|
162
162
|
return ret;
|
|
163
163
|
}
|
|
164
|
-
export function
|
|
164
|
+
export function __wbg___wbindgen_is_bigint_ec25c7f91b4d9e93(arg0) {
|
|
165
165
|
const ret = typeof(arg0) === 'bigint';
|
|
166
166
|
return ret;
|
|
167
167
|
}
|
|
168
|
-
export function
|
|
168
|
+
export function __wbg___wbindgen_is_function_3baa9db1a987f47d(arg0) {
|
|
169
169
|
const ret = typeof(arg0) === 'function';
|
|
170
170
|
return ret;
|
|
171
171
|
}
|
|
172
|
-
export function
|
|
172
|
+
export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
|
|
173
173
|
const ret = arg0 === null;
|
|
174
174
|
return ret;
|
|
175
175
|
}
|
|
176
|
-
export function
|
|
176
|
+
export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
|
|
177
177
|
const val = arg0;
|
|
178
178
|
const ret = typeof(val) === 'object' && val !== null;
|
|
179
179
|
return ret;
|
|
180
180
|
}
|
|
181
|
-
export function
|
|
181
|
+
export function __wbg___wbindgen_is_string_6df3bf7ef1164ed3(arg0) {
|
|
182
182
|
const ret = typeof(arg0) === 'string';
|
|
183
183
|
return ret;
|
|
184
184
|
}
|
|
185
|
-
export function
|
|
185
|
+
export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
|
|
186
186
|
const ret = arg0 === undefined;
|
|
187
187
|
return ret;
|
|
188
188
|
}
|
|
189
|
-
export function
|
|
189
|
+
export function __wbg___wbindgen_jsval_eq_d3465d8a07697228(arg0, arg1) {
|
|
190
190
|
const ret = arg0 === arg1;
|
|
191
191
|
return ret;
|
|
192
192
|
}
|
|
193
|
-
export function
|
|
193
|
+
export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
|
|
194
194
|
const ret = arg0 == arg1;
|
|
195
195
|
return ret;
|
|
196
196
|
}
|
|
197
|
-
export function
|
|
197
|
+
export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
|
|
198
198
|
const obj = arg1;
|
|
199
199
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
200
200
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
201
201
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
202
202
|
}
|
|
203
|
-
export function
|
|
203
|
+
export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
|
|
204
204
|
const obj = arg1;
|
|
205
205
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
206
206
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -208,34 +208,34 @@ export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
|
208
208
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
209
209
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
210
210
|
}
|
|
211
|
-
export function
|
|
211
|
+
export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
|
|
212
212
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
213
213
|
}
|
|
214
|
-
export function
|
|
214
|
+
export function __wbg_call_14b169f759b26747() { return handleError(function (arg0, arg1) {
|
|
215
215
|
const ret = arg0.call(arg1);
|
|
216
216
|
return ret;
|
|
217
217
|
}, arguments); }
|
|
218
|
-
export function
|
|
218
|
+
export function __wbg_done_9158f7cc8751ba32(arg0) {
|
|
219
219
|
const ret = arg0.done;
|
|
220
220
|
return ret;
|
|
221
221
|
}
|
|
222
|
-
export function
|
|
222
|
+
export function __wbg_entries_e0b73aa8571ddb56(arg0) {
|
|
223
223
|
const ret = Object.entries(arg0);
|
|
224
224
|
return ret;
|
|
225
225
|
}
|
|
226
|
-
export function
|
|
227
|
-
const ret = arg0[arg1 >>> 0];
|
|
228
|
-
return ret;
|
|
229
|
-
}
|
|
230
|
-
export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
|
|
226
|
+
export function __wbg_get_1affdbdd5573b16a() { return handleError(function (arg0, arg1) {
|
|
231
227
|
const ret = Reflect.get(arg0, arg1);
|
|
232
228
|
return ret;
|
|
233
229
|
}, arguments); }
|
|
234
|
-
export function
|
|
230
|
+
export function __wbg_get_8360291721e2339f(arg0, arg1) {
|
|
231
|
+
const ret = arg0[arg1 >>> 0];
|
|
232
|
+
return ret;
|
|
233
|
+
}
|
|
234
|
+
export function __wbg_get_unchecked_17f53dad852b9588(arg0, arg1) {
|
|
235
235
|
const ret = arg0[arg1 >>> 0];
|
|
236
236
|
return ret;
|
|
237
237
|
}
|
|
238
|
-
export function
|
|
238
|
+
export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
|
|
239
239
|
let result;
|
|
240
240
|
try {
|
|
241
241
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -245,7 +245,7 @@ export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
|
|
|
245
245
|
const ret = result;
|
|
246
246
|
return ret;
|
|
247
247
|
}
|
|
248
|
-
export function
|
|
248
|
+
export function __wbg_instanceof_Map_1b76fd4635be43eb(arg0) {
|
|
249
249
|
let result;
|
|
250
250
|
try {
|
|
251
251
|
result = arg0 instanceof Map;
|
|
@@ -255,7 +255,7 @@ export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
|
|
|
255
255
|
const ret = result;
|
|
256
256
|
return ret;
|
|
257
257
|
}
|
|
258
|
-
export function
|
|
258
|
+
export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
|
|
259
259
|
let result;
|
|
260
260
|
try {
|
|
261
261
|
result = arg0 instanceof Uint8Array;
|
|
@@ -265,68 +265,68 @@ export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
|
|
|
265
265
|
const ret = result;
|
|
266
266
|
return ret;
|
|
267
267
|
}
|
|
268
|
-
export function
|
|
268
|
+
export function __wbg_isArray_c3109d14ffc06469(arg0) {
|
|
269
269
|
const ret = Array.isArray(arg0);
|
|
270
270
|
return ret;
|
|
271
271
|
}
|
|
272
|
-
export function
|
|
272
|
+
export function __wbg_isSafeInteger_4fc213d1989d6d2a(arg0) {
|
|
273
273
|
const ret = Number.isSafeInteger(arg0);
|
|
274
274
|
return ret;
|
|
275
275
|
}
|
|
276
|
-
export function
|
|
276
|
+
export function __wbg_iterator_013bc09ec998c2a7() {
|
|
277
277
|
const ret = Symbol.iterator;
|
|
278
278
|
return ret;
|
|
279
279
|
}
|
|
280
|
-
export function
|
|
280
|
+
export function __wbg_length_3d4ecd04bd8d22f1(arg0) {
|
|
281
281
|
const ret = arg0.length;
|
|
282
282
|
return ret;
|
|
283
283
|
}
|
|
284
|
-
export function
|
|
284
|
+
export function __wbg_length_9f1775224cf1d815(arg0) {
|
|
285
285
|
const ret = arg0.length;
|
|
286
286
|
return ret;
|
|
287
287
|
}
|
|
288
|
-
export function
|
|
289
|
-
const ret = new
|
|
288
|
+
export function __wbg_new_0c7403db6e782f19(arg0) {
|
|
289
|
+
const ret = new Uint8Array(arg0);
|
|
290
290
|
return ret;
|
|
291
291
|
}
|
|
292
|
-
export function
|
|
292
|
+
export function __wbg_new_34d45cc8e36aaead() {
|
|
293
293
|
const ret = new Map();
|
|
294
294
|
return ret;
|
|
295
295
|
}
|
|
296
|
-
export function
|
|
297
|
-
const ret = new Uint8Array(arg0);
|
|
298
|
-
return ret;
|
|
299
|
-
}
|
|
300
|
-
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
296
|
+
export function __wbg_new_5e360d2ff7b9e1c3(arg0, arg1) {
|
|
301
297
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
302
298
|
return ret;
|
|
303
299
|
}
|
|
304
|
-
export function
|
|
300
|
+
export function __wbg_new_682678e2f47e32bc() {
|
|
305
301
|
const ret = new Array();
|
|
306
302
|
return ret;
|
|
307
303
|
}
|
|
308
|
-
export function
|
|
309
|
-
const ret =
|
|
304
|
+
export function __wbg_new_aa8d0fa9762c29bd() {
|
|
305
|
+
const ret = new Object();
|
|
310
306
|
return ret;
|
|
311
307
|
}
|
|
312
|
-
export function
|
|
308
|
+
export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
|
|
313
309
|
const ret = arg0.next();
|
|
314
310
|
return ret;
|
|
315
311
|
}, arguments); }
|
|
316
|
-
export function
|
|
312
|
+
export function __wbg_next_7646edaa39458ef7(arg0) {
|
|
313
|
+
const ret = arg0.next;
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
|
|
317
317
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
318
318
|
}
|
|
319
|
-
export function
|
|
320
|
-
|
|
321
|
-
return ret;
|
|
319
|
+
export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
|
|
320
|
+
arg0[arg1 >>> 0] = arg2;
|
|
322
321
|
}
|
|
323
322
|
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
324
323
|
arg0[arg1] = arg2;
|
|
325
324
|
}
|
|
326
|
-
export function
|
|
327
|
-
|
|
325
|
+
export function __wbg_set_fde2cec06c23692b(arg0, arg1, arg2) {
|
|
326
|
+
const ret = arg0.set(arg1, arg2);
|
|
327
|
+
return ret;
|
|
328
328
|
}
|
|
329
|
-
export function
|
|
329
|
+
export function __wbg_value_ee3a06f4579184fa(arg0) {
|
|
330
330
|
const ret = arg0.value;
|
|
331
331
|
return ret;
|
|
332
332
|
}
|
package/tjson_bg.wasm
CHANGED
|
Binary file
|