Name: js-handler/node_modules/nodeunit/node_modules/tap/node_modules/difflet/README.markdown
| 1: | difflet |
| 2: | ======= |
| 3: | |
| 4: | Create colorful diffs for javascript objects. |
| 5: | |
| 6: | example |
| 7: | ======= |
| 8: | |
| 9: | string.js |
| 10: | --------- |
| 11: | |
| 12: | ``` js |
| 13: | var difflet = require('difflet'); |
| 14: | |
| 15: | var s = difflet.compare({ a : 2, c : 5 }, { a : 3, b : 4 }); |
| 16: | process.stdout.write(s); |
| 17: | ``` |
| 18: | |
| 19: | output: |
| 20: | |
| 21: |  |
| 22: | |
| 23: | colors.js |
| 24: | --------- |
| 25: | |
| 26: | ``` js |
| 27: | var diff = require('difflet')({ indent : 2 }); |
| 28: | |
| 29: | var prev = { |
| 30: | yy : 6, |
| 31: | zz : 5, |
| 32: | a : [1,2,3], |
| 33: | fn : 'beep', |
| 34: | c : { x : 7, z : 3 } |
| 35: | }; |
| 36: | |
| 37: | var next = { |
| 38: | a : [ 1, 2, "z", /beep/, new Buffer(3) ], |
| 39: | fn : function qqq () {}, |
| 40: | b : [5,6,7], |
| 41: | c : { x : 8, y : 5 } |
| 42: | }; |
| 43: | |
| 44: | diff(prev, next).pipe(process.stdout); |
| 45: | ``` |
| 46: | |
| 47: | output: |
| 48: | |
| 49: |  |
| 50: | |
| 51: | green for inserts, blue for updates, red for deletes |
| 52: | |
| 53: | methods |
| 54: | ======= |
| 55: | |
| 56: | var difflet = require('difflet') |
| 57: | |
| 58: | var diff = difflet(opts={}) |
| 59: | --------------------------- |
| 60: | |
| 61: | Create a difflet from optional options `opts`. |
| 62: | |
| 63: | With `opts.start(type, stream)` and `opts.stop(type, stream)`, |
| 64: | you can write custom handlers for all the types of differences: |
| 65: | `'inserted'`, `'updated'`, and `'deleted'`. |
| 66: | By default green is used for insertions, blue for updates, and red for |
| 67: | deletions. |
| 68: | |
| 69: | If `opts.indent` is set, output will span multiple lines and `opts.indent` |
| 70: | spaces will be used for leading whitespace. |
| 71: | |
| 72: | If `opts.comma === 'first'` then commas will be placed at the start of lines. |
| 73: | |
| 74: | Setting `opts.comment` to `true` will turn on comments with the previous |
| 75: | contents like this: |
| 76: | |
| 77: |  |
| 78: | |
| 79: | diff(prev, next) |
| 80: | ---------------- |
| 81: | |
| 82: | Return a stream with the colorful changes between objects `prev` and `next`. |
| 83: | |
| 84: | diff.compare(prev, next) |
| 85: | ------------------------ |
| 86: | |
| 87: | Return a string with the colorful changes between `prev` and `next`. |
| 88: | |
| 89: | difflet.compare(prev, next) |
| 90: | --------------------------- |
| 91: | |
| 92: | Return a string with the colorful changes between `prev` and `next` with the |
| 93: | default options. |
| 94: | |
| 95: | install |
| 96: | ======= |
| 97: | |
| 98: | With [npm](http://npmjs.org) do: |
| 99: | |
| 100: | ``` |
| 101: | npm install difflet |
| 102: | ``` |
| 103: | |
| 104: | test |
| 105: | ==== |
| 106: | |
| 107: | With [npm](http://npmjs.org) do: |
| 108: | |
| 109: | ``` |
| 110: | npm test |
| 111: | ``` |
| 112: | |
| 113: | license |
| 114: | ======= |
| 115: | |
| 116: | MIT/X11 |
