<commit_before>'use strict'

var nest = require('depnest')
var { Value, computed } = require('mutant')
var MutantPullDict = require('../../lib/mutant-pull-dict')

exports.needs = nest({
  'sbot.pull.stream': 'first'
})

exports.gives = nest({
  'contact.obs': ['following', 'followers', 'blocking', 'blockers', 'hops', 'reverseHops']
})

exports.create = function (api) {
  var cache = {}
  var reverseCache = {}

  window.contacts = {
    cache,
    reverseCache
  }

  var sync = Value(false)

  return nest('contact.obs', {
    following: (key) => matchingValueKeys(hops(key), 1),
    followers: (key) => matchingValueKeys(reverseHops(key), 1),
    blocking: (key) => matchingValueKeys(hops(key), -1),
    blockers: (key) => matchingValueKeys(reverseHops(key), -1),

    hops,
    reverseHops
  })

  function hops (feedId) {
    if (!cache[feedId]) {
      var obs = cache[feedId] = MutantPullDict(() => {
        return api.sbot.pull.stream((sbot) => sbot.patchwork.contacts.hopStream({ feedId, live: true, max: 1, old: true }))
      }, {<commit_msg>remove debug code in contact/obs<commit_after>'use strict'

var nest = require('depnest')
var { computed } = require('mutant')
var MutantPullDict = require('../../lib/mutant-pull-dict')

exports.needs = nest({
  'sbot.pull.stream': 'first'
})

exports.gives = nest({
  'contact.obs': ['following', 'followers', 'blocking', 'blockers', 'hops', 'reverseHops']
})

exports.create = function (api) {
  var cache = {}
  var reverseCache = {}

  return nest('contact.obs', {
    following: (key) => matchingValueKeys(hops(key), 1),
    followers: (key) => matchingValueKeys(reverseHops(key), 1),
    blocking: (key) => matchingValueKeys(hops(key), -1),
    blockers: (key) => matchingValueKeys(reverseHops(key), -1),

    hops,
    reverseHops
  })

  function hops (feedId) {
    if (!cache[feedId]) {
      var obs = cache[feedId] = MutantPullDict(() => {
        return api.sbot.pull.stream((sbot) => sbot.patchwork.contacts.hopStream({ feedId, live: true, max: 1, old: true }))
      }, {
{'fraction_non_alphanumeric': 0.1841332027424094, 'fraction_numerical': 0.004897159647404506, 'mean_word_length': 3.8642857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5683373', 'n_tokens_mistral': 721, 'n_tokens_neox': 684, 'n_words': 151}