<commit_before>var def = require('def.js')

var schema = module.exports = function() {
  return schema.fromJS.apply(this, arguments)
}

schema.fromJS = def()
<commit_msg>Add inheritance as a way of creating schemas.<commit_after>var def = require('def.js')
  , global = (function(){ return this }())

var schema = module.exports = function(f, options) {
  // If called as simple function, forward everything to fromJS
  if (this === global) return schema.fromJS.apply(this, arguments)
  
  // If called as parent constructor
  if (!this.validate) throw new Error('Schemas must have validate function.')
  
  var validate = this.validate.bind(this)
  
  for (var property in this) {
    if (this[property] instanceof Function) validate[property] = this[property].bind(this)
  }
  
  validate.schema = validate
  
  return validate
}

schema.fromJS = def()

{'fraction_non_alphanumeric': 0.1216374269005848, 'fraction_numerical': 0.0, 'mean_word_length': 4.035294117647059, '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': '5164921', 'n_tokens_mistral': 255, 'n_tokens_neox': 253, 'n_words': 80}