<commit_before>/**
 * @license
 * Copyright (c) 2017 Google Inc. All rights reserved.
 * This code may only be used under the BSD style license found at
 * http://polymer.github.io/LICENSE.txt
 * Code distributed by Google as part of this project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */

class Schema {
  constructor(parsedSchema, parent) {
    this.name = parsedSchema.name;
    this.parent = parent;
    this._normative = {};
    this._optional = {};
    for (var section of parsedSchema.sections) {
      var into = section.sectionType == 'normative' ? this._normative : this._optional;
      for (var field in section.fields) {
        // TODO normalize field types here?
        into[field] = section.fields[field];
      }
    }
  }

  get normative() {
    var dict = this.parent ? this.parent.normative : {};
    for (var key in this._normative)
      dict[key] = this._normative[key];
    return dict;
  }

  get optional() {
    var dict = this.parent ? this.parent.optional : {};
    for (var key in this._optional)
      dict[key] = this._optional[key];
    return dict;
  }  
}

module.exports = Schema;<commit_msg>Use Object.assign. It's better.<commit_after>/**
 * @license
 * Copyright (c) 2017 Google Inc. All rights reserved.
 * This code may only be used under the BSD style license found at
 * http://polymer.github.io/LICENSE.txt
 * Code distributed by Google as part of this project is also
 * subject to an additional IP rights grant found at
 * http://polymer.github.io/PATENTS.txt
 */

class Schema {
  constructor(parsedSchema, parent) {
    this.name = parsedSchema.name;
    this.parent = parent;
    this._normative = {};
    this._optional = {};
    for (var section of parsedSchema.sections) {
      var into = section.sectionType == 'normative' ? this._normative : this._optional;
      for (var field in section.fields) {
        // TODO normalize field types here?
        into[field] = section.fields[field];
      }
    }
  }

  get normative() {
    var dict = this.parent ? this.parent.normative : {};
    Object.assign(dict, this._normative);
    return dict;
  }

  get optional() {
    var dict = this.parent ? this.parent.optional : {};
    Object.assign(dict, this._optional);
    return dict;
  }  
}

module.exports = Schema;
{'fraction_non_alphanumeric': 0.11820128479657388, 'fraction_numerical': 0.003426124197002141, 'mean_word_length': 2.8484349258649093, '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': '2710529', 'n_tokens_mistral': 700, 'n_tokens_neox': 675, 'n_words': 212}