Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[dist] Added new examples

  • Loading branch information...
commit a693826c9b1bb80dae83ee5e92dc12de9b6d5e5d 1 parent 340aa8e
@Marak Marak authored
View
25 example/save-data-pull-from-hnet.js
@@ -0,0 +1,25 @@
+var Hnet = require('../lib/hnet').Hnet;
+
+var hnet = new Hnet();
+
+
+hnet.on('node', function (node, data, options) {
+ //console.log('level::' + options.currentDepth + '::' + node.uri);
+});
+
+hnet.on('level::*', function(nodes, options){
+ //console.log('level::' + this.event.split('::')[1] + '::loaded');
+ //console.log(JSON.stringify(hnet.get(), true, 2));
+});
+
+hnet.on('level::0', function(nodes, options){
+ //consoleonsole.log(hnet.nodes);
+ hnet.save(function(err, response, body){
+
+ //console.log(err, body);
+
+ });
+});
+
+hnet.load(['http://hnet.iriscouch.com/public/0']);
+
View
12 example/save-new-data.js
@@ -0,0 +1,12 @@
+var Hnet = require('../lib/hnet').Hnet;
+
+var hnet = new Hnet();
+
+hnet.store = ["foo", {"boo": "bar"}];
+
+hnet.save(function(err, response, body){
+ if(err) {
+ console.log(err);
+ }
+
+});
View
26 example/ttl-with-circular-links.js
@@ -0,0 +1,26 @@
+var Hnet = require('../lib/hnet').Hnet;
+
+var hnet = new Hnet({
+ ttl: 5000
+});
+
+hnet.on('node', function (node, data, options) {
+ // loaded a node !!!
+ // console.log(this.event);
+
+});
+
+hnet.on('level::*', function(nodes, options) {
+ // loaded an entire level of nodes !
+
+ //
+ // Remark: Pretty print local data to console
+ //
+ console.log(JSON.stringify(hnet.get(), true, 2));
+});
+
+
+//
+// Will start lazy loading sources
+//
+hnet.load(['http://hnet.iriscouch.com/public/0']);
Please sign in to comment.
Something went wrong with that request. Please try again.