diff --git a/biome.json b/biome.json index ffad265675..a45844b6f2 100644 --- a/biome.json +++ b/biome.json @@ -15,7 +15,6 @@ "complexity": { "noUselessSwitchCase": "off", "noUselessTernary": "off", - "useArrowFunction": "off", "useOptionalChain": "off" }, "correctness": { @@ -30,7 +29,6 @@ "noGlobalEval": "off" }, "style": { - "noArguments": "off", "noCommaOperator": "off", "noParameterAssign": "off", "noUselessElse": "off", diff --git a/runtime/backtrace.js b/runtime/backtrace.js index af63260989..4d922e7bad 100644 --- a/runtime/backtrace.js +++ b/runtime/backtrace.js @@ -19,7 +19,7 @@ //Requires: jsoo_sys_getenv var caml_record_backtrace_env_flag = FLAG("with-js-error"); -(function () { +(() => { var r = jsoo_sys_getenv("OCAMLRUNPARAM"); if (r !== undefined) { var l = r.split(","); diff --git a/runtime/blake2.js b/runtime/blake2.js index ca17a471b0..5d07d2dcf0 100644 --- a/runtime/blake2.js +++ b/runtime/blake2.js @@ -1,6 +1,6 @@ //Provides: blake2b //Version: >= 5.2 -var blake2b = (function () { +var blake2b = (() => { // Blake2B in pure Javascript // Adapted from the reference implementation in RFC7693 // Ported to Javascript by DC - https://github.com/dcposch @@ -104,11 +104,7 @@ var blake2b = (function () { // These are offsets into a uint64 buffer. // Multiply them all by 2 to make them offsets into a uint32 buffer, // because this is Javascript and we don't have uint64s - const SIGMA82 = new Uint8Array( - SIGMA8.map(function (x) { - return x * 2; - }), - ); + const SIGMA82 = new Uint8Array(SIGMA8.map((x) => x * 2)); // Compression function. 'last' flag indicates last block. // Note we're representing 16 uint64s as 32 uint32s diff --git a/runtime/effect.js b/runtime/effect.js index d80a444932..0c9f33747f 100644 --- a/runtime/effect.js +++ b/runtime/effect.js @@ -60,7 +60,7 @@ function caml_push_trap(handler) { //If: effects function caml_pop_trap() { if (!caml_exn_stack) - return function (x) { + return (x) => { throw x; }; var h = caml_exn_stack[1]; diff --git a/runtime/fs_fake.js b/runtime/fs_fake.js index 1b88bc1496..3dea7de97b 100644 --- a/runtime/fs_fake.js +++ b/runtime/fs_fake.js @@ -42,9 +42,7 @@ MlFakeDevice.prototype.create_dir_if_needed = function (name) { this.content[res] = Symbol("directory"); } }; -MlFakeDevice.prototype.slash = function (name) { - return /\/$/.test(name) ? name : name + "/"; -}; +MlFakeDevice.prototype.slash = (name) => (/\/$/.test(name) ? name : name + "/"); MlFakeDevice.prototype.lookup = function (name) { if (!this.content[name] && this.lookupFun) { var res = this.lookupFun( @@ -347,18 +345,14 @@ MlFakeFile.prototype.read = function (offset, buf, pos, len) { //Requires: caml_raise_sys_error function MlFakeFd_out(fd, flags) { MlFakeFile.call(this, caml_create_bytes(0)); - this.log = function (s) { - return 0; - }; + this.log = (s) => 0; if (fd == 1 && typeof console.log == "function") this.log = console.log; else if (fd == 2 && typeof console.error == "function") this.log = console.error; else if (typeof console.log == "function") this.log = console.log; this.flags = flags; } -MlFakeFd_out.prototype.length = function () { - return 0; -}; +MlFakeFd_out.prototype.length = () => 0; MlFakeFd_out.prototype.write = function (offset, buf, pos, len) { if (this.log) { if ( diff --git a/runtime/fs_node.js b/runtime/fs_node.js index 8e6d6bf127..66461d630a 100644 --- a/runtime/fs_node.js +++ b/runtime/fs_node.js @@ -190,7 +190,7 @@ MlNodeDevice.prototype.opendir = function (name, raise_unix) { this.raise_nodejs_error(err, raise_unix); } }; -MlNodeDevice.prototype.raise_nodejs_error = function (err, raise_unix) { +MlNodeDevice.prototype.raise_nodejs_error = (err, raise_unix) => { var unix_error = caml_named_value("Unix.Unix_error"); if (raise_unix && unix_error) { var args = make_unix_err_args(err.code, err.syscall, err.path, err.errno); @@ -199,7 +199,7 @@ MlNodeDevice.prototype.raise_nodejs_error = function (err, raise_unix) { caml_raise_sys_error(err.toString()); } }; -MlNodeDevice.prototype.stats_from_js = function (js_stats) { +MlNodeDevice.prototype.stats_from_js = (js_stats) => { /* ===Unix.file_kind=== * type file_kind = * S_REG (** Regular file *) diff --git a/runtime/gc.js b/runtime/gc.js index 8855240497..549ef88854 100644 --- a/runtime/gc.js +++ b/runtime/gc.js @@ -65,7 +65,7 @@ function caml_final_register() { var all_finalizers = new globalThis.Set(); function caml_final_register_called_without_value(cb, a) { if (globalThis.FinalizationRegistry && a instanceof Object) { - var x = new globalThis.FinalizationRegistry(function (x) { + var x = new globalThis.FinalizationRegistry((x) => { all_finalizers.delete(x); cb(0); return; diff --git a/runtime/graphics.js b/runtime/graphics.js index 24c11e8ffb..c36512a685 100644 --- a/runtime/graphics.js +++ b/runtime/graphics.js @@ -76,7 +76,7 @@ function caml_gr_open_graph(info) { canvas.width = w; canvas.height = h; var ctx = caml_gr_state_create(canvas, w, h); - ctx.set_title = function (title) { + ctx.set_title = (title) => { doc.title = title; }; caml_gr_state_set(ctx); @@ -460,7 +460,7 @@ function caml_gr_draw_image(im, x, y) { canvas.height = s.height; canvas.getContext("2d").putImageData(im, 0, 0); var image = new globalThis.Image(); - image.onload = function () { + image.onload = () => { s.context.drawImage(image, x, s.height - im.height - y); im.image = image; }; diff --git a/runtime/io.js b/runtime/io.js index 2812b1bb96..6c56e3f5e7 100644 --- a/runtime/io.js +++ b/runtime/io.js @@ -94,7 +94,7 @@ function caml_sys_open(name, flags, _perms) { var file = root.device.open(root.rest, f); return caml_sys_open_internal(file, undefined); } -(function () { +(() => { function file(fd, flags) { if (fs_node_supported()) { return caml_sys_open_for_node(fd, flags); @@ -284,7 +284,7 @@ function caml_ml_channel_size_64(chanid) { //Requires: caml_ml_channel_get function caml_ml_set_channel_output(chanid, f) { var chan = caml_ml_channel_get(chanid); - chan.output = function (s) { + chan.output = (s) => { f(s); }; return 0; diff --git a/runtime/jslib.js b/runtime/jslib.js index 2d7887564f..8d215a55fe 100644 --- a/runtime/jslib.js +++ b/runtime/jslib.js @@ -111,9 +111,7 @@ function caml_callback(f, args) { }; var res = { joo_tramp: f, - joo_args: args.concat(function (x) { - return x; - }), + joo_args: args.concat((x) => x), }; do { caml_stack_depth = 40; @@ -378,12 +376,8 @@ function caml_ojs_new_arr(c, a) { //Provides: caml_js_wrap_callback const (const) //Requires: caml_callback function caml_js_wrap_callback(f) { - return function () { - var len = arguments.length; - if (len > 0) { - var args = new Array(len); - for (var i = 0; i < len; i++) args[i] = arguments[i]; - } else { + return (...args) => { + if (args.length <= 0) { args = [undefined]; } var res = caml_callback(f, args); @@ -394,76 +388,55 @@ function caml_js_wrap_callback(f) { //Provides: caml_js_wrap_callback_arguments //Requires: caml_callback function caml_js_wrap_callback_arguments(f) { - return function () { - var len = arguments.length; - var args = new Array(len); - for (var i = 0; i < len; i++) args[i] = arguments[i]; - return caml_callback(f, [args]); - }; + return (...args) => caml_callback(f, [args]); } //Provides: caml_js_wrap_callback_strict const //Requires: caml_callback function caml_js_wrap_callback_strict(arity, f) { - return function () { - var n = arguments.length; - var args = new Array(arity); - var len = Math.min(arguments.length, arity); - for (var i = 0; i < len; i++) args[i] = arguments[i]; + return (...args) => { + args.length = arity; return caml_callback(f, args); }; } //Provides: caml_js_wrap_callback_unsafe const (const) //Requires: caml_callback, caml_js_function_arity function caml_js_wrap_callback_unsafe(f) { - return function () { + return (...args) => { var len = caml_js_function_arity(f); - var args = new Array(len); - for (var i = 0; i < len; i++) args[i] = arguments[i]; + args.length = len; return caml_callback(f, args); }; } //Provides: caml_js_wrap_meth_callback const (const) //Requires: caml_callback, caml_js_wrap_callback function caml_js_wrap_meth_callback(f) { - return function () { - var len = arguments.length; - var args = new Array(len + 1); - args[0] = this; - for (var i = 0; i < len; i++) args[i + 1] = arguments[i]; - var res = caml_callback(f, args); + return function (...args) { + const res = caml_callback(f, [this].concat(args)); return res instanceof Function ? caml_js_wrap_callback(res) : res; }; } //Provides: caml_js_wrap_meth_callback_arguments const (const) //Requires: caml_callback function caml_js_wrap_meth_callback_arguments(f) { - return function () { - var len = arguments.length; - var args = new Array(len); - for (var i = 0; i < len; i++) args[i] = arguments[i]; + return function (...args) { return caml_callback(f, [this, args]); }; } //Provides: caml_js_wrap_meth_callback_strict const //Requires: caml_callback function caml_js_wrap_meth_callback_strict(arity, f) { - return function () { - var args = new Array(arity + 1); - var len = Math.min(arguments.length, arity); - args[0] = this; - for (var i = 0; i < len; i++) args[i + 1] = arguments[i]; - return caml_callback(f, args); + return function (...args) { + args.length = arity; + return caml_callback(f, [this].concat(args)); }; } //Provides: caml_js_wrap_meth_callback_unsafe const (const) //Requires: caml_callback, caml_js_function_arity function caml_js_wrap_meth_callback_unsafe(f) { - return function () { - var len = caml_js_function_arity(f) - 1; - var args = new Array(len + 1); - args[0] = this; - for (var i = 0; i < len; i++) args[i + 1] = arguments[i]; - return caml_callback(f, args); + return function (...args) { + const len = caml_js_function_arity(f) - 1; + args.length = len; + return caml_callback(f, [this].concat(args)); }; } diff --git a/runtime/marshal.js b/runtime/marshal.js index f6eca871cc..17c956caf1 100644 --- a/runtime/marshal.js +++ b/runtime/marshal.js @@ -307,17 +307,13 @@ var caml_custom_ops = { fixed_length: 4, }, _bigarray: { - deserialize: function (reader, sz) { - return caml_ba_deserialize(reader, sz, "_bigarray"); - }, + deserialize: (reader, sz) => caml_ba_deserialize(reader, sz, "_bigarray"), serialize: caml_ba_serialize, compare: caml_ba_compare, hash: caml_ba_hash, }, _bigarr02: { - deserialize: function (reader, sz) { - return caml_ba_deserialize(reader, sz, "_bigarr02"); - }, + deserialize: (reader, sz) => caml_ba_deserialize(reader, sz, "_bigarr02"), serialize: caml_ba_serialize, compare: caml_ba_compare, hash: caml_ba_hash, @@ -619,7 +615,7 @@ function caml_marshal_data_size(s, ofs) { //Provides: MlObjectTable var MlObjectTable; if (typeof globalThis.Map === "undefined") { - MlObjectTable = (function () { + MlObjectTable = (() => { /* polyfill (using linear search) */ function NaiveLookup(objs) { this.objs = objs; @@ -629,7 +625,7 @@ if (typeof globalThis.Map === "undefined") { if (this.objs[i] === v) return i; } }; - NaiveLookup.prototype.set = function () { + NaiveLookup.prototype.set = () => { // Do nothing here. [MlObjectTable.store] will push to [this.objs] directly. }; @@ -664,7 +660,7 @@ MlObjectTable.prototype.recall = function (v) { //Requires: caml_is_ml_string, caml_ml_string_length, caml_string_unsafe_get //Requires: MlObjectTable, caml_list_to_js_array, caml_custom_ops //Requires: caml_invalid_argument,caml_string_of_jsbytes, caml_is_continuation_tag -var caml_output_val = (function () { +var caml_output_val = (() => { function Writer() { this.chunk = []; } @@ -709,7 +705,7 @@ var caml_output_val = (function () { return this.chunk; }, }; - return function (v, flags) { + return (v, flags) => { flags = caml_list_to_js_array(flags); var no_sharing = flags.indexOf(0 /*Marshal.No_sharing*/) !== -1, diff --git a/runtime/md5.js b/runtime/md5.js index bf9a6f746c..d87d1793cf 100644 --- a/runtime/md5.js +++ b/runtime/md5.js @@ -53,7 +53,7 @@ function caml_md5_string(s, ofs, len) { } //Provides: caml_MD5Transform -var caml_MD5Transform = (function () { +var caml_MD5Transform = (() => { function add(x, y) { return (x + y) | 0; } @@ -74,7 +74,7 @@ var caml_MD5Transform = (function () { return xx(c ^ (b | ~d), a, b, x, s, t); } - return function (w, buffer) { + return (w, buffer) => { var a = w[0], b = w[1], c = w[2], diff --git a/runtime/stdlib.js b/runtime/stdlib.js index d9e267df76..0c52c91c6e 100644 --- a/runtime/stdlib.js +++ b/runtime/stdlib.js @@ -32,7 +32,7 @@ function caml_call_gen(f, args) { } else { switch (d) { case 1: { - var g = function (x) { + var g = (x) => { var nargs = new Array(argsLen + 1); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -41,7 +41,7 @@ function caml_call_gen(f, args) { break; } case 2: { - var g = function (x, y) { + var g = (x, y) => { var nargs = new Array(argsLen + 2); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -51,12 +51,11 @@ function caml_call_gen(f, args) { break; } default: { - var g = function () { - var extra_args = arguments.length == 0 ? 1 : arguments.length; - var nargs = new Array(args.length + extra_args); + var g = (...extra_args) => { + var nargs = new Array(args.length + extra_args.length); for (var i = 0; i < args.length; i++) nargs[i] = args[i]; - for (var i = 0; i < arguments.length; i++) - nargs[args.length + i] = arguments[i]; + for (var i = 0; i < extra_args.length; i++) + nargs[args.length + i] = extra_args[i]; return caml_call_gen(f, nargs); }; } @@ -79,7 +78,7 @@ function caml_call_gen(f, args) { var rest = args.slice(n - 1); var k = args[argsLen - 1]; args = args.slice(0, n); - args[n - 1] = function (g) { + args[n - 1] = (g) => { if (typeof g !== "function") return k(g); var args = rest.slice(); args[args.length - 1] = k; @@ -91,7 +90,7 @@ function caml_call_gen(f, args) { var k = args[argsLen]; switch (d) { case 1: { - var g = function (x, y) { + var g = (x, y) => { var nargs = new Array(argsLen + 2); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -101,7 +100,7 @@ function caml_call_gen(f, args) { break; } case 2: { - var g = function (x, y, z) { + var g = (x, y, z) => { var nargs = new Array(argsLen + 3); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -112,12 +111,11 @@ function caml_call_gen(f, args) { break; } default: { - var g = function () { - var extra_args = arguments.length == 0 ? 1 : arguments.length; - var nargs = new Array(argsLen + extra_args); + var g = (...extra_args) => { + var nargs = new Array(argsLen + extra_args.length); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; - for (var i = 0; i < arguments.length; i++) - nargs[argsLen + i] = arguments[i]; + for (var i = 0; i < extra_args.length; i++) + nargs[argsLen + i] = extra_args[i]; return caml_call_gen(f, nargs); }; } diff --git a/runtime/stdlib_modern.js b/runtime/stdlib_modern.js index f942292d4f..172fd945b3 100644 --- a/runtime/stdlib_modern.js +++ b/runtime/stdlib_modern.js @@ -30,7 +30,7 @@ function caml_call_gen(f, args) { } else { switch (d) { case 1: { - var g = function (x) { + var g = (x) => { var nargs = new Array(argsLen + 1); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -39,7 +39,7 @@ function caml_call_gen(f, args) { break; } case 2: { - var g = function (x, y) { + var g = (x, y) => { var nargs = new Array(argsLen + 2); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -49,12 +49,11 @@ function caml_call_gen(f, args) { break; } default: { - var g = function () { - var extra_args = arguments.length == 0 ? 1 : arguments.length; - var nargs = new Array(args.length + extra_args); + var g = (...extra_args) => { + var nargs = new Array(args.length + extra_args.length); for (var i = 0; i < args.length; i++) nargs[i] = args[i]; - for (var i = 0; i < arguments.length; i++) - nargs[args.length + i] = arguments[i]; + for (var i = 0; i < extra_args.length; i++) + nargs[args.length + i] = extra_args[i]; return caml_call_gen(f, nargs); }; } @@ -75,7 +74,7 @@ function caml_call_gen(f, args) { var rest = args.slice(n - 1); var k = args[argsLen - 1]; args = args.slice(0, n); - args[n - 1] = function (g) { + args[n - 1] = (g) => { if (typeof g !== "function") return k(g); var args = rest.slice(); args[args.length - 1] = k; @@ -87,7 +86,7 @@ function caml_call_gen(f, args) { var k = args[argsLen]; switch (d) { case 1: { - var g = function (x, y) { + var g = (x, y) => { var nargs = new Array(argsLen + 2); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -97,7 +96,7 @@ function caml_call_gen(f, args) { break; } case 2: { - var g = function (x, y, z) { + var g = (x, y, z) => { var nargs = new Array(argsLen + 3); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; nargs[argsLen] = x; @@ -108,12 +107,11 @@ function caml_call_gen(f, args) { break; } default: { - var g = function () { - var extra_args = arguments.length == 0 ? 1 : arguments.length; - var nargs = new Array(argsLen + extra_args); + var g = (...extra_args) => { + var nargs = new Array(argsLen + extra_args.length); for (var i = 0; i < argsLen; i++) nargs[i] = args[i]; - for (var i = 0; i < arguments.length; i++) - nargs[argsLen + i] = arguments[i]; + for (var i = 0; i < extra_args.length; i++) + nargs[argsLen + i] = extra_args[i]; return caml_call_gen(f, nargs); }; } diff --git a/runtime/str.js b/runtime/str.js index a58190b805..5578d0cae2 100644 --- a/runtime/str.js +++ b/runtime/str.js @@ -24,7 +24,7 @@ //Requires: caml_jsbytes_of_string, caml_js_from_array, caml_uint8_array_of_string //Requires: caml_string_get -var re_match = (function () { +var re_match = (() => { var re_word_letters = [ 0x00, 0x00, 0x00, 0x00 /* 0x00-0x1F: none */, 0x00, 0x00, 0xff, 0x03 /* 0x20-0x3F: digits 0-9 */, 0xfe, 0xff, 0xff, @@ -86,7 +86,7 @@ var re_match = (function () { } groups[0].start = pos; - var backtrack = function () { + var backtrack = () => { while (stack.length) { var item = stack.pop(); if (item.undo) { @@ -100,11 +100,11 @@ var re_match = (function () { quit = true; }; - var push = function (item) { + var push = (item) => { stack.push(item); }; - var accept = function () { + var accept = () => { groups[0].end = pos; var result = new Array(1 + groups.length * 2); result[0] = 0; // tag @@ -119,7 +119,7 @@ var re_match = (function () { return result; }; - var prefix_match = function () { + var prefix_match = () => { if (partial) return accept(); else backtrack(); }; diff --git a/runtime/sys.js b/runtime/sys.js index 9e596f1781..8527359962 100644 --- a/runtime/sys.js +++ b/runtime/sys.js @@ -134,7 +134,7 @@ function caml_sys_unsafe_getenv(name) { //Provides: caml_argv //Requires: caml_string_of_jsstring -var caml_argv = (function () { +var caml_argv = (() => { var process = globalThis.process; var main = "a.out"; var args = []; @@ -369,12 +369,12 @@ function caml_sys_is_regular_file(name) { function caml_setup_uncaught_exception_handler() { var process = globalThis.process; if (process && process.on) { - process.on("uncaughtException", function (err, origin) { + process.on("uncaughtException", (err, origin) => { caml_fatal_uncaught_exception(err); process.exit(2); }); } else if (globalThis.addEventListener) { - globalThis.addEventListener("error", function (event) { + globalThis.addEventListener("error", (event) => { if (event.error) { caml_fatal_uncaught_exception(event.error); } diff --git a/runtime/weak.js b/runtime/weak.js index ad5769abd4..a238a24106 100644 --- a/runtime/weak.js +++ b/runtime/weak.js @@ -169,7 +169,7 @@ function caml_ephe_get_data_copy(x) { function caml_ephe_set_data(x, data) { if (globalThis.FinalizationRegistry && globalThis.WeakRef) { if (!(x[1] instanceof globalThis.FinalizationRegistry)) { - x[1] = new globalThis.FinalizationRegistry(function () { + x[1] = new globalThis.FinalizationRegistry(() => { caml_ephe_unset_data(x); }); //register all keys diff --git a/runtime/zstd.js b/runtime/zstd.js index 01da0cad12..21bc73c2de 100644 --- a/runtime/zstd.js +++ b/runtime/zstd.js @@ -1,6 +1,6 @@ //Provides: zstd_decompress //Version: >= 5.1 -var zstd_decompress = (function () { +var zstd_decompress = (() => { // aliases for shorter compressed code (most minifers don't do this) var ab = ArrayBuffer, u8 = Uint8Array, @@ -8,7 +8,7 @@ var zstd_decompress = (function () { i16 = Int16Array, u32 = Uint32Array, i32 = Int32Array; - var slc = function (v, s, e) { + var slc = (v, s, e) => { if (u8.prototype.slice) return u8.prototype.slice.call(v, s, e); if (s == null || s < 0) s = 0; if (e == null || e > v.length) e = v.length; @@ -16,14 +16,14 @@ var zstd_decompress = (function () { n.set(v.subarray(s, e)); return n; }; - var fill = function (v, n, s, e) { + var fill = (v, n, s, e) => { if (u8.prototype.fill) return u8.prototype.fill.call(v, n, s, e); if (s == null || s < 0) s = 0; if (e == null || e > v.length) e = v.length; for (; s < e; ++s) v[s] = n; return v; }; - var cpw = function (v, t, s, e) { + var cpw = (v, t, s, e) => { if (u8.prototype.copyWithin) return u8.prototype.copyWithin.call(v, t, s, e); if (s == null || s < 0) s = 0; @@ -44,23 +44,22 @@ var zstd_decompress = (function () { "match distance too far back", "unexpected EOF", ]; - var err = function (ind, msg, nt) { + var err = (ind, msg, nt) => { var e = new Error(msg || ec[ind]); e.code = ind; if (!nt) throw e; return e; }; - var rb = function (d, b, n) { + var rb = (d, b, n) => { var i = 0, o = 0; for (; i < n; ++i) o |= d[b++] << (i << 3); return o; }; - var b4 = function (d, b) { - return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; - }; + var b4 = (d, b) => + (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; // read Zstandard frame header - var rzfh = function (dat, w) { + var rzfh = (dat, w) => { var n3 = dat[0] | (dat[1] << 8) | (dat[2] << 16); if (n3 == 0x2fb528 && dat[3] == 253) { // Zstandard @@ -111,13 +110,13 @@ var zstd_decompress = (function () { err(0); }; // most significant bit for nonzero - var msb = function (val) { + var msb = (val) => { var bits = 0; for (; 1 << bits <= val; ++bits); return bits - 1; }; // read finite state entropy - var rfse = function (dat, bt, mal) { + var rfse = (dat, bt, mal) => { // table pos var tpos = (bt << 3) + 4; // accuracy log @@ -215,7 +214,7 @@ var zstd_decompress = (function () { ]; }; // read huffman - var rhu = function (dat, bt) { + var rhu = (dat, bt) => { // index weight count var i = 0, wc = -1; @@ -350,7 +349,7 @@ var zstd_decompress = (function () { 5, )[1]; // bits to baseline - var b2bl = function (b, s) { + var b2bl = (b, s) => { var len = b.length, bl = new i32(len); for (var i = 0; i < len; ++i) { @@ -381,7 +380,7 @@ var zstd_decompress = (function () { // match length baseline var mlbl = /*#__PURE__ */ b2bl(mlb, 3); // decode huffman stream - var dhu = function (dat, out, hu) { + var dhu = (dat, out, hu) => { var len = dat.length, ss = out.length, lb = dat[len - 1], @@ -404,7 +403,7 @@ var zstd_decompress = (function () { }; // decode huffman stream 4x // TODO: use workers to parallelize - var dhu4 = function (dat, out, hu) { + var dhu4 = (dat, out, hu) => { var bt = 6; var ss = out.length, sz1 = (ss + 3) >> 2, @@ -428,7 +427,7 @@ var zstd_decompress = (function () { dhu(dat.subarray(bt), out.subarray(sz3), hu); }; // read Zstandard block - var rzb = function (dat, st, out) { + var rzb = (dat, st, out) => { var _a; var bt = st.b; // byte 0 block type @@ -643,7 +642,7 @@ var zstd_decompress = (function () { err(2); }; // concat - var cct = function (bufs, ol) { + var cct = (bufs, ol) => { if (bufs.length == 1) return bufs[0]; var buf = new u8(ol); for (var i = 0, b = 0; i < bufs.length; ++i) {