Skip to content
Browse files

[dist] Updating examples

  • Loading branch information...
1 parent 9e52546 commit 33bc6b97b989ba0ba527aef2724fff1e66a88e4b @Marak Marak committed
View
10 example/max-depth.js
@@ -5,12 +5,14 @@ var hnet = new Hnet({
});
hnet.on('node', function (node, data, options) {
- console.log('level::' + options.currentDepth + '::' + node.uri);
+ // loaded a node !!!
+ // console.log(this.event);
+
});
-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::*', function(nodes, options) {
+ // loaded an entire level of nodes !
+ // console.log(this.event);
});
//
View
13 example/mutli-top-level-nodes.js
@@ -3,14 +3,21 @@ var Hnet = require('../lib/hnet').Hnet;
var hnet = new Hnet();
hnet.on('node', function (node, data, options) {
- console.log('level::' + options.currentDepth + '::' + node.uri);
+ // loaded a node !!!
+ // console.log(this.event);
+
});
-hnet.on('level::*', function(nodes, options){
- console.log('level::' + this.event.split('::')[1] + '::loaded');
+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
//
View
19 example/resolve-circular-links.js
@@ -1,19 +0,0 @@
-var Hnet = require('../lib/hnet').Hnet;
-
-var hnet = new Hnet({
- ttl: 5000
-});
-
-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));
-});
-
-//
-// Will start lazy loading sources
-//
-hnet.load(['http://hnet.iriscouch.com/public/0']);
View
3 example/sample-hnet-application/server.js
@@ -2,7 +2,6 @@
// Super basic application that uses an hnet client
//
-
var http = require('http'),
Hnet = require('../../lib/hnet').Hnet;
@@ -14,6 +13,6 @@ hnet.load();
http.createServer(function(req, res){
- res.write(JSON.stringify(hnet.get()));
+ res.write(JSON.stringify(hnet.get(), true, 2));
res.end();
}).listen(9999);
View
27 example/save-data.js
@@ -1,27 +0,0 @@
-//
-// TODO: not complete
-//
-
-
-var Hnet = require('../lib/hnet').Hnet;
-
-var hnet = new Hnet();
-
-//
-// Will start lazy loading sources
-//
-hnet.set([
- {
- uri: "http://hnet.iriscouch.com/public/4",
- type: "couchdb",
- data: { "foo":"bar" }
- }
-], function(err, response, body){
- console.log('fff')
- if (err) {
- console.log(err);
- }
-
- console.log(body);
-
-});
View
25 example/save-pulled-hnet-data.js
@@ -1,25 +0,0 @@
-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){
- //console.log(hnet.nodes);
- hnet.save(function(err, response, body){
-
- //console.log(err, body);
-
- });
-});
-
-hnet.load(['http://hnet.iriscouch.com/public/0']);
-
View
2 example/single-top-level-node.js
@@ -14,5 +14,5 @@ hnet.on('level::*', function(nodes, options){
//
// Will start lazy loading sources
//
-hnet.load(['http://hnet.iriscouch.com/public/0']);
+hnet.load(['http://hnet.iriscouch.com/public/9f837517018addead7fa767f97011248']);

0 comments on commit 33bc6b9

Please sign in to comment.
Something went wrong with that request. Please try again.