summaryrefslogtreecommitdiffstats
path: root/toolkit/jetpack/diffpatcher/Readme.md
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-10 02:51:36 -0500
commit37d5300335d81cecbecc99812747a657588c63eb (patch)
tree765efa3b6a56bb715d9813a8697473e120436278 /toolkit/jetpack/diffpatcher/Readme.md
parentb2bdac20c02b12f2057b9ef70b0a946113a00e00 (diff)
parent4fb11cd5966461bccc3ed1599b808237be6b0de9 (diff)
downloadUXP-37d5300335d81cecbecc99812747a657588c63eb.tar
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.gz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.lz
UXP-37d5300335d81cecbecc99812747a657588c63eb.tar.xz
UXP-37d5300335d81cecbecc99812747a657588c63eb.zip
Merge branch 'ext-work'
Diffstat (limited to 'toolkit/jetpack/diffpatcher/Readme.md')
-rw-r--r--toolkit/jetpack/diffpatcher/Readme.md70
1 files changed, 70 insertions, 0 deletions
diff --git a/toolkit/jetpack/diffpatcher/Readme.md b/toolkit/jetpack/diffpatcher/Readme.md
new file mode 100644
index 000000000..1520b1c37
--- /dev/null
+++ b/toolkit/jetpack/diffpatcher/Readme.md
@@ -0,0 +1,70 @@
+# diffpatcher
+
+[![Build Status](https://secure.travis-ci.org/Gozala/diffpatcher.png)](http://travis-ci.org/Gozala/diffpatcher)
+
+[![Browser support](https://ci.testling.com/Gozala/diffpatcher.png)](http://ci.testling.com/Gozala/diffpatcher)
+
+Diffpatcher is a small library that lets you treat hashes as if they were
+git repositories.
+
+## diff
+
+Diff function that takes two hashes and returns delta hash.
+
+```js
+var diff = require("diffpatcher/diff")
+
+diff({ a: { b: 1 }, c: { d: 2 } }, // hash#1
+ { a: { e: 3 }, c: { d: 4 } }) // hash#2
+
+// => { // delta
+// a: {
+// b: null, // -
+// e: 3 // +
+// },
+// c: {
+// d: 4 // ±
+// }
+// }
+```
+
+As you can see from the example above `delta` makes no real distinction between
+proprety upadate and property addition. Try to think of additions as an update
+from `undefined` to whatever it's being updated to.
+
+## patch
+
+Patch fuction takes a `hash` and a `delta` and returns a new `hash` which is
+just like orginial but with delta applied to it. Let's apply delta from the
+previous example to the first hash from the same example
+
+
+```js
+var patch = require("diffpatcher/patch")
+
+patch({ a: { b: 1 }, c: { d: 2 } }, // hash#1
+ { // delta
+ a: {
+ b: null, // -
+ e: 3 // +
+ },
+ c: {
+ d: 4 // ±
+ }
+ })
+
+// => { a: { e: 3 }, c: { d: 4 } } // hash#2
+```
+
+That's about it really, just diffing hashes and applying thes diffs on them.
+
+
+### rebase
+
+And as Linus mentioned everything in git can be expressed with `rebase`, that
+also pretty much the case for `diffpatcher`. `rebase` takes `target` hash,
+and rebases `parent` onto it with `diff` applied.
+
+## Install
+
+ npm install diffpatcher