basedpl 0.1.43 → 0.1.44
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/basedpl_wasm.js +16 -3
- package/basedpl_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/basedpl_wasm.js
CHANGED
|
@@ -70,14 +70,17 @@ export function configure(base, panic) {
|
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Every case in `speed`, text in `speed.txt`'s format, with its cost, as `basedpl::timing::costs` times it: an array of
|
|
73
|
-
* `{section, code, budgets, cost}`. Throws when the setup or a case fails.
|
|
73
|
+
* `{section, code, budgets, cost}`. With `cases`, an array of codes, only those cases run. Throws when the setup or a case fails.
|
|
74
74
|
* @param {string} speed
|
|
75
|
+
* @param {string[] | null} [cases]
|
|
75
76
|
* @returns {any}
|
|
76
77
|
*/
|
|
77
|
-
export function costs(speed) {
|
|
78
|
+
export function costs(speed, cases) {
|
|
78
79
|
const ptr0 = passStringToWasm0(speed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
79
80
|
const len0 = WASM_VECTOR_LEN;
|
|
80
|
-
|
|
81
|
+
var ptr1 = isLikeNone(cases) ? 0 : passArrayJsValueToWasm0(cases, wasm.__wbindgen_malloc);
|
|
82
|
+
var len1 = WASM_VECTOR_LEN;
|
|
83
|
+
const ret = wasm.costs(ptr0, len0, ptr1, len1);
|
|
81
84
|
if (ret[2]) {
|
|
82
85
|
throw takeFromExternrefTable0(ret[1]);
|
|
83
86
|
}
|
|
@@ -913,6 +916,16 @@ function isLikeNone(x) {
|
|
|
913
916
|
return x === undefined || x === null;
|
|
914
917
|
}
|
|
915
918
|
|
|
919
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
920
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
921
|
+
for (let i = 0; i < array.length; i++) {
|
|
922
|
+
const add = addToExternrefTable0(array[i]);
|
|
923
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
924
|
+
}
|
|
925
|
+
WASM_VECTOR_LEN = array.length;
|
|
926
|
+
return ptr;
|
|
927
|
+
}
|
|
928
|
+
|
|
916
929
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
917
930
|
if (realloc === undefined) {
|
|
918
931
|
const buf = cachedTextEncoder.encode(arg);
|
package/basedpl_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basedpl",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.44",
|
|
4
4
|
"description": "BasedPL, the Based-array Programming Language, is an APL-derived array language, borrowing ideas from J and BQN, with an emphasis on simple, consistent notation.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|