<commit_before>import "reflect-metadata";
import {isArray, isClass, isFalsy, isFunction, isObject, isPresent, isString, toString} from "../core";
import {IProvider} from "../interfaces/iprovider";

export const INJECT_KEYS = "inject:paramtypes";
export const FUNCTION_KEYS = "function:decorators";
export const FUNCTION_PARAMS = "function:paramtypes";
export const DESIGN_PARAMTYPES_KEYS = "design:paramtypes";
export const DESIGN_KEYS = "design:type";
export const DESIGN_RETURN = "design:returntype";
export const COMPONENT_CONFIG_KEYS = "component:paramtypes";

/**
 * @since 1.0.0
 * @constructor
 * @function
 * @name Metadata
 *
 * @description
 * Metadata is responsible for getting or setting metadata definitions for some Class
 * It's crucial for injector
 */
export class Metadata {
  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#getName
   * @param {Object} Class
   * @param {string} prefix
   *
   * @description
   * Get class name
   */
  static getName(Class: any, prefix?: string): string {
    if (Metadata.isProvider(Class)) {
      return Metadata.getName(Class.provide);
    }
    let message = "";
    if (prefix) {
      message += prefix;
    }
    if (isPresent(Class)) {
      if (isPresent(Class.name)) {
        message += Class.name;
      } else if (isPresent(Class.constructor) && isPresent(Class.constructor.name)) {
        message += Class.constructor.name;
      }
    }
    return message;
  };

  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#isProvider
   * @param token
   * @returns {boolean}
   *
   * @description
   * Check if token is provider
   */
  static isProvider(token: any): boolean {
    return isPresent(token) &&
      isObject(token) &&
      isPresent(token.provide) &&
      (isString(token.provide) || isClass(token.provide)) &&
      (isPresent(token.useValue) || isClass(token.useClass) || isFunction(token.useFactory));
  }
<commit_msg>Added provider in providers check<commit_after>import "reflect-metadata";
import {isArray, isClass, isEqual, isFalsy, isFunction, isObject, isPresent, isString, toString} from "../core";
import {IProvider} from "../interfaces/iprovider";

export const INJECT_KEYS = "inject:paramtypes";
export const FUNCTION_KEYS = "function:decorators";
export const FUNCTION_PARAMS = "function:paramtypes";
export const DESIGN_PARAMTYPES_KEYS = "design:paramtypes";
export const DESIGN_KEYS = "design:type";
export const DESIGN_RETURN = "design:returntype";
export const COMPONENT_CONFIG_KEYS = "component:paramtypes";

/**
 * @since 1.0.0
 * @constructor
 * @function
 * @name Metadata
 *
 * @description
 * Metadata is responsible for getting or setting metadata definitions for some Class
 * It's crucial for injector
 */
export class Metadata {
  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#getName
   * @param {Object} Class
   * @param {string} prefix
   *
   * @description
   * Get class name
   */
  static getName(Class: any, prefix?: string): string {
    if (Metadata.isProvider(Class)) {
      return Metadata.getName(Class.provide);
    }
    let message = "";
    if (prefix) {
      message += prefix;
    }
    if (isPresent(Class)) {
      if (isPresent(Class.name)) {
        message += Class.name;
      } else if (isPresent(Class.constructor) && isPresent(Class.constructor.name)) {
        message += Class.constructor.name;
      }
    }
    return message;
  };

  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#inVerifiedProvider
   *
   * @param providers
   * @param provider
   * @returns {boolean}
   *
   * @description
   * Check if provider is in array of providers
   */
  static inVerifiedProviders(providers: Array<IProvider>, provider: IProvider) {
    return providers.some(item => isEqual(item, provider));
  }

  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#inProviders
   *
   * @param providers
   * @param provider
   * @returns {boolean}
   *
   * @description
   * Check if provider is in array of providers
   */
  static inProviders(providers: Array<any>, provider: any): boolean {
    return Metadata.inVerifiedProviders(Metadata.verifyProviders(providers), Metadata.verifyProvider(provider));
  }

  /**
   * @since 1.0.0
   * @static
   * @function
   * @name Metadata#isProvider
   * @param token
   * @returns {boolean}
   *
   * @description
   * Check if token is provider
   */
  static isProvider(token: any): boolean {
    return isPresent(token) &&
      isObject(token) &&
      isPresent(token.provide) &&
      (isString(token.provide) || isClass(token.provide)) &&
      (isPresent(token.useValue) || isClass(token.useClass) || isFunction(token.useFactory));
  }

{'fraction_non_alphanumeric': 0.1297548605240913, 'fraction_numerical': 0.00507185122569738, 'mean_word_length': 3.3783533765032376, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '5291448', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1468, 'n_words': 357}