sindresorhus/sort-keys

Incorrect behavior for deep sort of directly circular objects

Closed this issue · 1 comments

var sortKeys = require('sort-keys');
var obj = { z: 0 };
obj.self = obj;
var sortedObj = sortKeys(obj, {deep:true});
console.log(sortedObj);                 //{ self: { z: 0, self: [Circular] }, z: 0 }
console.log(sortedObj.self === obj);    //true

That is, sortedObj still contains a reference to obj (whose keys are unsorted) rather than itself.

Fixed by b698b51.