Skip to content

Commit

Permalink
Use less restrictive property check
Browse files Browse the repository at this point in the history
Fix #5
  • Loading branch information
bruth committed Sep 14, 2012
1 parent 5b4e2c8 commit f698bc3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
18 changes: 9 additions & 9 deletions jsonpatch.coffee
Expand Up @@ -142,7 +142,7 @@
getObject: (obj) ->
for loc in @path
if isArray obj then loc = parseInt(loc, 10)
if not hasOwnProperty.call(obj, loc)
if loc not of obj
throw new PatchConflictError('Array location out of bounds or not an instance property')
obj = obj[loc]
return obj
Expand Down Expand Up @@ -184,7 +184,7 @@
throw new PatchConflictError("Index #{acc} out of bounds")
obj.splice(acc, 0, value)
else
if hasOwnProperty.call(obj, acc)
if acc of obj
throw new PatchConflictError("Value at #{acc} exists")
obj[acc] = value
return
Expand All @@ -195,11 +195,11 @@

if isArray(obj)
acc = parseInt(acc, 10)
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
obj.splice(acc, 1)
else
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
delete obj[acc]
return
Expand All @@ -210,11 +210,11 @@

if isArray(obj)
acc = parseInt(acc, 10)
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
obj.splice(acc, 1, value)
else
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
obj[acc] = value
return
Expand All @@ -236,11 +236,11 @@

if isArray(obj)
acc = parseInt(acc, 10)
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
value = obj.splice(acc, 1)[0]
else
if not hasOwnProperty.call(obj, acc)
if acc not of obj
throw new PatchConflictError("Value at #{acc} does not exist")
value = obj[acc]
delete obj[acc]
Expand All @@ -255,7 +255,7 @@
throw new PatchConflictError("Index #{acc} out of bounds")
obj.splice(acc, 0, value)
else
if hasOwnProperty.call(obj, acc)
if acc of obj
throw new PatchConflictError("Value at #{acc} exists")
obj[acc] = value
return
Expand Down
18 changes: 9 additions & 9 deletions jsonpatch.js

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

0 comments on commit f698bc3

Please sign in to comment.