Skip to content

Commit

Permalink
Fix hasUndefined #163
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero committed May 1, 2017
1 parent 84053cc commit 17b141b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/json-patch-duplex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ declare module jsonpatch {
class JsonPatchError extends Error {
message: string;
name: string;
index: number;
operation: any;
tree: any;
index?: number;
operation?: any;
tree?: any;
constructor(message: string, name: string, index?: number, operation?: any, tree?: any);
}
/**
Expand Down
8 changes: 5 additions & 3 deletions src/json-patch-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,11 @@ var jsonpatch;
if (obj === undefined) {
return true;
}
if (typeof obj == "array" || typeof obj == "object") {
for (var i in obj) {
if (hasUndefined(obj[i])) {
if (obj && (_isArray(obj) || typeof obj === "object")) {
var objKeys = _objectKeys(obj);
var objKeysLength = objKeys.length;
for (var i = 0; i < objKeysLength; i++) {
if (hasUndefined(obj[objKeys[i]])) {
return true;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/json-patch-duplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,15 +567,16 @@ module jsonpatch {
if (obj === undefined) {
return true;
}
if (obj && (_isArray(obj) || typeof obj === "object")) {
var objKeys = _objectKeys(obj);
var objKeysLength = objKeys.length;

if (typeof obj == "array" || typeof obj == "object") {
for (var i in obj) {
if (hasUndefined(obj[i])) {
for (var i = 0; i < objKeysLength; i++) {
if (hasUndefined(obj[objKeys[i]])) {
return true;
}
}
}

return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/json-patch.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ declare module jsonpatch {
class JsonPatchError extends Error {
message: string;
name: string;
index: number;
operation: any;
tree: any;
index?: number;
operation?: any;
tree?: any;
constructor(message: string, name: string, index?: number, operation?: any, tree?: any);
}
/**
Expand Down
8 changes: 5 additions & 3 deletions src/json-patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ var jsonpatch;
if (obj === undefined) {
return true;
}
if (typeof obj == "array" || typeof obj == "object") {
for (var i in obj) {
if (hasUndefined(obj[i])) {
if (obj && (_isArray(obj) || typeof obj === "object")) {
var objKeys = _objectKeys(obj);
var objKeysLength = objKeys.length;
for (var i = 0; i < objKeysLength; i++) {
if (hasUndefined(obj[objKeys[i]])) {
return true;
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/json-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,16 @@ module jsonpatch {
if (obj === undefined) {
return true;
}
if (obj && (_isArray(obj) || typeof obj === "object")) {
var objKeys = _objectKeys(obj);
var objKeysLength = objKeys.length;

if (typeof obj == "array" || typeof obj == "object") {
for (var i in obj) {
if (hasUndefined(obj[i])) {
for (var i = 0; i < objKeysLength; i++) {
if (hasUndefined(obj[objKeys[i]])) {
return true;
}
}
}

return false;
}

Expand Down

0 comments on commit 17b141b

Please sign in to comment.