Skip to content

Commit

Permalink
Fix _objectKeys to ignore array properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin committed Nov 4, 2015
1 parent e2f331d commit bac89d6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/json-patch-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ var jsonpatch;
return;
}

var _objectKeys = (function () {
if (Object.keys)
return Object.keys;

return function (o) {
var keys = [];
for (var i in o) {
if (o.hasOwnProperty(i)) {
keys.push(i);
}
var _objectKeys = function (obj) {
if (_isArray(obj)) {
return Array.apply(null, { length: obj.length }).map(function (e, i, a) { return i.toString(); });
}

if (Object.keys) {
return Object.keys(obj);
}

var keys = [];
for (var i in o) {
if (o.hasOwnProperty(i)) {
keys.push(i);
}
return keys;
};
})();
}
return keys;
};

function _equals(a, b) {
switch (typeof a) {
Expand Down

0 comments on commit bac89d6

Please sign in to comment.