addon-sdk/source/lib/diffpatcher/Readme.md

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 # diffpatcher
     3 [![Build Status](https://secure.travis-ci.org/Gozala/diffpatcher.png)](http://travis-ci.org/Gozala/diffpatcher)
     5 [![Browser support](https://ci.testling.com/Gozala/diffpatcher.png)](http://ci.testling.com/Gozala/diffpatcher)
     7 Diffpatcher is a small library that lets you treat hashes as if they were
     8 git repositories.
    10 ## diff
    12 Diff function that takes two hashes and returns delta hash.
    14 ```js
    15 var diff = require("diffpatcher/diff")
    17 diff({ a: { b: 1 }, c: { d: 2 } },      // hash#1
    18      { a: { e: 3 }, c: { d: 4 } })      // hash#2
    20 // => {                                 // delta
    21 //      a: {
    22 //        b: null,        // -
    23 //        e: 3            // +
    24 //      },
    25 //      c: {
    26 //        d: 4            // ±
    27 //      }
    28 //    }
    29 ```
    31 As you can see from the example above `delta` makes no real distinction between
    32 proprety upadate and property addition. Try to think of additions as an update
    33 from `undefined` to whatever it's being updated to.
    35 ## patch
    37 Patch fuction takes a `hash` and a `delta` and returns a new `hash` which is
    38 just like orginial but with delta applied to it. Let's apply delta from the
    39 previous example to the first hash from the same example
    42 ```js
    43 var patch = require("diffpatcher/patch")
    45 patch({ a: { b: 1 }, c: { d: 2 } },     // hash#1
    46       {                                 // delta
    47         a: {
    48           b: null,        // -
    49           e: 3            // +
    50         },
    51         c: {
    52           d: 4            // ±
    53         }
    54       })
    56 // => { a: { e: 3 }, c: { d: 4 } }      // hash#2
    57 ```
    59 That's about it really, just diffing hashes and applying thes diffs on them.
    62 ### rebase
    64 And as Linus mentioned everything in git can be expressed with `rebase`, that
    65 also pretty much the case for `diffpatcher`. `rebase` takes `target` hash,
    66 and rebases `parent` onto it with `diff` applied.
    68 ## Install
    70     npm install diffpatcher

mercurial