Skip to content

Commit

Permalink
support setting to undefined values
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz committed May 9, 2011
1 parent 2ce2b7b commit ed44afe
Showing 1 changed file with 48 additions and 43 deletions.
91 changes: 48 additions & 43 deletions lib/nowUtil.js
Expand Up @@ -422,58 +422,63 @@ var nowUtil = {

switch (typeof value) {
case 'object':
if (!value) {
if (!value) {
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push(null);
}
return nu;
}
for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push(null);
nu.push({$ref: paths[i]});
}
return nu;
}
for (i = 0; i < objects.length; i += 1) {
if (objects[i] === value) {
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push({$ref: paths[i]});
}
return nu;
}
}
objects.push(value);
paths.push(path);
var values;
if (Object.prototype.toString.apply(value) === '[object Array]') {
nu = [];
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push([]);
}
objects.push(value);
paths.push(path);
var values;
if (Object.prototype.toString.apply(value) === '[object Array]') {
nu = [];
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push([]);
}
for (i = 0; i < value.length; i += 1) {
values = derez(value[i], path + '[' + i + ']', fqn+"."+i);
for(j in values) {
if (values.hasOwnProperty(j)) {
nu[j][i] = values[j];
}
}
}
} else {
nu = [];
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push({});
}
for (var name in value) {
if (Object.prototype.hasOwnProperty.call(value, name)) {
values = derez(value[name], path + '[' + JSON.stringify(name) + ']', fqn+"."+name);
for(j in values) {
if (values.hasOwnProperty(j)) {
nu[j][name] = values[j];
}
}
}
for (i = 0; i < value.length; i += 1) {
values = derez(value[i], path + '[' + i + ']', fqn+"."+i);
for(j in values) {
if (values.hasOwnProperty(j)) {
nu[j][i] = values[j];
}
}
}
return nu;
case 'function':
} else {
nu = [];
for(i = 0; i < funcHandlers.length; i += 1) {
output[i] = funcHandlers[i](fqn, value);
nu.push({});
}
return output;
for (var name in value) {
if (Object.prototype.hasOwnProperty.call(value, name)) {
values = derez(value[name], path + '[' + JSON.stringify(name) + ']', fqn+"."+name);
for(j in values) {
if (values.hasOwnProperty(j)) {
nu[j][name] = values[j];
}
}
}
}
}
return nu;
case 'function':
for(i = 0; i < funcHandlers.length; i += 1) {
output[i] = funcHandlers[i](fqn, value);
}
return output;
case 'undefined':
for(i = 0; i < funcHandlers.length; i += 1) {
nu.push(null);
}
return nu;
case 'number':
case 'string':
case 'boolean':
Expand Down

0 comments on commit ed44afe

Please sign in to comment.