<commit_before>'use strict'
var Emitter = require('../../../emitter')
var Base = require('../../../base')
var setKey = Base.prototype.setKey

module.exports = new Emitter({
  emitInstances: false,
  secondary: true,
  properties: {
    pattern: new Base({
      properties: {
        $condition: true
      },
      define: {
        setKey (key, val, event, nocontext, escape) {
          if (key === 'parent') {
            key = '$parent'
          }
          return setKey.call(this, key, val, event, nocontext, escape)
        }
      },
      ChildConstructor: 'Constructor'
    })
  },
  inject: [
    require('../run'),
    require('../field'),
    require('../object'),
    require('../upward'),
    require('../findemit'),
    require('../condition')
  ],
  define: {
    generateConstructor () {
      return function derivedBase (val, event, parent, key) {
        Base.apply(this, arguments)
        if (parent && !parent[key]) {
          this.subField(false, void 0, parent.parent, this.pattern, 0, true, {})
        }
      }
    }
  }
}).Constructor
<commit_msg>pattern is now an observable<commit_after>'use strict'
var Emitter = require('../../../emitter')
var Base = require('../../../base')

var LightObservable = new Base({
  inject: [
    require('../../constructor'),
    require('../../on'),
    require('../../emit'),
    require('../../off'),
    require('../../remove'),
    require('../../set')
  ]
}).Constructor

var setKey = LightObservable.prototype.setKey

module.exports = new Emitter({
  emitInstances: false,
  secondary: true,
  properties: {
    pattern: new LightObservable({
      define: {
        setKey (key, val, event, nocontext, escape) {
          if (key === 'parent') {
            key = '$parent'
          }
          return setKey.call(this, key, val, event, nocontext, escape)
        }
      },
      ChildConstructor: 'Constructor'
    })
  },
  inject: [
    require('../run'),
    require('../field'),
    require('../object'),
    require('../upward'),
    require('../findemit'),
    require('../condition')
  ],
  define: {
    generateConstructor () {
      return function derivedBase (val, event, parent, key) {
        Base.apply(this, arguments)
        if (parent && !parent[key]) {
          this.subField(false, void 0, parent.parent, this.pattern, 0, true, {})
        }
      }
    }
  }
}).Constructor

{'fraction_non_alphanumeric': 0.18778947368421053, 'fraction_numerical': 0.0016842105263157896, 'mean_word_length': 2.126315789473684, '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': '924900', 'n_tokens_mistral': 710, 'n_tokens_neox': 700, 'n_words': 163}