Bug 1363828 - Replace custom isArray() by Array.isArray() draft
authorflyingrub <flyinggrub@gmail.com>
Fri, 26 May 2017 17:05:18 +0200
changeset 585114 6019f5a26f9e38b755a63b52c46f2eccf878dc30
parent 585005 44e41de60c48a94a004494dd48f57dd1d8c157d8
child 585162 9eeba09ab5ed5d6b3352787a096c6332119cc91e
child 585164 a62fc652ff92ad0165141193f3a6c384b4de3e47
child 585179 fc90436e4078e67aa269b7cd263bb94ec8ac2418
child 585184 e2448ec68a55c518a8e3554409f4c1b02aef7173
push id61010
push userbmo:flyinggrub@gmail.com
push dateFri, 26 May 2017 15:05:42 +0000
bugs1363828
milestone55.0a1
Bug 1363828 - Replace custom isArray() by Array.isArray() MozReview-Commit-ID: 9uErcVbMgLv
toolkit/content/aboutTelemetry.js
--- a/toolkit/content/aboutTelemetry.js
+++ b/toolkit/content/aboutTelemetry.js
@@ -56,22 +56,18 @@ var documentRTLMode = "";
  * Caches result of check on first invocation.
  */
 function isRTL() {
   if (!documentRTLMode)
     documentRTLMode = window.getComputedStyle(document.body).direction;
   return (documentRTLMode == "rtl");
 }
 
-function isArray(arg) {
-  return Object.prototype.toString.call(arg) === "[object Array]";
-}
-
 function isFlatArray(obj) {
-  if (!isArray(obj)) {
+  if (!Array.isArray(obj)) {
     return false;
   }
   return !obj.some(e => typeof(e) == "object");
 }
 
 /**
  * This is a helper function for explodeObject.
  */
@@ -79,17 +75,17 @@ function flattenObject(obj, map, path, a
   for (let k of Object.keys(obj)) {
     let newPath = [...path, array ? "[" + k + "]" : k];
     let v = obj[k];
     if (!v || (typeof(v) != "object")) {
       map.set(newPath.join("."), v);
     } else if (isFlatArray(v)) {
       map.set(newPath.join("."), "[" + v.join(", ") + "]");
     } else {
-      flattenObject(v, map, newPath, isArray(v));
+      flattenObject(v, map, newPath, Array.isArray(v));
     }
   }
 }
 
 /**
  * This turns a JSON object into a "flat" stringified form.
  *
  * For an object like {a: "1", b: {c: "2", d: "3"}} it returns a Map of the