Replace `arguments` keyword with rest parameter

This commit is contained in:
Adam Scott 2024-07-29 15:10:28 -04:00
parent 0e9caa2d9c
commit 27dfbd9c04
No known key found for this signature in database
GPG Key ID: F6BA2A0302E21A77
3 changed files with 9 additions and 10 deletions

View File

@ -194,8 +194,8 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
* @ignore
* @type {?function(...*)}
*/
onPrint: function () {
console.log.apply(console, Array.from(arguments)); // eslint-disable-line no-console
onPrint: function (...args) {
console.log.apply(console, ...args); // eslint-disable-line no-console
},
/**
* A callback function for handling the standard error stream. This method should usually only be used in debug pages.
@ -209,8 +209,8 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-
* @ignore
* @type {?function(...*)}
*/
onPrintError: function (var_args) {
console.error.apply(console, Array.from(arguments)); // eslint-disable-line no-console
onPrintError: function (...args) {
console.error.apply(console, ...args); // eslint-disable-line no-console
},
};

View File

@ -215,7 +215,7 @@ const GodotJSWrapper = {
godot_js_wrapper_create_cb: function (p_ref, p_func) {
const func = GodotRuntime.get_func(p_func);
let id = 0;
const cb = function () {
const cb = function (...args) {
if (!GodotJSWrapper.get_proxied_value(id)) {
return undefined;
}
@ -223,7 +223,6 @@ const GodotJSWrapper = {
// "godot_js_wrapper_object_set_cb_ret" upon calling the user function.
// This is safe! JavaScript is single threaded (and using it in threads is not a good idea anyway).
GodotJSWrapper.cb_ret = null;
const args = Array.from(arguments);
const argsProxy = new GodotJSWrapper.MyProxy(args);
func(p_ref, argsProxy.get_id(), args.length);
argsProxy.unref();

View File

@ -40,12 +40,12 @@ const GodotRuntime = {
/*
* Prints
*/
error: function () {
err.apply(null, Array.from(arguments)); // eslint-disable-line no-undef
error: function (...args) {
err.apply(null, ...args); // eslint-disable-line no-undef
},
print: function () {
out.apply(null, Array.from(arguments)); // eslint-disable-line no-undef
print: function (...args) {
out.apply(null, ...args); // eslint-disable-line no-undef
},
/*