<commit_before>'use strict'
var test = require('tape')
var s = require('../s')
var subscribe = require('../subscribe')

// module.exports = function (target, subscription, handler, tree) {
test('simple subscription', function (t) {
  var state = s({
    field: true,
    something: false
  })
  // support functions in subscriptiosn
  var tree = subscribe(
    state,
    {
      // idea is if you pass an observable here it will just use the subs map from that observable
      field: true,
      other: {
        val: true,
        yuzi: true,
        fields: {
          '*': { title: true }
        }
      }
    },
    function (type, event) {
      console.log('update:', this, 'type:', type)
    }
  )

  state.set({
    other: {
      fields: [{ title: 'james' }, { title: 'yuz' }]
    }
  })

  console.log(JSON.stringify(tree, false, 2))

  t.end()
})<commit_msg>collection refined<commit_after>'use strict'
var test = require('tape')
var s = require('../s')
var subscribe = require('../subscribe')

// module.exports = function (target, subscription, handler, tree) {
test('simple subscription', function (t) {
  var state = s({
    field: true,
    something: false
  })
  // support functions in subs
  // idea is if you pass an observable here it will just use the subs map from that observable
  var tree = subscribe(
    state,
    {
      field: true,
      other: {
        // val: true, -- this is so nice gives any nested update -- may need to limit to value?
        yuzi: true,
        fields: {
          '*': { title: true }
        }
      }
    },
    function (type, event) {
      console.log('update:', this, 'type:', type)
    }
  )

  console.log('#set coll')

  state.set({
    other: {
      fields: [{ title: 'james' }, { title: 'yuz' }]
    }
  })

  console.log('#set field')

  state.other.fields[0].title.set('smurts')

  console.log('#tree')
  console.log(JSON.stringify(tree, false, 2))

  t.end()
})
{'fraction_non_alphanumeric': 0.15515463917525774, 'fraction_numerical': 0.0015463917525773195, 'mean_word_length': 2.3523316062176165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1945167', 'n_tokens_mistral': 633, 'n_tokens_neox': 612, 'n_words': 185}