Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf committed Aug 29, 2014
1 parent 6a97ad1 commit 83283aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ module.exports = function (str, options) {
// Iterate over the keys and setup the new object
//
for (var key in tempObj) {
if (Object.prototype.hasOwnProperty.call(tempObj, key)) {
if (tempObj.hasOwnProperty(key)) {
var newObj = internals.parseKeys(key, tempObj[key], options);
obj = Utils.merge(obj, newObj);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internals.stringify = function (obj, prefix) {
var values = [];

for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (obj.hasOwnProperty(key)) {
values = values.concat(internals.stringify(obj[key], prefix + '[' + key + ']'));
}
}
Expand All @@ -49,7 +49,7 @@ module.exports = function (obj, options) {
var keys = [];

for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (obj.hasOwnProperty(key)) {
keys = keys.concat(internals.stringify(obj[key], key));
}
}
Expand Down
23 changes: 4 additions & 19 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,17 @@ exports.arrayToObject = function (source) {
};


exports.clone = function (source, refs) {

if (typeof source !== 'object' ||
source === null) {

return source;
}
exports.clone = function (source) {

if (exports.isBuffer(source)) {
return source.toString();
}

refs = refs || [];

var lookup = refs.indexOf(source);
if (lookup !== -1) {
return refs[lookup];
}

var copy = Array.isArray(source) ? [] : source;

refs.push(source);
var copy = Array.isArray(source) ? [] : {};

for (var i in source) {
if (Object.prototype.hasOwnProperty.call(source, i)) {
copy[i] = exports.clone(source[i], refs);
copy[i] = source[i];
}
}

Expand Down Expand Up @@ -147,7 +132,7 @@ exports.compact = function (obj, refs) {
}

for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
if (obj.hasOwnProperty(key)) {
obj[key] = exports.compact(obj[key], refs);
}
}
Expand Down

0 comments on commit 83283aa

Please sign in to comment.