<commit_before>const hub = require('../')
const test = require('tape')

test('references', t => {
  const scraper = hub({
    _uid_: 'scraper',
    port: 6060,
    a: {
      b: {
        c: 'c!'
      }
    },
    bla: [ '@', 'parent', 'a', 'b', 'c' ]
  })

  const client = hub({
    _uid_: 'client',
    url: 'ws://localhost:6060'
  })

  client.subscribe({ bla: true })

  client.get([ 'a', 'b', 'c' ], {}).once('c!').then(() => {
    t.pass('received reference')
    client.set(null)
    scraper.set(null)
    t.end()
  })
  // make a few more
})<commit_msg>circular reference test<commit_after>const hub = require('../')
const test = require('tape')

test('references', t => {
  const scraper = hub({
    _uid_: 'scraper',
    port: 6060,
    a: {
      b: {
        c: 'c!'
      }
    },
    bla: [ '@', 'parent', 'a', 'b', 'c' ]
  })

  const client = hub({
    _uid_: 'client',
    url: 'ws://localhost:6060'
  })

  client.subscribe({ bla: true })

  client.get([ 'a', 'b', 'c' ], {}).once('c!').then(() => {
    t.pass('received reference')
    client.set(null)
    scraper.set(null)
    t.end()
  })
})

test('circular references', t => {
  const scraper = hub({
    _uid_: 'scraper',
    port: 6060,
    a: {
      items: {
        b: ['@', 'root', 'b'],
        c: ['@', 'root', 'c']
      }
    },
    b: {
      val: 'valB',
      siblings: ['@', 'root', 'a', 'items']
    },
    c: {
      val: 'valC',
      siblings: ['@', 'root', 'a', 'items']
    }
  })

  const client = hub({
    _uid_: 'client',
    url: 'ws://localhost:6060'
  })

  client.subscribe(true)

  client.get([ 'a', 'items', 'c', 'siblings', 'b' ], {}).once('valB').then(() => {
    t.pass('received circular reference')
    client.set(null)
    scraper.set(null)
    t.end()
  })
})
{'fraction_non_alphanumeric': 0.24392998306041785, 'fraction_numerical': 0.01355166572557877, 'mean_word_length': 2.2693726937269374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4075626', 'n_tokens_mistral': 722, 'n_tokens_neox': 693, 'n_words': 147}