UNPKG

telehash

Version:

A telehash library for node and browserify

22 lines (17 loc) 574 B
var telehash = require("./../../index.js") var fs = require("fs") telehash.load({id : "./hashleft.hn"}, (er, mesh) => { mesh.accept = (from) => { console.log("got accept ", from.hashname); mesh.link(from, () => { console.log("got link status", from.hashname) }) } mesh.stream((a, b, accept) => { fs.createReadStream("./hashleft.hn").pipe(accept()); }) mesh.link(JSON.parse(fs.readFileSync("./hashmiddle.json").toString()), () => { console.log("link middle") }) fs.writeFileSync("./hashleft.json", JSON.stringify(mesh.json())); })