<commit_before>'use strict';

const path = require('path');
const fs = require('fs');

class StrategyFactory {
  constructor(pathToStrategies) {
    if(pathToStrategies) {
      this.path = pathToStrategies;
    } else {
      this.path = path.resolve(__dirname,'../../../lib/strategies');
    }
  }

  resolveInstances() {
    return fs.readdirSync(this.path).filter(f => {
      return f.indexOf('.js') !== -1;
    }).map(f => {
      const file = require(path.join(this.path, f));
      return new file();
    });
  }
}
<commit_msg>Ensure StrategyFactory only uses classes that implement BotStrategyBase<commit_after>'use strict';

const path = require('path');
const fs = require('fs');
const BotStrategyBase = require('./bot-strategy-base');

class StrategyFactory {
  constructor(pathToStrategies) {
    if(pathToStrategies) {
      this.path = pathToStrategies;
    } else {
      this.path = path.resolve(__dirname,'../../../lib/strategies');
    }
  }

  resolveInstances() {
    return fs.readdirSync(this.path).filter(f => {
      return f.indexOf('.js') !== -1;
    }).reduce((results, f) => {
      const file = require(path.join(this.path, f));
      if (file.prototype instanceof BotStrategyBase) {
        results.push(new file());
      }

      return results;
    }, []);
  }
}

{'fraction_non_alphanumeric': 0.17039321511179645, 'fraction_numerical': 0.0015420200462606013, 'mean_word_length': 2.98159509202454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2191030', 'n_tokens_mistral': 416, 'n_tokens_neox': 410, 'n_words': 78}