<commit_before>import Report from './interfaces/Report';
import Options from './interfaces/Options';
import Slot from './interfaces/Slot';
import MarksIndex from './interfaces/MarksIndex';
import Loader from './interfaces/Loader';
import loaders from './loaders';

import {
  mergeOptions,
} from './utils';

const presetLoaders: Loader[] = [
  loaders.processCompress,
  loaders.slotGen,
  loaders.processCover,
  loaders.insertMarks,
  loaders.loadAsserts,
  loaders.indexObjGen,
  loaders.sortKeyGen
];

const defaultOptions: Options = {
  errorPrefix: 'error',
  idPrefix: new Date().getTime().toString(36),
  compress: {
    enable: true,
    needToCompressIdentifier: ['缺少空格', '多余空格'],
  },
  logs: {
    enable: true,
  },
  presetLoaders: {
    enable: true,
    loaders: presetLoaders,
  },
  customLoaders: {
    enable: false,
    loaders: null,
  },
};

class WRP {
  readonly article: string;
  readonly reportJSON: Report;
  readonly _config: Options;
  readonly _temp: any;
  readonly _data: any;

  private slots: Slot[];
  private marksIndex: MarksIndex;
  
  constructor(
    article: string,
    reportJSON: Report,
    options: Options
  ) {
    this.article = article;
    this.reportJSON = reportJSON;
    this._temp = {
      lastEndIndex: 0,
      compressMarks: [],
    };
    this._data = {
      slots: [],
    };

    this._config = mergeOptions(defaultOptions, options);
    // console.log(this._config);
    // console.log(loaders)
    let loaders: Loader[] = [];
    if (this._config.presetLoaders.enable) {
      loaders = loaders.concat(this._config.presetLoaders.loaders);
    }
    if (this._config.customLoaders.enable) {
      loaders = loaders.concat(this._config.customLoaders.loaders);
    }

    this.runLoaders(...loaders);
    this.slots = this._data.slots;
    this.marksIndex = this._data.indexObj;
  }

  getSlots() {
    return this.slots;
  }

  getMarksIndex() {
    return this.marksIndex;
  }

  private runLoaders(...loaders: Loader[]): void {
    var marks = this.reportJSON.marks;

    var self = this;
    loaders.forEach(function (loader) {
      loader.apply(self, marks)
    });
  }
}

module.exports = WRP;<commit_msg>fix: this<commit_after>import Report from './interfaces/Report';
import Options from './interfaces/Options';
import Slot from './interfaces/Slot';
import MarksIndex from './interfaces/MarksIndex';
import Loader from './interfaces/Loader';
import loaders from './loaders';

import {
  mergeOptions,
} from './utils';

const presetLoaders: Loader[] = [
  loaders.processCompress,
  loaders.slotGen,
  loaders.processCover,
  loaders.insertMarks,
  loaders.loadAsserts,
  loaders.indexObjGen,
  loaders.sortKeyGen
];

const defaultOptions: Options = {
  errorPrefix: 'error',
  idPrefix: new Date().getTime().toString(36),
  compress: {
    enable: true,
    needToCompressIdentifier: ['缺少空格', '多余空格'],
  },
  logs: {
    enable: true,
  },
  presetLoaders: {
    enable: true,
    loaders: presetLoaders,
  },
  customLoaders: {
    enable: false,
    loaders: null,
  },
};

class WRP {
  readonly article: string;
  readonly reportJSON: Report;
  readonly _config: Options;
  readonly _temp: any;
  readonly _data: any;

  private slots: Slot[];
  private marksIndex: MarksIndex;
  
  constructor(
    article: string,
    reportJSON: Report,
    options: Options
  ) {
    this.article = article;
    this.reportJSON = reportJSON;
    this._temp = {
      lastEndIndex: 0,
      compressMarks: [],
    };
    this._data = {
      slots: [],
    };

    this._config = mergeOptions(defaultOptions, options);
    // console.log(this._config);
    // console.log(loaders)
    let loaders: Loader[] = [];
    if (this._config.presetLoaders.enable) {
      loaders = loaders.concat(this._config.presetLoaders.loaders);
    }
    if (this._config.customLoaders.enable) {
      loaders = loaders.concat(this._config.customLoaders.loaders);
    }

    this.runLoaders(...loaders);
    this.slots = this._data.slots;
    this.marksIndex = this._data.indexObj;
  }

  getSlots() {
    return this.slots;
  }

  getMarksIndex() {
    return this.marksIndex;
  }

  private runLoaders(...loaders: Loader[]): void {
    var marks = this.reportJSON.marks;

   loaders.forEach((loader) => {
      loader.apply(this, marks)
    });
  }
}

module.exports = WRP;
{'fraction_non_alphanumeric': 0.13489125404905136, 'fraction_numerical': 0.0013882461823229986, 'mean_word_length': 3.128939828080229, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '7338587', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1445, 'n_words': 292}