@rfanth/tjson 0.3.2 → 0.4.2
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 +215 -33
- 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,14 +128,10 @@ 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 __wbg_Number_f257194b7002d6f9(arg0) {
|
|
58
|
-
const ret = Number(arg0);
|
|
59
|
-
return ret;
|
|
60
|
-
}
|
|
61
135
|
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
62
136
|
const ret = String(arg1);
|
|
63
137
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -65,60 +139,68 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
65
139
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
66
140
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
67
141
|
}
|
|
68
|
-
export function
|
|
142
|
+
export function __wbg___wbindgen_bigint_get_as_i64_2c5082002e4826e2(arg0, arg1) {
|
|
69
143
|
const v = arg1;
|
|
70
144
|
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
71
145
|
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
72
146
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
73
147
|
}
|
|
74
|
-
export function
|
|
148
|
+
export function __wbg___wbindgen_boolean_get_a86c216575a75c30(arg0) {
|
|
75
149
|
const v = arg0;
|
|
76
150
|
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
77
151
|
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
78
152
|
}
|
|
79
|
-
export function
|
|
153
|
+
export function __wbg___wbindgen_debug_string_dd5d2d07ce9e6c57(arg0, arg1) {
|
|
80
154
|
const ret = debugString(arg1);
|
|
81
155
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
82
156
|
const len1 = WASM_VECTOR_LEN;
|
|
83
157
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
84
158
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
85
159
|
}
|
|
86
|
-
export function
|
|
160
|
+
export function __wbg___wbindgen_in_4bd7a57e54337366(arg0, arg1) {
|
|
87
161
|
const ret = arg0 in arg1;
|
|
88
162
|
return ret;
|
|
89
163
|
}
|
|
90
|
-
export function
|
|
164
|
+
export function __wbg___wbindgen_is_bigint_6c98f7e945dacdde(arg0) {
|
|
91
165
|
const ret = typeof(arg0) === 'bigint';
|
|
92
166
|
return ret;
|
|
93
167
|
}
|
|
94
|
-
export function
|
|
168
|
+
export function __wbg___wbindgen_is_function_49868bde5eb1e745(arg0) {
|
|
169
|
+
const ret = typeof(arg0) === 'function';
|
|
170
|
+
return ret;
|
|
171
|
+
}
|
|
172
|
+
export function __wbg___wbindgen_is_null_344c8750a8525473(arg0) {
|
|
95
173
|
const ret = arg0 === null;
|
|
96
174
|
return ret;
|
|
97
175
|
}
|
|
98
|
-
export function
|
|
176
|
+
export function __wbg___wbindgen_is_object_40c5a80572e8f9d3(arg0) {
|
|
99
177
|
const val = arg0;
|
|
100
178
|
const ret = typeof(val) === 'object' && val !== null;
|
|
101
179
|
return ret;
|
|
102
180
|
}
|
|
103
|
-
export function
|
|
181
|
+
export function __wbg___wbindgen_is_string_b29b5c5a8065ba1a(arg0) {
|
|
182
|
+
const ret = typeof(arg0) === 'string';
|
|
183
|
+
return ret;
|
|
184
|
+
}
|
|
185
|
+
export function __wbg___wbindgen_is_undefined_c0cca72b82b86f4d(arg0) {
|
|
104
186
|
const ret = arg0 === undefined;
|
|
105
187
|
return ret;
|
|
106
188
|
}
|
|
107
|
-
export function
|
|
189
|
+
export function __wbg___wbindgen_jsval_eq_7d430e744a913d26(arg0, arg1) {
|
|
108
190
|
const ret = arg0 === arg1;
|
|
109
191
|
return ret;
|
|
110
192
|
}
|
|
111
|
-
export function
|
|
193
|
+
export function __wbg___wbindgen_jsval_loose_eq_3a72ae764d46d944(arg0, arg1) {
|
|
112
194
|
const ret = arg0 == arg1;
|
|
113
195
|
return ret;
|
|
114
196
|
}
|
|
115
|
-
export function
|
|
197
|
+
export function __wbg___wbindgen_number_get_7579aab02a8a620c(arg0, arg1) {
|
|
116
198
|
const obj = arg1;
|
|
117
199
|
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
118
200
|
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
119
201
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
120
202
|
}
|
|
121
|
-
export function
|
|
203
|
+
export function __wbg___wbindgen_string_get_914df97fcfa788f2(arg0, arg1) {
|
|
122
204
|
const obj = arg1;
|
|
123
205
|
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
124
206
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -126,14 +208,34 @@ export function __wbg___wbindgen_string_get_f1161390414f9b59(arg0, arg1) {
|
|
|
126
208
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
127
209
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
128
210
|
}
|
|
129
|
-
export function
|
|
211
|
+
export function __wbg___wbindgen_throw_81fc77679af83bc6(arg0, arg1) {
|
|
130
212
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
131
213
|
}
|
|
132
|
-
export function
|
|
133
|
-
const ret = arg0
|
|
214
|
+
export function __wbg_call_7f2987183bb62793() { return handleError(function (arg0, arg1) {
|
|
215
|
+
const ret = arg0.call(arg1);
|
|
216
|
+
return ret;
|
|
217
|
+
}, arguments); }
|
|
218
|
+
export function __wbg_done_547d467e97529006(arg0) {
|
|
219
|
+
const ret = arg0.done;
|
|
134
220
|
return ret;
|
|
135
221
|
}
|
|
136
|
-
export function
|
|
222
|
+
export function __wbg_entries_616b1a459b85be0b(arg0) {
|
|
223
|
+
const ret = Object.entries(arg0);
|
|
224
|
+
return ret;
|
|
225
|
+
}
|
|
226
|
+
export function __wbg_get_4848e350b40afc16(arg0, arg1) {
|
|
227
|
+
const ret = arg0[arg1 >>> 0];
|
|
228
|
+
return ret;
|
|
229
|
+
}
|
|
230
|
+
export function __wbg_get_ed0642c4b9d31ddf() { return handleError(function (arg0, arg1) {
|
|
231
|
+
const ret = Reflect.get(arg0, arg1);
|
|
232
|
+
return ret;
|
|
233
|
+
}, arguments); }
|
|
234
|
+
export function __wbg_get_unchecked_7d7babe32e9e6a54(arg0, arg1) {
|
|
235
|
+
const ret = arg0[arg1 >>> 0];
|
|
236
|
+
return ret;
|
|
237
|
+
}
|
|
238
|
+
export function __wbg_instanceof_ArrayBuffer_ff7c1337a5e3b33a(arg0) {
|
|
137
239
|
let result;
|
|
138
240
|
try {
|
|
139
241
|
result = arg0 instanceof ArrayBuffer;
|
|
@@ -143,7 +245,17 @@ export function __wbg_instanceof_ArrayBuffer_8d855993947fc3a2(arg0) {
|
|
|
143
245
|
const ret = result;
|
|
144
246
|
return ret;
|
|
145
247
|
}
|
|
146
|
-
export function
|
|
248
|
+
export function __wbg_instanceof_Map_a10a2795ef4bfe97(arg0) {
|
|
249
|
+
let result;
|
|
250
|
+
try {
|
|
251
|
+
result = arg0 instanceof Map;
|
|
252
|
+
} catch (_) {
|
|
253
|
+
result = false;
|
|
254
|
+
}
|
|
255
|
+
const ret = result;
|
|
256
|
+
return ret;
|
|
257
|
+
}
|
|
258
|
+
export function __wbg_instanceof_Uint8Array_4b8da683deb25d72(arg0) {
|
|
147
259
|
let result;
|
|
148
260
|
try {
|
|
149
261
|
result = arg0 instanceof Uint8Array;
|
|
@@ -153,27 +265,82 @@ export function __wbg_instanceof_Uint8Array_ce24d58a5f4bdcc3(arg0) {
|
|
|
153
265
|
const ret = result;
|
|
154
266
|
return ret;
|
|
155
267
|
}
|
|
156
|
-
export function
|
|
268
|
+
export function __wbg_isArray_db61795ad004c139(arg0) {
|
|
269
|
+
const ret = Array.isArray(arg0);
|
|
270
|
+
return ret;
|
|
271
|
+
}
|
|
272
|
+
export function __wbg_isSafeInteger_ea83862ba994770c(arg0) {
|
|
157
273
|
const ret = Number.isSafeInteger(arg0);
|
|
158
274
|
return ret;
|
|
159
275
|
}
|
|
160
|
-
export function
|
|
276
|
+
export function __wbg_iterator_de403ef31815a3e6() {
|
|
277
|
+
const ret = Symbol.iterator;
|
|
278
|
+
return ret;
|
|
279
|
+
}
|
|
280
|
+
export function __wbg_length_0c32cb8543c8e4c8(arg0) {
|
|
161
281
|
const ret = arg0.length;
|
|
162
282
|
return ret;
|
|
163
283
|
}
|
|
164
|
-
export function
|
|
284
|
+
export function __wbg_length_6e821edde497a532(arg0) {
|
|
285
|
+
const ret = arg0.length;
|
|
286
|
+
return ret;
|
|
287
|
+
}
|
|
288
|
+
export function __wbg_new_4f9fafbb3909af72() {
|
|
289
|
+
const ret = new Object();
|
|
290
|
+
return ret;
|
|
291
|
+
}
|
|
292
|
+
export function __wbg_new_99cabae501c0a8a0() {
|
|
293
|
+
const ret = new Map();
|
|
294
|
+
return ret;
|
|
295
|
+
}
|
|
296
|
+
export function __wbg_new_a560378ea1240b14(arg0) {
|
|
165
297
|
const ret = new Uint8Array(arg0);
|
|
166
298
|
return ret;
|
|
167
299
|
}
|
|
168
|
-
export function
|
|
300
|
+
export function __wbg_new_e3b04b4d53d1b593(arg0, arg1) {
|
|
301
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
302
|
+
return ret;
|
|
303
|
+
}
|
|
304
|
+
export function __wbg_new_f3c9df4f38f3f798() {
|
|
305
|
+
const ret = new Array();
|
|
306
|
+
return ret;
|
|
307
|
+
}
|
|
308
|
+
export function __wbg_next_01132ed6134b8ef5(arg0) {
|
|
309
|
+
const ret = arg0.next;
|
|
310
|
+
return ret;
|
|
311
|
+
}
|
|
312
|
+
export function __wbg_next_b3713ec761a9dbfd() { return handleError(function (arg0) {
|
|
313
|
+
const ret = arg0.next();
|
|
314
|
+
return ret;
|
|
315
|
+
}, arguments); }
|
|
316
|
+
export function __wbg_prototypesetcall_3e05eb9545565046(arg0, arg1, arg2) {
|
|
169
317
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
170
318
|
}
|
|
171
|
-
export function
|
|
319
|
+
export function __wbg_set_08463b1df38a7e29(arg0, arg1, arg2) {
|
|
320
|
+
const ret = arg0.set(arg1, arg2);
|
|
321
|
+
return ret;
|
|
322
|
+
}
|
|
323
|
+
export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
|
|
324
|
+
arg0[arg1] = arg2;
|
|
325
|
+
}
|
|
326
|
+
export function __wbg_set_6c60b2e8ad0e9383(arg0, arg1, arg2) {
|
|
327
|
+
arg0[arg1 >>> 0] = arg2;
|
|
328
|
+
}
|
|
329
|
+
export function __wbg_value_7f6052747ccf940f(arg0) {
|
|
330
|
+
const ret = arg0.value;
|
|
331
|
+
return ret;
|
|
332
|
+
}
|
|
333
|
+
export function __wbindgen_cast_0000000000000001(arg0) {
|
|
334
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
335
|
+
const ret = arg0;
|
|
336
|
+
return ret;
|
|
337
|
+
}
|
|
338
|
+
export function __wbindgen_cast_0000000000000002(arg0, arg1) {
|
|
172
339
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
173
340
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
174
341
|
return ret;
|
|
175
342
|
}
|
|
176
|
-
export function
|
|
343
|
+
export function __wbindgen_cast_0000000000000003(arg0) {
|
|
177
344
|
// Cast intrinsic for `U64 -> Externref`.
|
|
178
345
|
const ret = BigInt.asUintN(64, arg0);
|
|
179
346
|
return ret;
|
|
@@ -187,6 +354,12 @@ export function __wbindgen_init_externref_table() {
|
|
|
187
354
|
table.set(offset + 2, true);
|
|
188
355
|
table.set(offset + 3, false);
|
|
189
356
|
}
|
|
357
|
+
function addToExternrefTable0(obj) {
|
|
358
|
+
const idx = wasm.__externref_table_alloc();
|
|
359
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
360
|
+
return idx;
|
|
361
|
+
}
|
|
362
|
+
|
|
190
363
|
function debugString(val) {
|
|
191
364
|
// primitive types
|
|
192
365
|
const type = typeof val;
|
|
@@ -278,6 +451,15 @@ function getUint8ArrayMemory0() {
|
|
|
278
451
|
return cachedUint8ArrayMemory0;
|
|
279
452
|
}
|
|
280
453
|
|
|
454
|
+
function handleError(f, args) {
|
|
455
|
+
try {
|
|
456
|
+
return f.apply(this, args);
|
|
457
|
+
} catch (e) {
|
|
458
|
+
const idx = addToExternrefTable0(e);
|
|
459
|
+
wasm.__wbindgen_exn_store(idx);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
281
463
|
function isLikeNone(x) {
|
|
282
464
|
return x === undefined || x === null;
|
|
283
465
|
}
|
package/tjson_bg.wasm
CHANGED
|
Binary file
|