<commit_before>var assert = require('assert'),
    _ = require('lodash'),
    Model = require('./model');

var Finder = function Finder(store) {
  this._store = store;
  this._finders = {};
  this._observers = [];

  this._store.observe(this._observeStore.bind(this));
};

Finder.prototype.finder = function Finder$finder(name, paramTypes, fn) {
  if (process.env.NODE_ENV !== 'production') {
    assert.ok(name && typeof name === 'string', 'Finder(): finder name must be string');
    assert.ok(_.isPlainObject(paramTypes), 'Finder(): paramTypes must be a model-like schema of key:string -> type:Str/Decimal/Bool');
  }
  this._finders[name] = {
    paramClass: Model.define(paramTypes),
    finder: fn
  };
};

Finder.prototype.observe = function Finder$observe(name, fn, params) {
  if (process.env.NODE_ENV === 'production') {
    assert.ok(name in this._finders, 'Finder(): finder name must be a defined finder() ' + name);
    assert.equal(typeof fn, 'function', 'Finder(): observer must be a function');
    assert.ok(!params || _.isPlainObject(params), 'Finder(): params is an optional object');
  }
  var finder = this._finders[name],
      paramModel = new finder.paramClass(params || {}),
      observer,
      unobserver;

  observer = function Finder$computed$observer(snapshot) {<commit_msg>add finder assert on fn<commit_after>var assert = require('assert'),
    _ = require('lodash'),
    Model = require('./model');

var Finder = function Finder(store) {
  this._store = store;
  this._finders = {};
  this._observers = [];

  this._store.observe(this._observeStore.bind(this));
};

Finder.prototype.finder = function Finder$finder(name, paramTypes, fn) {
  if (process.env.NODE_ENV !== 'production') {
    assert.ok(name && typeof name === 'string', 'Finder(): finder name must be string');
    assert.ok(_.isPlainObject(paramTypes), 'Finder(): paramTypes must be a model-like schema of key:string -> type:Str/Decimal/Bool');
    assert.equal(typeof fn, 'function', 'Finder(): finder function must be function');
  }
  this._finders[name] = {
    paramClass: Model.define(paramTypes),
    finder: fn
  };
};

Finder.prototype.observe = function Finder$observe(name, fn, params) {
  if (process.env.NODE_ENV === 'production') {
    assert.ok(name in this._finders, 'Finder(): finder name must be a defined finder() ' + name);
    assert.equal(typeof fn, 'function', 'Finder(): observer must be a function');
    assert.ok(!params || _.isPlainObject(params), 'Finder(): params is an optional object');
  }
  var finder = this._finders[name],
      paramModel = new finder.paramClass(params || {}),
      observer,
      unobserver;

  observer = function Finder$computed$observer(snapshot) {
{'fraction_non_alphanumeric': 0.15847801994828223, 'fraction_numerical': 0.0, 'mean_word_length': 4.217726396917149, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2590265', 'n_tokens_mistral': 840, 'n_tokens_neox': 834, 'n_words': 207}