<commit_before>// external
import { Inject, ModuleWithProviders, NgModule, Optional } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';

// internal
import { FormElementComponent } from './ngx-form-element.component';
import { FormElementConfig, FormElementService } from './ngx-form-element.service';
import { ValidatorService } from './ngx-form-element-validator.service';

/**
 * To dynamic create HTML Form Elements.
 * @export
 * @class FormElementModule
 */
@NgModule({
  imports: [
    CommonModule,
    ReactiveFormsModule
  ],
  declarations: [ FormElementComponent ],
  exports: [ FormElementComponent ]
})
export class FormElementModule {
  /**
   * forRoot with param config to configure before html elements.
   * @static
   * @param {FormElementConfig} config
   * @returns {ModuleWithProviders}
   * @memberof FormElementModule
   */
  static forRoot( @Optional() @Inject(FormElementConfig) config?: FormElementConfig): ModuleWithProviders {
    return {
      ngModule: FormElementModule,
      providers: (config) ?
        [
          FormElementService,
          ValidatorService,
          { provide: FormElementConfig, useValue: config }
        ] :
        [
          FormElementService,
          ValidatorService
        ]
    }
  }

  /**
   * @static
   * @returns
   * @memberof FormElementModule
   */
  static forChild() {
    return {
      ngModule: FormElementModule
    };
  }
}<commit_msg>refactor: simplify code, add providers to forChild static method<commit_after>// external
import { forwardRef, Inject, ModuleWithProviders, NgModule, Optional } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';

// internal
import { FormElementComponent } from './ngx-form-element.component';
import { FormElementConfig, FormElementService } from './ngx-form-element.service';
import { ValidatorService } from './ngx-form-element-validator.service';

/**
 * To dynamic create HTML Form Elements.
 * @export
 * @class FormElementModule
 */
@NgModule({
  imports: [
    CommonModule,
    ReactiveFormsModule
  ],
  declarations: [ FormElementComponent ],
  exports: [ FormElementComponent ]
})
export class FormElementModule {
  /**
   * forRoot with param config to configure before html elements.
   * @static
   * @param {FormElementConfig} config
   * @returns {ModuleWithProviders}
   * @memberof FormElementModule
   */
  static forRoot(@Optional() @Inject(FormElementConfig) config?: FormElementConfig): ModuleWithProviders {
    return {
      ngModule: FormElementModule,
      providers: [
        FormElementService,
        ValidatorService,
        {provide: FormElementConfig, useValue: config, multi: true}
      ]
    }
  }

  /**
   * @static
   * @returns
   * @memberof FormElementModule
   */
  static forChild(config: FormElementConfig): ModuleWithProviders {
    return {
      ngModule: FormElementModule,
      providers: [
        {provide: FormElementConfig, useValue: config, multi: true}
      ]
    };
  }
}
{'fraction_non_alphanumeric': 0.10975217251367879, 'fraction_numerical': 0.0, 'mean_word_length': 3.396039603960396, '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': '1759690', 'n_tokens_mistral': 863, 'n_tokens_neox': 862, 'n_words': 210}