commit
6742f09a4f
@ -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;
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user