Skip to content

Commit

Permalink
Hopefully final fix for #36
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Lagendijk committed Feb 26, 2015
1 parent d3f9735 commit dfbaa12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lodash-deep.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
currentObject[property] = value;
}
else if(!_.isObject(currentObject[property])){
currentObject[property] = isNaN(properties[index + 1]) ? {}: [];
currentObject[property] = isArrayKey(properties[index + 1]) ? [] : {};
}
currentObject = currentObject[property];
});
Expand Down Expand Up @@ -468,5 +468,16 @@
};
}

/**
* Checks whether key is a valid array key
* @param key
* @returns {boolean}
*/
function isArrayKey(key){
var array = [];
array[key] = null;
return array.length > 0;
}

return mixins;
}));
2 changes: 1 addition & 1 deletion lodash-deep.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dfbaa12

Please sign in to comment.