{ "name": "diffpatcher", "id": "diffpatcher", "version": "1.0.0", "description": "Utilities for diff-ing & patch-ing hashes", "keywords": [ "diff", "patch", "rebase", "hash", "changes", "versions" ], "author": { "name": "Irakli Gozalishvili", "email": "rfobic@gmail.com", "url": "http://jeditoolkit.com" }, "homepage": "https://github.com/Gozala/diffpatcher", "repository": { "type": "git", "url": "https://github.com/Gozala/diffpatcher.git", "web": "https://github.com/Gozala/diffpatcher" }, "bugs": { "url": "http://github.com/Gozala/diffpatcher/issues/" }, "devDependencies": { "test": "~0.x.0", "repl-utils": "~1.0.0", "phantomify": "~0.1.0" }, "main": "./index.js", "scripts": { "test": "npm run test-node && npm run test-browser", "test-browser": "node ./node_modules/phantomify/bin/cmd.js ./test/index.js", "test-node": "node ./test/index.js", "repl": "node node_modules/repl-utils" }, "licenses": [ { "type": "MIT", "url": "https://github.com/Gozala/diffpatcher/License.md" } ], "dependencies": { "method": "~1.0.0" }, "readme": "# diffpatcher\n\n[![Build Status](https://secure.travis-ci.org/Gozala/diffpatcher.png)](http://travis-ci.org/Gozala/diffpatcher)\n\nDiffpatcher is a small library that lets you treat hashes as if they were\ngit repositories.\n\n## diff\n\nDiff function that takes two hashes and returns delta hash.\n\n```js\nvar diff = require(\"diffpatcher/diff\")\n\ndiff({ a: { b: 1 }, c: { d: 2 } }, // hash#1\n { a: { e: 3 }, c: { d: 4 } }) // hash#2\n\n// => { // delta\n// a: {\n// b: null, // -\n// e: 3 // +\n// },\n// c: {\n// d: 4 // ±\n// }\n// }\n```\n\nAs you can see from the example above `delta` makes no real distinction between\nproprety upadate and property addition. Try to think of additions as an update\nfrom `undefined` to whatever it's being updated to.\n\n## patch\n\nPatch fuction takes a `hash` and a `delta` and returns a new `hash` which is\njust like orginial but with delta applied to it. Let's apply delta from the\nprevious example to the first hash from the same example\n\n\n```js\nvar patch = require(\"diffpatcher/patch\")\n\npatch({ a: { b: 1 }, c: { d: 2 } }, // hash#1\n { // delta\n a: {\n b: null, // -\n e: 3 // +\n },\n c: {\n d: 4 // ±\n }\n })\n\n// => { a: { e: 3 }, c: { d: 4 } } // hash#2\n```\n\nThat's about it really, just diffing hashes and applying thes diffs on them.\n\n\n### rebase\n\nAnd as Linus mentioned everything in git can be expressed with `rebase`, that\nalso pretty much the case for `diffpatcher`. `rebase` takes `target` hash,\nand rebases `parent` onto it with `diff` applied.\n\n## Install\n\n npm install diffpatcher\n", "readmeFilename": "Readme.md", "_id": "diffpatcher@1.0.0", "_from": "diffpatcher" }