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 1.0.1 to 2.0.0

~/.uzbl/config/configstore/insight-bower.yml

2

bower.json
{
"name": "jsonpatch",
"version": "1.0.0-dev",
"version": "1.0.1-dev",
"main": "lib/jsonpatch.js",

@@ -5,0 +5,0 @@ "ignore": [

@@ -331,2 +331,5 @@ /* @preserve

this._action(doc, function (node, lastSegment) {
if (!Object.hasOwnProperty.call(node,lastSegment)) {
throw new PatchApplyError('Path not found in document');
}
value = node[lastSegment];

@@ -333,0 +336,0 @@ return node;

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

@@ -12,6 +12,6 @@ "keywords": ["diff", "patch", "json", "jsonpatch", "jsonpointer"],

"devDependencies": {
"mocha": "1.8.1",
"expect.js": "0.2.0",
"jshint": "0.3.0",
"uglify-js": "2.3.5"
"expect.js": "^0.3.1",
"jshint": "^2.5.10",
"mocha": "^2.0.1",
"uglify-js": "^2.4.15"
},

@@ -18,0 +18,0 @@ "scripts": {

@@ -150,4 +150,3 @@ if ('function' === typeof require) {

"/numbers/010": 10,
"/numbers/00010": 10,
"/numbers/-": undefined
"/numbers/00010": 10
};

@@ -171,2 +170,7 @@

});
it('should throw when pointer references a nonexistent value', function () {
expect(do_get).withArgs('/foo/anArray/-', example).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Path not found in document') });
expect(do_get).withArgs('/foo/bar', example).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Path not found in document') });
});
});

@@ -188,16 +192,22 @@ });

});
it('should raise an error for patches that arent arrays', function () {
it('should raise an error for patches that aren\'t arrays', function () {
expect(function () {patch = new jsonpatch.JSONPatch({});}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('Patch must be an array of operations') });
});
it('should raise an error if value is not supplied for add or replace operation', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{op:"add", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('add must have key value') });
expect(function () {patch = new jsonpatch.JSONPatch([{op:"replace", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('replace must have key value') });
});
it('should raise an error if an operation is not specified', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('Operation missing!') });
});
it('should raise an error if un-recognised operation is specified', function () {
it('should raise an error if unrecognised operation is specified', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{op:"blam"}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('Invalid operation!') });
});
it('should raise an error for operations without path', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{op:"add"}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('Path missing!')});
});
it('should raise an error if value is not supplied for add, replace or test operation', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{op:"add", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('add must have key value') });
expect(function () {patch = new jsonpatch.JSONPatch([{op:"replace", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('replace must have key value') });
expect(function () {patch = new jsonpatch.JSONPatch([{op:"test", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('test must have key value') }); });
it('should raise an error if from is not supplied for move or copy operation', function () {
expect(function () {patch = new jsonpatch.JSONPatch([{op:"move", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('move must have key from') });
expect(function () {patch = new jsonpatch.JSONPatch([{op:"copy", path:'/'}]);}).throwException(function (e) { expect(e).a(jsonpatch.InvalidPatch); expect(e.message).equal('copy must have key from') });
});
});

@@ -283,2 +293,42 @@

});
it('should raise an error if from key supplied does not exist for move or copy operation', function () {
var doc = {
"foo": {
"anArray": [
{ "prop": 44 },
"second",
"third"
],
"another prop": {
"baz": "A string"
}
}
};
expect(function () {
jsonpatch.apply_patch(doc, [{op:"move", from: '/bar', path:'/'}]);
}).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Path not found in document') });
expect(function () {
jsonpatch.apply_patch(doc, [{op:"copy", from: '/bar', path:'/'}]);
}).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Path not found in document') });
});
it('should raise an error if path key supplied does not exist for remove or replace operation', function () {
var doc = {
"foo": {
"anArray": [
{ "prop": 44 },
"second",
"third"
],
"another prop": {
"baz": "A string"
}
}
};
expect(function () {
jsonpatch.apply_patch(doc, [{op:"remove", path:'/bar'}]);
}).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Remove operation must point to an existing value!') });
expect(function () {
jsonpatch.apply_patch(doc, [{op:"replace", path:'/bar', value: ''}]);
}).throwException(function (e) { expect(e).a(jsonpatch.PatchApplyError); expect(e.message).equal('Replace operation must point to an existing value!') });
});
});

@@ -285,0 +335,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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