diff --git a/4chan_x.user.js b/4chan_x.user.js index 8fca7d626..8f0152165 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -186,17 +186,15 @@ (flatten = function(parent, obj) { var key, val, _results; - if (typeof obj === 'object') { - if (obj.length) { - return conf[parent] = obj[0]; - } else { - _results = []; - for (key in obj) { - val = obj[key]; - _results.push(flatten(key, val)); - } - return _results; + if (obj instanceof Array) { + return conf[parent] = obj[0]; + } else if (typeof obj === 'object') { + _results = []; + for (key in obj) { + val = obj[key]; + _results.push(flatten(key, val)); } + return _results; } else { return conf[parent] = obj; } diff --git a/script.coffee b/script.coffee index 6d7a7f3ef..329c28c48 100644 --- a/script.coffee +++ b/script.coffee @@ -112,12 +112,10 @@ log = console.log.bind? console # flatten the config conf = {} (flatten = (parent, obj) -> - if typeof obj is 'object' - # array - if obj.length - conf[parent] = obj[0] - # object - else for key, val of obj + if obj instanceof Array + conf[parent] = obj[0] + else if typeof obj is 'object' + for key, val of obj flatten key, val else # string or number conf[parent] = obj