Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

proper html example

  • Loading branch information...
commit c0b7ce10ee4da384c8bd7a10dd45200d49243e90 1 parent cd7c421
James Halliday authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 example/html.js
34 example/html.js
View
@@ -0,0 +1,34 @@
+var difflet = require('../');
+var ent = require('ent');
+
+var tags = {
+ inserted : '<span class="g">',
+ updated : '<span class="b">',
+ deleted : '<span class="r">',
+};
+var diff = difflet({
+ start : function (t, s) {
+ s.write(tags[t]);
+ },
+ stop : function (t, s) {
+ s.write('</span>');
+ },
+ write : function (buf) {
+ stream.write(ent.encode(buf))
+ },
+});
+
+var prev = {
+ yy : 6,
+ zz : 5,
+ a : [1,2,3],
+ fn : function qq () {}
+};
+var next = {
+ a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ],
+ fn : 'I <3 robots',
+ b : [5,6,7]
+};
+
+var stream = diff(prev, next);
+stream.pipe(process.stdout, { end : false });
Please sign in to comment.
Something went wrong with that request. Please try again.