<commit_before>import * as Debug from 'debug';

const d = Debug('DI');

const singletons: Object = {};

export const registerSingleton = (target: any) => {
  d('registering singleton:', target);

  const className = target.name;
  d('classname: ', className);


  (singletons as any)[className] = new target();

  d('singletons', singletons);
}

export const getSingleton = (name: string) => {

  d('retrieving singleton:', singletons);

  return (singletons as any)[name];

}

// export class DIManager {
//
//   private singletons: Object = {};
//
//   constructor() {
//
//   }
//
//   public registrer(singleton: any) {
//     d('registering singleton:', singleton);
//     // this.singletons[singleton.constructor.name] = new singleton();
//   }
//
// }<commit_msg>di should expose instantiated singletons using name defined in decorator<commit_after>import * as Debug from 'debug';

const d = Debug('DI');

const singletons: Object = {};

export const registerSingleton = (target: any) => {
  d('registering singleton:', target);

  const className = target.name;
  d('classname: ', className);

  const serviceName = target.prototype['__service__'].name;

  d('serviceName: ', serviceName);


  (singletons as any)[serviceName] = new target();

  d('singletons', singletons);
}

export const getSingleton = (name: string) => {

  d('retrieving singleton:', singletons);

  return (singletons as any)[name];

}

export const getServices = () => {
  return singletons;
}

// export class DIManager {
//
//   private singletons: Object = {};
//
//   constructor() {
//
//   }
//
//   public registrer(singleton: any) {
//     d('registering singleton:', singleton);
//     // this.singletons[singleton.constructor.name] = new singleton();
//   }
//
// }
{'fraction_non_alphanumeric': 0.17131474103585656, 'fraction_numerical': 0.0, 'mean_word_length': 3.5309278350515463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '587832', 'n_tokens_mistral': 576, 'n_tokens_neox': 536, 'n_words': 137}