@rfanth/tjson 0.3.2 → 0.4.1
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 +103 -96
- package/package.json +1 -1
- package/tjson.d.ts +86 -6
- package/tjson.js +1 -1
- package/tjson_bg.js +218 -28
- package/tjson_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -1,120 +1,127 @@
|
|
|
1
|
-
# tjson
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
TJSON
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
[
|
|
15
|
-
|
|
1
|
+
# @rfanth/tjson
|
|
2
|
+
|
|
3
|
+
JavaScript/TypeScript bindings for [TJSON](https://textjson.com) — a readable, round-trip-safe alternative to JSON.
|
|
4
|
+
|
|
5
|
+
TJSON represents the same data model as JSON but renders it in a way that feels like text: bare strings and keys, pipe tables for arrays of objects, multiline string literals, line folding, and comments. It is not a superset or subset of JSON — it is a different surface syntax for the same underlying data, fully convertible in both directions without data loss.
|
|
6
|
+
|
|
7
|
+
**Input JSON**
|
|
8
|
+
```json
|
|
9
|
+
{
|
|
10
|
+
"name": "Alice",
|
|
11
|
+
"age": 30,
|
|
12
|
+
"active": true,
|
|
13
|
+
"bio": "She is a developer.\nShe loves Rust.",
|
|
14
|
+
"scores": [90, 85, 92],
|
|
15
|
+
"tags": ["rust", "wasm", "json", "serialization"],
|
|
16
|
+
"team": [
|
|
17
|
+
{"name": "Alice", "age": 30, "role": "admin"},
|
|
18
|
+
{"name": "Bob", "age": 25, "role": "user"},
|
|
19
|
+
{"name": "Carol", "age": 35, "role": "user"}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
16
22
|
```
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
cargo install tjson-rs
|
|
24
|
+
**TJSON output**
|
|
22
25
|
```
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
let value: TjsonValue = " hello world".parse()?;
|
|
26
|
+
name: Alice age:30 active:true
|
|
27
|
+
bio: ``
|
|
28
|
+
| She is a developer.
|
|
29
|
+
| She loves Rust.
|
|
30
|
+
``
|
|
31
|
+
scores: 90, 85, 92
|
|
32
|
+
tags: rust, wasm, json, serialization
|
|
33
|
+
team:
|
|
34
|
+
|name |age |role |
|
|
35
|
+
| Alice |30 | admin |
|
|
36
|
+
| Bob |25 | user |
|
|
37
|
+
| Carol |35 | user |
|
|
36
38
|
```
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
```rust
|
|
41
|
-
use tjson::{TjsonValue, TjsonOptions};
|
|
42
|
-
|
|
43
|
-
let value = TjsonValue::from(serde_json::json!({"name": "Alice", "age": 30}));
|
|
44
|
-
|
|
45
|
-
// Default options
|
|
46
|
-
let tjson = value.to_tjson_with(TjsonOptions::default())?;
|
|
47
|
-
|
|
48
|
-
// Canonical (one key per line, no packing)
|
|
49
|
-
let canonical = value.to_tjson_with(TjsonOptions::canonical())?;
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### Serde integration
|
|
53
|
-
|
|
54
|
-
```rust
|
|
55
|
-
use serde::{Deserialize, Serialize};
|
|
56
|
-
|
|
57
|
-
#[derive(Serialize, Deserialize)]
|
|
58
|
-
struct Person {
|
|
59
|
-
name: String,
|
|
60
|
-
age: u32,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Deserialize from TJSON
|
|
64
|
-
let person: Person = tjson::from_str(" name: Alice\n age:30")?;
|
|
65
|
-
|
|
66
|
-
// Serialize to TJSON
|
|
67
|
-
let tjson = tjson::to_string(&person)?;
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## CLI Usage
|
|
40
|
+
## Installation
|
|
71
41
|
|
|
72
42
|
```sh
|
|
73
|
-
|
|
74
|
-
echo '{"name":"Alice","scores":[1,2,3]}' | tjson
|
|
75
|
-
|
|
76
|
-
# TJSON to JSON
|
|
77
|
-
echo ' name: Alice' | tjson --json
|
|
78
|
-
|
|
79
|
-
# From/to files
|
|
80
|
-
tjson -i data.json -o data.tjson
|
|
81
|
-
tjson --json -i data.tjson -o data.json
|
|
82
|
-
|
|
83
|
-
# Canonical output
|
|
84
|
-
tjson --canonical -i data.json
|
|
43
|
+
npm install @rfanth/tjson
|
|
85
44
|
```
|
|
86
45
|
|
|
87
|
-
|
|
46
|
+
Or via CDN (no bundler needed):
|
|
88
47
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
```sh
|
|
92
|
-
npm install @rfanth/tjson
|
|
48
|
+
```js
|
|
49
|
+
import { parse, stringify, fromJson, toJson } from 'https://esm.sh/@rfanth/tjson';
|
|
93
50
|
```
|
|
94
51
|
|
|
95
|
-
Usage
|
|
52
|
+
## Usage
|
|
96
53
|
|
|
97
|
-
```
|
|
98
|
-
import { parse, stringify } from '@rfanth/tjson';
|
|
54
|
+
```ts
|
|
55
|
+
import { parse, stringify, fromJson, toJson } from '@rfanth/tjson';
|
|
56
|
+
|
|
57
|
+
// JS value → TJSON
|
|
58
|
+
const tjson = stringify({ name: 'Alice', scores: [95, 87, 92] });
|
|
99
59
|
|
|
100
|
-
//
|
|
101
|
-
const
|
|
60
|
+
// TJSON → JS value
|
|
61
|
+
const value = parse(tjson);
|
|
102
62
|
|
|
103
|
-
// With options
|
|
104
|
-
const canonical = stringify(
|
|
105
|
-
const narrow
|
|
63
|
+
// With options
|
|
64
|
+
const canonical = stringify({ name: 'Alice' }, { canonical: true });
|
|
65
|
+
const narrow = stringify({ name: 'Alice' }, { wrapWidth: 40, stringArrayStyle: 'preferSpaces' });
|
|
106
66
|
|
|
107
|
-
//
|
|
108
|
-
const
|
|
67
|
+
// String pipeline variants (if you already have a JSON string)
|
|
68
|
+
const tjson2 = fromJson('{"name":"Alice"}');
|
|
69
|
+
const json = toJson(tjson2);
|
|
109
70
|
```
|
|
110
71
|
|
|
72
|
+
`stringify` accepts any JSON-serializable JS value and returns a TJSON string.
|
|
73
|
+
`parse` accepts a TJSON string and returns a JS value — just like `JSON.parse`.
|
|
74
|
+
`fromJson`/`toJson` are the string-in/string-out variants for JSON string pipelines.
|
|
75
|
+
|
|
76
|
+
All four functions throw an `Error` on invalid input.
|
|
77
|
+
|
|
78
|
+
## Options
|
|
79
|
+
|
|
80
|
+
`stringify` and `fromJson` accept an optional [`StringifyOptions`](https://github.com/rfanth/tjson/blob/master/src/wasm.rs) object. TypeScript users get full autocomplete and inline documentation for all options — hover over any field in your editor.
|
|
81
|
+
|
|
82
|
+
Options use **camelCase** in JavaScript. The underlying library's Rust API uses snake_case and idiomatic Rust, but exposes the same options.
|
|
83
|
+
|
|
84
|
+
Key options at a glance:
|
|
85
|
+
|
|
86
|
+
| Option | Default | Description |
|
|
87
|
+
|---|---|---|
|
|
88
|
+
| `canonical` | `false` | One key per line, no packing, no tables |
|
|
89
|
+
| `wrapWidth` | `80` | Column wrap limit; `0` for unlimited |
|
|
90
|
+
| `tables` | `true` | Render arrays-of-objects as pipe tables |
|
|
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
|
+
| `inlineObjects` | `true` | Pack multiple key-value pairs onto one line |
|
|
95
|
+
| `inlineArrays` | `true` | Pack multiple array items onto one line |
|
|
96
|
+
| `stringArrayStyle` | `"preferComma"` | How to pack all-string arrays |
|
|
97
|
+
| `indentGlyphStyle` | `"auto"` | When to emit `/<` `/>` glyphs for deeply nested content |
|
|
98
|
+
| `forceMarkers` | `false` | Always emit `=` / `:` markers, even when inferrable |
|
|
99
|
+
| `multilineStyle` | `"bold"` | Multiline block style (`"bold"`, `"floating"`, etc.) |
|
|
100
|
+
| `multilineMinLines` | `1` | Min newlines in a string before using a block |
|
|
101
|
+
| `multilineMaxLines` | `10` | Max lines in a block before falling back |
|
|
102
|
+
| `tableFold` | `false` | Fold long table rows across continuation lines |
|
|
103
|
+
| `tableUnindentStyle` | `"auto"` | How to reposition wide tables using indent glyphs |
|
|
104
|
+
| `tableMinRows` | `3` | Min rows required to render a table |
|
|
105
|
+
| `tableMinCols` | `3` | Min columns required to render a table |
|
|
106
|
+
| `tableMinSimilarity` | `0.8` | Min fraction of rows sharing a column |
|
|
107
|
+
| `tableColumnMaxWidth` | `40` | Bail on table if any column exceeds this width |
|
|
108
|
+
| `fold` | — | Set all four fold styles at once; more specific options override |
|
|
109
|
+
| `numberFoldStyle` | `"auto"` | How to fold long numbers across lines |
|
|
110
|
+
| `stringBareFoldStyle` | `"auto"` | How to fold long bare strings |
|
|
111
|
+
| `stringQuotedFoldStyle` | `"auto"` | How to fold long quoted strings |
|
|
112
|
+
| `stringMultilineFoldStyle` | `"none"` | How to fold multiline block continuation lines |
|
|
113
|
+
| `indentGlyphMarkerStyle` | `"compact"` | Where to place the opening `/<` glyph |
|
|
114
|
+
|
|
115
|
+
Full option reference with documentation is in the TypeScript types bundled with the package.
|
|
111
116
|
|
|
112
117
|
## Resources
|
|
113
118
|
|
|
114
|
-
- Website and
|
|
115
|
-
- Specification
|
|
116
|
-
- Test suite
|
|
119
|
+
- **Website and live demo**: [textjson.com](https://textjson.com)
|
|
120
|
+
- **Specification**: [tjson-specification.md](https://github.com/rfanth/tjson-spec/blob/master/tjson-specification.md)
|
|
121
|
+
- **Test suite**: [tjson-tests](https://github.com/rfanth/tjson-tests)
|
|
122
|
+
- **Rust/WASM crate**: [tjson-rs](https://crates.io/crates/tjson-rs) — same options, snake_case API
|
|
123
|
+
- **MariaDB/MySQL UDF**: [tjson-udf](https://github.com/rfanth/tjson-udf) — same options in SQL
|
|
117
124
|
|
|
118
125
|
## License
|
|
119
126
|
|
|
120
|
-
BSD-3-Clause
|
|
127
|
+
BSD-3-Clause
|
package/package.json
CHANGED
package/tjson.d.ts
CHANGED
|
@@ -1,12 +1,92 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
4
|
+
export type BareStyle = "prefer" | "none";
|
|
5
|
+
export type FoldStyle = "auto" | "fixed" | "none";
|
|
6
|
+
export type MultilineStyle = "floating" | "bold" | "boldFloating" | "transparent" | "light" | "foldingQuotes";
|
|
7
|
+
export type TableUnindentStyle = "left" | "auto" | "floating" | "none";
|
|
8
|
+
export type StringArrayStyle = "spaces" | "preferSpaces" | "comma" | "preferComma" | "none";
|
|
9
|
+
export type IndentGlyphStyle = "auto" | "fixed" | "none";
|
|
10
|
+
export type IndentGlyphMarkerStyle = "compact" | "separate";
|
|
11
|
+
|
|
12
|
+
export interface StringifyOptions {
|
|
13
|
+
/** Start from a preset canonical configuration (one pair per line, no packing, no tables). */
|
|
14
|
+
canonical?: boolean;
|
|
15
|
+
/** Wrap width in columns. 0 means unlimited. Values between 1 and 19 are clamped to 20. */
|
|
16
|
+
wrapWidth?: number;
|
|
17
|
+
/** Force explicit `[` / `{` indent markers on arrays and objects, even for single-step indents that would normally be implicit. */
|
|
18
|
+
forceMarkers?: boolean;
|
|
19
|
+
/** Whether to use bare (unquoted) strings. Default: `"prefer"`. */
|
|
20
|
+
bareStrings?: BareStyle;
|
|
21
|
+
/** Whether to use bare (unquoted) object keys. Default: `"prefer"`. */
|
|
22
|
+
bareKeys?: BareStyle;
|
|
23
|
+
/** Allow packing multiple key-value pairs onto one line. Default: `true`. */
|
|
24
|
+
inlineObjects?: boolean;
|
|
25
|
+
/** Allow packing multiple array items onto one line. Default: `true`. */
|
|
26
|
+
inlineArrays?: boolean;
|
|
27
|
+
/** Allow multiline string blocks for strings containing newlines. Default: `true`. */
|
|
28
|
+
multilineStrings?: boolean;
|
|
29
|
+
/** Multiline block style. Default: `"bold"`. */
|
|
30
|
+
multilineStyle?: MultilineStyle;
|
|
31
|
+
/** Minimum number of lines before a multiline block is used. Default: `1`. */
|
|
32
|
+
multilineMinLines?: number;
|
|
33
|
+
/** Maximum number of lines in a multiline block before falling back. Default: `10`. */
|
|
34
|
+
multilineMaxLines?: number;
|
|
35
|
+
/** Enable table rendering for uniform arrays-of-objects. Default: `true`. */
|
|
36
|
+
tables?: boolean;
|
|
37
|
+
/** Allow folding long table rows across continuation lines. Default: `false`. */
|
|
38
|
+
tableFold?: boolean;
|
|
39
|
+
/** How to horizontally reposition tables using indent-offset glyphs. Default: `"auto"`. */
|
|
40
|
+
tableUnindentStyle?: TableUnindentStyle;
|
|
41
|
+
/** Minimum rows required to render a table. Default: `3`. */
|
|
42
|
+
tableMinRows?: number;
|
|
43
|
+
/** Minimum columns required to render a table. Default: `3`. */
|
|
44
|
+
tableMinCols?: number;
|
|
45
|
+
/** Minimum fraction [0–1] of rows sharing a column before it's included. Default: `0.8`. */
|
|
46
|
+
tableMinSimilarity?: number;
|
|
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`. */
|
|
48
|
+
tableColumnMaxWidth?: number;
|
|
49
|
+
/** How to pack short-string arrays onto one line. Default: `"preferComma"`. */
|
|
50
|
+
stringArrayStyle?: StringArrayStyle;
|
|
51
|
+
/** Set all fold styles at once. More specific fold options override this if also set. */
|
|
52
|
+
fold?: FoldStyle;
|
|
53
|
+
/** How to fold long numbers across lines. Default: `"auto"`. */
|
|
54
|
+
numberFoldStyle?: FoldStyle;
|
|
55
|
+
/** How to fold bare strings. Default: `"auto"`. */
|
|
56
|
+
stringBareFoldStyle?: FoldStyle;
|
|
57
|
+
/** How to fold quoted strings. Default: `"auto"`. */
|
|
58
|
+
stringQuotedFoldStyle?: FoldStyle;
|
|
59
|
+
/** How to fold multiline string continuation lines. Default: `"none"`. */
|
|
60
|
+
stringMultilineFoldStyle?: FoldStyle;
|
|
61
|
+
/** When to emit `/<` `/>` indent-offset glyphs. Default: `"auto"`. */
|
|
62
|
+
indentGlyphStyle?: IndentGlyphStyle;
|
|
63
|
+
/** Where to place the opening `/<` glyph. Default: `"compact"`. */
|
|
64
|
+
indentGlyphMarkerStyle?: IndentGlyphMarkerStyle;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Parse a TJSON string and return a JSON string. */
|
|
68
|
+
export function toJson(input: string): string;
|
|
69
|
+
|
|
70
|
+
/** Render a JSON string as TJSON, with optional options. */
|
|
71
|
+
export function fromJson(input: string, options?: StringifyOptions): string;
|
|
72
|
+
|
|
73
|
+
/** Render a JavaScript value as TJSON, with optional options. */
|
|
74
|
+
export function stringify(input: any, options?: StringifyOptions): string;
|
|
75
|
+
|
|
76
|
+
|
|
8
77
|
|
|
9
78
|
/**
|
|
10
|
-
*
|
|
79
|
+
* Parse a TJSON string and return a JavaScript value.
|
|
80
|
+
*
|
|
81
|
+
* Accepts the full TJSON format: bare strings and keys, multiline strings,
|
|
82
|
+
* pipe tables, line folding, and comments. The output is a live JavaScript
|
|
83
|
+
* value — object, array, string, number, boolean, or null.
|
|
84
|
+
*
|
|
85
|
+
* ```js
|
|
86
|
+
* const value = parse(" name: Alice\n age: 30");
|
|
87
|
+
* // → { name: "Alice", age: 30 }
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* Throws an `Error` if the input is not valid TJSON.
|
|
11
91
|
*/
|
|
12
|
-
export function
|
|
92
|
+
export function parse(input: string): any;
|
package/tjson.js
CHANGED
package/tjson_bg.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Render a JSON string as TJSON, with optional options object.
|
|
3
|
+
*
|
|
4
|
+
* Like `stringify`, but accepts a JSON string instead of a JavaScript value.
|
|
5
|
+
* Useful when you already have a JSON string and want to avoid parsing it first.
|
|
6
|
+
*
|
|
7
|
+
* Throws an `Error` if the input is not valid JSON, or if an option value is unrecognised.
|
|
3
8
|
* @param {string} input
|
|
9
|
+
* @param {any} options
|
|
4
10
|
* @returns {string}
|
|
5
11
|
*/
|
|
6
|
-
export function
|
|
12
|
+
export function fromJson(input, options) {
|
|
7
13
|
let deferred3_0;
|
|
8
14
|
let deferred3_1;
|
|
9
15
|
try {
|
|
10
16
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
11
17
|
const len0 = WASM_VECTOR_LEN;
|
|
12
|
-
const ret = wasm.
|
|
18
|
+
const ret = wasm.fromJson(ptr0, len0, options);
|
|
13
19
|
var ptr2 = ret[0];
|
|
14
20
|
var len2 = ret[1];
|
|
15
21
|
if (ret[3]) {
|
|
@@ -25,18 +31,90 @@ export function parse(input) {
|
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
/**
|
|
28
|
-
*
|
|
34
|
+
* Parse a TJSON string and return a JavaScript value.
|
|
35
|
+
*
|
|
36
|
+
* Accepts the full TJSON format: bare strings and keys, multiline strings,
|
|
37
|
+
* pipe tables, line folding, and comments. The output is a live JavaScript
|
|
38
|
+
* value — object, array, string, number, boolean, or null.
|
|
39
|
+
*
|
|
40
|
+
* ```js
|
|
41
|
+
* const value = parse(" name: Alice\n age: 30");
|
|
42
|
+
* // → { name: "Alice", age: 30 }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* Throws an `Error` if the input is not valid TJSON.
|
|
29
46
|
* @param {string} input
|
|
47
|
+
* @returns {any}
|
|
48
|
+
*/
|
|
49
|
+
export function parse(input) {
|
|
50
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
51
|
+
const len0 = WASM_VECTOR_LEN;
|
|
52
|
+
const ret = wasm.parse(ptr0, len0);
|
|
53
|
+
if (ret[2]) {
|
|
54
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
55
|
+
}
|
|
56
|
+
return takeFromExternrefTable0(ret[0]);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Render a JavaScript value as TJSON, with optional options object.
|
|
61
|
+
*
|
|
62
|
+
* Accepts any JSON-serializable value — object, array, string, number,
|
|
63
|
+
* boolean, or null. Options control formatting details — wrap width, tables,
|
|
64
|
+
* multiline strings, folding, and more. Omit `options` to
|
|
65
|
+
* use defaults (80-column wrap, tables enabled, bare strings preferred).
|
|
66
|
+
*
|
|
67
|
+
* ```js
|
|
68
|
+
* const tjson = stringify({ name: "Alice", scores: [1, 2, 3] });
|
|
69
|
+
*
|
|
70
|
+
* // Canonical: one key per line, no packing, no tables
|
|
71
|
+
* const canonical = stringify({ name: "Alice" }, { canonical: true });
|
|
72
|
+
*
|
|
73
|
+
* // Narrow output with space-separated string arrays
|
|
74
|
+
* const narrow = stringify({ name: "Alice" }, { wrapWidth: 40, stringArrayStyle: "preferSpaces" });
|
|
75
|
+
* ```
|
|
76
|
+
*
|
|
77
|
+
* Throws an `Error` if the value is not JSON-serializable, or if an option value is unrecognised.
|
|
78
|
+
* @param {any} input
|
|
30
79
|
* @param {any} options
|
|
31
80
|
* @returns {string}
|
|
32
81
|
*/
|
|
33
82
|
export function stringify(input, options) {
|
|
83
|
+
let deferred2_0;
|
|
84
|
+
let deferred2_1;
|
|
85
|
+
try {
|
|
86
|
+
const ret = wasm.stringify(input, options);
|
|
87
|
+
var ptr1 = ret[0];
|
|
88
|
+
var len1 = ret[1];
|
|
89
|
+
if (ret[3]) {
|
|
90
|
+
ptr1 = 0; len1 = 0;
|
|
91
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
92
|
+
}
|
|
93
|
+
deferred2_0 = ptr1;
|
|
94
|
+
deferred2_1 = len1;
|
|
95
|
+
return getStringFromWasm0(ptr1, len1);
|
|
96
|
+
} finally {
|
|
97
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Parse a TJSON string and return a JSON string.
|
|
103
|
+
*
|
|
104
|
+
* Like `parse`, but returns a JSON string instead of a JavaScript value.
|
|
105
|
+
* Useful when you need to pass the result to another JSON consumer.
|
|
106
|
+
*
|
|
107
|
+
* Throws an `Error` if the input is not valid TJSON.
|
|
108
|
+
* @param {string} input
|
|
109
|
+
* @returns {string}
|
|
110
|
+
*/
|
|
111
|
+
export function toJson(input) {
|
|
34
112
|
let deferred3_0;
|
|
35
113
|
let deferred3_1;
|
|
36
114
|
try {
|
|
37
115
|
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
38
116
|
const len0 = WASM_VECTOR_LEN;
|
|
39
|
-
const ret = wasm.
|
|
117
|
+
const ret = wasm.toJson(ptr0, len0);
|
|
40
118
|
var ptr2 = ret[0];
|
|
41
119
|
var len2 = ret[1];
|
|
42
120
|
if (ret[3]) {
|
|
@@ -50,11 +128,11 @@ export function stringify(input, options) {
|
|
|
50
128
|
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
51
129
|
}
|
|
52
130
|
}
|
|
53
|
-
export function
|
|
131
|
+
export function __wbg_Error_2e59b1b37a9a34c3(arg0, arg1) {
|
|
54
132
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
55
133
|
return ret;
|
|
56
134
|
}
|
|
57
|
-
export function
|
|
135
|
+
export function __wbg_Number_e6ffdb596c888833(arg0) {
|
|
58
136
|
const ret = Number(arg0);
|
|
59
137
|
return ret;
|
|
60
138
|
}
|
|
@@ -65,60 +143,68 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
65
143
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
66
144
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
67
145
|
}
|
|
68
|
-
export function
|
|
146
|
+
export function __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2(arg0, arg1) {
|
|
69
147
|
const v = arg1;
|
|
70
148
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
71
149
|
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
72
150
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
73
151
|
}
|
|
74
|
-
export function
|
|
152
|
+
export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
|
|
75
153
|
const v = arg0;
|
|
76
154
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
77
155
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
78
156
|
}
|
|
79
|
-
export function
|
|
157
|
+
export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
|
|
80
158
|
const ret = debugString(arg1);
|
|
81
159
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
82
160
|
const len1 = WASM_VECTOR_LEN;
|
|
83
161
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
84
162
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
85
163
|
}
|
|
86
|
-
export function
|
|
164
|
+
export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
|
|
87
165
|
const ret = arg0 in arg1;
|
|
88
166
|
return ret;
|
|
89
167
|
}
|
|
90
|
-
export function
|
|
168
|
+
export function __wbg___wbindgen_is_bigint_6c98f7e945dacdde(arg0) {
|
|
91
169
|
const ret = typeof(arg0) === 'bigint';
|
|
92
170
|
return ret;
|
|
93
171
|
}
|
|
94
|
-
export function
|
|
172
|
+
export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
|
|
173
|
+
const ret = typeof(arg0) === 'function';
|
|
174
|
+
return ret;
|
|
175
|
+
}
|
|
176
|
+
export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
|
|
95
177
|
const ret = arg0 === null;
|
|
96
178
|
return ret;
|
|
97
179
|
}
|
|
98
|
-
export function
|
|
180
|
+
export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
|
|
99
181
|
const val = arg0;
|
|
100
182
|
const ret = typeof(val) === 'object' && val !== null;
|
|
101
183
|
return ret;
|
|
102
184
|
}
|
|
103
|
-
export function
|
|
185
|
+
export function __wbg___wbindgen_is_string_b29b5c5a8065ba1a(arg0) {
|
|
186
|
+
const ret = typeof(arg0) === 'string';
|
|
187
|
+
return ret;
|
|
188
|
+
}
|
|
189
|
+
export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
|
|
104
190
|
const ret = arg0 === undefined;
|
|
105
191
|
return ret;
|
|
106
192
|
}
|
|
107
|
-
export function
|
|
193
|
+
export function __wbg___wbindgen_jsval_eq_7d430e744a913d26(arg0, arg1) {
|
|
108
194
|
const ret = arg0 === arg1;
|
|
109
195
|
return ret;
|
|
110
196
|
}
|
|
111
|
-
export function
|
|
197
|
+
export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
|
|
112
198
|
const ret = arg0 == arg1;
|
|
113
199
|
return ret;
|
|
114
200
|
}
|
|
115
|
-
export function
|
|
201
|
+
export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
|
|
116
202
|
const obj = arg1;
|
|
117
203
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
118
204
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
119
205
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
120
206
|
}
|
|
121
|
-
export function
|
|
207
|
+
export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
122
208
|
const obj = arg1;
|
|
123
209
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
124
210
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -126,14 +212,38 @@ export function __wbg___wbindgen_string_get_f1161390414f9b59(arg0, arg1) {
|
|
|
126
212
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
127
213
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
128
214
|
}
|
|
129
|
-
export function
|
|
215
|
+
export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
|
|
130
216
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
131
217
|
}
|
|
218
|
+
export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
|
|
219
|
+
const ret = arg0.call(arg1);
|
|
220
|
+
return ret;
|
|
221
|
+
}, arguments); }
|
|
222
|
+
export function __wbg_done_547d467e97529006(arg0) {
|
|
223
|
+
const ret = arg0.done;
|
|
224
|
+
return ret;
|
|
225
|
+
}
|
|
226
|
+
export function __wbg_entries_616b1a459b85be0b(arg0) {
|
|
227
|
+
const ret = Object.entries(arg0);
|
|
228
|
+
return ret;
|
|
229
|
+
}
|
|
230
|
+
export function __wbg_get_4848e350b40afc16(arg0, arg1) {
|
|
231
|
+
const ret = arg0[arg1 >>> 0];
|
|
232
|
+
return ret;
|
|
233
|
+
}
|
|
234
|
+
export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
|
|
235
|
+
const ret = Reflect.get(arg0, arg1);
|
|
236
|
+
return ret;
|
|
237
|
+
}, arguments); }
|
|
238
|
+
export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
|
|
239
|
+
const ret = arg0[arg1 >>> 0];
|
|
240
|
+
return ret;
|
|
241
|
+
}
|
|
132
242
|
export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
|
|
133
243
|
const ret = arg0[arg1];
|
|
134
244
|
return ret;
|
|
135
245
|
}
|
|
136
|
-
export function
|
|
246
|
+
export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
|
|
137
247
|
let result;
|
|
138
248
|
try {
|
|
139
249
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -143,7 +253,17 @@ export function __wbg_instanceof_ArrayBuffer_8d855993947fc3a2(arg0) {
|
|
|
143
253
|
const ret = result;
|
|
144
254
|
return ret;
|
|
145
255
|
}
|
|
146
|
-
export function
|
|
256
|
+
export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
|
|
257
|
+
let result;
|
|
258
|
+
try {
|
|
259
|
+
result = arg0 instanceof Map;
|
|
260
|
+
} catch (_) {
|
|
261
|
+
result = false;
|
|
262
|
+
}
|
|
263
|
+
const ret = result;
|
|
264
|
+
return ret;
|
|
265
|
+
}
|
|
266
|
+
export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
|
|
147
267
|
let result;
|
|
148
268
|
try {
|
|
149
269
|
result = arg0 instanceof Uint8Array;
|
|
@@ -153,27 +273,82 @@ export function __wbg_instanceof_Uint8Array_ce24d58a5f4bdcc3(arg0) {
|
|
|
153
273
|
const ret = result;
|
|
154
274
|
return ret;
|
|
155
275
|
}
|
|
156
|
-
export function
|
|
276
|
+
export function __wbg_isArray_db61795ad004c139(arg0) {
|
|
277
|
+
const ret = Array.isArray(arg0);
|
|
278
|
+
return ret;
|
|
279
|
+
}
|
|
280
|
+
export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
|
|
157
281
|
const ret = Number.isSafeInteger(arg0);
|
|
158
282
|
return ret;
|
|
159
283
|
}
|
|
160
|
-
export function
|
|
284
|
+
export function __wbg_iterator_de403ef31815a3e6() {
|
|
285
|
+
const ret = Symbol.iterator;
|
|
286
|
+
return ret;
|
|
287
|
+
}
|
|
288
|
+
export function __wbg_length_0c32cb8543c8e4c8(arg0) {
|
|
161
289
|
const ret = arg0.length;
|
|
162
290
|
return ret;
|
|
163
291
|
}
|
|
164
|
-
export function
|
|
292
|
+
export function __wbg_length_6e821edde497a532(arg0) {
|
|
293
|
+
const ret = arg0.length;
|
|
294
|
+
return ret;
|
|
295
|
+
}
|
|
296
|
+
export function __wbg_new_4f9fafbb3909af72() {
|
|
297
|
+
const ret = new Object();
|
|
298
|
+
return ret;
|
|
299
|
+
}
|
|
300
|
+
export function __wbg_new_99cabae501c0a8a0() {
|
|
301
|
+
const ret = new Map();
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
export function __wbg_new_a560378ea1240b14(arg0) {
|
|
165
305
|
const ret = new Uint8Array(arg0);
|
|
166
306
|
return ret;
|
|
167
307
|
}
|
|
168
|
-
export function
|
|
308
|
+
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
309
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
310
|
+
return ret;
|
|
311
|
+
}
|
|
312
|
+
export function __wbg_new_f3c9df4f38f3f798() {
|
|
313
|
+
const ret = new Array();
|
|
314
|
+
return ret;
|
|
315
|
+
}
|
|
316
|
+
export function __wbg_next_01132ed6134b8ef5(arg0) {
|
|
317
|
+
const ret = arg0.next;
|
|
318
|
+
return ret;
|
|
319
|
+
}
|
|
320
|
+
export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
|
|
321
|
+
const ret = arg0.next();
|
|
322
|
+
return ret;
|
|
323
|
+
}, arguments); }
|
|
324
|
+
export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
|
|
169
325
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
170
326
|
}
|
|
171
|
-
export function
|
|
327
|
+
export function __wbg_set_08463b1df38a7e29(arg0, arg1, arg2) {
|
|
328
|
+
const ret = arg0.set(arg1, arg2);
|
|
329
|
+
return ret;
|
|
330
|
+
}
|
|
331
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
332
|
+
arg0[arg1] = arg2;
|
|
333
|
+
}
|
|
334
|
+
export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
|
|
335
|
+
arg0[arg1 >>> 0] = arg2;
|
|
336
|
+
}
|
|
337
|
+
export function __wbg_value_7f6052747ccf940f(arg0) {
|
|
338
|
+
const ret = arg0.value;
|
|
339
|
+
return ret;
|
|
340
|
+
}
|
|
341
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
342
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
343
|
+
const ret = arg0;
|
|
344
|
+
return ret;
|
|
345
|
+
}
|
|
346
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
172
347
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
173
348
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
174
349
|
return ret;
|
|
175
350
|
}
|
|
176
|
-
export function
|
|
351
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
177
352
|
// Cast intrinsic for `U64 -> Externref`.
|
|
178
353
|
const ret = BigInt.asUintN(64, arg0);
|
|
179
354
|
return ret;
|
|
@@ -187,6 +362,12 @@ export function __wbindgen_init_externref_table() {
|
|
|
187
362
|
table.set(offset + 2, true);
|
|
188
363
|
table.set(offset + 3, false);
|
|
189
364
|
}
|
|
365
|
+
function addToExternrefTable0(obj) {
|
|
366
|
+
const idx = wasm.__externref_table_alloc();
|
|
367
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
368
|
+
return idx;
|
|
369
|
+
}
|
|
370
|
+
|
|
190
371
|
function debugString(val) {
|
|
191
372
|
// primitive types
|
|
192
373
|
const type = typeof val;
|
|
@@ -278,6 +459,15 @@ function getUint8ArrayMemory0() {
|
|
|
278
459
|
return cachedUint8ArrayMemory0;
|
|
279
460
|
}
|
|
280
461
|
|
|
462
|
+
function handleError(f, args) {
|
|
463
|
+
try {
|
|
464
|
+
return f.apply(this, args);
|
|
465
|
+
} catch (e) {
|
|
466
|
+
const idx = addToExternrefTable0(e);
|
|
467
|
+
wasm.__wbindgen_exn_store(idx);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
281
471
|
function isLikeNone(x) {
|
|
282
472
|
return x === undefined || x === null;
|
|
283
473
|
}
|
package/tjson_bg.wasm
CHANGED
|
Binary file
|