@moucashi/test-parser 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "@moucashi/test-parser",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "files": [
6
+ "test_parser_bg.wasm",
7
+ "test_parser.js",
8
+ "test_parser_bg.js",
9
+ "test_parser.d.ts"
10
+ ],
11
+ "main": "test_parser.js",
12
+ "types": "test_parser.d.ts",
13
+ "sideEffects": [
14
+ "./test_parser.js",
15
+ "./snippets/*"
16
+ ]
17
+ }
@@ -0,0 +1,4 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function parse_macro(text: string): any[];
package/test_parser.js ADDED
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./test_parser_bg.wasm";
2
+ export * from "./test_parser_bg.js";
3
+ import { __wbg_set_wasm } from "./test_parser_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -0,0 +1,231 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+ function debugString(val) {
7
+ // primitive types
8
+ const type = typeof val;
9
+ if (type == 'number' || type == 'boolean' || val == null) {
10
+ return `${val}`;
11
+ }
12
+ if (type == 'string') {
13
+ return `"${val}"`;
14
+ }
15
+ if (type == 'symbol') {
16
+ const description = val.description;
17
+ if (description == null) {
18
+ return 'Symbol';
19
+ } else {
20
+ return `Symbol(${description})`;
21
+ }
22
+ }
23
+ if (type == 'function') {
24
+ const name = val.name;
25
+ if (typeof name == 'string' && name.length > 0) {
26
+ return `Function(${name})`;
27
+ } else {
28
+ return 'Function';
29
+ }
30
+ }
31
+ // objects
32
+ if (Array.isArray(val)) {
33
+ const length = val.length;
34
+ let debug = '[';
35
+ if (length > 0) {
36
+ debug += debugString(val[0]);
37
+ }
38
+ for(let i = 1; i < length; i++) {
39
+ debug += ', ' + debugString(val[i]);
40
+ }
41
+ debug += ']';
42
+ return debug;
43
+ }
44
+ // Test for built-in
45
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
46
+ let className;
47
+ if (builtInMatches && builtInMatches.length > 1) {
48
+ className = builtInMatches[1];
49
+ } else {
50
+ // Failed to match the standard '[object ClassName]'
51
+ return toString.call(val);
52
+ }
53
+ if (className == 'Object') {
54
+ // we're a user defined class or Object
55
+ // JSON.stringify avoids problems with cycles, and is generally much
56
+ // easier than looping through ownProperties of `val`.
57
+ try {
58
+ return 'Object(' + JSON.stringify(val) + ')';
59
+ } catch (_) {
60
+ return 'Object';
61
+ }
62
+ }
63
+ // errors
64
+ if (val instanceof Error) {
65
+ return `${val.name}: ${val.message}\n${val.stack}`;
66
+ }
67
+ // TODO we could test for more things here, like `Set`s and `Map`s.
68
+ return className;
69
+ }
70
+
71
+ function getArrayJsValueFromWasm0(ptr, len) {
72
+ ptr = ptr >>> 0;
73
+ const mem = getDataViewMemory0();
74
+ const result = [];
75
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
76
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
77
+ }
78
+ wasm.__externref_drop_slice(ptr, len);
79
+ return result;
80
+ }
81
+
82
+ let cachedDataViewMemory0 = null;
83
+ function getDataViewMemory0() {
84
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
85
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
86
+ }
87
+ return cachedDataViewMemory0;
88
+ }
89
+
90
+ function getStringFromWasm0(ptr, len) {
91
+ ptr = ptr >>> 0;
92
+ return decodeText(ptr, len);
93
+ }
94
+
95
+ let cachedUint8ArrayMemory0 = null;
96
+ function getUint8ArrayMemory0() {
97
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
98
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
99
+ }
100
+ return cachedUint8ArrayMemory0;
101
+ }
102
+
103
+ function passStringToWasm0(arg, malloc, realloc) {
104
+ if (realloc === undefined) {
105
+ const buf = cachedTextEncoder.encode(arg);
106
+ const ptr = malloc(buf.length, 1) >>> 0;
107
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
108
+ WASM_VECTOR_LEN = buf.length;
109
+ return ptr;
110
+ }
111
+
112
+ let len = arg.length;
113
+ let ptr = malloc(len, 1) >>> 0;
114
+
115
+ const mem = getUint8ArrayMemory0();
116
+
117
+ let offset = 0;
118
+
119
+ for (; offset < len; offset++) {
120
+ const code = arg.charCodeAt(offset);
121
+ if (code > 0x7F) break;
122
+ mem[ptr + offset] = code;
123
+ }
124
+ if (offset !== len) {
125
+ if (offset !== 0) {
126
+ arg = arg.slice(offset);
127
+ }
128
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
129
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
130
+ const ret = cachedTextEncoder.encodeInto(arg, view);
131
+
132
+ offset += ret.written;
133
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
134
+ }
135
+
136
+ WASM_VECTOR_LEN = offset;
137
+ return ptr;
138
+ }
139
+
140
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
141
+ cachedTextDecoder.decode();
142
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
143
+ let numBytesDecoded = 0;
144
+ function decodeText(ptr, len) {
145
+ numBytesDecoded += len;
146
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
147
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
148
+ cachedTextDecoder.decode();
149
+ numBytesDecoded = len;
150
+ }
151
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
152
+ }
153
+
154
+ const cachedTextEncoder = new TextEncoder();
155
+
156
+ if (!('encodeInto' in cachedTextEncoder)) {
157
+ cachedTextEncoder.encodeInto = function (arg, view) {
158
+ const buf = cachedTextEncoder.encode(arg);
159
+ view.set(buf);
160
+ return {
161
+ read: arg.length,
162
+ written: buf.length
163
+ };
164
+ }
165
+ }
166
+
167
+ let WASM_VECTOR_LEN = 0;
168
+
169
+ /**
170
+ * @param {string} text
171
+ * @returns {any[]}
172
+ */
173
+ export function parse_macro(text) {
174
+ const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
175
+ const len0 = WASM_VECTOR_LEN;
176
+ const ret = wasm.parse_macro(ptr0, len0);
177
+ var v2 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
178
+ wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
179
+ return v2;
180
+ }
181
+
182
+ export function __wbg_Number_2d1dcfcf4ec51736(arg0) {
183
+ const ret = Number(arg0);
184
+ return ret;
185
+ };
186
+
187
+ export function __wbg___wbindgen_debug_string_adfb662ae34724b6(arg0, arg1) {
188
+ const ret = debugString(arg1);
189
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
190
+ const len1 = WASM_VECTOR_LEN;
191
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
192
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
193
+ };
194
+
195
+ export function __wbg___wbindgen_throw_dd24417ed36fc46e(arg0, arg1) {
196
+ throw new Error(getStringFromWasm0(arg0, arg1));
197
+ };
198
+
199
+ export function __wbg_new_1ba21ce319a06297() {
200
+ const ret = new Object();
201
+ return ret;
202
+ };
203
+
204
+ export function __wbg_new_25f239778d6112b9() {
205
+ const ret = new Array();
206
+ return ret;
207
+ };
208
+
209
+ export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
210
+ arg0[arg1] = arg2;
211
+ };
212
+
213
+ export function __wbg_set_7df433eea03a5c14(arg0, arg1, arg2) {
214
+ arg0[arg1 >>> 0] = arg2;
215
+ };
216
+
217
+ export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
218
+ // Cast intrinsic for `Ref(String) -> Externref`.
219
+ const ret = getStringFromWasm0(arg0, arg1);
220
+ return ret;
221
+ };
222
+
223
+ export function __wbindgen_init_externref_table() {
224
+ const table = wasm.__wbindgen_externrefs;
225
+ const offset = table.grow(4);
226
+ table.set(0, undefined);
227
+ table.set(offset + 0, undefined);
228
+ table.set(offset + 1, null);
229
+ table.set(offset + 2, true);
230
+ table.set(offset + 3, false);
231
+ };
Binary file