Skip to content

Commit

Permalink
no spread to build array
Browse files Browse the repository at this point in the history
  • Loading branch information
hhugo committed Dec 9, 2024
1 parent c0c7179 commit ea9c35a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions runtime/js/jslib.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ function caml_js_wrap_callback_unsafe(f) {
//Requires: caml_callback, caml_js_wrap_callback
function caml_js_wrap_meth_callback(f) {
return function (...args) {
var res = caml_callback(f, [this, ...args]);
args.unshift(this);
var res = caml_callback(f, args);
return res instanceof Function ? caml_js_wrap_callback(res) : res;
};
}
Expand All @@ -431,8 +432,8 @@ function caml_js_wrap_meth_callback_arguments(f) {
//Requires: caml_callback
function caml_js_wrap_meth_callback_strict(arity, f) {
return function (...args) {
args = [this, ...args];
args.length = arity + 1;
args.length = arity;
args.unshift(this);
return caml_callback(f, args);
};
}
Expand All @@ -441,7 +442,7 @@ function caml_js_wrap_meth_callback_strict(arity, f) {
function caml_js_wrap_meth_callback_unsafe(f) {
return function (...args) {
var len = caml_js_function_arity(f);
args = [this, ...args];
args.unshift(this);
args.length = len;
return caml_callback(f, args);
};
Expand Down
4 changes: 2 additions & 2 deletions runtime/js/stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function caml_call_gen(f, args) {
default: {
var g = function (...extra_args) {
if (extra_args.length === 0) extra_args = [undefined];
return caml_call_gen(f, [...args, ...extra_args]);
return caml_call_gen(f, args.concat(extra_args));
};
}
}
Expand Down Expand Up @@ -111,7 +111,7 @@ function caml_call_gen(f, args) {
args.length = argsLen;
var g = function (...extra_args) {
if (extra_args.length === 0) extra_args = [undefined];
return caml_call_gen(f, [...args, ...extra_args]);
return caml_call_gen(f, args.concat(extra_args));
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/js/stdlib_modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function caml_call_gen(f, args) {
default: {
var g = function (...extra_args) {
if (extra_args.length === 0) extra_args = [undefined];
return caml_call_gen(f, [...args, ...extra_args]);
return caml_call_gen(f, args.concat(extra_args));
};
}
}
Expand Down Expand Up @@ -107,7 +107,7 @@ function caml_call_gen(f, args) {
args.length = argsLen;
var g = function (...extra_args) {
if (extra_args.length === 0) extra_args = [undefined];
return caml_call_gen(f, [...args, ...extra_args]);
return caml_call_gen(f, args.concat(extra_args));
};
}
}
Expand Down

0 comments on commit ea9c35a

Please sign in to comment.