evalsuite 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,20 @@
1
- # Temporary Holding Version
1
+ # evalsuite (npm)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The EvalSuite metric engine for JavaScript, compiled from Rust to WebAssembly: the same results as the
4
+ `evalsuite-python` package and the `evalsuite` crate.
5
+
6
+ ```js
7
+ // Node
8
+ const es = require("evalsuite");
9
+ es.evaluate("f1", { y_true: [0, 1, 1, 0], y_pred: [0, 1, 0, 0] }); // { metric: "f1", value: 0.6666666666666666 }
10
+
11
+ // Browser / bundlers
12
+ import init, { evaluate } from "evalsuite/web";
13
+ await init();
14
+ evaluate("bleu", { references: ["the cat sat on the mat"], predictions: ["the cat sat on a mat"] });
15
+ ```
16
+
17
+ Metrics: `es.metrics()`: accuracy, balanced_accuracy, precision, recall, f1, specificity, mcc, roc_auc,
18
+ average_precision, log_loss, brier_score, mae, mse, rmse, r2, mape, median_absolute_error, max_error, bleu, chrf,
19
+ ter, rouge_1, rouge_2, rouge_l, psi, ks. Arguments: `y_true`, `y_pred`, `y_prob`, `average`, `sample_weight`;
20
+ `references` / `predictions` for text; `reference` / `current` for drift.
package/evalsuite.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Computes a metric on a plain JS object of arguments and returns the result object
6
+ * (`{ metric, value }` or `{ metric, values }`); throws an `Error` with EvalSuite's message.
7
+ */
8
+ export function evaluate(metric: string, args: any): any;
9
+
10
+ /**
11
+ * Computes a metric. `args` is a JSON string (the JS wrapper passes `JSON.stringify(args)`); returns the
12
+ * JSON result or throws an `Error` with EvalSuite's message.
13
+ */
14
+ export function evaluateJson(metric: string, args: string): string;
15
+
16
+ /**
17
+ * The metric names `evaluateJson` understands.
18
+ */
19
+ export function metrics(): string[];
20
+
21
+ /**
22
+ * The engine version.
23
+ */
24
+ export function version(): string;
package/evalsuite.js ADDED
@@ -0,0 +1,279 @@
1
+ /* @ts-self-types="./evalsuite.d.ts" */
2
+
3
+ /**
4
+ * Computes a metric on a plain JS object of arguments and returns the result object
5
+ * (`{ metric, value }` or `{ metric, values }`); throws an `Error` with EvalSuite's message.
6
+ * @param {string} metric
7
+ * @param {any} args
8
+ * @returns {any}
9
+ */
10
+ function evaluate(metric, args) {
11
+ try {
12
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
13
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
14
+ const len0 = WASM_VECTOR_LEN;
15
+ wasm.evaluate(retptr, ptr0, len0, args);
16
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
17
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
18
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
19
+ if (r2) {
20
+ throw takeFromExternrefTable0(r1);
21
+ }
22
+ return takeFromExternrefTable0(r0);
23
+ } finally {
24
+ wasm.__wbindgen_add_to_stack_pointer(16);
25
+ }
26
+ }
27
+ exports.evaluate = evaluate;
28
+
29
+ /**
30
+ * Computes a metric. `args` is a JSON string (the JS wrapper passes `JSON.stringify(args)`); returns the
31
+ * JSON result or throws an `Error` with EvalSuite's message.
32
+ * @param {string} metric
33
+ * @param {string} args
34
+ * @returns {string}
35
+ */
36
+ function evaluateJson(metric, args) {
37
+ let deferred4_0;
38
+ let deferred4_1;
39
+ try {
40
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
41
+ let ptr0, len0, ptr1, len1;
42
+ try {
43
+ ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
44
+ len0 = WASM_VECTOR_LEN;
45
+ ptr1 = passStringToWasm0(args, wasm.__wbindgen_export, wasm.__wbindgen_export2);
46
+ len1 = WASM_VECTOR_LEN;
47
+ } catch (e) {
48
+ if (ptr1) { wasm.__wbindgen_export3(ptr1, len1 * 1, 1); }
49
+ if (ptr0) { wasm.__wbindgen_export3(ptr0, len0 * 1, 1); }
50
+ throw e;
51
+ }
52
+ wasm.evaluateJson(retptr, ptr0, len0, ptr1, len1);
53
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
54
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
55
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
56
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
57
+ var ptr3 = r0;
58
+ var len3 = r1;
59
+ if (r3) {
60
+ ptr3 = 0; len3 = 0;
61
+ throw takeFromExternrefTable0(r2);
62
+ }
63
+ deferred4_0 = ptr3;
64
+ deferred4_1 = len3;
65
+ return getStringFromWasm0(ptr3, len3);
66
+ } finally {
67
+ wasm.__wbindgen_add_to_stack_pointer(16);
68
+ wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
69
+ }
70
+ }
71
+ exports.evaluateJson = evaluateJson;
72
+
73
+ /**
74
+ * The metric names `evaluateJson` understands.
75
+ * @returns {string[]}
76
+ */
77
+ function metrics() {
78
+ try {
79
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
80
+ wasm.metrics(retptr);
81
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
82
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
83
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
84
+ wasm.__wbindgen_export3(r0, r1 * 4, 4);
85
+ return v1;
86
+ } finally {
87
+ wasm.__wbindgen_add_to_stack_pointer(16);
88
+ }
89
+ }
90
+ exports.metrics = metrics;
91
+
92
+ /**
93
+ * The engine version.
94
+ * @returns {string}
95
+ */
96
+ function version() {
97
+ let deferred1_0;
98
+ let deferred1_1;
99
+ try {
100
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
101
+ wasm.version(retptr);
102
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
103
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
104
+ deferred1_0 = r0;
105
+ deferred1_1 = r1;
106
+ return getStringFromWasm0(r0, r1);
107
+ } finally {
108
+ wasm.__wbindgen_add_to_stack_pointer(16);
109
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
110
+ }
111
+ }
112
+ exports.version = version;
113
+ function __wbg_get_imports() {
114
+ const import0 = {
115
+ __proto__: null,
116
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
117
+ const ret = Error(getStringFromWasm0(arg0, arg1));
118
+ return ret;
119
+ },
120
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
121
+ const obj = arg1;
122
+ const ret = typeof(obj) === 'string' ? obj : undefined;
123
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
124
+ var len1 = WASM_VECTOR_LEN;
125
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
126
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
127
+ },
128
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
129
+ throw new Error(getStringFromWasm0(arg0, arg1));
130
+ },
131
+ __wbg_parse_c3f72b5a24f83c01: function() { return handleError(function (arg0, arg1) {
132
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
133
+ return ret;
134
+ }, arguments); },
135
+ __wbg_stringify_0a0fbf2ef722380a: function() { return handleError(function (arg0) {
136
+ const ret = JSON.stringify(arg0);
137
+ return ret;
138
+ }, arguments); },
139
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
140
+ // Cast intrinsic for `Ref(String) -> Externref`.
141
+ const ret = getStringFromWasm0(arg0, arg1);
142
+ return ret;
143
+ },
144
+ __wbindgen_init_externref_table: function() {
145
+ const table = wasm.__wbindgen_externrefs;
146
+ table.set(0, undefined);
147
+ table.set(1024, undefined);
148
+ table.set(1025, null);
149
+ table.set(1026, true);
150
+ table.set(1027, false);
151
+ },
152
+ };
153
+ return {
154
+ __proto__: null,
155
+ "./evalsuite_bg.js": import0,
156
+ };
157
+ }
158
+
159
+ function addToExternrefTable0(obj) {
160
+ const idx = wasm.__wbindgen_export5();
161
+ wasm.__wbindgen_externrefs.set(idx, obj);
162
+ return idx;
163
+ }
164
+
165
+ function getArrayJsValueFromWasm0(ptr, len) {
166
+ ptr = ptr >>> 0;
167
+ const mem = getDataViewMemory0();
168
+ const result = [];
169
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
170
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
171
+ }
172
+ wasm.__wbindgen_export7(ptr, len);
173
+ return result;
174
+ }
175
+
176
+ let cachedDataViewMemory0 = null;
177
+ function getDataViewMemory0() {
178
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
179
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
180
+ }
181
+ return cachedDataViewMemory0;
182
+ }
183
+
184
+ function getStringFromWasm0(ptr, len) {
185
+ ptr = ptr >>> 0;
186
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
187
+ }
188
+
189
+ let cachedUint8ArrayMemory0 = null;
190
+ function getUint8ArrayMemory0() {
191
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
192
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
193
+ }
194
+ return cachedUint8ArrayMemory0;
195
+ }
196
+
197
+ function handleError(f, args) {
198
+ try {
199
+ return f.apply(this, args);
200
+ } catch (e) {
201
+ const idx = addToExternrefTable0(e);
202
+ wasm.__wbindgen_export4(idx);
203
+ }
204
+ }
205
+
206
+ function isLikeNone(x) {
207
+ return x === undefined || x === null;
208
+ }
209
+
210
+ function passStringToWasm0(arg, malloc, realloc) {
211
+ if (realloc === undefined) {
212
+ const buf = cachedTextEncoder.encode(arg);
213
+ const ptr = malloc(buf.length, 1) >>> 0;
214
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
215
+ WASM_VECTOR_LEN = buf.length;
216
+ return ptr;
217
+ }
218
+
219
+ let len = arg.length;
220
+ let ptr = malloc(len, 1) >>> 0;
221
+
222
+ const mem = getUint8ArrayMemory0();
223
+
224
+ let offset = 0;
225
+
226
+ for (; offset < len; offset++) {
227
+ const code = arg.charCodeAt(offset);
228
+ if (code > 0x7F) break;
229
+ mem[ptr + offset] = code;
230
+ }
231
+ if (offset !== len) {
232
+ if (offset !== 0) {
233
+ arg = arg.slice(offset);
234
+ }
235
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
236
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
237
+ const ret = cachedTextEncoder.encodeInto(arg, view);
238
+
239
+ offset += ret.written;
240
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
241
+ }
242
+
243
+ WASM_VECTOR_LEN = offset;
244
+ return ptr;
245
+ }
246
+
247
+ function takeFromExternrefTable0(idx) {
248
+ const value = wasm.__wbindgen_externrefs.get(idx);
249
+ wasm.__wbindgen_export6(idx);
250
+ return value;
251
+ }
252
+
253
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
254
+ cachedTextDecoder.decode();
255
+ function decodeText(bytes) {
256
+ return cachedTextDecoder.decode(bytes);
257
+ }
258
+
259
+ const cachedTextEncoder = new TextEncoder();
260
+
261
+ if (!('encodeInto' in cachedTextEncoder)) {
262
+ cachedTextEncoder.encodeInto = function (arg, view) {
263
+ const buf = cachedTextEncoder.encode(arg);
264
+ view.set(buf);
265
+ return {
266
+ read: arg.length,
267
+ written: buf.length
268
+ };
269
+ };
270
+ }
271
+
272
+ let WASM_VECTOR_LEN = 0;
273
+
274
+ const wasmPath = `${__dirname}/evalsuite_bg.wasm`;
275
+ const wasmBytes = require('fs').readFileSync(wasmPath);
276
+ const wasmModule = new WebAssembly.Module(wasmBytes);
277
+ let wasmInstance = new WebAssembly.Instance(wasmModule, __wbg_get_imports());
278
+ let wasm = wasmInstance.exports;
279
+ wasm.__wbindgen_start();
Binary file
@@ -0,0 +1,17 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const evaluate: (a: number, b: number, c: number, d: any) => void;
5
+ export const evaluateJson: (a: number, b: number, c: number, d: number, e: number) => void;
6
+ export const metrics: (a: number) => void;
7
+ export const version: (a: number) => void;
8
+ export const __wbindgen_export: (a: number, b: number) => number;
9
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
10
+ export const __wbindgen_export3: (a: number, b: number, c: number) => void;
11
+ export const __wbindgen_export4: (a: number) => void;
12
+ export const __wbindgen_export5: () => number;
13
+ export const __wbindgen_externrefs: WebAssembly.Table;
14
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
15
+ export const __wbindgen_export6: (a: number) => void;
16
+ export const __wbindgen_export7: (a: number, b: number) => void;
17
+ export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "evalsuite",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Evaluation metrics (classification, regression, text, drift) from the EvalSuite Rust engine, for Node and the browser via WebAssembly.",
5
+ "license": "MIT OR Apache-2.0",
6
+ "author": "Manoj Kumar C S <cs.manojkumar18@gmail.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/mkcs28/evalsuite-python"
10
+ },
11
+ "homepage": "https://github.com/mkcs28/evalsuite-python",
12
+ "keywords": [
13
+ "metrics",
14
+ "evaluation",
15
+ "machine-learning",
16
+ "wasm",
17
+ "bleu",
18
+ "f1",
19
+ "roc-auc"
20
+ ],
21
+ "main": "evalsuite.js",
22
+ "types": "evalsuite.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./evalsuite.d.ts",
26
+ "browser": "./web/evalsuite.js",
27
+ "default": "./evalsuite.js"
28
+ },
29
+ "./web": "./web/evalsuite.js"
30
+ },
31
+ "files": [
32
+ "evalsuite*",
33
+ "web/",
34
+ "README.md"
35
+ ]
36
+ }
@@ -0,0 +1,66 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /**
5
+ * Computes a metric on a plain JS object of arguments and returns the result object
6
+ * (`{ metric, value }` or `{ metric, values }`); throws an `Error` with EvalSuite's message.
7
+ */
8
+ export function evaluate(metric: string, args: any): any;
9
+
10
+ /**
11
+ * Computes a metric. `args` is a JSON string (the JS wrapper passes `JSON.stringify(args)`); returns the
12
+ * JSON result or throws an `Error` with EvalSuite's message.
13
+ */
14
+ export function evaluateJson(metric: string, args: string): string;
15
+
16
+ /**
17
+ * The metric names `evaluateJson` understands.
18
+ */
19
+ export function metrics(): string[];
20
+
21
+ /**
22
+ * The engine version.
23
+ */
24
+ export function version(): string;
25
+
26
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
27
+
28
+ export interface InitOutput {
29
+ readonly memory: WebAssembly.Memory;
30
+ readonly evaluate: (a: number, b: number, c: number, d: any) => void;
31
+ readonly evaluateJson: (a: number, b: number, c: number, d: number, e: number) => void;
32
+ readonly metrics: (a: number) => void;
33
+ readonly version: (a: number) => void;
34
+ readonly __wbindgen_export: (a: number, b: number) => number;
35
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
36
+ readonly __wbindgen_export3: (a: number, b: number, c: number) => void;
37
+ readonly __wbindgen_export4: (a: number) => void;
38
+ readonly __wbindgen_export5: () => number;
39
+ readonly __wbindgen_externrefs: WebAssembly.Table;
40
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
41
+ readonly __wbindgen_export6: (a: number) => void;
42
+ readonly __wbindgen_export7: (a: number, b: number) => void;
43
+ readonly __wbindgen_start: () => void;
44
+ }
45
+
46
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
47
+
48
+ /**
49
+ * Instantiates the given `module`, which can either be bytes or
50
+ * a precompiled `WebAssembly.Module`.
51
+ *
52
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
53
+ *
54
+ * @returns {InitOutput}
55
+ */
56
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
57
+
58
+ /**
59
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
60
+ * for everything else, calls `WebAssembly.instantiate` directly.
61
+ *
62
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
63
+ *
64
+ * @returns {Promise<InitOutput>}
65
+ */
66
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,382 @@
1
+ /* @ts-self-types="./evalsuite.d.ts" */
2
+
3
+ /**
4
+ * Computes a metric on a plain JS object of arguments and returns the result object
5
+ * (`{ metric, value }` or `{ metric, values }`); throws an `Error` with EvalSuite's message.
6
+ * @param {string} metric
7
+ * @param {any} args
8
+ * @returns {any}
9
+ */
10
+ export function evaluate(metric, args) {
11
+ try {
12
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
13
+ const ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
14
+ const len0 = WASM_VECTOR_LEN;
15
+ wasm.evaluate(retptr, ptr0, len0, args);
16
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
17
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
18
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
19
+ if (r2) {
20
+ throw takeFromExternrefTable0(r1);
21
+ }
22
+ return takeFromExternrefTable0(r0);
23
+ } finally {
24
+ wasm.__wbindgen_add_to_stack_pointer(16);
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Computes a metric. `args` is a JSON string (the JS wrapper passes `JSON.stringify(args)`); returns the
30
+ * JSON result or throws an `Error` with EvalSuite's message.
31
+ * @param {string} metric
32
+ * @param {string} args
33
+ * @returns {string}
34
+ */
35
+ export function evaluateJson(metric, args) {
36
+ let deferred4_0;
37
+ let deferred4_1;
38
+ try {
39
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
40
+ let ptr0, len0, ptr1, len1;
41
+ try {
42
+ ptr0 = passStringToWasm0(metric, wasm.__wbindgen_export, wasm.__wbindgen_export2);
43
+ len0 = WASM_VECTOR_LEN;
44
+ ptr1 = passStringToWasm0(args, wasm.__wbindgen_export, wasm.__wbindgen_export2);
45
+ len1 = WASM_VECTOR_LEN;
46
+ } catch (e) {
47
+ if (ptr1) { wasm.__wbindgen_export3(ptr1, len1 * 1, 1); }
48
+ if (ptr0) { wasm.__wbindgen_export3(ptr0, len0 * 1, 1); }
49
+ throw e;
50
+ }
51
+ wasm.evaluateJson(retptr, ptr0, len0, ptr1, len1);
52
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
53
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
54
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
55
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
56
+ var ptr3 = r0;
57
+ var len3 = r1;
58
+ if (r3) {
59
+ ptr3 = 0; len3 = 0;
60
+ throw takeFromExternrefTable0(r2);
61
+ }
62
+ deferred4_0 = ptr3;
63
+ deferred4_1 = len3;
64
+ return getStringFromWasm0(ptr3, len3);
65
+ } finally {
66
+ wasm.__wbindgen_add_to_stack_pointer(16);
67
+ wasm.__wbindgen_export3(deferred4_0, deferred4_1, 1);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * The metric names `evaluateJson` understands.
73
+ * @returns {string[]}
74
+ */
75
+ export function metrics() {
76
+ try {
77
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
78
+ wasm.metrics(retptr);
79
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
80
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
81
+ var v1 = getArrayJsValueFromWasm0(r0, r1);
82
+ wasm.__wbindgen_export3(r0, r1 * 4, 4);
83
+ return v1;
84
+ } finally {
85
+ wasm.__wbindgen_add_to_stack_pointer(16);
86
+ }
87
+ }
88
+
89
+ /**
90
+ * The engine version.
91
+ * @returns {string}
92
+ */
93
+ export function version() {
94
+ let deferred1_0;
95
+ let deferred1_1;
96
+ try {
97
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16) >>> 0;
98
+ wasm.version(retptr);
99
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
100
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
101
+ deferred1_0 = r0;
102
+ deferred1_1 = r1;
103
+ return getStringFromWasm0(r0, r1);
104
+ } finally {
105
+ wasm.__wbindgen_add_to_stack_pointer(16);
106
+ wasm.__wbindgen_export3(deferred1_0, deferred1_1, 1);
107
+ }
108
+ }
109
+ function __wbg_get_imports() {
110
+ const import0 = {
111
+ __proto__: null,
112
+ __wbg_Error_208446807d0d1e30: function(arg0, arg1) {
113
+ const ret = Error(getStringFromWasm0(arg0, arg1));
114
+ return ret;
115
+ },
116
+ __wbg___wbindgen_string_get_7ce8eee7fd327545: function(arg0, arg1) {
117
+ const obj = arg1;
118
+ const ret = typeof(obj) === 'string' ? obj : undefined;
119
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
120
+ var len1 = WASM_VECTOR_LEN;
121
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
122
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
123
+ },
124
+ __wbg___wbindgen_throw_4c88d8bf264fd984: function(arg0, arg1) {
125
+ throw new Error(getStringFromWasm0(arg0, arg1));
126
+ },
127
+ __wbg_parse_c3f72b5a24f83c01: function() { return handleError(function (arg0, arg1) {
128
+ const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
129
+ return ret;
130
+ }, arguments); },
131
+ __wbg_stringify_0a0fbf2ef722380a: function() { return handleError(function (arg0) {
132
+ const ret = JSON.stringify(arg0);
133
+ return ret;
134
+ }, arguments); },
135
+ __wbindgen_generic_0000000000000001: function(arg0, arg1) {
136
+ // Cast intrinsic for `Ref(String) -> Externref`.
137
+ const ret = getStringFromWasm0(arg0, arg1);
138
+ return ret;
139
+ },
140
+ __wbindgen_init_externref_table: function() {
141
+ const table = wasm.__wbindgen_externrefs;
142
+ table.set(0, undefined);
143
+ table.set(1024, undefined);
144
+ table.set(1025, null);
145
+ table.set(1026, true);
146
+ table.set(1027, false);
147
+ },
148
+ };
149
+ return {
150
+ __proto__: null,
151
+ "./evalsuite_bg.js": import0,
152
+ };
153
+ }
154
+
155
+ function addToExternrefTable0(obj) {
156
+ const idx = wasm.__wbindgen_export5();
157
+ wasm.__wbindgen_externrefs.set(idx, obj);
158
+ return idx;
159
+ }
160
+
161
+ function getArrayJsValueFromWasm0(ptr, len) {
162
+ ptr = ptr >>> 0;
163
+ const mem = getDataViewMemory0();
164
+ const result = [];
165
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
166
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
167
+ }
168
+ wasm.__wbindgen_export7(ptr, len);
169
+ return result;
170
+ }
171
+
172
+ let cachedDataViewMemory0 = null;
173
+ function getDataViewMemory0() {
174
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
175
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
176
+ }
177
+ return cachedDataViewMemory0;
178
+ }
179
+
180
+ function getStringFromWasm0(ptr, len) {
181
+ ptr = ptr >>> 0;
182
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
183
+ }
184
+
185
+ let cachedUint8ArrayMemory0 = null;
186
+ function getUint8ArrayMemory0() {
187
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
188
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
189
+ }
190
+ return cachedUint8ArrayMemory0;
191
+ }
192
+
193
+ function handleError(f, args) {
194
+ try {
195
+ return f.apply(this, args);
196
+ } catch (e) {
197
+ const idx = addToExternrefTable0(e);
198
+ wasm.__wbindgen_export4(idx);
199
+ }
200
+ }
201
+
202
+ function isLikeNone(x) {
203
+ return x === undefined || x === null;
204
+ }
205
+
206
+ function passStringToWasm0(arg, malloc, realloc) {
207
+ if (realloc === undefined) {
208
+ const buf = cachedTextEncoder.encode(arg);
209
+ const ptr = malloc(buf.length, 1) >>> 0;
210
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
211
+ WASM_VECTOR_LEN = buf.length;
212
+ return ptr;
213
+ }
214
+
215
+ let len = arg.length;
216
+ let ptr = malloc(len, 1) >>> 0;
217
+
218
+ const mem = getUint8ArrayMemory0();
219
+
220
+ let offset = 0;
221
+
222
+ for (; offset < len; offset++) {
223
+ const code = arg.charCodeAt(offset);
224
+ if (code > 0x7F) break;
225
+ mem[ptr + offset] = code;
226
+ }
227
+ if (offset !== len) {
228
+ if (offset !== 0) {
229
+ arg = arg.slice(offset);
230
+ }
231
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
232
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
233
+ const ret = cachedTextEncoder.encodeInto(arg, view);
234
+
235
+ offset += ret.written;
236
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
237
+ }
238
+
239
+ WASM_VECTOR_LEN = offset;
240
+ return ptr;
241
+ }
242
+
243
+ function takeFromExternrefTable0(idx) {
244
+ const value = wasm.__wbindgen_externrefs.get(idx);
245
+ wasm.__wbindgen_export6(idx);
246
+ return value;
247
+ }
248
+
249
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
250
+ cachedTextDecoder.decode();
251
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
252
+ let numBytesDecoded = 0;
253
+ function decodeText(bytes) {
254
+ numBytesDecoded += bytes.length;
255
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
256
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
257
+ cachedTextDecoder.decode();
258
+ numBytesDecoded = bytes.length;
259
+ }
260
+ return cachedTextDecoder.decode(bytes);
261
+ }
262
+
263
+ const cachedTextEncoder = new TextEncoder();
264
+
265
+ if (!('encodeInto' in cachedTextEncoder)) {
266
+ cachedTextEncoder.encodeInto = function (arg, view) {
267
+ const buf = cachedTextEncoder.encode(arg);
268
+ view.set(buf);
269
+ return {
270
+ read: arg.length,
271
+ written: buf.length
272
+ };
273
+ };
274
+ }
275
+
276
+ let WASM_VECTOR_LEN = 0;
277
+
278
+ let wasmModule, wasmInstance, wasm;
279
+ function __wbg_finalize_init(instance, module) {
280
+ wasmInstance = instance;
281
+ wasm = instance.exports;
282
+ wasmModule = module;
283
+ cachedDataViewMemory0 = null;
284
+ cachedUint8ArrayMemory0 = null;
285
+ wasm.__wbindgen_start();
286
+ return wasm;
287
+ }
288
+
289
+ async function __wbg_load(module, imports) {
290
+ if (typeof Response === 'function' && module instanceof Response) {
291
+ if (!module.ok) {
292
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
293
+ }
294
+
295
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
296
+ try {
297
+ return await WebAssembly.instantiateStreaming(module, imports);
298
+ } catch (e) {
299
+ const validResponse = expectedResponseType(module.type);
300
+
301
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
302
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
303
+
304
+ } else { throw e; }
305
+ }
306
+ }
307
+
308
+ const bytes = await module.arrayBuffer();
309
+ return await WebAssembly.instantiate(bytes, imports);
310
+ } else {
311
+ const instance = await WebAssembly.instantiate(module, imports);
312
+
313
+ if (instance instanceof WebAssembly.Instance) {
314
+ return { instance, module };
315
+ } else {
316
+ return instance;
317
+ }
318
+ }
319
+
320
+ function expectedResponseType(type) {
321
+ switch (type) {
322
+ case 'basic': case 'cors': case 'default': return true;
323
+ }
324
+ return false;
325
+ }
326
+ }
327
+
328
+ function initSync(module) {
329
+ if (wasm !== undefined) return wasm;
330
+
331
+
332
+ if (module !== undefined) {
333
+ if (Object.getPrototypeOf(module) === Object.prototype) {
334
+ ({module} = module)
335
+ } else {
336
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
337
+ }
338
+ }
339
+
340
+ const imports = __wbg_get_imports();
341
+ if (!(module instanceof WebAssembly.Module)) {
342
+ module = new WebAssembly.Module(module);
343
+ }
344
+ const instance = new WebAssembly.Instance(module, imports);
345
+ return __wbg_finalize_init(instance, module);
346
+ }
347
+
348
+ let __wbg_init_promise;
349
+ async function __wbg_init(module_or_path) {
350
+ if (wasm !== undefined) return wasm;
351
+ if (__wbg_init_promise === undefined) {
352
+ __wbg_init_promise = __wbg_init_once(module_or_path);
353
+ __wbg_init_promise.catch(() => { __wbg_init_promise = undefined; });
354
+ }
355
+ return __wbg_init_promise;
356
+ }
357
+
358
+ async function __wbg_init_once(module_or_path) {
359
+
360
+ if (module_or_path !== undefined) {
361
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
362
+ ({module_or_path} = module_or_path)
363
+ } else {
364
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
365
+ }
366
+ }
367
+
368
+ if (module_or_path === undefined) {
369
+ module_or_path = new URL('evalsuite_bg.wasm', import.meta.url);
370
+ }
371
+ const imports = __wbg_get_imports();
372
+
373
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
374
+ module_or_path = fetch(module_or_path);
375
+ }
376
+
377
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
378
+
379
+ return __wbg_finalize_init(instance, module);
380
+ }
381
+
382
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,17 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const evaluate: (a: number, b: number, c: number, d: any) => void;
5
+ export const evaluateJson: (a: number, b: number, c: number, d: number, e: number) => void;
6
+ export const metrics: (a: number) => void;
7
+ export const version: (a: number) => void;
8
+ export const __wbindgen_export: (a: number, b: number) => number;
9
+ export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
10
+ export const __wbindgen_export3: (a: number, b: number, c: number) => void;
11
+ export const __wbindgen_export4: (a: number) => void;
12
+ export const __wbindgen_export5: () => number;
13
+ export const __wbindgen_externrefs: WebAssembly.Table;
14
+ export const __wbindgen_add_to_stack_pointer: (a: number) => number;
15
+ export const __wbindgen_export6: (a: number) => void;
16
+ export const __wbindgen_export7: (a: number, b: number) => void;
17
+ export const __wbindgen_start: () => void;