diff --git a/README.md b/README.md index a3643b7..36e900e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# json-diff-patch +# diff-to-patch A function that compares two JavaScript-objects and returns an array of JSON Patch-operations representing the difference between the two objects. ## Install ```bash -npm install json-diff-patch +npm install diff-to-patch ``` ## Usage @@ -13,24 +13,24 @@ npm install json-diff-patch To use the function, simply ```require``` it and pass two objects you want to compare to it: ```javascript -const jsonDiffPatch = require('json-diff-patch'); +const diffToPatch = require('diff-to-patch'); -jsonDiffPatch({ foo: 'bar' }, { foo: 'baz' }); +diffToPatch({ foo: 'bar' }, { foo: 'baz' }); // => [{ op: 'replace', path: '/foo', value: 'baz' }] -jsonDiffPatch({}, { foo: 'bar' }); +diffToPatch({}, { foo: 'bar' }); // => [{ op: 'add', path: '/foo', value: 'bar' }] -jsonDiffPatch({ foo: 'bar' }, {}); +diffToPatch({ foo: 'bar' }, {}); // => [{ op: 'remove', path: '/foo' }] -jsonDiffPatch([1, 2, 3], [1, 2, 4]); +diffToPatch([1, 2, 3], [1, 2, 4]); // => [{ op: 'replace', path: '/2', value: 4}] -jsonDiffPatch([1, 2, 3], [1, 2, 3, 4]); +diffToPatch([1, 2, 3], [1, 2, 3, 4]); // => [{ op: 'add', path: '/3', value: 4}] -jsonDiffPatch([1, 2, 3], [1, 2]); +diffToPatch([1, 2, 3], [1, 2]); // => [{ op: 'remove', path: '/2'}] ``` @@ -66,7 +66,7 @@ let objB = { email: 'bob@gmail.com' } -jsonDiffPatch(objA, objB); +diffToPatch(objA, objB); /* => [ { op: 'replace', path: '/name', value: 'Bobby' }, diff --git a/package.json b/package.json index 3eeec7a..d3863b5 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "json-diff-patch", + "name": "diff-to-patch", "version": "0.1.0", "description": "A function that compares two JavaScript-objects and returns an array of JSON Patch-operations representing the difference between the two objects.", "main": "index.js", @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/taylanken/json-diff-patch.git" + "url": "git+https://github.com/taylanken/diff-to-patch.git" }, "keywords": [ "json", @@ -23,7 +23,7 @@ "author": "Taylan Kenanoglu", "license": "MIT", "bugs": { - "url": "https://github.com/taylanken/json-diff-patch/issues" + "url": "https://github.com/taylanken/diff-to-patch/issues" }, - "homepage": "https://github.com/taylanken/json-diff-patch#readme" + "homepage": "https://github.com/taylanken/diff-to-patch#readme" } \ No newline at end of file