Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-json-patch

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-json-patch - npm Package Compare versions

Comparing version 0.3.6 to 0.3.8

.idea/jsLibraryMappings.xml

4

LICENSE.txt
(The MIT License)
Copyright (c) 2013 Joachim Wester <joachimwester@me.com>
Copyright (c) 2013, 2014 Joachim Wester <joachimwester@me.com>

@@ -22,2 +22,2 @@ Permission is hereby granted, free of charge, to any person obtaining

TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
"name": "fast-json-patch",
"version": "0.3.6",
"version": "0.3.8",
"description": "JSON-Patch allows you to update a JSON document by sending the changes rather than the whole document.",
"homepage": "https://github.com/Starcounter-Jack/JSON-Patch",
"keywords": ["json", "patch", "http", "rest"],
"keywords": [
"json",
"patch",
"http",
"rest"
],
"repository": {

@@ -19,8 +24,16 @@ "type": "git",

},
"licenses": [ {
"type": "MIT",
"url": "http://www.opensource.org/licenses/MIT"
} ],
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/MIT"
}
],
"main": "./src/json-patch-duplex",
"engines": { "node": ">= 0.4.0" }
"engines": {
"node": ">= 0.4.0"
},
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-uglify": "~0.5.0"
}
}

@@ -9,3 +9,3 @@ JSON-Patch

JSON-Patch [(RFC6902)](http://tools.ietf.org/html/rfc6902) is a new standard format that
JSON-Patch [(RFC6902)](http://tools.ietf.org/html/rfc6902) is a standard format that
allows you to update a JSON document by sending the changes rather than the whole document.

@@ -34,2 +34,21 @@ JSON Patch plays well with the HTTP PATCH verb (method) and REST style programming.

## Install
Install the current version (and save it as a dependency):
### npm
```sh
$ npm install fast-json-patch --save
```
### bower
```sh
$ bower install fast-json-patch --save
```
### [download as ZIP](https://github.com/my-user/my-repo/archive/master.zip)
## Adding to your project

@@ -44,8 +63,2 @@

Install the current version (and save it as a dependency in package.json):
```
$ npm install fast-json-patch --save
```
Call require to get the instance:

@@ -86,2 +99,9 @@

```
Comparing two object trees:
```
var objA = {user: {firstName: "Albert", lastName: "Einstein"}};
var objB = {user: {firstName: "Albert", lastName: "Collins"}};
var diff = jsonpatch.compare(objA, objB));
//diff == [{op: "replace", path: "/user/lastName", value: "Collins"}]
```

@@ -150,4 +170,22 @@ ## Testing

#### jsonpatch.compare (`obj1` Object, `obj2` Object) : `patches` Array
Available in *json-patch-duplex.js*
Compares object trees `obj1` and `obj2` and returns the difference relative to `obj1` as a patches array.
If there are no differences, returns an empty array.
## Changelog
#### 0.3.8 (Jul 18, 2014)
Feature:
- minified build now available in [dist/](https://github.com/Starcounter-Jack/JSON-Patch/tree/master/dist) directory ([#9](https://github.com/Starcounter-Jack/JSON-Patch/issues/9))
#### 0.3.7 (May 5, 2014)
Feature:
- add a new method `compare` ([#24](https://github.com/Starcounter-Jack/JSON-Patch/issues/24))
#### 0.3.6 (Nov 14, 2013)

@@ -176,2 +214,2 @@

- code cleanup
- removed sourcemap reference from output js file
- removed sourcemap reference from output js file

@@ -1,6 +0,16 @@

// json-patch-duplex.js 0.3.6
// (c) 2013 Joachim Wester
// MIT license
/*!
* json-patch-duplex.js 0.3.8
* (c) 2013 Joachim Wester
* MIT license
*/
var jsonpatch;
(function (jsonpatch) {
/* We use a Javascript hash to store each
function. Each hash entry (property) uses
the operation identifiers specified in rfc6902.
In this way, we can map each patch operation
to its dedicated function in efficient way.
*/
/* The operations applicable to an object */
var objOps = {

@@ -46,2 +56,3 @@ add: function (obj, key) {

/* The operations applicable to an array. Many are the same as for the object */
var arrOps = {

@@ -71,4 +82,3 @@ add: function (arr, i) {

path: path + escapePathComponent(this.name),
value: this.object[this.name]
};
value: this.object[this.name] };
patches.push(patch);

@@ -243,3 +253,3 @@ },

mirror.value = JSON.parse(JSON.stringify(obj));
mirror.value = JSON.parse(JSON.stringify(obj)); // Faster than ES5 clone - http://jsperf.com/deep-cloning-of-objects/5

@@ -251,2 +261,5 @@ if (callback) {

var intervals = this.intervals || [100, 1000, 10000, 60000];
if (intervals.push === void 0) {
throw new Error("jsonpatch.intervals must be an array");
}
var currentInterval = 0;

@@ -388,3 +401,3 @@

delete mirror[key];
deleted = true;
deleted = true; // property has been deleted
}

@@ -431,3 +444,3 @@ }

if (t >= len) {
result = arrOps[patch.op].call(patch, obj, index, tree);
result = arrOps[patch.op].call(patch, obj, index, tree); // Apply patch
break;

@@ -439,6 +452,6 @@ }

if (key.indexOf('~') != -1)
key = key.replace(/~1/g, '/').replace(/~0/g, '~');
key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
t++;
if (t >= len) {
result = objOps[patch.op].call(patch, obj, key, tree);
result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
break;

@@ -454,2 +467,9 @@ }

jsonpatch.apply = apply;
function compare(tree1, tree2) {
var patches = [];
_generate(tree1, tree2, patches, '');
return patches;
}
jsonpatch.compare = compare;
})(jsonpatch || (jsonpatch = {}));

@@ -456,0 +476,0 @@

@@ -1,4 +0,6 @@

// json-patch-duplex.js 0.3.6
// (c) 2013 Joachim Wester
// MIT license
/*!
* json-patch-duplex.js 0.3.8
* (c) 2013 Joachim Wester
* MIT license
*/

@@ -13,2 +15,10 @@ interface Object {

/* We use a Javascript hash to store each
function. Each hash entry (property) uses
the operation identifiers specified in rfc6902.
In this way, we can map each patch operation
to its dedicated function in efficient way.
*/
/* The operations applicable to an object */
var objOps = {

@@ -54,2 +64,3 @@ add: function (obj, key) {

/* The operations applicable to an array. Many are the same as for the object */
var arrOps = {

@@ -268,2 +279,5 @@ add: function (arr, i) {

var intervals = this.intervals || [100, 1000, 10000, 60000];
if (intervals.push === void 0) {
throw new Error("jsonpatch.intervals must be an array");
}
var currentInterval = 0;

@@ -476,2 +490,8 @@

}
export function compare(tree1:any, tree2:any):any[] {
var patches = [];
_generate(tree1, tree2, patches, '');
return patches;
}
}

@@ -486,2 +506,2 @@

exports.generate = jsonpatch.generate;
}
}

@@ -1,4 +0,6 @@

// json-patch.js 0.3.6
// (c) 2013 Joachim Wester
// MIT license
/*!
* json-patch-duplex.js 0.3.8
* (c) 2013 Joachim Wester
* MIT license
*/
var jsonpatch;

@@ -90,3 +92,3 @@ (function (jsonpatch) {

if (t >= len) {
result = arrOps[patch.op].call(patch, obj, index, tree);
result = arrOps[patch.op].call(patch, obj, index, tree); // Apply patch
break;

@@ -98,6 +100,6 @@ }

if (key.indexOf('~') != -1)
key = key.replace(/~1/g, '/').replace(/~0/g, '~');
key = key.replace(/~1/g, '/').replace(/~0/g, '~'); // escape chars
t++;
if (t >= len) {
result = objOps[patch.op].call(patch, obj, key, tree);
result = objOps[patch.op].call(patch, obj, key, tree); // Apply patch
break;

@@ -104,0 +106,0 @@ }

@@ -1,4 +0,6 @@

// json-patch.js 0.3.6
// (c) 2013 Joachim Wester
// MIT license
/*!
* json-patch-duplex.js 0.3.8
* (c) 2013 Joachim Wester
* MIT license
*/

@@ -5,0 +7,0 @@ module jsonpatch {

@@ -0,0 +0,0 @@ jasmine.HtmlReporterHelpers = {};

@@ -0,0 +0,0 @@ // JSLitmus.js

@@ -603,4 +603,32 @@ var obj, obj2, patches;

describe('compare', function () {
it('should return an add for a property that does not exist in the first obj', function () {
var objA = {user: {firstName: "Albert"}};
var objB = {user: {firstName: "Albert", lastName: "Einstein"}};
expect(jsonpatch.compare(objA, objB)).toEqual([
{op: "add", path: "/user/lastName", value: "Einstein"}
]);
});
it('should return a remove for a property that does not exist in the second obj', function () {
var objA = {user: {firstName: "Albert", lastName: "Einstein"}};
var objB = {user: {firstName: "Albert"}};
expect(jsonpatch.compare(objA, objB)).toEqual([
{op: "remove", path: "/user/lastName"}
]);
});
it('should return a replace for a property that exists in both', function () {
var objA = {user: {firstName: "Albert", lastName: "Einstein"}};
var objB = {user: {firstName: "Albert", lastName: "Collins"}};
expect(jsonpatch.compare(objA, objB)).toEqual([
{op: "replace", path: "/user/lastName", value: "Collins"}
]);
});
});
describe("Registering multiple observers with the same callback", function () {

@@ -607,0 +635,0 @@

@@ -0,0 +0,0 @@ var obj, compiled;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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