<commit_before>﻿import nj from '../core';
import * as tools from './tools';
const { components, componentConfig } = nj;

export default function registerComponent(name, component, options) {
  let params = name, ret;
  if (!tools.isObject(name)) {
    params = {};
    params[name] = {
      component,
      options
    };
  }

  tools.each(params, (v, k, i) => {
    let comp;
    if (v != null) {
      const { component, options } = v;
      const name = k.toLowerCase();

      comp = component ? component : v;
      components[name] = comp;
      componentConfig.set(comp, options);
    }

    if (i == 0) {
      ret = comp;
    }
    else {
      if (i == 1) {
        ret = [ret];
      }
      ret.push(comp);
    }
  }, false);

  return ret;
}

export function getComponentConfig(name) {
  return componentConfig.get(tools.isString(name) ? components[name] : name);
}

export function copyComponentConfig(component, from) {
  componentConfig.set(component, componentConfig.get(from));
  return component;<commit_msg>Fixed bug for default component config<commit_after>﻿import nj from '../core';
import * as tools from './tools';
const { components, componentConfig } = nj;

export default function registerComponent(name, component, options) {
  let params = name, ret;
  if (!tools.isObject(name)) {
    params = {};
    params[name] = {
      component,
      options
    };
  }

  tools.each(params, (v, k, i) => {
    let comp;
    if (v != null) {
      const { component, options } = v;
      const name = k.toLowerCase();

      comp = component ? component : v;
      components[name] = comp;
      componentConfig.set(comp, options);
    }

    if (i == 0) {
      ret = comp;
    }
    else {
      if (i == 1) {
        ret = [ret];
      }
      ret.push(comp);
    }
  }, false);

  return ret;
}

export function getComponentConfig(name) {
  return componentConfig.get(tools.isString(name) ? components[name] || name : name);
}

export function copyComponentConfig(component, from) {
  componentConfig.set(component, componentConfig.get(from));
  return component;
{'fraction_non_alphanumeric': 0.1406025824964132, 'fraction_numerical': 0.001912960306073649, 'mean_word_length': 2.7092198581560285, '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': '5501336', 'n_tokens_mistral': 650, 'n_tokens_neox': 644, 'n_words': 171}