<commit_before>'use strict'

module.exports = makeContainer()

const components = require('./components')

function makeContainer() {
  return class Container {
    constructor(components) {
      this.components = {}
      Object.keys(components || {}).forEach(key => {
        this.set(key, components[key])
      })
    }

    set(key, component) {
      return this._addComponent(key, components.coerce(component))
    }

    nest(key, container) {
      return this._addComponent(key, components.container(container))
    }

    store(key, value) {
      return this._addComponent(key, components.value(value))
    }

    define(key, factory, context) {
      return this._addComponent(key, components.factory(factory, context))
    }

    link(key, targetKey, context) {
      return this._addComponent(key, components.link(context || this, targetKey))
    }

    _addComponent(key, component) {
      this.components[key] = component
      return this._defineGetter(key)<commit_msg>Container: extract #setAll method<commit_after>'use strict'

module.exports = makeContainer()

const components = require('./components')

function makeContainer() {
  return class Container {
    constructor(components) {
      this.components = {}
      this.setAll(components)
    }

    setAll(components) {
      Object.keys(components || {}).forEach(key => {
        this.set(key, components[key])
      })
    }

    set(key, component) {
      return this._setComponent(key, components.coerce(component))
    }

    nest(key, container) {
      return this._setComponent(key, components.container(container))
    }

    store(key, value) {
      return this._setComponent(key, components.value(value))
    }

    define(key, factory, context) {
      return this._setComponent(key, components.factory(factory, context))
    }

    link(key, targetKey, context) {
      return this._setComponent(key, components.link(context || this, targetKey))
    }

    _setComponent(key, component) {
      this.components[key] = component
      return this._defineGetter(key)
{'fraction_non_alphanumeric': 0.12572815533980583, 'fraction_numerical': 0.0, 'mean_word_length': 3.29375, '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': '1599655', 'n_tokens_mistral': 588, 'n_tokens_neox': 573, 'n_words': 112}