New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jsonpatch

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonpatch - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

9

lib/jsonpatch.js

@@ -136,4 +136,4 @@ /* @preserve

} else {
// Must be a non-negative integer in base-10
if (!segment.match(/^[0-9]*$/)) {
// Must be a non-negative integer in base-10 without leading zeros
if (!segment.match(/^0$|^[1-9][0-9]*$/)) {
throw new PatchApplyError('Expected a number to segment an array');

@@ -395,5 +395,8 @@ }

for (var i = 0; i < a.length; i++) {
return deepEqual(a[i], b[i]);
if(!deepEqual(a[i], b[i])) {
return false;
}
}
}
return true;
} else {

@@ -400,0 +403,0 @@ // Check each key of the object recursively

{
"name": "jsonpatch",
"version": "3.0.1",
"version": "3.1.0",
"description": "An implementation of JSON Patch and JSON Pointer IETF RFCs",

@@ -39,5 +39,5 @@ "keywords": ["diff", "patch", "json", "jsonpatch", "jsonpointer"],

"engines": { "node": ">=0.4.0" },
"licenses": ["MIT"] ,
"license": "MIT" ,
"main": "lib/jsonpatch.js",
"typings": "lib/jsonpatch.d.ts"
}

@@ -118,2 +118,8 @@ // A wrapper round the tests from https://github.com/json-patch/json-patch-tests

{ "comment": "Add, /foo/ deep target (trailing slash)",
"doc": {"foo": {}},
"patch": [{"op": "add", "path": "/foo/", "value": 1}],
"expected": {"foo": {"": 1}}
},
{ "comment": "Add composite value at top level",

@@ -166,6 +172,12 @@ "doc": {"foo": 1},

{ "doc": ["foo", "sil"],
{ "comment": "push item to array via last index + 1",
"doc": ["foo", "sil"],
"patch": [{"op":"add", "path": "/2", "value": "bar"}],
"expected": ["foo", "sil", "bar"] },
{ "comment": "add item to array at index > length should fail",
"doc": ["foo", "sil"],
"patch": [{"op": "add", "path": "/3", "value": "bar"}],
"error": "index is greater than number of items in array" },
{ "comment": "test against implementation-specific numeric parsing",

@@ -231,2 +243,7 @@ "doc": {"1e0": "foo"},

{ "comment": "replace whole document",
"doc": {"foo": "bar"},
"patch": [{"op": "replace", "path": "", "value": {"baz": "qux"}}],
"expected": {"baz": "qux"} },
{ "comment": "spurious patch properties",

@@ -239,4 +256,29 @@ "doc": {"foo": 1},

"patch": [{"op": "test", "path": "/foo", "value": null}],
"comment": "null value should still be valid obj property" },
"comment": "null value should be valid obj property" },
{ "doc": {"foo": null},
"patch": [{"op": "replace", "path": "/foo", "value": "truthy"}],
"expected": {"foo": "truthy"},
"comment": "null value should be valid obj property to be replaced with something truthy" },
{ "doc": {"foo": null},
"patch": [{"op": "move", "from": "/foo", "path": "/bar"}],
"expected": {"bar": null},
"comment": "null value should be valid obj property to be moved" },
{ "doc": {"foo": null},
"patch": [{"op": "copy", "from": "/foo", "path": "/bar"}],
"expected": {"foo": null, "bar": null},
"comment": "null value should be valid obj property to be copied" },
{ "doc": {"foo": null},
"patch": [{"op": "remove", "path": "/foo"}],
"expected": {},
"comment": "null value should be valid obj property to be removed" },
{ "doc": {"foo": "bar"},
"patch": [{"op": "replace", "path": "/foo", "value": null}],
"expected": {"foo": null},
"comment": "null value should still be valid obj property replace other value" },
{ "doc": {"foo": {"foo": 1, "bar": 2}},

@@ -325,2 +367,97 @@ "patch": [{"op": "test", "path": "/foo", "value": {"bar": 2, "foo": 1}}],

{ "comment": "test remove with bad number should fail",
"doc": {"foo": 1, "baz": [{"qux": "hello"}]},
"patch": [{"op": "remove", "path": "/baz/1e0/qux"}],
"error": "remove op shouldn't remove from array with bad number" },
{ "comment": "test remove on array",
"doc": [1, 2, 3, 4],
"patch": [{"op": "remove", "path": "/0"}],
"expected": [2, 3, 4] },
{ "comment": "test repeated removes",
"doc": [1, 2, 3, 4],
"patch": [{"op": "remove", "path": "/1"},
{"op": "remove", "path": "/2"}],
"expected": [1, 3] },
{ "comment": "test remove with bad index should fail",
"doc": [1, 2, 3, 4],
"patch": [{"op": "remove", "path": "/1e0"}],
"error": "remove op shouldn't remove from array with bad number" },
{ "comment": "test replace with bad number should fail",
"doc": [""],
"patch": [{"op": "replace", "path": "/1e0", "value": false}],
"error": "replace op shouldn't replace in array with bad number" },
{ "comment": "test copy with bad number should fail",
"doc": {"baz": [1, 2, 3], "bar": 1},
"patch": [{"op": "copy", "from": "/baz/1e0", "path": "/boo"}],
"error": "copy op shouldn't work with bad number" },
{ "comment": "test move with bad number should fail",
"doc": {"foo": 1, "baz": [1, 2, 3, 4]},
"patch": [{"op": "move", "from": "/baz/1e0", "path": "/foo"}],
"error": "move op shouldn't work with bad number" },
{ "comment": "test add with bad number should fail",
"doc": ["foo", "sil"],
"patch": [{"op": "add", "path": "/1e0", "value": "bar"}],
"error": "add op shouldn't add to array with bad number" },
{ "comment": "missing 'value' parameter to add",
"doc": [1],
"patch": [{"op": "add", "path": "/-"}],
"error": "missing 'value' parameter" },
{ "comment": "missing 'value' parameter to replace",
"doc": [1],
"patch": [{"op": "replace", "path": "/0"}],
"error": "missing 'value' parameter" },
{ "comment": "missing 'value' parameter to test",
"doc": [null],
"patch": [{"op": "test", "path": "/0"}],
"error": "missing 'value' parameter" },
{ "comment": "missing value parameter to test - where undef is falsy",
"doc": [false],
"patch": [{"op": "test", "path": "/0"}],
"error": "missing 'value' parameter" },
{ "comment": "missing from parameter to copy",
"doc": [1],
"patch": [{"op": "copy", "path": "/-"}],
"error": "missing 'from' parameter" },
{ "comment": "missing from parameter to move",
"doc": {"foo": 1},
"patch": [{"op": "move", "path": ""}],
"error": "missing 'from' parameter" },
{ "comment": "duplicate ops",
"doc": {"foo": "bar"},
"patch": [{
"op": "add", "path": "/baz", "value": "qux",
"op": "move", "from": "/foo"
}],
"error": "patch has two 'op' members",
"disabled": true },
{ "comment": "unrecognized op should fail",
"doc": {"foo": 1},
"patch": [{"op": "spam", "path": "/foo", "value": 1}],
"error": "Unrecognized op 'spam'" },
{ "comment": "test with bad array number that has leading zeros",
"doc": ["foo", "bar"],
"patch": [{"op": "test", "path": "/00", "value": "foo"}],
"error": "test op should reject the array value, it has leading zeros" },
{ "comment": "test with bad array number that has leading zeros",
"doc": ["foo", "bar"],
"patch": [{"op": "test", "path": "/01", "value": "bar"}],
"error": "test op should reject the array value, it has leading zeros" },
{ "comment": "tests complete" }

@@ -505,3 +642,3 @@ ]);

{
"comment": "A.12. Adding to a Non-existant Target",
"comment": "A.12. Adding to a Non-existent Target",
"doc": {

@@ -513,3 +650,3 @@ "foo": "bar"

],
"error": "add to a non-existant target"
"error": "add to a non-existent target"
},

@@ -516,0 +653,0 @@

@@ -147,6 +147,3 @@ if ('function' === typeof require) {

"/m~0n" :8,
"/m~0n~0o" :"blarg",
// Extra examples
"/numbers/010": 10,
"/numbers/00010": 10
"/m~0n~0o" :"blarg"
};

@@ -153,0 +150,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc