<commit_before>import {SchemaArray} from './SchemaArray.js'
import {SchemaStruct} from './SchemaStruct.js'
import {isObject, isArray} from 'sav-util'
import {SCHEMA_ARRAY} from './consts.js'

let injects = {
  check (obj, fields) {
    return this.validate(obj, true, fields)
  },
  checkThen (obj, fields) {
    return Promise.resolve().then(() => this.check(obj, fields))
  },
  extract (obj, fields) {
    return this.validate(obj, false, fields)
  },
  extractThen (obj, fields) {
    return Promise.resolve().then(() => this.extract(obj, fields))
  },
  createRequest (obj) {
    return this.create(createInput(this, obj || this.opts.req))
  },
  createResponse (obj) {
    return this.create(createInput(this, obj || this.opts.res))
  }
}

function createInput (self, obj) {
  let ret
  if (self.schemaType === SCHEMA_ARRAY) {<commit_msg>add getopt<commit_after>import {SchemaArray} from './SchemaArray.js'
import {SchemaStruct} from './SchemaStruct.js'
import {isObject, isArray} from 'sav-util'
import {SCHEMA_ARRAY} from './consts.js'

let injects = {
  check (obj, fields) {
    return this.validate(obj, true, fields)
  },
  checkThen (obj, fields) {
    return Promise.resolve().then(() => this.check(obj, fields))
  },
  extract (obj, fields) {
    return this.validate(obj, false, fields)
  },
  extractThen (obj, fields) {
    return Promise.resolve().then(() => this.extract(obj, fields))
  },
  createRequest (obj) {
    return this.create(createInput(this, obj || this.opts.req))
  },
  createResponse (obj) {
    return this.create(createInput(this, obj || this.opts.res))
  },
  getOpt (name) {
    return this.opts[name]
  }
}

function createInput (self, obj) {
  let ret
  if (self.schemaType === SCHEMA_ARRAY) {
{'fraction_non_alphanumeric': 0.16023054755043228, 'fraction_numerical': 0.0, 'mean_word_length': 3.917847025495751, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5429383', 'n_tokens_mistral': 581, 'n_tokens_neox': 578, 'n_words': 141}