<commit_before>'use strict'

var pointer = require('json-pointer')

var delegates = new WeakMap // <callback, delegate>

var Delegate = function(callback) {
  this.callback  = callback
  this.observers = new WeakMap
  var self = this
  this.handleChangeRecords = function(records) {
    self.callback(records.map(self.transform, self).filter(function(record) {
      return record !== null
    }))
  }
}

Delegate.prototype.transform = function(record) {
  var target = record.object
  var observer = this.observers.get(target)
  return observer.transform(record)
}

var Observer = function(root, delegate, accept) {
  this.root = root
  this.delegate = delegate
  this.callback = delegate.handleChangeRecords
  this.accept = accept
  this.paths = new WeakMap
}

Observer.prototype.observe = function(obj, path) {
  if (!path) path = []

  this.paths.set(obj, path.slice())
  this.delegate.observers.set(obj, this)
  if (Array.isArray(obj) && !this.accept) {
    Array.observe(obj, this.callback)
  } else {
    Object.observe(obj, this.callback, this.accept)
  }

  for (var key in obj) {<commit_msg>achieve observe-shim compatibility<commit_after>'use strict'

var pointer = require('json-pointer')

var delegates = new WeakMap // <callback, delegate>

var Delegate = function(callback) {
  this.callback  = callback
  this.observers = new WeakMap
  var self = this
  this.handleChangeRecords = function(records) {
    self.callback(records.map(self.transform, self).filter(function(record) {
      return record !== null
    }))
  }
}

Delegate.prototype.transform = function(record) {
  var target = record.object
  var observer = this.observers.get(target)
  return observer.transform(record)
}

var Observer = function(root, delegate, accept) {
  this.root = root
  this.delegate = delegate
  this.callback = delegate.handleChangeRecords
  this.accept = accept
  this.paths = new WeakMap
}

Observer.prototype.observe = function(obj, path) {
  if (!path) path = []

  this.paths.set(obj, path.slice())
  this.delegate.observers.set(obj, this)
  if (Array.isArray(obj) && !this.accept) {
    Object.observe(obj, this.callback, ['add', 'update', 'delete', 'splice'])
  } else {
    Object.observe(obj, this.callback, this.accept)
  }

  for (var key in obj) {
{'fraction_non_alphanumeric': 0.1312417145382236, 'fraction_numerical': 0.0, 'mean_word_length': 3.9649122807017543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5951086', 'n_tokens_mistral': 724, 'n_tokens_neox': 713, 'n_words': 164}