Skip to content

Commit

Permalink
better clone objects with no prototype for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Silva committed Dec 27, 2013
1 parent b5dbf5d commit fef0b85
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/our-tests-no-hasOwnProperty.js
Expand Up @@ -22,6 +22,12 @@ var BLACKLISTED_TESTS = {
};

function duplicateWithNullPrototype(src) {
if (!(src instanceof Object)) { return src; }

if (Array.isArray(src)) {
return Array.prototype.map.call(src, duplicateWithNullPrototype);
}

var dest = Object.create(null);
Object.keys(src).forEach(function(key) {
if (src[key] instanceof Object) {
Expand Down

0 comments on commit fef0b85

Please sign in to comment.