How to use ssb-friends - 4 common examples

To help you get started, we’ve selected a few ssb-friends examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-server / plugins / friends.js View on Github external
//this code handles real time streaming of the hops map.
          function push (to, hops) {
            out.push(meta ? {id: to, hops: hops} : to)
          }

          var out = [], g = post.value

          //the edge has already been added to g
          if(!reachable) {
            reachable = F.reachable(g, start, block)
            for(var k in reachable)
              if(block.isWanted(reachable[k]))
                push(k, reachable[k][0])
          } else {
            var _reachable = F.reachable(g, start, block)
            var patch = F.diff(reachable, _reachable, block)
            for(var k in patch) {
              if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1])
                push(k, -1)
              else if(block.isWanted(patch[k]))
                push(k, patch[k][0])
            }
            reachable = _reachable
          }
          return out
        })
github ssbc / ssb-server / plugins / friends.js View on Github external
FlatMap(function (v) {
          if(!v) return []

          //this code handles real time streaming of the hops map.
          function push (to, hops) {
            out.push(meta ? {id: to, hops: hops} : to)
          }

          var out = [], g = post.value

          //the edge has already been added to g
          if(!reachable) {
            reachable = F.reachable(g, start, block)
            for(var k in reachable)
              if(block.isWanted(reachable[k]))
                push(k, reachable[k][0])
          } else {
            var _reachable = F.reachable(g, start, block)
            var patch = F.diff(reachable, _reachable, block)
            for(var k in patch) {
              if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1])
                push(k, -1)
              else if(block.isWanted(patch[k]))
                push(k, patch[k][0])
            }
            reachable = _reachable
          }
          return out
        })
github ssbc / ssb-server / plugins / friends.js View on Github external
//this code handles real time streaming of the hops map.
          function push (to, hops) {
            out.push(meta ? {id: to, hops: hops} : to)
          }

          var out = [], g = post.value

          //the edge has already been added to g
          if(!reachable) {
            reachable = F.reachable(g, start, block)
            for(var k in reachable)
              if(block.isWanted(reachable[k]))
                push(k, reachable[k][0])
          } else {
            var _reachable = F.reachable(g, start, block)
            var patch = F.diff(reachable, _reachable, block)
            for(var k in patch) {
              if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1])
                push(k, -1)
              else if(block.isWanted(patch[k]))
                push(k, patch[k][0])
            }
            reachable = _reachable
          }
          return out
        })
github ssbc / ssb-server / plugins / friends.js View on Github external
FlatMap(function (v) {
          if(!v) return []

          //this code handles real time streaming of the hops map.
          function push (to, hops) {
            out.push(meta ? {id: to, hops: hops} : to)
          }

          var out = [], g = post.value

          //the edge has already been added to g
          if(!reachable) {
            reachable = F.reachable(g, start, block)
            for(var k in reachable)
              if(block.isWanted(reachable[k]))
                push(k, reachable[k][0])
          } else {
            var _reachable = F.reachable(g, start, block)
            var patch = F.diff(reachable, _reachable, block)
            for(var k in patch) {
              if(patch[k] == null || patch[k][0] == null || patch[k][0] > patch[k][1])
                push(k, -1)
              else if(block.isWanted(patch[k]))
                push(k, patch[k][0])
            }
            reachable = _reachable
          }
          return out
        })

ssb-friends

The logic of who to replicate in ssb.

MIT
Latest version published 7 months ago

Package Health Score

53 / 100
Full package analysis

Similar packages