toon-ld 0.1.2 → 0.2.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 CHANGED
@@ -13,7 +13,7 @@ TOON-LD extends TOON in the same way that JSON-LD extends JSON: **every valid TO
13
13
  - **Full JSON-LD Compatibility**: Round-trip conversion without data loss
14
14
  - **Tabular Arrays**: Serialize arrays of objects as CSV-like rows with shared headers
15
15
  - **All JSON-LD 1.1 Keywords**: Complete support for `@context`, `@graph`, `@id`, `@type`, value nodes, etc.
16
- - **WebAssembly Performance**: Compiled from Rust for near-native speed
16
+ - **WebAssembly Performance**: Compiled from Rust for high-performance parsing and serialization
17
17
  - **TypeScript Support**: Fully typed API with excellent IDE support
18
18
  - **Browser & Node.js**: Works in both environments
19
19
 
@@ -32,8 +32,9 @@ yarn add toon-ld
32
32
  ## Quick Start
33
33
 
34
34
  ```javascript
35
- import { convert_jsonld_to_toon, convert_toon_to_jsonld } from 'toon-ld';
35
+ import { encode, decode, parse, stringify } from 'toon-ld';
36
36
 
37
+ // 1. String Conversion
37
38
  // Convert JSON-LD to TOON-LD
38
39
  const jsonLd = JSON.stringify({
39
40
  "@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
@@ -41,7 +42,7 @@ const jsonLd = JSON.stringify({
41
42
  "foaf:age": 30
42
43
  });
43
44
 
44
- const toon = convert_jsonld_to_toon(jsonLd);
45
+ const toon = encode(jsonLd);
45
46
  console.log(toon);
46
47
  // Output:
47
48
  // @context:
@@ -50,9 +51,20 @@ console.log(toon);
50
51
  // foaf:age: 30
51
52
 
52
53
  // Convert back to JSON-LD
53
- const backToJson = convert_toon_to_jsonld(toon);
54
+ const backToJson = decode(toon);
54
55
  const parsed = JSON.parse(backToJson);
55
56
  console.log(parsed);
57
+
58
+ // 2. Object Helper Functions
59
+ // Parse directly to JS Object
60
+ const data = parse(toon);
61
+ console.log(data['foaf:name']); // "Alice"
62
+
63
+ // Serialize JS Object directly to TOON-LD
64
+ const toonStr = stringify({
65
+ "@context": {"schema": "http://schema.org/"},
66
+ "schema:name": "Bob"
67
+ });
56
68
  ```
57
69
 
58
70
  ## Tabular Arrays - The Key Feature
@@ -85,9 +97,9 @@ Notice how object keys appear once in the header instead of repeating for each o
85
97
 
86
98
  ## API Reference
87
99
 
88
- ### `convert_jsonld_to_toon(json: string): string`
100
+ ### `encode(json: string): string`
89
101
 
90
- Convert a JSON-LD string to TOON-LD format.
102
+ Convert (encode) a JSON-LD string to TOON-LD format.
91
103
 
92
104
  **Parameters:**
93
105
  - `json` - A JSON or JSON-LD formatted string
@@ -98,15 +110,9 @@ Convert a JSON-LD string to TOON-LD format.
98
110
  **Throws:**
99
111
  - Error with message if the input is invalid JSON
100
112
 
101
- **Example:**
102
- ```javascript
103
- const jsonLd = '{"@context": {"foaf": "http://xmlns.com/foaf/0.1/"}, "foaf:name": "Alice"}';
104
- const toon = convert_jsonld_to_toon(jsonLd);
105
- ```
106
-
107
- ### `convert_toon_to_jsonld(toon: string): string`
113
+ ### `decode(toon: string): string`
108
114
 
109
- Convert a TOON-LD string to JSON-LD format.
115
+ Convert (decode) a TOON-LD string to JSON-LD format.
110
116
 
111
117
  **Parameters:**
112
118
  - `toon` - A TOON-LD formatted string
@@ -117,15 +123,27 @@ Convert a TOON-LD string to JSON-LD format.
117
123
  **Throws:**
118
124
  - Error with message if the input is invalid TOON-LD
119
125
 
120
- **Example:**
121
- ```javascript
122
- const toon = `@context:
123
- foaf: http://xmlns.com/foaf/0.1/
124
- foaf:name: Alice`;
125
- const jsonLd = convert_toon_to_jsonld(toon);
126
- ```
126
+ ### `parse(toon: string): any`
127
+
128
+ Parse a TOON-LD string directly into a JavaScript Object.
129
+
130
+ **Parameters:**
131
+ - `toon` - A TOON-LD formatted string
132
+
133
+ **Returns:**
134
+ - JavaScript Object representing the data
135
+
136
+ ### `stringify(data: any): string`
137
+
138
+ Stringify a JavaScript Object directly into a TOON-LD string.
139
+
140
+ **Parameters:**
141
+ - `data` - A JavaScript Object
142
+
143
+ **Returns:**
144
+ - TOON-LD formatted string
127
145
 
128
- ### `validate_json(json: string): boolean`
146
+ ### `validateJson(json: string): boolean`
129
147
 
130
148
  Validate a JSON-LD string.
131
149
 
@@ -135,13 +153,7 @@ Validate a JSON-LD string.
135
153
  **Returns:**
136
154
  - `true` if the string is valid JSON, `false` otherwise
137
155
 
138
- **Example:**
139
- ```javascript
140
- const isValid = validate_json('{"name": "Alice"}');
141
- console.log(isValid); // true
142
- ```
143
-
144
- ### `validate_toon(toon: string): boolean`
156
+ ### `validateToonld(toon: string): boolean`
145
157
 
146
158
  Validate a TOON-LD string.
147
159
 
@@ -151,12 +163,6 @@ Validate a TOON-LD string.
151
163
  **Returns:**
152
164
  - `true` if the string is valid TOON-LD, `false` otherwise
153
165
 
154
- **Example:**
155
- ```javascript
156
- const isValid = validate_toon('name: Alice');
157
- console.log(isValid); // true
158
- ```
159
-
160
166
  ### `init(): void`
161
167
 
162
168
  Initialize panic hook for better error messages in the browser console. This is optional but recommended for development.
@@ -174,15 +180,15 @@ This package includes TypeScript type definitions out of the box:
174
180
 
175
181
  ```typescript
176
182
  import {
177
- convert_jsonld_to_toon,
178
- convert_toon_to_jsonld,
179
- validate_json,
180
- validate_toon
183
+ encode,
184
+ decode,
185
+ validateJson,
186
+ validateToonld
181
187
  } from 'toon-ld';
182
188
 
183
189
  const jsonLd: string = '{"name": "Alice"}';
184
- const toon: string = convert_jsonld_to_toon(jsonLd);
185
- const isValid: boolean = validate_toon(toon);
190
+ const toon: string = encode(jsonLd);
191
+ const isValid: boolean = validateToonld(toon);
186
192
  ```
187
193
 
188
194
  ## Usage Examples
@@ -191,14 +197,14 @@ const isValid: boolean = validate_toon(toon);
191
197
 
192
198
  ```javascript
193
199
  import express from 'express';
194
- import { convert_jsonld_to_toon, convert_toon_to_jsonld } from 'toon-ld';
200
+ import { encode, decode } from 'toon-ld';
195
201
 
196
202
  const app = express();
197
203
  app.use(express.text({ type: 'text/toon' }));
198
204
 
199
205
  app.post('/convert/to-toon', (req, res) => {
200
206
  try {
201
- const toon = convert_jsonld_to_toon(req.body);
207
+ const toon = encode(req.body);
202
208
  res.type('text/toon').send(toon);
203
209
  } catch (error) {
204
210
  res.status(400).json({ error: error.message });
@@ -207,7 +213,7 @@ app.post('/convert/to-toon', (req, res) => {
207
213
 
208
214
  app.post('/convert/to-jsonld', (req, res) => {
209
215
  try {
210
- const jsonLd = convert_toon_to_jsonld(req.body);
216
+ const jsonLd = decode(req.body);
211
217
  res.json(JSON.parse(jsonLd));
212
218
  } catch (error) {
213
219
  res.status(400).json({ error: error.message });
@@ -225,7 +231,7 @@ app.post('/convert/to-jsonld', (req, res) => {
225
231
  </head>
226
232
  <body>
227
233
  <script type="module">
228
- import { convert_jsonld_to_toon, init } from 'https://unpkg.com/toon-ld';
234
+ import { encode, init } from 'https://unpkg.com/toon-ld';
229
235
 
230
236
  init(); // Better error messages
231
237
 
@@ -234,7 +240,7 @@ app.post('/convert/to-jsonld', (req, res) => {
234
240
  "schema:name": "Example"
235
241
  });
236
242
 
237
- const toon = convert_jsonld_to_toon(jsonLd);
243
+ const toon = encode(jsonLd);
238
244
  console.log(toon);
239
245
  </script>
240
246
  </body>
@@ -254,7 +260,7 @@ const jsonLd = JSON.stringify({
254
260
  ]
255
261
  });
256
262
 
257
- const toon = convert_jsonld_to_toon(jsonLd);
263
+ const toon = encode(jsonLd);
258
264
  console.log(toon);
259
265
  // Output:
260
266
  // @context:
@@ -267,10 +273,10 @@ console.log(toon);
267
273
  ### Error Handling
268
274
 
269
275
  ```javascript
270
- import { convert_toon_to_jsonld } from 'toon-ld';
276
+ import { decode } from 'toon-ld';
271
277
 
272
278
  try {
273
- const result = convert_toon_to_jsonld("invalid: [unclosed");
279
+ const result = decode("invalid: [unclosed");
274
280
  } catch (error) {
275
281
  console.error("Conversion failed:", error.message);
276
282
  // Error message includes line numbers and helpful context
package/package.json CHANGED
@@ -5,31 +5,16 @@
5
5
  "Kush Bisen"
6
6
  ],
7
7
  "description": "WASM bindings for TOON-LD serializer/parser",
8
- "version": "0.1.2",
8
+ "version": "0.2.2",
9
9
  "license": "MIT",
10
- "repository": {
11
- "type": "git",
12
- "url": "https://github.com/argahsuknesib/toon-ld"
13
- },
14
- "homepage": "https://github.com/argahsuknesib/toon-ld#readme",
15
- "keywords": [
16
- "toon",
17
- "json-ld",
18
- "rdf",
19
- "linked-data",
20
- "serialization",
21
- "wasm",
22
- "webassembly"
23
- ],
24
10
  "files": [
25
11
  "toon_wasm_bg.wasm",
26
12
  "toon_wasm.js",
27
- "toon_wasm.d.ts",
28
- "README.md"
13
+ "toon_wasm.d.ts"
29
14
  ],
30
15
  "main": "toon_wasm.js",
31
16
  "types": "toon_wasm.d.ts",
32
17
  "sideEffects": [
33
18
  "./snippets/*"
34
19
  ]
35
- }
20
+ }
package/toon_wasm.d.ts CHANGED
@@ -1,34 +1,60 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ export function convert_jsonld_to_toonld(json: string): string;
5
+
4
6
  /**
5
- * Convert JSON-LD string to TOON-LD format
7
+ * Convert TOON-LD string to JSON-LD format
6
8
  *
7
9
  * # Arguments
8
- * * `json` - A JSON or JSON-LD formatted string
10
+ * * `toon` - A TOON-LD formatted string
9
11
  *
10
12
  * # Returns
11
- * * TOON-LD formatted string on success
13
+ * * JSON-LD formatted string (pretty-printed) on success
12
14
  * * Error message on failure
13
15
  */
14
- export function convert_jsonld_to_toon(json: string): string;
16
+ export function convert_toonld_to_jsonld(toon: string): string;
15
17
 
16
18
  /**
17
- * Convert TOON-LD string to JSON-LD format
19
+ * Decode TOON-LD string to JSON-LD format
20
+ *
21
+ * Alias for `convert_toonld_to_jsonld`
22
+ */
23
+ export function decode(toon: string): string;
24
+
25
+ /**
26
+ * Encode JSON-LD string to TOON-LD format
27
+ *
28
+ * Alias for `convert_jsonld_to_toonld`
29
+ */
30
+ export function encode(json: string): string;
31
+
32
+ /**
33
+ * Initialize panic hook for better error messages in browser console
34
+ */
35
+ export function init(): void;
36
+
37
+ /**
38
+ * Parse TOON-LD string to a JavaScript Object
18
39
  *
19
40
  * # Arguments
20
41
  * * `toon` - A TOON-LD formatted string
21
42
  *
22
43
  * # Returns
23
- * * JSON-LD formatted string (pretty-printed) on success
24
- * * Error message on failure
44
+ * * JavaScript Object representing the parsed data
25
45
  */
26
- export function convert_toon_to_jsonld(toon: string): string;
46
+ export function parse(toon: string): any;
27
47
 
28
48
  /**
29
- * Initialize panic hook for better error messages in browser console
49
+ * Stringify a JavaScript Object to TOON-LD format
50
+ *
51
+ * # Arguments
52
+ * * `data` - A JavaScript Object
53
+ *
54
+ * # Returns
55
+ * * TOON-LD formatted string
30
56
  */
31
- export function init(): void;
57
+ export function stringify(data: any): string;
32
58
 
33
59
  /**
34
60
  * Validate a JSON-LD string
@@ -40,7 +66,7 @@ export function init(): void;
40
66
  * * `true` if the string is valid JSON
41
67
  * * `false` otherwise
42
68
  */
43
- export function validate_json(json: string): boolean;
69
+ export function validateJson(json: string): boolean;
44
70
 
45
71
  /**
46
72
  * Validate a TOON-LD string
@@ -52,21 +78,27 @@ export function validate_json(json: string): boolean;
52
78
  * * `true` if the string is valid TOON-LD
53
79
  * * `false` otherwise
54
80
  */
55
- export function validate_toon(toon: string): boolean;
81
+ export function validateToonld(toon: string): boolean;
56
82
 
57
83
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
58
84
 
59
85
  export interface InitOutput {
60
86
  readonly memory: WebAssembly.Memory;
61
87
  readonly init: () => void;
62
- readonly convert_jsonld_to_toon: (a: number, b: number) => [number, number, number, number];
63
- readonly convert_toon_to_jsonld: (a: number, b: number) => [number, number, number, number];
64
- readonly validate_toon: (a: number, b: number) => number;
65
- readonly validate_json: (a: number, b: number) => number;
66
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
88
+ readonly convert_jsonld_to_toonld: (a: number, b: number) => [number, number, number, number];
89
+ readonly convert_toonld_to_jsonld: (a: number, b: number) => [number, number, number, number];
90
+ readonly validateToonld: (a: number, b: number) => number;
91
+ readonly validateJson: (a: number, b: number) => number;
92
+ readonly parse: (a: number, b: number) => [number, number, number];
93
+ readonly stringify: (a: any) => [number, number, number, number];
94
+ readonly encode: (a: number, b: number) => [number, number, number, number];
95
+ readonly decode: (a: number, b: number) => [number, number, number, number];
67
96
  readonly __wbindgen_malloc: (a: number, b: number) => number;
68
97
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
98
+ readonly __wbindgen_exn_store: (a: number) => void;
99
+ readonly __externref_table_alloc: () => number;
69
100
  readonly __wbindgen_externrefs: WebAssembly.Table;
101
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
70
102
  readonly __externref_table_dealloc: (a: number) => void;
71
103
  readonly __wbindgen_start: () => void;
72
104
  }
package/toon_wasm.js CHANGED
@@ -1,5 +1,81 @@
1
1
  let wasm;
2
2
 
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function debugString(val) {
10
+ // primitive types
11
+ const type = typeof val;
12
+ if (type == 'number' || type == 'boolean' || val == null) {
13
+ return `${val}`;
14
+ }
15
+ if (type == 'string') {
16
+ return `"${val}"`;
17
+ }
18
+ if (type == 'symbol') {
19
+ const description = val.description;
20
+ if (description == null) {
21
+ return 'Symbol';
22
+ } else {
23
+ return `Symbol(${description})`;
24
+ }
25
+ }
26
+ if (type == 'function') {
27
+ const name = val.name;
28
+ if (typeof name == 'string' && name.length > 0) {
29
+ return `Function(${name})`;
30
+ } else {
31
+ return 'Function';
32
+ }
33
+ }
34
+ // objects
35
+ if (Array.isArray(val)) {
36
+ const length = val.length;
37
+ let debug = '[';
38
+ if (length > 0) {
39
+ debug += debugString(val[0]);
40
+ }
41
+ for(let i = 1; i < length; i++) {
42
+ debug += ', ' + debugString(val[i]);
43
+ }
44
+ debug += ']';
45
+ return debug;
46
+ }
47
+ // Test for built-in
48
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
49
+ let className;
50
+ if (builtInMatches && builtInMatches.length > 1) {
51
+ className = builtInMatches[1];
52
+ } else {
53
+ // Failed to match the standard '[object ClassName]'
54
+ return toString.call(val);
55
+ }
56
+ if (className == 'Object') {
57
+ // we're a user defined class or Object
58
+ // JSON.stringify avoids problems with cycles, and is generally much
59
+ // easier than looping through ownProperties of `val`.
60
+ try {
61
+ return 'Object(' + JSON.stringify(val) + ')';
62
+ } catch (_) {
63
+ return 'Object';
64
+ }
65
+ }
66
+ // errors
67
+ if (val instanceof Error) {
68
+ return `${val.name}: ${val.message}\n${val.stack}`;
69
+ }
70
+ // TODO we could test for more things here, like `Set`s and `Map`s.
71
+ return className;
72
+ }
73
+
74
+ function getArrayU8FromWasm0(ptr, len) {
75
+ ptr = ptr >>> 0;
76
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
77
+ }
78
+
3
79
  let cachedDataViewMemory0 = null;
4
80
  function getDataViewMemory0() {
5
81
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -21,6 +97,19 @@ function getUint8ArrayMemory0() {
21
97
  return cachedUint8ArrayMemory0;
22
98
  }
23
99
 
100
+ function handleError(f, args) {
101
+ try {
102
+ return f.apply(this, args);
103
+ } catch (e) {
104
+ const idx = addToExternrefTable0(e);
105
+ wasm.__wbindgen_exn_store(idx);
106
+ }
107
+ }
108
+
109
+ function isLikeNone(x) {
110
+ return x === undefined || x === null;
111
+ }
112
+
24
113
  function passStringToWasm0(arg, malloc, realloc) {
25
114
  if (realloc === undefined) {
26
115
  const buf = cachedTextEncoder.encode(arg);
@@ -94,24 +183,16 @@ if (!('encodeInto' in cachedTextEncoder)) {
94
183
  let WASM_VECTOR_LEN = 0;
95
184
 
96
185
  /**
97
- * Convert JSON-LD string to TOON-LD format
98
- *
99
- * # Arguments
100
- * * `json` - A JSON or JSON-LD formatted string
101
- *
102
- * # Returns
103
- * * TOON-LD formatted string on success
104
- * * Error message on failure
105
186
  * @param {string} json
106
187
  * @returns {string}
107
188
  */
108
- export function convert_jsonld_to_toon(json) {
189
+ export function convert_jsonld_to_toonld(json) {
109
190
  let deferred3_0;
110
191
  let deferred3_1;
111
192
  try {
112
193
  const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
113
194
  const len0 = WASM_VECTOR_LEN;
114
- const ret = wasm.convert_jsonld_to_toon(ptr0, len0);
195
+ const ret = wasm.convert_jsonld_to_toonld(ptr0, len0);
115
196
  var ptr2 = ret[0];
116
197
  var len2 = ret[1];
117
198
  if (ret[3]) {
@@ -138,13 +219,69 @@ export function convert_jsonld_to_toon(json) {
138
219
  * @param {string} toon
139
220
  * @returns {string}
140
221
  */
141
- export function convert_toon_to_jsonld(toon) {
222
+ export function convert_toonld_to_jsonld(toon) {
223
+ let deferred3_0;
224
+ let deferred3_1;
225
+ try {
226
+ const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
227
+ const len0 = WASM_VECTOR_LEN;
228
+ const ret = wasm.convert_toonld_to_jsonld(ptr0, len0);
229
+ var ptr2 = ret[0];
230
+ var len2 = ret[1];
231
+ if (ret[3]) {
232
+ ptr2 = 0; len2 = 0;
233
+ throw takeFromExternrefTable0(ret[2]);
234
+ }
235
+ deferred3_0 = ptr2;
236
+ deferred3_1 = len2;
237
+ return getStringFromWasm0(ptr2, len2);
238
+ } finally {
239
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Decode TOON-LD string to JSON-LD format
245
+ *
246
+ * Alias for `convert_toonld_to_jsonld`
247
+ * @param {string} toon
248
+ * @returns {string}
249
+ */
250
+ export function decode(toon) {
142
251
  let deferred3_0;
143
252
  let deferred3_1;
144
253
  try {
145
254
  const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
146
255
  const len0 = WASM_VECTOR_LEN;
147
- const ret = wasm.convert_toon_to_jsonld(ptr0, len0);
256
+ const ret = wasm.decode(ptr0, len0);
257
+ var ptr2 = ret[0];
258
+ var len2 = ret[1];
259
+ if (ret[3]) {
260
+ ptr2 = 0; len2 = 0;
261
+ throw takeFromExternrefTable0(ret[2]);
262
+ }
263
+ deferred3_0 = ptr2;
264
+ deferred3_1 = len2;
265
+ return getStringFromWasm0(ptr2, len2);
266
+ } finally {
267
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Encode JSON-LD string to TOON-LD format
273
+ *
274
+ * Alias for `convert_jsonld_to_toonld`
275
+ * @param {string} json
276
+ * @returns {string}
277
+ */
278
+ export function encode(json) {
279
+ let deferred3_0;
280
+ let deferred3_1;
281
+ try {
282
+ const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
283
+ const len0 = WASM_VECTOR_LEN;
284
+ const ret = wasm.encode(ptr0, len0);
148
285
  var ptr2 = ret[0];
149
286
  var len2 = ret[1];
150
287
  if (ret[3]) {
@@ -166,6 +303,57 @@ export function init() {
166
303
  wasm.init();
167
304
  }
168
305
 
306
+ /**
307
+ * Parse TOON-LD string to a JavaScript Object
308
+ *
309
+ * # Arguments
310
+ * * `toon` - A TOON-LD formatted string
311
+ *
312
+ * # Returns
313
+ * * JavaScript Object representing the parsed data
314
+ * @param {string} toon
315
+ * @returns {any}
316
+ */
317
+ export function parse(toon) {
318
+ const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
319
+ const len0 = WASM_VECTOR_LEN;
320
+ const ret = wasm.parse(ptr0, len0);
321
+ if (ret[2]) {
322
+ throw takeFromExternrefTable0(ret[1]);
323
+ }
324
+ return takeFromExternrefTable0(ret[0]);
325
+ }
326
+
327
+ /**
328
+ * Stringify a JavaScript Object to TOON-LD format
329
+ *
330
+ * # Arguments
331
+ * * `data` - A JavaScript Object
332
+ *
333
+ * # Returns
334
+ * * TOON-LD formatted string
335
+ * @param {any} data
336
+ * @returns {string}
337
+ */
338
+ export function stringify(data) {
339
+ let deferred2_0;
340
+ let deferred2_1;
341
+ try {
342
+ const ret = wasm.stringify(data);
343
+ var ptr1 = ret[0];
344
+ var len1 = ret[1];
345
+ if (ret[3]) {
346
+ ptr1 = 0; len1 = 0;
347
+ throw takeFromExternrefTable0(ret[2]);
348
+ }
349
+ deferred2_0 = ptr1;
350
+ deferred2_1 = len1;
351
+ return getStringFromWasm0(ptr1, len1);
352
+ } finally {
353
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
354
+ }
355
+ }
356
+
169
357
  /**
170
358
  * Validate a JSON-LD string
171
359
  *
@@ -178,10 +366,10 @@ export function init() {
178
366
  * @param {string} json
179
367
  * @returns {boolean}
180
368
  */
181
- export function validate_json(json) {
369
+ export function validateJson(json) {
182
370
  const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
183
371
  const len0 = WASM_VECTOR_LEN;
184
- const ret = wasm.validate_json(ptr0, len0);
372
+ const ret = wasm.validateJson(ptr0, len0);
185
373
  return ret !== 0;
186
374
  }
187
375
 
@@ -197,10 +385,10 @@ export function validate_json(json) {
197
385
  * @param {string} toon
198
386
  * @returns {boolean}
199
387
  */
200
- export function validate_toon(toon) {
388
+ export function validateToonld(toon) {
201
389
  const ptr0 = passStringToWasm0(toon, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
202
390
  const len0 = WASM_VECTOR_LEN;
203
- const ret = wasm.validate_toon(ptr0, len0);
391
+ const ret = wasm.validateToonld(ptr0, len0);
204
392
  return ret !== 0;
205
393
  }
206
394
 
@@ -239,6 +427,93 @@ async function __wbg_load(module, imports) {
239
427
  function __wbg_get_imports() {
240
428
  const imports = {};
241
429
  imports.wbg = {};
430
+ imports.wbg.__wbg_Error_52673b7de5a0ca89 = function(arg0, arg1) {
431
+ const ret = Error(getStringFromWasm0(arg0, arg1));
432
+ return ret;
433
+ };
434
+ imports.wbg.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) {
435
+ const ret = String(arg1);
436
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
437
+ const len1 = WASM_VECTOR_LEN;
438
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
439
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
440
+ };
441
+ imports.wbg.__wbg___wbindgen_bigint_get_as_i64_6e32f5e6aff02e1d = function(arg0, arg1) {
442
+ const v = arg1;
443
+ const ret = typeof(v) === 'bigint' ? v : undefined;
444
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
445
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
446
+ };
447
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
448
+ const v = arg0;
449
+ const ret = typeof(v) === 'boolean' ? v : undefined;
450
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
451
+ };
452
+ imports.wbg.__wbg___wbindgen_debug_string_adfb662ae34724b6 = function(arg0, arg1) {
453
+ const ret = debugString(arg1);
454
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
455
+ const len1 = WASM_VECTOR_LEN;
456
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
457
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
458
+ };
459
+ imports.wbg.__wbg___wbindgen_in_0d3e1e8f0c669317 = function(arg0, arg1) {
460
+ const ret = arg0 in arg1;
461
+ return ret;
462
+ };
463
+ imports.wbg.__wbg___wbindgen_is_bigint_0e1a2e3f55cfae27 = function(arg0) {
464
+ const ret = typeof(arg0) === 'bigint';
465
+ return ret;
466
+ };
467
+ imports.wbg.__wbg___wbindgen_is_function_8d400b8b1af978cd = function(arg0) {
468
+ const ret = typeof(arg0) === 'function';
469
+ return ret;
470
+ };
471
+ imports.wbg.__wbg___wbindgen_is_object_ce774f3490692386 = function(arg0) {
472
+ const val = arg0;
473
+ const ret = typeof(val) === 'object' && val !== null;
474
+ return ret;
475
+ };
476
+ imports.wbg.__wbg___wbindgen_is_string_704ef9c8fc131030 = function(arg0) {
477
+ const ret = typeof(arg0) === 'string';
478
+ return ret;
479
+ };
480
+ imports.wbg.__wbg___wbindgen_jsval_eq_b6101cc9cef1fe36 = function(arg0, arg1) {
481
+ const ret = arg0 === arg1;
482
+ return ret;
483
+ };
484
+ imports.wbg.__wbg___wbindgen_jsval_loose_eq_766057600fdd1b0d = function(arg0, arg1) {
485
+ const ret = arg0 == arg1;
486
+ return ret;
487
+ };
488
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
489
+ const obj = arg1;
490
+ const ret = typeof(obj) === 'number' ? obj : undefined;
491
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
492
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
493
+ };
494
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
495
+ const obj = arg1;
496
+ const ret = typeof(obj) === 'string' ? obj : undefined;
497
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
498
+ var len1 = WASM_VECTOR_LEN;
499
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
500
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
501
+ };
502
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
503
+ throw new Error(getStringFromWasm0(arg0, arg1));
504
+ };
505
+ imports.wbg.__wbg_call_abb4ff46ce38be40 = function() { return handleError(function (arg0, arg1) {
506
+ const ret = arg0.call(arg1);
507
+ return ret;
508
+ }, arguments) };
509
+ imports.wbg.__wbg_done_62ea16af4ce34b24 = function(arg0) {
510
+ const ret = arg0.done;
511
+ return ret;
512
+ };
513
+ imports.wbg.__wbg_entries_83c79938054e065f = function(arg0) {
514
+ const ret = Object.entries(arg0);
515
+ return ret;
516
+ };
242
517
  imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
243
518
  let deferred0_0;
244
519
  let deferred0_1;
@@ -250,10 +525,105 @@ function __wbg_get_imports() {
250
525
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
251
526
  }
252
527
  };
528
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
529
+ const ret = arg0[arg1 >>> 0];
530
+ return ret;
531
+ };
532
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
533
+ const ret = Reflect.get(arg0, arg1);
534
+ return ret;
535
+ }, arguments) };
536
+ imports.wbg.__wbg_instanceof_ArrayBuffer_f3320d2419cd0355 = function(arg0) {
537
+ let result;
538
+ try {
539
+ result = arg0 instanceof ArrayBuffer;
540
+ } catch (_) {
541
+ result = false;
542
+ }
543
+ const ret = result;
544
+ return ret;
545
+ };
546
+ imports.wbg.__wbg_instanceof_Map_084be8da74364158 = function(arg0) {
547
+ let result;
548
+ try {
549
+ result = arg0 instanceof Map;
550
+ } catch (_) {
551
+ result = false;
552
+ }
553
+ const ret = result;
554
+ return ret;
555
+ };
556
+ imports.wbg.__wbg_instanceof_Uint8Array_da54ccc9d3e09434 = function(arg0) {
557
+ let result;
558
+ try {
559
+ result = arg0 instanceof Uint8Array;
560
+ } catch (_) {
561
+ result = false;
562
+ }
563
+ const ret = result;
564
+ return ret;
565
+ };
566
+ imports.wbg.__wbg_isArray_51fd9e6422c0a395 = function(arg0) {
567
+ const ret = Array.isArray(arg0);
568
+ return ret;
569
+ };
570
+ imports.wbg.__wbg_isSafeInteger_ae7d3f054d55fa16 = function(arg0) {
571
+ const ret = Number.isSafeInteger(arg0);
572
+ return ret;
573
+ };
574
+ imports.wbg.__wbg_iterator_27b7c8b35ab3e86b = function() {
575
+ const ret = Symbol.iterator;
576
+ return ret;
577
+ };
578
+ imports.wbg.__wbg_length_22ac23eaec9d8053 = function(arg0) {
579
+ const ret = arg0.length;
580
+ return ret;
581
+ };
582
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
583
+ const ret = arg0.length;
584
+ return ret;
585
+ };
586
+ imports.wbg.__wbg_new_1ba21ce319a06297 = function() {
587
+ const ret = new Object();
588
+ return ret;
589
+ };
590
+ imports.wbg.__wbg_new_25f239778d6112b9 = function() {
591
+ const ret = new Array();
592
+ return ret;
593
+ };
594
+ imports.wbg.__wbg_new_6421f6084cc5bc5a = function(arg0) {
595
+ const ret = new Uint8Array(arg0);
596
+ return ret;
597
+ };
253
598
  imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
254
599
  const ret = new Error();
255
600
  return ret;
256
601
  };
602
+ imports.wbg.__wbg_new_b546ae120718850e = function() {
603
+ const ret = new Map();
604
+ return ret;
605
+ };
606
+ imports.wbg.__wbg_next_138a17bbf04e926c = function(arg0) {
607
+ const ret = arg0.next;
608
+ return ret;
609
+ };
610
+ imports.wbg.__wbg_next_3cfe5c0fe2a4cc53 = function() { return handleError(function (arg0) {
611
+ const ret = arg0.next();
612
+ return ret;
613
+ }, arguments) };
614
+ imports.wbg.__wbg_prototypesetcall_dfe9b766cdc1f1fd = function(arg0, arg1, arg2) {
615
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
616
+ };
617
+ imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
618
+ arg0[arg1] = arg2;
619
+ };
620
+ imports.wbg.__wbg_set_7df433eea03a5c14 = function(arg0, arg1, arg2) {
621
+ arg0[arg1 >>> 0] = arg2;
622
+ };
623
+ imports.wbg.__wbg_set_efaaf145b9377369 = function(arg0, arg1, arg2) {
624
+ const ret = arg0.set(arg1, arg2);
625
+ return ret;
626
+ };
257
627
  imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
258
628
  const ret = arg1.stack;
259
629
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -261,11 +631,30 @@ function __wbg_get_imports() {
261
631
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
262
632
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
263
633
  };
634
+ imports.wbg.__wbg_value_57b7b035e117f7ee = function(arg0) {
635
+ const ret = arg0.value;
636
+ return ret;
637
+ };
264
638
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
265
639
  // Cast intrinsic for `Ref(String) -> Externref`.
266
640
  const ret = getStringFromWasm0(arg0, arg1);
267
641
  return ret;
268
642
  };
643
+ imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
644
+ // Cast intrinsic for `U64 -> Externref`.
645
+ const ret = BigInt.asUintN(64, arg0);
646
+ return ret;
647
+ };
648
+ imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
649
+ // Cast intrinsic for `I64 -> Externref`.
650
+ const ret = arg0;
651
+ return ret;
652
+ };
653
+ imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
654
+ // Cast intrinsic for `F64 -> Externref`.
655
+ const ret = arg0;
656
+ return ret;
657
+ };
269
658
  imports.wbg.__wbindgen_init_externref_table = function() {
270
659
  const table = wasm.__wbindgen_externrefs;
271
660
  const offset = table.grow(4);
package/toon_wasm_bg.wasm CHANGED
Binary file