Bug 1363828 - Replace custom isArray() by Array.isArray()
MozReview-Commit-ID: 9uErcVbMgLv
--- 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