<commit_before>require('dotenv').config();

import RiotRateLimiter from 'riot-ratelimiter';
const RRLStrategies = require('riot-ratelimiter/dist/RateLimiter').STRATEGY;

import ParameterHelper from './Utils/ParameterHelper';
import Errors from './Errors';

import ChallengerEndpoint from './Endpoints/LeagueEndpoint/ChallengerEndpoint';
import ChampionEndpoint from './Endpoints/ChampionEndpoint';
import ChampionMasteryEndpoint from './Endpoints/ChampionMasteryEndpoint';
import CurrentGameEndpoint from './Endpoints/SpectatorEndpoint/CurrentGameEndpoint';
import FeaturedGamesEndpoint from './Endpoints/SpectatorEndpoint/FeaturedGamesEndpoint';
import LeagueEndpoint from './Endpoints/LeagueEndpoint/LeagueEndpoint';
import LeaguePositionsEndpoint from './Endpoints/LeagueEndpoint/LeaguePositionsEndpoint';
import LeaguesEndpoint from './Endpoints/LeagueEndpoint/LeaguesEndpoint';
import MasterEndpoint from './Endpoints/LeagueEndpoint/MasterEndpoint';
import MasteriesEndpoint from './Endpoints/MasteriesEndpoint';
import MatchEndpoint from './Endpoints/MatchEndpoint/MatchEndpoint';
import MatchlistEndpoint from './Endpoints/MatchEndpoint/MatchlistEndpoint';
import RunesEndpoint from './Endpoints/RunesEndpoint';
import StaticChampionEndpoint from './Endpoints/StaticEndpoints/StaticChampionEndpoint';
import StaticItemEndpoint from './Endpoints/StaticEndpoints/StaticItemEndpoint';
import StaticLanguageStringsEndpoint from './Endpoints/StaticEndpoints/StaticLanguageStringsEndpoint';
import StaticLanguageEndpoint from './Endpoints/StaticEndpoints/StaticLanguageEndpoint';
import StaticMapEndpoint from './Endpoints/StaticEndpoints/StaticMapEndpoint';
import StaticMasteryEndpoint from './Endpoints/StaticEndpoints/StaticMasteryEndpoint';
import StaticProfileIconEndpoint from './Endpoints/StaticEndpoints/StaticProfileIconEndpoint';
import StaticRealmEndpoint from './Endpoints/StaticEndpoints/StaticRealmEndpoint';
import StaticRuneEndpoint from './Endpoints/StaticEndpoints/StaticRuneEndpoint';
import StaticSummonerSpellEndpoint from './Endpoints/StaticEndpoints/StaticSummonerSpellEndpoint.js';
import StaticVersionEndpoint from './Endpoints/StaticEndpoints/StaticVersionEndpoint';
import StatusEndpoint from './Endpoints/StatusEndpoint';
import SummonerEndpoint from './Endpoints/SummonerEndpoint';

const defaultConfig = {
  region: 'na',
  debugOptions: {
    isEnabled: true,
    showKey: false,
  },
  requestOptions: {
    shouldRetry: true,
    numberOfRetriesBeforeAbort: 3,
    delayBeforeRetry: 1000,
    burst: false,
  },
  cacheOptions: {
    cache: null,
    ttls: {},
  },
};

class Kayn {
  constructor(key = process.env.RIOT_LOL_API_KEY, config = defaultConfig) {
    if (!ParameterHelper.isKeyValid(key)) {
      throw new Error('Failed to initialize Kayn');
    }

    this.config = {
      ...defaultConfig,
      ...config,
      key,
    };

    const strategy = this.config.requestOptions.burst
      ? RRLStrategies.BURST
      : RRLStrategies.SPREAD;

    this.limiter = new RiotRateLimiter({
      strategy,
    });

    // Set up interfaces
    this.Challenger = new ChallengerEndpoint(this.config, this.limiter);
    this.Champion = new ChampionEndpoint(this.config, this.limiter);
    this.ChampionMastery = new ChampionMasteryEndpoint(
      this.config,
      this.limiter,
    );
    this.CurrentGame = new CurrentGameEndpoint(this.config, this.limiter);
    this.FeaturedGames = new FeaturedGamesEndpoint(this.config, this.limiter);
    this.League = new LeagueEndpoint(this.config, this.limiter);
    this.LeaguePositions = new LeaguePositionsEndpoint(
      this.config,
      this.limiter,
    );
    this.Leagues = new LeaguesEndpoint(this.config, this.limiter);
    this.Master = new MasterEndpoint(this.config, this.limiter);
    this.Masteries = new MasteriesEndpoint(this.config, this.limiter);
    this.Match = new MatchEndpoint(this.config, this.limiter);
    this.Matchlist = new MatchlistEndpoint(this.config, this.limiter);
    this.Runes = new RunesEndpoint(this.config, this.limiter);
    this.Static = {
      Champion: new StaticChampionEndpoint(this.config, this.limiter),
      Item: new StaticItemEndpoint(this.config, this.limiter),
      LanguageString: new StaticLanguageStringsEndpoint(
        this.config,
        this.limiter,
      ),
      Language: new StaticLanguageEndpoint(this.config, this.limiter),
      Map: new StaticMapEndpoint(this.config, this.limiter),
      Mastery: new StaticMasteryEndpoint(this.config, this.limiter),
      ProfileIcon: new StaticProfileIconEndpoint(this.config, this.limiter),
      Realm: new StaticRealmEndpoint(this.config, this.limiter),
      Rune: new StaticRuneEndpoint(this.config, this.limiter),
      SummonerSpell: new StaticSummonerSpellEndpoint(this.config, this.limiter),
      Version: new StaticVersionEndpoint(this.config, this.limiter),
    };
    this.Summoner = new SummonerEndpoint(this.config, this.limiter);
    this.Status = new StatusEndpoint(this.config, this.limiter);
  }

  flushCache(cb) {
    return new Promise(async (resolve, reject) => {
      if (cb) {
        this.config.cacheOptions.cache.flushCache(cb);
      } else {
        this.config.cacheOptions.cache.flushCache((err, data) => {
          err ? reject(err) : resolve(data);
        });
      }
    });
  }
}

import REGIONS from 'Enums/regions';
import METHOD_NAMES from 'Enums/method-names';<commit_msg>chore (Kayn) - remove leftover async<commit_after>require('dotenv').config();

import RiotRateLimiter from 'riot-ratelimiter';
const RRLStrategies = require('riot-ratelimiter/dist/RateLimiter').STRATEGY;

import ParameterHelper from './Utils/ParameterHelper';
import Errors from './Errors';

import ChallengerEndpoint from './Endpoints/LeagueEndpoint/ChallengerEndpoint';
import ChampionEndpoint from './Endpoints/ChampionEndpoint';
import ChampionMasteryEndpoint from './Endpoints/ChampionMasteryEndpoint';
import CurrentGameEndpoint from './Endpoints/SpectatorEndpoint/CurrentGameEndpoint';
import FeaturedGamesEndpoint from './Endpoints/SpectatorEndpoint/FeaturedGamesEndpoint';
import LeagueEndpoint from './Endpoints/LeagueEndpoint/LeagueEndpoint';
import LeaguePositionsEndpoint from './Endpoints/LeagueEndpoint/LeaguePositionsEndpoint';
import LeaguesEndpoint from './Endpoints/LeagueEndpoint/LeaguesEndpoint';
import MasterEndpoint from './Endpoints/LeagueEndpoint/MasterEndpoint';
import MasteriesEndpoint from './Endpoints/MasteriesEndpoint';
import MatchEndpoint from './Endpoints/MatchEndpoint/MatchEndpoint';
import MatchlistEndpoint from './Endpoints/MatchEndpoint/MatchlistEndpoint';
import RunesEndpoint from './Endpoints/RunesEndpoint';
import StaticChampionEndpoint from './Endpoints/StaticEndpoints/StaticChampionEndpoint';
import StaticItemEndpoint from './Endpoints/StaticEndpoints/StaticItemEndpoint';
import StaticLanguageStringsEndpoint from './Endpoints/StaticEndpoints/StaticLanguageStringsEndpoint';
import StaticLanguageEndpoint from './Endpoints/StaticEndpoints/StaticLanguageEndpoint';
import StaticMapEndpoint from './Endpoints/StaticEndpoints/StaticMapEndpoint';
import StaticMasteryEndpoint from './Endpoints/StaticEndpoints/StaticMasteryEndpoint';
import StaticProfileIconEndpoint from './Endpoints/StaticEndpoints/StaticProfileIconEndpoint';
import StaticRealmEndpoint from './Endpoints/StaticEndpoints/StaticRealmEndpoint';
import StaticRuneEndpoint from './Endpoints/StaticEndpoints/StaticRuneEndpoint';
import StaticSummonerSpellEndpoint from './Endpoints/StaticEndpoints/StaticSummonerSpellEndpoint.js';
import StaticVersionEndpoint from './Endpoints/StaticEndpoints/StaticVersionEndpoint';
import StatusEndpoint from './Endpoints/StatusEndpoint';
import SummonerEndpoint from './Endpoints/SummonerEndpoint';

const defaultConfig = {
  region: 'na',
  debugOptions: {
    isEnabled: true,
    showKey: false,
  },
  requestOptions: {
    shouldRetry: true,
    numberOfRetriesBeforeAbort: 3,
    delayBeforeRetry: 1000,
    burst: false,
  },
  cacheOptions: {
    cache: null,
    ttls: {},
  },
};

class Kayn {
  constructor(key = process.env.RIOT_LOL_API_KEY, config = defaultConfig) {
    if (!ParameterHelper.isKeyValid(key)) {
      throw new Error('Failed to initialize Kayn');
    }

    this.config = {
      ...defaultConfig,
      ...config,
      key,
    };

    const strategy = this.config.requestOptions.burst
      ? RRLStrategies.BURST
      : RRLStrategies.SPREAD;

    this.limiter = new RiotRateLimiter({
      strategy,
    });

    // Set up interfaces
    this.Challenger = new ChallengerEndpoint(this.config, this.limiter);
    this.Champion = new ChampionEndpoint(this.config, this.limiter);
    this.ChampionMastery = new ChampionMasteryEndpoint(
      this.config,
      this.limiter,
    );
    this.CurrentGame = new CurrentGameEndpoint(this.config, this.limiter);
    this.FeaturedGames = new FeaturedGamesEndpoint(this.config, this.limiter);
    this.League = new LeagueEndpoint(this.config, this.limiter);
    this.LeaguePositions = new LeaguePositionsEndpoint(
      this.config,
      this.limiter,
    );
    this.Leagues = new LeaguesEndpoint(this.config, this.limiter);
    this.Master = new MasterEndpoint(this.config, this.limiter);
    this.Masteries = new MasteriesEndpoint(this.config, this.limiter);
    this.Match = new MatchEndpoint(this.config, this.limiter);
    this.Matchlist = new MatchlistEndpoint(this.config, this.limiter);
    this.Runes = new RunesEndpoint(this.config, this.limiter);
    this.Static = {
      Champion: new StaticChampionEndpoint(this.config, this.limiter),
      Item: new StaticItemEndpoint(this.config, this.limiter),
      LanguageString: new StaticLanguageStringsEndpoint(
        this.config,
        this.limiter,
      ),
      Language: new StaticLanguageEndpoint(this.config, this.limiter),
      Map: new StaticMapEndpoint(this.config, this.limiter),
      Mastery: new StaticMasteryEndpoint(this.config, this.limiter),
      ProfileIcon: new StaticProfileIconEndpoint(this.config, this.limiter),
      Realm: new StaticRealmEndpoint(this.config, this.limiter),
      Rune: new StaticRuneEndpoint(this.config, this.limiter),
      SummonerSpell: new StaticSummonerSpellEndpoint(this.config, this.limiter),
      Version: new StaticVersionEndpoint(this.config, this.limiter),
    };
    this.Summoner = new SummonerEndpoint(this.config, this.limiter);
    this.Status = new StatusEndpoint(this.config, this.limiter);
  }

  flushCache(cb) {
    return new Promise((resolve, reject) => {
      if (cb) {
        this.config.cacheOptions.cache.flushCache(cb);
      } else {
        this.config.cacheOptions.cache.flushCache((err, data) => {
          err ? reject(err) : resolve(data);
        });
      }
    });
  }
}

import REGIONS from 'Enums/regions';
import METHOD_NAMES from 'Enums/method-names';
{'fraction_non_alphanumeric': 0.10547199409430655, 'fraction_numerical': 0.0009227646027498385, 'mean_word_length': 4.633056133056133, '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': '1395644', 'n_tokens_mistral': 3078, 'n_tokens_neox': 3008, 'n_words': 608}