linreg-core 0.6.1 → 0.8.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 +224 -4
- package/linreg_core.d.ts +383 -1
- package/linreg_core.js +726 -0
- package/linreg_core_bg.wasm +0 -0
- package/package.json +2 -3
package/linreg_core.js
CHANGED
|
@@ -340,6 +340,97 @@ export function durbin_watson_test(y_json, x_vars_json) {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Fits an elastic net regularization path via WASM (Optimized).
|
|
345
|
+
*
|
|
346
|
+
* Computes the coefficient path for a sequence of lambda values.
|
|
347
|
+
* Returns a lightweight summary to avoid excessive JSON serialization overhead.
|
|
348
|
+
*
|
|
349
|
+
* # Arguments
|
|
350
|
+
*
|
|
351
|
+
* * `y_json` - JSON array of response variable values
|
|
352
|
+
* * `x_vars_json` - JSON array of predictor arrays
|
|
353
|
+
* * `n_lambda` - Number of lambda values (default: 100)
|
|
354
|
+
* * `lambda_min_ratio` - Ratio for smallest lambda
|
|
355
|
+
* * `alpha` - Mixing parameter (0 = Ridge, 1 = Lasso)
|
|
356
|
+
* * `standardize` - Whether to standardize predictors
|
|
357
|
+
* * `max_iter` - Maximum iterations per lambda
|
|
358
|
+
* * `tol` - Convergence tolerance
|
|
359
|
+
*
|
|
360
|
+
* # Returns
|
|
361
|
+
*
|
|
362
|
+
* JSON string containing `PathResult` (lambdas, coefficients, stats).
|
|
363
|
+
* @param {string} y_json
|
|
364
|
+
* @param {string} x_vars_json
|
|
365
|
+
* @param {number} n_lambda
|
|
366
|
+
* @param {number} lambda_min_ratio
|
|
367
|
+
* @param {number} alpha
|
|
368
|
+
* @param {boolean} standardize
|
|
369
|
+
* @param {number} max_iter
|
|
370
|
+
* @param {number} tol
|
|
371
|
+
* @returns {string}
|
|
372
|
+
*/
|
|
373
|
+
export function elastic_net_path_wasm(y_json, x_vars_json, n_lambda, lambda_min_ratio, alpha, standardize, max_iter, tol) {
|
|
374
|
+
let deferred3_0;
|
|
375
|
+
let deferred3_1;
|
|
376
|
+
try {
|
|
377
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
378
|
+
const len0 = WASM_VECTOR_LEN;
|
|
379
|
+
const ptr1 = passStringToWasm0(x_vars_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
380
|
+
const len1 = WASM_VECTOR_LEN;
|
|
381
|
+
const ret = wasm.elastic_net_path_wasm(ptr0, len0, ptr1, len1, n_lambda, lambda_min_ratio, alpha, standardize, max_iter, tol);
|
|
382
|
+
deferred3_0 = ret[0];
|
|
383
|
+
deferred3_1 = ret[1];
|
|
384
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
385
|
+
} finally {
|
|
386
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Computes approximate Elastic Net regression prediction intervals via WASM.
|
|
392
|
+
*
|
|
393
|
+
* # Arguments
|
|
394
|
+
*
|
|
395
|
+
* * `y_json` - JSON array of response variable values
|
|
396
|
+
* * `x_vars_json` - JSON array of predictor arrays (training data)
|
|
397
|
+
* * `new_x_json` - JSON array of predictor arrays (new observations)
|
|
398
|
+
* * `alpha` - Significance level (e.g., 0.05 for 95% PI)
|
|
399
|
+
* * `lambda` - Regularization strength
|
|
400
|
+
* * `enet_alpha` - Elastic net mixing parameter (0 = Ridge, 1 = Lasso)
|
|
401
|
+
* * `standardize` - Whether to standardize predictors
|
|
402
|
+
* * `max_iter` - Maximum coordinate descent iterations
|
|
403
|
+
* * `tol` - Convergence tolerance
|
|
404
|
+
* @param {string} y_json
|
|
405
|
+
* @param {string} x_vars_json
|
|
406
|
+
* @param {string} new_x_json
|
|
407
|
+
* @param {number} alpha
|
|
408
|
+
* @param {number} lambda
|
|
409
|
+
* @param {number} enet_alpha
|
|
410
|
+
* @param {boolean} standardize
|
|
411
|
+
* @param {number} max_iter
|
|
412
|
+
* @param {number} tol
|
|
413
|
+
* @returns {string}
|
|
414
|
+
*/
|
|
415
|
+
export function elastic_net_prediction_intervals(y_json, x_vars_json, new_x_json, alpha, lambda, enet_alpha, standardize, max_iter, tol) {
|
|
416
|
+
let deferred4_0;
|
|
417
|
+
let deferred4_1;
|
|
418
|
+
try {
|
|
419
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
420
|
+
const len0 = WASM_VECTOR_LEN;
|
|
421
|
+
const ptr1 = passStringToWasm0(x_vars_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
422
|
+
const len1 = WASM_VECTOR_LEN;
|
|
423
|
+
const ptr2 = passStringToWasm0(new_x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
424
|
+
const len2 = WASM_VECTOR_LEN;
|
|
425
|
+
const ret = wasm.elastic_net_prediction_intervals(ptr0, len0, ptr1, len1, ptr2, len2, alpha, lambda, enet_alpha, standardize, max_iter, tol);
|
|
426
|
+
deferred4_0 = ret[0];
|
|
427
|
+
deferred4_1 = ret[1];
|
|
428
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
429
|
+
} finally {
|
|
430
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
343
434
|
/**
|
|
344
435
|
* Performs Elastic Net regression via WASM.
|
|
345
436
|
*
|
|
@@ -393,6 +484,73 @@ export function elastic_net_regression(y_json, x_vars_json, _variable_names, lam
|
|
|
393
484
|
}
|
|
394
485
|
}
|
|
395
486
|
|
|
487
|
+
/**
|
|
488
|
+
* Computes complete feature importance analysis for OLS regression.
|
|
489
|
+
*
|
|
490
|
+
* This combines standardized coefficients, SHAP values, VIF ranking,
|
|
491
|
+
* and permutation importance into a single call.
|
|
492
|
+
*
|
|
493
|
+
* # Arguments
|
|
494
|
+
*
|
|
495
|
+
* * `y_json` - JSON array of response values
|
|
496
|
+
* * `x_json` - JSON array of predictor arrays (each array is a column)
|
|
497
|
+
* * `variable_names_json` - JSON array of variable names
|
|
498
|
+
* * `y_std` - Standard deviation of response variable
|
|
499
|
+
* * `n_permutations` - Number of permutation iterations
|
|
500
|
+
* * `seed` - Random seed (use 0 for no seed)
|
|
501
|
+
*
|
|
502
|
+
* # Returns
|
|
503
|
+
*
|
|
504
|
+
* JSON string with all feature importance metrics
|
|
505
|
+
*
|
|
506
|
+
* # Example
|
|
507
|
+
*
|
|
508
|
+
* ```javascript
|
|
509
|
+
* const y = [2.5, 3.7, 4.2, 5.1, 6.3];
|
|
510
|
+
* const x = [[1,2,3,4,5], [2,4,5,4,3]];
|
|
511
|
+
* const names = ["Temperature", "Pressure"];
|
|
512
|
+
*
|
|
513
|
+
* const result = JSON.parse(feature_importance_ols(
|
|
514
|
+
* JSON.stringify(y),
|
|
515
|
+
* JSON.stringify(x),
|
|
516
|
+
* JSON.stringify(names),
|
|
517
|
+
* 2.5, // y_std
|
|
518
|
+
* 50, // n_permutations
|
|
519
|
+
* 42 // seed
|
|
520
|
+
* ));
|
|
521
|
+
*
|
|
522
|
+
* console.log(result.standardized_coefficients);
|
|
523
|
+
* console.log(result.shap);
|
|
524
|
+
* console.log(result.permutation_importance);
|
|
525
|
+
* console.log(result.vif_ranking);
|
|
526
|
+
* ```
|
|
527
|
+
* @param {string} y_json
|
|
528
|
+
* @param {string} x_json
|
|
529
|
+
* @param {string} variable_names_json
|
|
530
|
+
* @param {number} y_std
|
|
531
|
+
* @param {number} n_permutations
|
|
532
|
+
* @param {bigint} seed
|
|
533
|
+
* @returns {string}
|
|
534
|
+
*/
|
|
535
|
+
export function feature_importance_ols(y_json, x_json, variable_names_json, y_std, n_permutations, seed) {
|
|
536
|
+
let deferred4_0;
|
|
537
|
+
let deferred4_1;
|
|
538
|
+
try {
|
|
539
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
540
|
+
const len0 = WASM_VECTOR_LEN;
|
|
541
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
542
|
+
const len1 = WASM_VECTOR_LEN;
|
|
543
|
+
const ptr2 = passStringToWasm0(variable_names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
544
|
+
const len2 = WASM_VECTOR_LEN;
|
|
545
|
+
const ret = wasm.feature_importance_ols(ptr0, len0, ptr1, len1, ptr2, len2, y_std, n_permutations, seed);
|
|
546
|
+
deferred4_0 = ret[0];
|
|
547
|
+
deferred4_1 = ret[1];
|
|
548
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
549
|
+
} finally {
|
|
550
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
396
554
|
/**
|
|
397
555
|
* Extract metadata from a serialized model without deserializing the full model.
|
|
398
556
|
*
|
|
@@ -830,6 +988,48 @@ export function kfold_cv_ridge(y_json, x_vars_json, lambda, standardize, n_folds
|
|
|
830
988
|
}
|
|
831
989
|
}
|
|
832
990
|
|
|
991
|
+
/**
|
|
992
|
+
* Computes approximate Lasso regression prediction intervals via WASM.
|
|
993
|
+
*
|
|
994
|
+
* # Arguments
|
|
995
|
+
*
|
|
996
|
+
* * `y_json` - JSON array of response variable values
|
|
997
|
+
* * `x_vars_json` - JSON array of predictor arrays (training data)
|
|
998
|
+
* * `new_x_json` - JSON array of predictor arrays (new observations)
|
|
999
|
+
* * `alpha` - Significance level (e.g., 0.05 for 95% PI)
|
|
1000
|
+
* * `lambda` - Regularization strength
|
|
1001
|
+
* * `standardize` - Whether to standardize predictors
|
|
1002
|
+
* * `max_iter` - Maximum coordinate descent iterations
|
|
1003
|
+
* * `tol` - Convergence tolerance
|
|
1004
|
+
* @param {string} y_json
|
|
1005
|
+
* @param {string} x_vars_json
|
|
1006
|
+
* @param {string} new_x_json
|
|
1007
|
+
* @param {number} alpha
|
|
1008
|
+
* @param {number} lambda
|
|
1009
|
+
* @param {boolean} standardize
|
|
1010
|
+
* @param {number} max_iter
|
|
1011
|
+
* @param {number} tol
|
|
1012
|
+
* @returns {string}
|
|
1013
|
+
*/
|
|
1014
|
+
export function lasso_prediction_intervals(y_json, x_vars_json, new_x_json, alpha, lambda, standardize, max_iter, tol) {
|
|
1015
|
+
let deferred4_0;
|
|
1016
|
+
let deferred4_1;
|
|
1017
|
+
try {
|
|
1018
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1019
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1020
|
+
const ptr1 = passStringToWasm0(x_vars_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1021
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1022
|
+
const ptr2 = passStringToWasm0(new_x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1023
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1024
|
+
const ret = wasm.lasso_prediction_intervals(ptr0, len0, ptr1, len1, ptr2, len2, alpha, lambda, standardize, max_iter, tol);
|
|
1025
|
+
deferred4_0 = ret[0];
|
|
1026
|
+
deferred4_1 = ret[1];
|
|
1027
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1028
|
+
} finally {
|
|
1029
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
|
|
833
1033
|
/**
|
|
834
1034
|
* Performs Lasso regression via WASM.
|
|
835
1035
|
*
|
|
@@ -1050,6 +1250,47 @@ export function make_lambda_path(y_json, x_vars_json, n_lambda, lambda_min_ratio
|
|
|
1050
1250
|
}
|
|
1051
1251
|
}
|
|
1052
1252
|
|
|
1253
|
+
/**
|
|
1254
|
+
* Computes OLS prediction intervals via WASM.
|
|
1255
|
+
*
|
|
1256
|
+
* Fits an OLS model to the training data and computes prediction intervals
|
|
1257
|
+
* for the new observations.
|
|
1258
|
+
*
|
|
1259
|
+
* # Arguments
|
|
1260
|
+
*
|
|
1261
|
+
* * `y_json` - JSON array of response variable values
|
|
1262
|
+
* * `x_vars_json` - JSON array of predictor arrays (training data)
|
|
1263
|
+
* * `new_x_json` - JSON array of predictor arrays (new observations)
|
|
1264
|
+
* * `alpha` - Significance level (e.g., 0.05 for 95% PI)
|
|
1265
|
+
*
|
|
1266
|
+
* # Returns
|
|
1267
|
+
*
|
|
1268
|
+
* JSON string containing predicted values, lower/upper bounds, SE, leverage.
|
|
1269
|
+
* @param {string} y_json
|
|
1270
|
+
* @param {string} x_vars_json
|
|
1271
|
+
* @param {string} new_x_json
|
|
1272
|
+
* @param {number} alpha
|
|
1273
|
+
* @returns {string}
|
|
1274
|
+
*/
|
|
1275
|
+
export function ols_prediction_intervals(y_json, x_vars_json, new_x_json, alpha) {
|
|
1276
|
+
let deferred4_0;
|
|
1277
|
+
let deferred4_1;
|
|
1278
|
+
try {
|
|
1279
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1280
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1281
|
+
const ptr1 = passStringToWasm0(x_vars_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1282
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1283
|
+
const ptr2 = passStringToWasm0(new_x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1284
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1285
|
+
const ret = wasm.ols_prediction_intervals(ptr0, len0, ptr1, len1, ptr2, len2, alpha);
|
|
1286
|
+
deferred4_0 = ret[0];
|
|
1287
|
+
deferred4_1 = ret[1];
|
|
1288
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1289
|
+
} finally {
|
|
1290
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1053
1294
|
/**
|
|
1054
1295
|
* Performs OLS regression via WASM.
|
|
1055
1296
|
*
|
|
@@ -1141,6 +1382,291 @@ export function parse_csv(content) {
|
|
|
1141
1382
|
}
|
|
1142
1383
|
}
|
|
1143
1384
|
|
|
1385
|
+
/**
|
|
1386
|
+
* Computes permutation importance for OLS regression.
|
|
1387
|
+
*
|
|
1388
|
+
* # Arguments
|
|
1389
|
+
*
|
|
1390
|
+
* * `y_json` - JSON array of response values
|
|
1391
|
+
* * `x_json` - JSON array of predictor arrays (each array is a column)
|
|
1392
|
+
* * `fit_json` - JSON string of OLS fit result
|
|
1393
|
+
* * `n_permutations` - Number of permutation iterations
|
|
1394
|
+
* * `seed` - Random seed (use 0 for no seed)
|
|
1395
|
+
*
|
|
1396
|
+
* # Returns
|
|
1397
|
+
*
|
|
1398
|
+
* JSON string of [`PermutationImportanceOutput`]
|
|
1399
|
+
*
|
|
1400
|
+
* # Example
|
|
1401
|
+
*
|
|
1402
|
+
* ```javascript
|
|
1403
|
+
* const y = [2.5, 3.7, 4.2, 5.1, 6.3];
|
|
1404
|
+
* const x = [[1,2,3,4,5], [2,4,5,4,3]];
|
|
1405
|
+
* const fit = JSON.parse(ols_regression(...)); // from regression module
|
|
1406
|
+
*
|
|
1407
|
+
* const result = JSON.parse(permutation_importance_ols(
|
|
1408
|
+
* JSON.stringify(y),
|
|
1409
|
+
* JSON.stringify(x),
|
|
1410
|
+
* JSON.stringify(fit),
|
|
1411
|
+
* 50, // n_permutations
|
|
1412
|
+
* 42 // seed
|
|
1413
|
+
* ));
|
|
1414
|
+
* console.log(result.importance);
|
|
1415
|
+
* ```
|
|
1416
|
+
* @param {string} y_json
|
|
1417
|
+
* @param {string} x_json
|
|
1418
|
+
* @param {string} fit_json
|
|
1419
|
+
* @param {number} n_permutations
|
|
1420
|
+
* @param {bigint} seed
|
|
1421
|
+
* @returns {string}
|
|
1422
|
+
*/
|
|
1423
|
+
export function permutation_importance_ols(y_json, x_json, fit_json, n_permutations, seed) {
|
|
1424
|
+
let deferred4_0;
|
|
1425
|
+
let deferred4_1;
|
|
1426
|
+
try {
|
|
1427
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1428
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1429
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1430
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1431
|
+
const ptr2 = passStringToWasm0(fit_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1432
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1433
|
+
const ret = wasm.permutation_importance_ols(ptr0, len0, ptr1, len1, ptr2, len2, n_permutations, seed);
|
|
1434
|
+
deferred4_0 = ret[0];
|
|
1435
|
+
deferred4_1 = ret[1];
|
|
1436
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1437
|
+
} finally {
|
|
1438
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
/**
|
|
1443
|
+
* Fit polynomial Elastic Net regression via WASM.
|
|
1444
|
+
*
|
|
1445
|
+
* Elastic Net combines L1 and L2 penalties, balancing variable selection
|
|
1446
|
+
* with multicollinearity handling.
|
|
1447
|
+
*
|
|
1448
|
+
* # Arguments
|
|
1449
|
+
*
|
|
1450
|
+
* * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
|
|
1451
|
+
* * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
|
|
1452
|
+
* * `degree` - Polynomial degree (≥ 1)
|
|
1453
|
+
* * `lambda` - Regularization strength (≥ 0)
|
|
1454
|
+
* * `alpha` - Mixing parameter: 0 = Ridge, 1 = Lasso
|
|
1455
|
+
* * `center` - Whether to center x before expansion (reduces multicollinearity)
|
|
1456
|
+
* * `standardize` - Whether to standardize features (recommended)
|
|
1457
|
+
*
|
|
1458
|
+
* # Returns
|
|
1459
|
+
*
|
|
1460
|
+
* JSON string of the ElasticNetFit result, which includes:
|
|
1461
|
+
* - `intercept`, `coefficients`
|
|
1462
|
+
* - `fitted_values`, `residuals`
|
|
1463
|
+
* - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
|
|
1464
|
+
* - `n_nonzero`, `converged`, `n_iterations`
|
|
1465
|
+
* - `log_likelihood`, `aic`, `bic`
|
|
1466
|
+
* @param {string} y_json
|
|
1467
|
+
* @param {string} x_json
|
|
1468
|
+
* @param {number} degree
|
|
1469
|
+
* @param {number} lambda
|
|
1470
|
+
* @param {number} alpha
|
|
1471
|
+
* @param {boolean} center
|
|
1472
|
+
* @param {boolean} standardize
|
|
1473
|
+
* @returns {string}
|
|
1474
|
+
*/
|
|
1475
|
+
export function polynomial_elastic_net_wasm(y_json, x_json, degree, lambda, alpha, center, standardize) {
|
|
1476
|
+
let deferred3_0;
|
|
1477
|
+
let deferred3_1;
|
|
1478
|
+
try {
|
|
1479
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1480
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1481
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1482
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1483
|
+
const ret = wasm.polynomial_elastic_net_wasm(ptr0, len0, ptr1, len1, degree, lambda, alpha, center, standardize);
|
|
1484
|
+
deferred3_0 = ret[0];
|
|
1485
|
+
deferred3_1 = ret[1];
|
|
1486
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1487
|
+
} finally {
|
|
1488
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Fit polynomial Lasso regression via WASM.
|
|
1494
|
+
*
|
|
1495
|
+
* Lasso can perform variable selection among polynomial terms,
|
|
1496
|
+
* potentially eliminating higher-order terms.
|
|
1497
|
+
*
|
|
1498
|
+
* # Arguments
|
|
1499
|
+
*
|
|
1500
|
+
* * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
|
|
1501
|
+
* * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
|
|
1502
|
+
* * `degree` - Polynomial degree (≥ 1)
|
|
1503
|
+
* * `lambda` - Regularization strength (≥ 0)
|
|
1504
|
+
* * `center` - Whether to center x before expansion (reduces multicollinearity)
|
|
1505
|
+
* * `standardize` - Whether to standardize features (recommended)
|
|
1506
|
+
*
|
|
1507
|
+
* # Returns
|
|
1508
|
+
*
|
|
1509
|
+
* JSON string of the LassoFit result, which includes:
|
|
1510
|
+
* - `intercept`, `coefficients`
|
|
1511
|
+
* - `fitted_values`, `residuals`
|
|
1512
|
+
* - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
|
|
1513
|
+
* - `n_nonzero`, `converged`, `n_iterations`
|
|
1514
|
+
* - `log_likelihood`, `aic`, `bic`
|
|
1515
|
+
* @param {string} y_json
|
|
1516
|
+
* @param {string} x_json
|
|
1517
|
+
* @param {number} degree
|
|
1518
|
+
* @param {number} lambda
|
|
1519
|
+
* @param {boolean} center
|
|
1520
|
+
* @param {boolean} standardize
|
|
1521
|
+
* @returns {string}
|
|
1522
|
+
*/
|
|
1523
|
+
export function polynomial_lasso_wasm(y_json, x_json, degree, lambda, center, standardize) {
|
|
1524
|
+
let deferred3_0;
|
|
1525
|
+
let deferred3_1;
|
|
1526
|
+
try {
|
|
1527
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1528
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1529
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1530
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1531
|
+
const ret = wasm.polynomial_lasso_wasm(ptr0, len0, ptr1, len1, degree, lambda, center, standardize);
|
|
1532
|
+
deferred3_0 = ret[0];
|
|
1533
|
+
deferred3_1 = ret[1];
|
|
1534
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1535
|
+
} finally {
|
|
1536
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* Predict using a fitted polynomial model via WASM.
|
|
1542
|
+
*
|
|
1543
|
+
* # Arguments
|
|
1544
|
+
*
|
|
1545
|
+
* * `fit_json` - JSON string of the `PolynomialFit` returned by [`polynomial_regression_wasm`]
|
|
1546
|
+
* * `x_new_json` - JSON array of new predictor values, e.g. `[6.0, 7.0]`
|
|
1547
|
+
*
|
|
1548
|
+
* # Returns
|
|
1549
|
+
*
|
|
1550
|
+
* JSON array of predicted values, or a JSON error object on failure.
|
|
1551
|
+
* @param {string} fit_json
|
|
1552
|
+
* @param {string} x_new_json
|
|
1553
|
+
* @returns {string}
|
|
1554
|
+
*/
|
|
1555
|
+
export function polynomial_predict_wasm(fit_json, x_new_json) {
|
|
1556
|
+
let deferred3_0;
|
|
1557
|
+
let deferred3_1;
|
|
1558
|
+
try {
|
|
1559
|
+
const ptr0 = passStringToWasm0(fit_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1560
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1561
|
+
const ptr1 = passStringToWasm0(x_new_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1562
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1563
|
+
const ret = wasm.polynomial_predict_wasm(ptr0, len0, ptr1, len1);
|
|
1564
|
+
deferred3_0 = ret[0];
|
|
1565
|
+
deferred3_1 = ret[1];
|
|
1566
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1567
|
+
} finally {
|
|
1568
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
/**
|
|
1573
|
+
* Fit polynomial regression via WASM.
|
|
1574
|
+
*
|
|
1575
|
+
* # Arguments
|
|
1576
|
+
*
|
|
1577
|
+
* * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
|
|
1578
|
+
* * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
|
|
1579
|
+
* * `degree` - Polynomial degree (≥ 1)
|
|
1580
|
+
* * `center` - Whether to center x before expanding (reduces multicollinearity)
|
|
1581
|
+
* * `standardize` - Whether to standardize polynomial features
|
|
1582
|
+
*
|
|
1583
|
+
* # Returns
|
|
1584
|
+
*
|
|
1585
|
+
* JSON string of the complete [`PolynomialFit`], which includes:
|
|
1586
|
+
* - `ols_output` — full OLS regression output (coefficients, R², F-stat, etc.)
|
|
1587
|
+
* - `degree`, `centered`, `x_mean`, `x_std`, `standardized`
|
|
1588
|
+
* - `feature_names`, `feature_means`, `feature_stds`
|
|
1589
|
+
*
|
|
1590
|
+
* The returned JSON can be passed directly to [`polynomial_predict_wasm`].
|
|
1591
|
+
*
|
|
1592
|
+
* # Errors
|
|
1593
|
+
*
|
|
1594
|
+
* Returns a JSON error object `{"error": "…"}` if:
|
|
1595
|
+
* - JSON parsing fails
|
|
1596
|
+
* - `degree` is 0
|
|
1597
|
+
* - `y` and `x` have different lengths
|
|
1598
|
+
* - Insufficient data
|
|
1599
|
+
* - Domain check fails
|
|
1600
|
+
* @param {string} y_json
|
|
1601
|
+
* @param {string} x_json
|
|
1602
|
+
* @param {number} degree
|
|
1603
|
+
* @param {boolean} center
|
|
1604
|
+
* @param {boolean} standardize
|
|
1605
|
+
* @returns {string}
|
|
1606
|
+
*/
|
|
1607
|
+
export function polynomial_regression_wasm(y_json, x_json, degree, center, standardize) {
|
|
1608
|
+
let deferred3_0;
|
|
1609
|
+
let deferred3_1;
|
|
1610
|
+
try {
|
|
1611
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1612
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1613
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1614
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1615
|
+
const ret = wasm.polynomial_regression_wasm(ptr0, len0, ptr1, len1, degree, center, standardize);
|
|
1616
|
+
deferred3_0 = ret[0];
|
|
1617
|
+
deferred3_1 = ret[1];
|
|
1618
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1619
|
+
} finally {
|
|
1620
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Fit polynomial Ridge regression via WASM.
|
|
1626
|
+
*
|
|
1627
|
+
* Ridge regularization helps with multicollinearity in polynomial features.
|
|
1628
|
+
*
|
|
1629
|
+
* # Arguments
|
|
1630
|
+
*
|
|
1631
|
+
* * `y_json` - JSON array of response values, e.g. `[1.0, 4.0, 9.0]`
|
|
1632
|
+
* * `x_json` - JSON array of predictor values, e.g. `[1.0, 2.0, 3.0]`
|
|
1633
|
+
* * `degree` - Polynomial degree (≥ 1)
|
|
1634
|
+
* * `lambda` - Regularization strength (≥ 0)
|
|
1635
|
+
* * `center` - Whether to center x before expansion (reduces multicollinearity)
|
|
1636
|
+
* * `standardize` - Whether to standardize features (recommended)
|
|
1637
|
+
*
|
|
1638
|
+
* # Returns
|
|
1639
|
+
*
|
|
1640
|
+
* JSON string of the RidgeFit result, which includes:
|
|
1641
|
+
* - `intercept`, `coefficients`
|
|
1642
|
+
* - `fitted_values`, `residuals`
|
|
1643
|
+
* - `r_squared`, `adj_r_squared`, `mse`, `rmse`, `mae`
|
|
1644
|
+
* - `effective_df`, `log_likelihood`, `aic`, `bic`
|
|
1645
|
+
* @param {string} y_json
|
|
1646
|
+
* @param {string} x_json
|
|
1647
|
+
* @param {number} degree
|
|
1648
|
+
* @param {number} lambda
|
|
1649
|
+
* @param {boolean} center
|
|
1650
|
+
* @param {boolean} standardize
|
|
1651
|
+
* @returns {string}
|
|
1652
|
+
*/
|
|
1653
|
+
export function polynomial_ridge_wasm(y_json, x_json, degree, lambda, center, standardize) {
|
|
1654
|
+
let deferred3_0;
|
|
1655
|
+
let deferred3_1;
|
|
1656
|
+
try {
|
|
1657
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1658
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1659
|
+
const ptr1 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1660
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1661
|
+
const ret = wasm.polynomial_ridge_wasm(ptr0, len0, ptr1, len1, degree, lambda, center, standardize);
|
|
1662
|
+
deferred3_0 = ret[0];
|
|
1663
|
+
deferred3_1 = ret[1];
|
|
1664
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1665
|
+
} finally {
|
|
1666
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1144
1670
|
/**
|
|
1145
1671
|
* Performs the Python method White test for heteroscedasticity via WASM.
|
|
1146
1672
|
*
|
|
@@ -1314,6 +1840,47 @@ export function reset_test(y_json, x_vars_json, powers_json, type_) {
|
|
|
1314
1840
|
}
|
|
1315
1841
|
}
|
|
1316
1842
|
|
|
1843
|
+
/**
|
|
1844
|
+
* Computes approximate Ridge regression prediction intervals via WASM.
|
|
1845
|
+
*
|
|
1846
|
+
* Fits a Ridge model and computes conservative prediction intervals using
|
|
1847
|
+
* leverage from unpenalized X'X and MSE from the ridge fit.
|
|
1848
|
+
*
|
|
1849
|
+
* # Arguments
|
|
1850
|
+
*
|
|
1851
|
+
* * `y_json` - JSON array of response variable values
|
|
1852
|
+
* * `x_vars_json` - JSON array of predictor arrays (training data)
|
|
1853
|
+
* * `new_x_json` - JSON array of predictor arrays (new observations)
|
|
1854
|
+
* * `alpha` - Significance level (e.g., 0.05 for 95% PI)
|
|
1855
|
+
* * `lambda` - Regularization strength
|
|
1856
|
+
* * `standardize` - Whether to standardize predictors
|
|
1857
|
+
* @param {string} y_json
|
|
1858
|
+
* @param {string} x_vars_json
|
|
1859
|
+
* @param {string} new_x_json
|
|
1860
|
+
* @param {number} alpha
|
|
1861
|
+
* @param {number} lambda
|
|
1862
|
+
* @param {boolean} standardize
|
|
1863
|
+
* @returns {string}
|
|
1864
|
+
*/
|
|
1865
|
+
export function ridge_prediction_intervals(y_json, x_vars_json, new_x_json, alpha, lambda, standardize) {
|
|
1866
|
+
let deferred4_0;
|
|
1867
|
+
let deferred4_1;
|
|
1868
|
+
try {
|
|
1869
|
+
const ptr0 = passStringToWasm0(y_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1870
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1871
|
+
const ptr1 = passStringToWasm0(x_vars_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1872
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1873
|
+
const ptr2 = passStringToWasm0(new_x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1874
|
+
const len2 = WASM_VECTOR_LEN;
|
|
1875
|
+
const ret = wasm.ridge_prediction_intervals(ptr0, len0, ptr1, len1, ptr2, len2, alpha, lambda, standardize);
|
|
1876
|
+
deferred4_0 = ret[0];
|
|
1877
|
+
deferred4_1 = ret[1];
|
|
1878
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
1879
|
+
} finally {
|
|
1880
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
|
|
1317
1884
|
/**
|
|
1318
1885
|
* Performs Ridge regression via WASM.
|
|
1319
1886
|
*
|
|
@@ -1429,6 +1996,54 @@ export function serialize_model(model_json, model_type, name) {
|
|
|
1429
1996
|
}
|
|
1430
1997
|
}
|
|
1431
1998
|
|
|
1999
|
+
/**
|
|
2000
|
+
* Computes SHAP (SHapley Additive exPlanations) values for linear models.
|
|
2001
|
+
*
|
|
2002
|
+
* # Arguments
|
|
2003
|
+
*
|
|
2004
|
+
* * `x_json` - JSON array of predictor arrays (each array is a column)
|
|
2005
|
+
* * `coefficients_json` - JSON array of coefficients including intercept
|
|
2006
|
+
* * `variable_names_json` - JSON array of variable names
|
|
2007
|
+
*
|
|
2008
|
+
* # Returns
|
|
2009
|
+
*
|
|
2010
|
+
* JSON string of [`ShapOutput`]
|
|
2011
|
+
*
|
|
2012
|
+
* # Example
|
|
2013
|
+
*
|
|
2014
|
+
* ```javascript
|
|
2015
|
+
* const result = JSON.parse(shap_values_linear(
|
|
2016
|
+
* JSON.stringify([[1,2,3], [2,4,6]]),
|
|
2017
|
+
* JSON.stringify([5, 2, 3]),
|
|
2018
|
+
* JSON.stringify(["X1", "X2"])
|
|
2019
|
+
* ));
|
|
2020
|
+
* console.log(result.mean_abs_shap); // Global importance
|
|
2021
|
+
* console.log(result.shap_values); // Local contributions
|
|
2022
|
+
* ```
|
|
2023
|
+
* @param {string} x_json
|
|
2024
|
+
* @param {string} coefficients_json
|
|
2025
|
+
* @param {string} variable_names_json
|
|
2026
|
+
* @returns {string}
|
|
2027
|
+
*/
|
|
2028
|
+
export function shap_values_linear(x_json, coefficients_json, variable_names_json) {
|
|
2029
|
+
let deferred4_0;
|
|
2030
|
+
let deferred4_1;
|
|
2031
|
+
try {
|
|
2032
|
+
const ptr0 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2033
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2034
|
+
const ptr1 = passStringToWasm0(coefficients_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2035
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2036
|
+
const ptr2 = passStringToWasm0(variable_names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2037
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2038
|
+
const ret = wasm.shap_values_linear(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
2039
|
+
deferred4_0 = ret[0];
|
|
2040
|
+
deferred4_1 = ret[1];
|
|
2041
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2042
|
+
} finally {
|
|
2043
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
|
|
1432
2047
|
/**
|
|
1433
2048
|
* Performs the Shapiro-Wilk test for normality via WASM.
|
|
1434
2049
|
*
|
|
@@ -1470,6 +2085,56 @@ export function shapiro_wilk_test(y_json, x_vars_json) {
|
|
|
1470
2085
|
}
|
|
1471
2086
|
}
|
|
1472
2087
|
|
|
2088
|
+
/**
|
|
2089
|
+
* Computes standardized coefficients for feature importance.
|
|
2090
|
+
*
|
|
2091
|
+
* # Arguments
|
|
2092
|
+
*
|
|
2093
|
+
* * `x_json` - JSON array of predictor arrays (each array is a column)
|
|
2094
|
+
* * `coefficients_json` - JSON array of coefficients including intercept
|
|
2095
|
+
* * `variable_names_json` - JSON array of variable names
|
|
2096
|
+
* * `y_std` - Standard deviation of response variable
|
|
2097
|
+
*
|
|
2098
|
+
* # Returns
|
|
2099
|
+
*
|
|
2100
|
+
* JSON string of [`StandardizedCoefficientsOutput`]
|
|
2101
|
+
*
|
|
2102
|
+
* # Example
|
|
2103
|
+
*
|
|
2104
|
+
* ```javascript
|
|
2105
|
+
* const result = JSON.parse(standardized_coefficients(
|
|
2106
|
+
* JSON.stringify([[1,2,3,4,5], [10,20,30,40,50]]),
|
|
2107
|
+
* JSON.stringify([1, 0.5, -0.3]),
|
|
2108
|
+
* JSON.stringify(["Temperature", "Pressure"]),
|
|
2109
|
+
* 2.5
|
|
2110
|
+
* ));
|
|
2111
|
+
* console.log(result.standardized_coefficients);
|
|
2112
|
+
* ```
|
|
2113
|
+
* @param {string} x_json
|
|
2114
|
+
* @param {string} coefficients_json
|
|
2115
|
+
* @param {string} variable_names_json
|
|
2116
|
+
* @param {number} y_std
|
|
2117
|
+
* @returns {string}
|
|
2118
|
+
*/
|
|
2119
|
+
export function standardized_coefficients(x_json, coefficients_json, variable_names_json, y_std) {
|
|
2120
|
+
let deferred4_0;
|
|
2121
|
+
let deferred4_1;
|
|
2122
|
+
try {
|
|
2123
|
+
const ptr0 = passStringToWasm0(x_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2124
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2125
|
+
const ptr1 = passStringToWasm0(coefficients_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2126
|
+
const len1 = WASM_VECTOR_LEN;
|
|
2127
|
+
const ptr2 = passStringToWasm0(variable_names_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2128
|
+
const len2 = WASM_VECTOR_LEN;
|
|
2129
|
+
const ret = wasm.standardized_coefficients(ptr0, len0, ptr1, len1, ptr2, len2, y_std);
|
|
2130
|
+
deferred4_0 = ret[0];
|
|
2131
|
+
deferred4_1 = ret[1];
|
|
2132
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2133
|
+
} finally {
|
|
2134
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
|
|
1473
2138
|
/**
|
|
1474
2139
|
* Computes the correlation coefficient between two JSON arrays of f64 values.
|
|
1475
2140
|
*
|
|
@@ -1770,6 +2435,42 @@ export function test_t_critical(df, alpha) {
|
|
|
1770
2435
|
}
|
|
1771
2436
|
}
|
|
1772
2437
|
|
|
2438
|
+
/**
|
|
2439
|
+
* Computes VIF (Variance Inflation Factor) ranking.
|
|
2440
|
+
*
|
|
2441
|
+
* # Arguments
|
|
2442
|
+
*
|
|
2443
|
+
* * `vif_json` - JSON array of VIF results from OLS output
|
|
2444
|
+
*
|
|
2445
|
+
* # Returns
|
|
2446
|
+
*
|
|
2447
|
+
* JSON string of [`VifRankingOutput`]
|
|
2448
|
+
*
|
|
2449
|
+
* # Example
|
|
2450
|
+
*
|
|
2451
|
+
* ```javascript
|
|
2452
|
+
* const fit = JSON.parse(ols_regression(...));
|
|
2453
|
+
* const result = JSON.parse(vif_ranking(JSON.stringify(fit.vif)));
|
|
2454
|
+
* console.log(result.ranking); // Sorted by VIF (lowest first)
|
|
2455
|
+
* ```
|
|
2456
|
+
* @param {string} vif_json
|
|
2457
|
+
* @returns {string}
|
|
2458
|
+
*/
|
|
2459
|
+
export function vif_ranking(vif_json) {
|
|
2460
|
+
let deferred2_0;
|
|
2461
|
+
let deferred2_1;
|
|
2462
|
+
try {
|
|
2463
|
+
const ptr0 = passStringToWasm0(vif_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2464
|
+
const len0 = WASM_VECTOR_LEN;
|
|
2465
|
+
const ret = wasm.vif_ranking(ptr0, len0);
|
|
2466
|
+
deferred2_0 = ret[0];
|
|
2467
|
+
deferred2_1 = ret[1];
|
|
2468
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
2469
|
+
} finally {
|
|
2470
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
|
|
1773
2474
|
/**
|
|
1774
2475
|
* Performs Variance Inflation Factor (VIF) analysis via WASM.
|
|
1775
2476
|
*
|
|
@@ -1927,9 +2628,25 @@ export function wls_regression(y_json, x_vars_json, weights_json) {
|
|
|
1927
2628
|
function __wbg_get_imports() {
|
|
1928
2629
|
const import0 = {
|
|
1929
2630
|
__proto__: null,
|
|
2631
|
+
__wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
|
|
2632
|
+
const obj = arg1;
|
|
2633
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
2634
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2635
|
+
var len1 = WASM_VECTOR_LEN;
|
|
2636
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
2637
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
2638
|
+
},
|
|
1930
2639
|
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
1931
2640
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1932
2641
|
},
|
|
2642
|
+
__wbg_new_0_73afc35eb544e539: function() {
|
|
2643
|
+
const ret = new Date();
|
|
2644
|
+
return ret;
|
|
2645
|
+
},
|
|
2646
|
+
__wbg_toISOString_c04e0b8b70650552: function(arg0) {
|
|
2647
|
+
const ret = arg0.toISOString();
|
|
2648
|
+
return ret;
|
|
2649
|
+
},
|
|
1933
2650
|
__wbindgen_init_externref_table: function() {
|
|
1934
2651
|
const table = wasm.__wbindgen_externrefs;
|
|
1935
2652
|
const offset = table.grow(4);
|
|
@@ -1946,6 +2663,14 @@ function __wbg_get_imports() {
|
|
|
1946
2663
|
};
|
|
1947
2664
|
}
|
|
1948
2665
|
|
|
2666
|
+
let cachedDataViewMemory0 = null;
|
|
2667
|
+
function getDataViewMemory0() {
|
|
2668
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
2669
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
2670
|
+
}
|
|
2671
|
+
return cachedDataViewMemory0;
|
|
2672
|
+
}
|
|
2673
|
+
|
|
1949
2674
|
function getStringFromWasm0(ptr, len) {
|
|
1950
2675
|
ptr = ptr >>> 0;
|
|
1951
2676
|
return decodeText(ptr, len);
|
|
@@ -2033,6 +2758,7 @@ let wasmModule, wasm;
|
|
|
2033
2758
|
function __wbg_finalize_init(instance, module) {
|
|
2034
2759
|
wasm = instance.exports;
|
|
2035
2760
|
wasmModule = module;
|
|
2761
|
+
cachedDataViewMemory0 = null;
|
|
2036
2762
|
cachedUint8ArrayMemory0 = null;
|
|
2037
2763
|
wasm.__wbindgen_start();
|
|
2038
2764
|
return wasm;
|