Explorar el Código

ajax: use Object.entries

Simon Legner hace 1 año
padre
commit
228090ad83
Se han modificado 1 ficheros con 6 adiciones y 8 borrados
  1. 6 8
      assets/javascripts/lib/ajax.js

+ 6 - 8
assets/javascripts/lib/ajax.js

@@ -59,14 +59,12 @@ var serializeData = function (options) {
 };
 
 var serializeParams = (params) =>
-  (() => {
-    const result = [];
-    for (var key in params) {
-      var value = params[key];
-      result.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
-    }
-    return result;
-  })().join("&");
+  Object.entries(params)
+    .map(
+      ([key, value]) =>
+        `${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
+    )
+    .join("&");
 
 var applyCallbacks = function (xhr, options) {
   if (!options.async) {