Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kindred-api

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kindred-api - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

src/helpers/colorize-status-message.js

4

dist/kindred-api.min.js

@@ -1,2 +0,2 @@

!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","redis","double-ended-queue","xregexp","request","chalk","xregexp","query-string"],t);else if("undefined"!=typeof exports)t(module,require("redis"),require("double-ended-queue"),require("xregexp"),require("request"),require("chalk"),require("xregexp"),require("query-string"));else{var n={exports:{}};t(n,e.redis,e.doubleEndedQueue,e.xregexp,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=n.exports}}(this,function(e,t,n,i,r,s,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),g=function(){function e(){u(this,e),this.cache={}}return m(e,[{key:"get",value:function(e,t){return this.cache[e.key]?Date.now()>this.cache[e.key].expires?(delete this.cache[e.key],t("expired cache key")):t(null,this.cache[e.key].value):t("cache key doesn't exist")}},{key:"set",value:function(e,t){this.cache[e.key]={expires:e.ttl?Date.now()+1e3*e.ttl:null,value:t}}}]),e}(),h=function(){function e(n){u(this,e);var i=Object.assign({},n||{},{host:"127.0.0.1",port:6379,keyPrefix:"kindredAPI-"});this.client=t.createClient(i.port,i.host),this.client.on("error",function(e){console.log("Redis error:",e)}),process.on("exit",function(){console.log("closing"),this.client.quit()}),this.prefix=i.keyPrefix}return m(e,[{key:"get",value:function(e,t){this.client.get(this.prefix+e.key,function(e,n){n?t(e,n):t(e)})}},{key:"set",value:function(e,n){this.client.setex(this.prefix+e.key,1e3*e.ttl,n,t.print),console.log("set for "+1e3*e.ttl+" milliiseconds")}}]),e}(),d=function(){function e(t,i){u(this,e),this.allowedRequests=t,this.seconds=i,this.madeRequests=new n}return m(e,[{key:"__reload",value:function(){for(var e=(new Date).getTime();this.madeRequests.length>0&&e-this.madeRequests.peekFront()>=1e3*this.seconds;)this.madeRequests.shift()}},{key:"addRequest",value:function(){this.madeRequests.push((new Date).getTime()+1e3*this.seconds)}},{key:"requestAvailable",value:function(){return this.__reload(),this.madeRequests.length<this.allowedRequests}}]),e}(),c={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},p={CHAMPION:c.MONTH,CHAMPION_MASTERY:c.SIX_HOURS,CURRENT_GAME:c.NONE,FEATURED_GAMES:c.NONE,GAME:c.HOUR,LEAGUE:c.SIX_HOURS,STATIC:c.MONTH,STATUS:c.NONE,MATCH:c.MONTH,MATCH_LIST:c.ONE_HOUR,RUNES_MASTERIES:c.WEEK,STATS:c.HOUR,SUMMONER:c.DAY},y={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},v={BRAZIL:"BR1",EUROPE:"EUN1",EUROPE_WEST:"EUW1",KOREA:"KR",LATIN_AMERICA_NORTH:"LA1",LATIN_AMERICA_SOUTH:"LA2",NORTH_AMERICA:"NA1",OCEANIA:"OC1",RUSSIA:"RU",TURKEY:"TR1",JAPAN:"JP1"},f={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},R={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},S={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},I=["in-memory-cache","redis"],b=i("^[0-9\\p{L} _\\.]+$"),_={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},E={int:function(e){return e&&Array.isArray(e)&&_.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&_.string(e)&&e.length>0}},M=function(e){var t=!0,n=!1,i=void 0;try{for(var r,s=Object.keys(f)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(f[o]===e)return!0}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}return!1},q={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},A=function(e){var t=q[e];if(t)return t},U=function(e){return(Array.isArray(e)&&2!==e.length||!E.int(e[0])||2!==e[0].length||!E.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},D=function(){function e(t){var n=t.key,i=t.defaultRegion,r=void 0===i?f.NORTH_AMERICA:i,o=t.debug,a=void 0!==o&&o,l=t.limits,m=t.cacheOptions,c=t.cacheTTL;if(u(this,e),this.key=n,this.defaultRegion=M(r)?r:void 0,this.defaultRegion||(console.log(""+s.red("Initialization of Kindred failed: "+s.yellow(r)+" is an invalid region.")),console.log(""+s.red("Try importing "+s.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=a,m?(m===I[0]?this.cache=new g:m===I[1]?this.cache=new h:this.cache=m,this.CACHE_TIMERS=c?c:p):this.cache={get:function(e,t){return t(null,null)},set:function(e,t){}},this.CACHE_TIMERS||(this.CACHE_TIMERS={CHAMPION:0,CHAMPION_MASTERY:0,CURRENT_GAME:0,FEATURED_GAMES:0,GAME:0,LEAGUE:0,STATIC:0,STATUS:0,MATCH:0,MATCH_LIST:0,RUNES_MASTERIES:0,STATS:0,SUMMONER:0}),l){U(l)&&(console.log(s.red("Initialization of Kindred failed: Invalid "+s.yellow("limits")+". Valid examples: "+s.yellow("[[10, 10], [500, 600]]"))+"."),console.log(s.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+s.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===l&&(l=y.DEV),"prod"===l&&(l=y.PROD);var v=!0,R=!1,S=void 0;try{for(var b,_=Object.keys(f)[Symbol.iterator]();!(v=(b=_.next()).done);v=!0){var E=b.value;this.limits[f[E]]=[new d(l[0][0],l[0][1]),new d(l[1][0],l[1][1])]}}catch(e){R=!0,S=e}finally{try{!v&&_.return&&_.return()}finally{if(R)throw S}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),getTopChampions:this.getTopChamps.bind(this),top:this.getTopChamps.bind(this),best:this.getTopChamps.bind(this)},this.CurrentGame={getCurrentGame:this.getCurrentGame.bind(this),get:this.getCurrentGame.bind(this)},this.FeaturedGames={getFeaturedGames:this.getFeaturedGames.bind(this),get:this.getFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),getMap:this.getMap.bind(this),map:this.getMap.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),realmData:this.getRealmData.bind(this),realm:this.getRealmData.bind(this),realms:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),runes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),rune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),summonerSpells:this.getSummonerSpells.bind(this),spells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),summonerSpell:this.getSummonerSpell.bind(this),spell:this.getSummonerSpell.bind(this),getVersionData:this.getVersionData.bind(this),versionData:this.getVersionData.bind(this),version:this.getVersionData.bind(this),versions:this.getVersionData.bind(this)},this.Status={getShardStatus:this.getShardStatus.bind(this),getStatus:this.getShardStatus.bind(this),get:this.getShardStatus.bind(this),getShardList:this.getShardList.bind(this),getShards:this.getShardList.bind(this),getAll:this.getShardList.bind(this),all:this.getShardList.bind(this)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Runes={get:this.getRunes.bind(this)},this.Masteries={get:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoners:this.getSummoners.bind(this),getAll:this.getSummoners.bind(this),all:this.getSummoners.bind(this),getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),getSummonerNames:this.getSummonerNames.bind(this),getNames:this.getSummonerNames.bind(this),names:this.getSummonerNames.bind(this),getSummonerName:this.getSummonerName.bind(this),getName:this.getSummonerName.bind(this),name:this.getSummonerName.bind(this)}}return m(e,[{key:"canMakeRequest",value:function(e){return!(!this.limits[e][0].requestAvailable()||!this.limits[e][1].requestAvailable())}},{key:"_sanitizeName",value:function(e){if(this._validName(e))return e.replace(/\s/g,"").toLowerCase();this._logError(this._validName.name,"Name "+s.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return b.test(e)}},{key:"_makeUrl",value:function(e,t,n,i,r,s){var o=n?"":t+"/";return"https://"+t+".api.riotgames.com/"+(i||r||s?"":"api/lol/"+o)+encodeURI(e)}},{key:"_baseRequest",value:function(e,t){var n=this,i=e.endUrl,o=e.region,u=void 0===o?this.defaultRegion:o,l=e.status,m=void 0!==l&&l,g=e.observerMode,h=void 0!==g&&g,d=e.staticReq,c=void 0!==d&&d,p=e.championMastery,y=void 0!==p&&p,v=e.options,f=void 0===v?{}:v,R=e.cacheParams,S=void 0===R?{}:R,I=function(){return new Promise(function(e,o){var l=c?"global":u,g=a.stringify(f),d=g?"?"+g:"",p=n._makeUrl(i+d,l,c,m,h,y),v=p+(p.lastIndexOf("?")===-1?"?":"&")+"api_key="+n.key;n.cache.get({key:p},function(i,a){if(a){var l=JSON.parse(a);return t?t(i,l):e(l)}if(n.limits){var m=n;!function t(n){m.canMakeRequest(u)?(c||(m.limits[u][0].addRequest(),m.limits[u][1].addRequest()),r({url:v},function(i,r,a){if(r&&a){var u=void 0,l=r.statusCode;if(l>=200&&l<300?u=s.green(l):l>=400&&l<500?u=s.red(l+" "+A(l)):l>=500&&(u=s.bold.red(l+" "+A(l))),m.debug&&(console.log(u,v),console.log({"x-app-rate-limit-count":r.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":r.headers["x-method-rate-limit-count"],"x-rate-limit-count":r.headers["x-rate-limit-count"],"retry-after":r.headers["retry-after"]}),console.log()),"function"==typeof n)return l>=500&&(m.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(m)(n)},1e3)),429===l&&(m.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(m)(n)},1e3*r.headers["retry-after"]+50)),l>=400?n(u+" : "+s.yellow(p)):(Number.isInteger(S.ttl)&&S.ttl>0&&m.cache.set({key:p,ttl:S.ttl},a),n(i,JSON.parse(a)));if(500===l)m.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return o("retry")},1e3);else{if(429!==l)return i||l>=400?o("err:",i,l):(Number.isInteger(S.ttl)&&S.ttl>0&&m.cache.set({key:p,ttl:S.ttl},a),e(JSON.parse(a)));m.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return o("retry")},1e3*r.headers["retry-after"]+50)}}else console.log(i,v)})):setTimeout(function(){t.bind(m)(n)},1e3)}(t)}else r({url:v},function(i,r,a){if(r){var u=void 0,l=r.statusCode;return l>=200&&l<300?u=s.green(l):l>=400&&l<500?u=s.red(l+" "+A(l)):l>=500&&(u=s.bold.red(l+" "+A(l))),n.debug&&(console.log(r&&u,p),console.log({"x-app-rate-limit-count":r.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":r.headers["x-method-rate-limit-count"],"x-rate-limit-count":r.headers["x-rate-limit-count"],"retry-after":r.headers["retry-after"]})),"function"==typeof t?l>=400?t(u+" : "+s.yellow(p)):t(i,JSON.parse(a)):i?o("err:",i):e(JSON.parse(a))}console.log(i,p)})})})};return t?I():I().catch(I).catch(I).catch(I).then(function(e){return e})}},{key:"_observerRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.cacheParams;return this._baseRequest({endUrl:"observer-mode/rest/"+n,observerMode:!0,region:i,cacheParams:r},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.CHAMPION+"/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"championmastery/location/"+n,region:i,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_currentGameRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+r+"/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.CURRENT_GAME}},t)}},{key:"_featuredGamesRequest",value:function(e,t){var n=e.endUrl,i=e.region;e.platformId;return this._observerRequest({endUrl:""+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.FEATURED_GAMES}},t)}},{key:"_staticRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=void 0===i?this.defaultRegion:i,s=e.options;return this._baseRequest({endUrl:"static-data/"+r+"/v"+S.STATIC_DATA+"/"+n,staticReq:!0,region:r,options:s,cacheParams:{ttl:this.CACHE_TIMERS.STATIC}},t)}},{key:"_statusRequest",value:function(e,t){var n=e.endUrl,i=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+S.STATUS+"/"+n,status:!0,options:i,cacheParams:{ttl:this.CACHE_TIMERS.STATUS}},t)}},{key:"_gameRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+S.GAME+"/game/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.GAME}},t)}},{key:"_leagueRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.LEAGUE+"/league/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.MATCH+"/match/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchListRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.MATCH_LIST+"/matchlist/by-summoner/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH_LIST}},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._summonerRequest({endUrl:n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.RUNES_MASTERIES}},t)}},{key:"_statsRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.STATS+"/stats/by-summoner/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+S.SUMMONER+"/summoner/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_logError",value:function(e,t){console.log(s.bold.yellow(e),s.red("request"),s.bold.red("FAILED")+s.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=e}},{key:"getChamps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._championRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,r=arguments[1];return Number.isInteger(n)||Number.isInteger(i)?this._championRequest({endUrl:"champion/"+(n||i),region:t},r):this._logError(this.getChamp.name,"required params "+s.yellow("`id/championID` (int)")+" not passed in")}},{key:"getChampMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=void 0===t?this.defaultRegion:t,i=e.playerID,r=e.championID,o=e.options,a=arguments[1];if(Number.isInteger(i)&&Number.isInteger(r)){var u=v[R[n]];return this._championMasteryRequest({endUrl:u+"/player/"+i+"/champion/"+r,region:n,options:o},a)}return this._logError(this.getChampMastery.name,"required params "+s.yellow("`playerID` (int) AND `championID` (int)")+" not passed in")}},{key:"getChampMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,o=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||o||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||o||a)+"/champions",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/champions",region:i},g))})})}return this._logError(this.getChampMasteries.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (str)")+" not passed in")}},{key:"getTotalChampMasteryScore",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,o=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||o||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||o||a)+"/score",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/score",region:i},g))})})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (str)")+" not passed in")}},{key:"getTopChamps",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,o=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||o||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||o||a)+"/topchampions",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/topchampions",region:i},g))})})}return this._logError(this.getTopChamps.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,o=t.summonerID,a=t.playerID,u=t.name,m=arguments[1],g=v[R[i]];return Number.isInteger(r||o||a)?this._currentGameRequest({endUrl:""+(r||o||a),platformId:g,region:i},m):"object"===l(arguments[0])&&"string"==typeof u?new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(m?m(r):n(r)):t(e._currentGameRequest({endUrl:""+s[e._sanitizeName(u)].id,platformId:g,region:i},m))})}):this._logError(this.getCurrentGame.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (string)")+" not passed in")}},{key:"getFeaturedGames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._featuredGamesRequest({endUrl:"featured",region:t},n=t?n:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,o=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(i||r||o)?this._gameRequest({endUrl:"by-summoner/"+(i||r||o)+"/recent",region:n},u):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(u?u(r):i(r)):t(e._gameRequest({endUrl:"by-summoner/"+s[e._sanitizeName(a)].id+"/recent",region:n},u))})}):this._logError(this.getRecentGames.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (string)")+" not passed in")}},{key:"getLeagues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,o=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=t.options,c=arguments[1];return E.int(i||r||o)?this._leagueRequest({endUrl:"by-summoner/"+(i||r||o).join(","),region:n,options:d},c):Number.isInteger(i||a||r||u||o||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||r||u||o||m),region:n,options:d},c):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(c?c(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var p=m.value;o.push(s[e._sanitizeName(p)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(","),region:n,options:d},c))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getLeagues.name,"required params "+s.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+s.yellow("`id/summonerID/playerID` (int)")+", "+s.yellow("`names` ([str]/str)")+", or "+s.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id,region:n,options:d},c))})})}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,o=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||o)?this._leagueRequest({endUrl:"by-summoner/"+(i||r||o).join(",")+"/entry",region:n},d):Number.isInteger(i||a||r||u||o||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||r||u||o||m)+"/entry",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var c=m.value;o.push(s[e._sanitizeName(c)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(",")+"/entry",region:n},d))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getLeagueEntries.name,"required params "+s.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+s.yellow("`id/summonerID/playerID` (int)")+", "+s.yellow("`names` ([str]/str)")+", or "+s.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id+"/entry",region:n},d))})})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,r=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"champion/"+(n||i),region:t,options:r},o):this._logError(this.getChampion.name,"required params "+s.yellow("`id/championID` (int)")+" not passed in")}},{key:"getItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"item",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.itemID,r=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"item/"+(n||i),region:t,options:r},o):this._logError(this.getItem.name,"required params "+s.yellow("`id/itemID` (int)")+" not passed in")}},{key:"getLanguageStrings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"language-strings",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"languages",region:t},n=t?n:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"map",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"mastery",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.masteryID,r=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"mastery/"+(n||i),region:t,options:r},o):this._logError(this.getMastery.name,"required params "+s.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"realm",region:t},n=t?n:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"rune",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.runeID,r=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"rune/"+(n||i),region:t,options:r},o):this._logError(this.getRune.name,"required params "+s.yellow("`id/runeID` (int)")+" not passed in")}},{key:"getSummonerSpells",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.spellID,r=e.summonerSpellID,o=e.options,a=arguments[1];return Number.isInteger(n||i||r)?this._staticRequest({endUrl:"summoner-spell/"+(n||i||r),region:t,options:o},a):this._logError(this.getSummonerSpell.name,"required params "+s.yellow("`id/spellID/summonerSpellID` (int)")+" not passed in")}},{key:"getVersionData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"versions",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shard",region:t},n=t?n:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shards",region:t},n=t?n:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.matchID,r=e.options,o=void 0===r?{includeTimeline:!0}:r,a=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:""+(n||i),region:t,options:o},a):this._logError(this.getMatch.name,"required params "+s.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,o=t.playerID,a=t.name,u=t.options,m=void 0===u?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:u,g=arguments[1];return Number.isInteger(i||r||o)?this._matchListRequest({endUrl:""+(i||r||o),region:n,options:m},g):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchListRequest({endUrl:""+s[e._sanitizeName(a)].id,region:n,options:m},g))})}):this._logError(this.getMatchList.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,o=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||o)?this._runesMasteriesRequest({endUrl:(i||r||o).join()+"/runes",region:n},d):Number.isInteger(i||a||r||u||o||m)?this._runesMasteriesRequest({endUrl:(i||a||r||u||o||m)+"/runes",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var c=m.value;o.push(s[e._sanitizeName(c)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/runes",region:n},d))})
}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getRunes.name,"required params "+s.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+s.yellow("`id/summonerID/playerID` (int)")+", "+s.yellow("`names` ([str]/str)")+", or "+s.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/runes",region:n},d))})})}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,o=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||o)?this._runesMasteriesRequest({endUrl:(i||r||o).join()+"/masteries",region:n},d):Number.isInteger(i||a||r||u||o||m)?this._runesMasteriesRequest({endUrl:(i||a||r||u||o||m)+"/masteries",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var c=m.value;o.push(s[e._sanitizeName(c)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/masteries",region:n},d))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getMasteries.name,"required params "+s.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+s.yellow("`id/summonerID/playerID` (int)")+", "+s.yellow("`names` ([str]/str)")+", or "+s.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/masteries",region:n},d))})})}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,o=t.playerID,a=t.name,u=t.options,m=arguments[1];return Number.isInteger(i||r||o)?this._statsRequest({endUrl:(i||r||o)+"/ranked",region:n,options:u},m):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/ranked",region:n,options:u},m))})}):void this._logError(this.getRankedStats.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (string)")+" not passed in")}},{key:"getStatsSummary",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,o=t.playerID,a=t.name,u=t.options,m=arguments[1];return Number.isInteger(i||r||o)?this._statsRequest({endUrl:(i||r||o)+"/summary",region:n,options:u},m):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/summary",region:n,options:u},m))})}):void this._logError(this.getRankedStats.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,o=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||o)?this._summonerRequest({endUrl:""+(i||r||o).join(","),region:n},d):Number.isInteger(i||a||r||u||o||m)?this._summonerRequest({endUrl:""+(i||a||r||u||o||m),region:n},d):E.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:n},d):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getSummoners.name,"required params "+s.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+s.yellow("`id/summonerID/playerID` (int)")+", "+s.yellow("`names` ([str]/str)")+", or "+s.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||h),region:n},d)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,r=e.playerID,o=e.name,a=arguments[1];return Number.isInteger(n||i||r)?this.getSummoners({region:t,ids:[n||i||r]},a):"object"===l(arguments[0])&&"string"==typeof o?this.getSummoners({region:t,names:[o]},a):this._logError(this.getSummoner.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" or "+s.yellow("`name` (string)")+" not passed in")}},{key:"getSummonerNames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.ids,i=e.summonerIDs,r=e.playerIDs,o=e.id,a=e.summonerID,u=e.playerID,l=arguments[1];return E.int(n||i||r)?this._summonerRequest({endUrl:(n||i||r).join(",")+"/name",region:t},l):Number.isInteger(n||o||i||a||r||u)?this._summonerRequest({endUrl:(n||o||i||a||r||u)+"/name",region:t},l):void this._logError(this.getSummonerNames.name,"required params "+s.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+s.yellow("`id/summonerID/playerID` (int)")+" not passed in")}},{key:"getSummonerName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,r=e.playerID,o=arguments[1];if(Number.isInteger(n))return this.getSummonerNames({region:t,id:n||i||r},o);this._logError(this.getSummonerName.name,"required params "+s.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),T={Kindred:D,REGIONS:f,LIMITS:y,TIME_CONSTANTS:c,CACHE_TYPES:I};e.exports=T});
!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","redis","double-ended-queue","xregexp","chalk","request","chalk","query-string"],t);else if("undefined"!=typeof exports)t(module,require("redis"),require("double-ended-queue"),require("xregexp"),require("chalk"),require("request"),require("chalk"),require("query-string"));else{var n={exports:{}};t(n,e.redis,e.doubleEndedQueue,e.xregexp,e.chalk,e.request,e.chalk,e.queryString),e.kindredApi=n.exports}}(this,function(e,t,n,i,r,s,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),g=function(){function e(){u(this,e),this.cache={}}return m(e,[{key:"get",value:function(e,t){return this.cache[e.key]?Date.now()>this.cache[e.key].expires?(delete this.cache[e.key],t("expired cache key")):t(null,this.cache[e.key].value):t("cache key doesn't exist")}},{key:"set",value:function(e,t){this.cache[e.key]={expires:e.ttl?Date.now()+1e3*e.ttl:null,value:t}}}]),e}(),h=function(){function e(n){u(this,e);var i=Object.assign({},n||{},{host:"127.0.0.1",port:6379,keyPrefix:"kindredAPI-"});this.client=t.createClient(i.port,i.host),this.client.on("error",function(e){console.log("Redis error:",e)}),process.on("exit",function(){console.log("closing"),this.client.quit()}),this.prefix=i.keyPrefix}return m(e,[{key:"get",value:function(e,t){this.client.get(this.prefix+e.key,function(e,n){n?t(e,n):t(e)})}},{key:"set",value:function(e,n){this.client.setex(this.prefix+e.key,1e3*e.ttl,n,t.print),console.log("set for "+1e3*e.ttl+" milliiseconds")}}]),e}(),d=function(){function e(t,i){u(this,e),this.allowedRequests=t,this.seconds=i,this.madeRequests=new n}return m(e,[{key:"__reload",value:function(){for(var e=(new Date).getTime();this.madeRequests.length>0&&e-this.madeRequests.peekFront()>=1e3*this.seconds;)this.madeRequests.shift()}},{key:"addRequest",value:function(){this.madeRequests.push((new Date).getTime()+1e3*this.seconds)}},{key:"requestAvailable",value:function(){return this.__reload(),this.madeRequests.length<this.allowedRequests}}]),e}(),c={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},p={CHAMPION:c.MONTH,CHAMPION_MASTERY:c.SIX_HOURS,CURRENT_GAME:c.NONE,FEATURED_GAMES:c.NONE,GAME:c.HOUR,LEAGUE:c.SIX_HOURS,STATIC:c.MONTH,STATUS:c.NONE,MATCH:c.MONTH,MATCH_LIST:c.ONE_HOUR,RUNES_MASTERIES:c.WEEK,STATS:c.HOUR,SUMMONER:c.DAY},y={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},v={BRAZIL:"BR1",EUROPE:"EUN1",EUROPE_WEST:"EUW1",KOREA:"KR",LATIN_AMERICA_NORTH:"LA1",LATIN_AMERICA_SOUTH:"LA2",NORTH_AMERICA:"NA1",OCEANIA:"OC1",RUSSIA:"RU",TURKEY:"TR1",JAPAN:"JP1"},f={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},R={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},S={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},I=["in-memory-cache","redis"],b=i("^[0-9\\p{L} _\\.]+$"),_={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},E={int:function(e){return e&&Array.isArray(e)&&_.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&_.string(e)&&e.length>0}},M=function(e){var t=!0,n=!1,i=void 0;try{for(var r,s=Object.keys(f)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(f[o]===e)return!0}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}return!1},q={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},A=function(e){var t=q[e];if(t)return t},U=[200,400,500],T=function(e){return e>=U[0]&&e<=U[1]?r.green(e):e>=U[1]&&e<=U[2]?r.red(e+" "+A(e)):r.bold.red(e+" "+A(e))},D=function(e){return(Array.isArray(e)&&2!==e.length||!E.int(e[0])||2!==e[0].length||!E.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},N=function(e,t,n){console.log(t,n),console.log({"x-app-rate-limit-count":e.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":e.headers["x-method-rate-limit-count"],"x-rate-limit-count":e.headers["x-rate-limit-count"],"retry-after":e.headers["retry-after"]}),console.log()},C=function(){function e(t){var n=t.key,i=t.defaultRegion,r=void 0===i?f.NORTH_AMERICA:i,s=t.debug,a=void 0!==s&&s,l=t.limits,m=t.cacheOptions,c=t.cacheTTL;if(u(this,e),this.key=n,this.defaultRegion=M(r)?r:void 0,this.defaultRegion||(console.log(""+o.red("Initialization of Kindred failed: "+o.yellow(r)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=a,m?(m===I[0]?this.cache=new g:m===I[1]?this.cache=new h:this.cache=m,this.CACHE_TIMERS=c?c:p):this.cache={get:function(e,t){return t(null,null)},set:function(e,t){}},this.CACHE_TIMERS||(this.CACHE_TIMERS={CHAMPION:0,CHAMPION_MASTERY:0,CURRENT_GAME:0,FEATURED_GAMES:0,GAME:0,LEAGUE:0,STATIC:0,STATUS:0,MATCH:0,MATCH_LIST:0,RUNES_MASTERIES:0,STATS:0,SUMMONER:0}),l){D(l)&&(console.log(o.red("Initialization of Kindred failed: Invalid "+o.yellow("limits")+". Valid examples: "+o.yellow("[[10, 10], [500, 600]]"))+"."),console.log(o.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+o.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===l&&(l=y.DEV),"prod"===l&&(l=y.PROD);var v=!0,R=!1,S=void 0;try{for(var b,_=Object.keys(f)[Symbol.iterator]();!(v=(b=_.next()).done);v=!0){var E=b.value;this.limits[f[E]]=[new d(l[0][0],l[0][1]),new d(l[1][0],l[1][1])]}}catch(e){R=!0,S=e}finally{try{!v&&_.return&&_.return()}finally{if(R)throw S}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),getTopChampions:this.getTopChamps.bind(this),top:this.getTopChamps.bind(this),best:this.getTopChamps.bind(this)},this.CurrentGame={getCurrentGame:this.getCurrentGame.bind(this),get:this.getCurrentGame.bind(this)},this.FeaturedGames={getFeaturedGames:this.getFeaturedGames.bind(this),get:this.getFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),getMap:this.getMap.bind(this),map:this.getMap.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),realmData:this.getRealmData.bind(this),realm:this.getRealmData.bind(this),realms:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),runes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),rune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),summonerSpells:this.getSummonerSpells.bind(this),spells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),summonerSpell:this.getSummonerSpell.bind(this),spell:this.getSummonerSpell.bind(this),getVersionData:this.getVersionData.bind(this),versionData:this.getVersionData.bind(this),version:this.getVersionData.bind(this),versions:this.getVersionData.bind(this)},this.Status={getShardStatus:this.getShardStatus.bind(this),getStatus:this.getShardStatus.bind(this),get:this.getShardStatus.bind(this),getShardList:this.getShardList.bind(this),getShards:this.getShardList.bind(this),getAll:this.getShardList.bind(this),all:this.getShardList.bind(this)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Runes={get:this.getRunes.bind(this)},this.Masteries={get:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoners:this.getSummoners.bind(this),getAll:this.getSummoners.bind(this),all:this.getSummoners.bind(this),getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),getSummonerNames:this.getSummonerNames.bind(this),getNames:this.getSummonerNames.bind(this),names:this.getSummonerNames.bind(this),getSummonerName:this.getSummonerName.bind(this),getName:this.getSummonerName.bind(this),name:this.getSummonerName.bind(this)}}return m(e,[{key:"canMakeRequest",value:function(e){return!(!this.limits[e][0].requestAvailable()||!this.limits[e][1].requestAvailable())}},{key:"_sanitizeName",value:function(e){if(this._validName(e))return e.replace(/\s/g,"").toLowerCase();this._logError(this._validName.name,"Name "+o.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return b.test(e)}},{key:"_makeUrl",value:function(e,t,n,i,r,s){var o=n?"":t+"/";return"https://"+t+".api.riotgames.com/"+(i||r||s?"":"api/lol/"+o)+encodeURI(e)}},{key:"_baseRequest",value:function(e,t){var n=this,i=e.endUrl,r=e.region,u=void 0===r?this.defaultRegion:r,l=e.status,m=void 0!==l&&l,g=e.observerMode,h=void 0!==g&&g,d=e.staticReq,c=void 0!==d&&d,p=e.championMastery,y=void 0!==p&&p,v=e.options,f=void 0===v?{}:v,R=e.cacheParams,S=void 0===R?{}:R,I=function(){return new Promise(function(e,r){var l=c?"global":u,g=!0,d=!1,p=void 0;try{for(var v,R=Object.keys(f)[Symbol.iterator]();!(g=(v=R.next()).done);g=!0){var I=v.value;Array.isArray(f[I])&&(f[I]=f[I].join(","))}}catch(e){d=!0,p=e}finally{try{!g&&R.return&&R.return()}finally{if(d)throw p}}var b=a.stringify(f),_=b?"?"+b:"",E=n._makeUrl(i+_,l,c,m,h,y),M=E+(E.lastIndexOf("?")===-1?"?":"&")+"api_key="+n.key;n.cache.get({key:E},function(i,a){if(a){var l=JSON.parse(a);return t?t(i,l):e(l)}if(n.limits){var m=n;!function t(n){m.canMakeRequest(u)?(c||(m.limits[u][0].addRequest(),m.limits[u][1].addRequest()),s({url:M},function(i,s,a){if(s&&a){var u=s.statusCode,l=T(u);if(m.debug&&N(s,l,M),"function"==typeof n)return u>=500&&(m.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(m)(n)},1e3)),429===u&&(m.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(m)(n)},1e3*s.headers["retry-after"]+50)),u>=400?n(l+" : "+o.yellow(E)):(Number.isInteger(S.ttl)&&S.ttl>0&&m.cache.set({key:E,ttl:S.ttl},a),n(i,JSON.parse(a)));if(500===u)m.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3);else{if(429!==u)return i||u>=400?r("err:",i,u):(Number.isInteger(S.ttl)&&S.ttl>0&&m.cache.set({key:E,ttl:S.ttl},a),e(JSON.parse(a)));m.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(i,M)})):setTimeout(function(){t.bind(m)(n)},1e3)}(t)}else s({url:M},function(n,i,s){if(i){var a=i.statusCode,u=T(a);return m.debug&&N(i,u,M),"function"==typeof t?a>=400?t(u+" : "+o.yellow(E)):t(n,JSON.parse(s)):n?r("err:",n):e(JSON.parse(s))}console.log(n,E)})})})};return t?I():I().catch(I).catch(I).catch(I).then(function(e){return e})}},{key:"_observerRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.cacheParams;return this._baseRequest({endUrl:"observer-mode/rest/"+n,observerMode:!0,region:i,cacheParams:r},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.CHAMPION+"/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"championmastery/location/"+n,region:i,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_currentGameRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+r+"/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.CURRENT_GAME}},t)}},{key:"_featuredGamesRequest",value:function(e,t){var n=e.endUrl,i=e.region;e.platformId;return this._observerRequest({endUrl:""+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.FEATURED_GAMES}},t)}},{key:"_staticRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=void 0===i?this.defaultRegion:i,s=e.options;return this._baseRequest({endUrl:"static-data/"+r+"/v"+S.STATIC_DATA+"/"+n,staticReq:!0,region:r,options:s,cacheParams:{ttl:this.CACHE_TIMERS.STATIC}},t)}},{key:"_statusRequest",value:function(e,t){var n=e.endUrl,i=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+S.STATUS+"/"+n,status:!0,options:i,cacheParams:{ttl:this.CACHE_TIMERS.STATUS}},t)}},{key:"_gameRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+S.GAME+"/game/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.GAME}},t)}},{key:"_leagueRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.LEAGUE+"/league/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.MATCH+"/match/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchListRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.MATCH_LIST+"/matchlist/by-summoner/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH_LIST}},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._summonerRequest({endUrl:n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.RUNES_MASTERIES}},t)}},{key:"_statsRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+S.STATS+"/stats/by-summoner/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+S.SUMMONER+"/summoner/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_logError",value:function(e,t){console.log(o.bold.yellow(e),o.red("request"),o.bold.red("FAILED")+o.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=M(e)?e:void 0,console.log(""+o.red("setRegion() by Kindred failed: "+o.yellow(e)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)}},{key:"getChamps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._championRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,r=arguments[1];return Number.isInteger(n)||Number.isInteger(i)?this._championRequest({endUrl:"champion/"+(n||i),region:t},r):this._logError(this.getChamp.name,"required params "+o.yellow("`id/championID` (int)")+" not passed in")}},{key:"getChampMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=void 0===t?this.defaultRegion:t,i=e.playerID,r=e.championID,s=e.options,a=arguments[1];if(Number.isInteger(i)&&Number.isInteger(r)){var u=v[R[n]];return this._championMasteryRequest({endUrl:u+"/player/"+i+"/champion/"+r,region:n,options:s},a)}return this._logError(this.getChampMastery.name,"required params "+o.yellow("`playerID` (int) AND `championID` (int)")+" not passed in")}},{key:"getChampMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||s||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||s||a)+"/champions",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/champions",region:i},g))})})}return this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getTotalChampMasteryScore",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||s||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||s||a)+"/score",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/score",region:i},g))})})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getTopChamps",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,m=t.options,g=arguments[1];if(Number.isInteger(r||s||a)){var h=v[R[i]];return this._championMasteryRequest({endUrl:h+"/player/"+(r||s||a)+"/topchampions",region:i,options:m},g)}if("object"===l(arguments[0])&&"string"==typeof u){var d=v[R[i]];return new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:d+"/player/"+s[e._sanitizeName(u)].id+"/topchampions",region:i},g))})})}return this._logError(this.getTopChamps.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,m=arguments[1],g=v[R[i]];return Number.isInteger(r||s||a)?this._currentGameRequest({endUrl:""+(r||s||a),platformId:g,region:i},m):"object"===l(arguments[0])&&"string"==typeof u?new Promise(function(t,n){return e.getSummoner({name:u,region:i},function(r,s){return r?void(m?m(r):n(r)):t(e._currentGameRequest({endUrl:""+s[e._sanitizeName(u)].id,platformId:g,region:i},m))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getFeaturedGames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._featuredGamesRequest({endUrl:"featured",region:t},n=t?n:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(i||r||s)?this._gameRequest({endUrl:"by-summoner/"+(i||r||s)+"/recent",region:n},u):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(u?u(r):i(r)):t(e._gameRequest({endUrl:"by-summoner/"+s[e._sanitizeName(a)].id+"/recent",region:n},u))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getLeagues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,s=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=t.options,c=arguments[1];return E.int(i||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(i||r||s).join(","),region:n,options:d},c):Number.isInteger(i||a||r||u||s||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||r||u||s||m),region:n,options:d},c):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(c?c(r):i(r));var o=g.map(function(t){return s[e._sanitizeName(t)].id});return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(","),region:n,options:d},c))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getLeagues.name,"required params "+o.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`names` ([str]/str)")+", or "+o.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id,region:n,options:d},c))})})}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,s=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(i||r||s).join(",")+"/entry",region:n},d):Number.isInteger(i||a||r||u||s||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||r||u||s||m)+"/entry",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=g.map(function(t){return s[e._sanitizeName(t)].id});return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(",")+"/entry",region:n},d))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getLeagueEntries.name,"required params "+o.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`names` ([str]/str)")+", or "+o.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id+"/entry",region:n},d))})})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,r=e.options,s=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"champion/"+(n||i),region:t,options:r},s):this._logError(this.getChampion.name,"required params "+o.yellow("`id/championID` (int)")+" not passed in")}},{key:"getItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"item",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.itemID,r=e.options,s=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"item/"+(n||i),region:t,options:r},s):this._logError(this.getItem.name,"required params "+o.yellow("`id/itemID` (int)")+" not passed in")}},{key:"getLanguageStrings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"language-strings",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"languages",region:t},n=t?n:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"map",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"mastery",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.masteryID,r=e.options,s=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"mastery/"+(n||i),region:t,options:r},s):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"realm",region:t},n=t?n:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"rune",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.runeID,r=e.options,s=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"rune/"+(n||i),region:t,options:r},s):this._logError(this.getRune.name,"required params "+o.yellow("`id/runeID` (int)")+" not passed in")}},{key:"getSummonerSpells",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.spellID,r=e.summonerSpellID,s=e.options,a=arguments[1];return Number.isInteger(n||i||r)?this._staticRequest({endUrl:"summoner-spell/"+(n||i||r),region:t,options:s},a):this._logError(this.getSummonerSpell.name,"required params "+o.yellow("`id/spellID/summonerSpellID` (int)")+" not passed in")}},{key:"getVersionData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"versions",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shard",region:t},n=t?n:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shards",region:t},n=t?n:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.matchID,r=e.options,s=void 0===r?{includeTimeline:!0}:r,a=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:""+(n||i),region:t,options:s},a):this._logError(this.getMatch.name,"required params "+o.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,m=void 0===u?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:u,g=arguments[1];return Number.isInteger(i||r||s)?this._matchListRequest({endUrl:""+(i||r||s),region:n,options:m},g):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchListRequest({endUrl:""+s[e._sanitizeName(a)].id,region:n,options:m},g))})}):this._logError(this.getMatchList.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,s=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||s)?this._runesMasteriesRequest({endUrl:(i||r||s).join()+"/runes",region:n},d):Number.isInteger(i||a||r||u||s||m)?this._runesMasteriesRequest({endUrl:(i||a||r||u||s||m)+"/runes",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=g.map(function(t){return s[e._sanitizeName(t)].id});return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/runes",region:n},d))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getRunes.name,"required params "+o.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`names` ([str]/str)")+", or "+o.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){
return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/runes",region:n},d))})})}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,s=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||s)?this._runesMasteriesRequest({endUrl:(i||r||s).join()+"/masteries",region:n},d):Number.isInteger(i||a||r||u||s||m)?this._runesMasteriesRequest({endUrl:(i||a||r||u||s||m)+"/masteries",region:n},d):E.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=g.map(function(t){return s[e._sanitizeName(t)].id});return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/masteries",region:n},d))})}):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getMasteries.name,"required params "+o.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`names` ([str]/str)")+", or "+o.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/masteries",region:n},d))})})}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,m=arguments[1];return Number.isInteger(i||r||s)?this._statsRequest({endUrl:(i||r||s)+"/ranked",region:n,options:u},m):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/ranked",region:n,options:u},m))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getStatsSummary",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,m=arguments[1];return Number.isInteger(i||r||s)?this._statsRequest({endUrl:(i||r||s)+"/summary",region:n,options:u},m):"object"===l(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/summary",region:n,options:u},m))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,r=t.summonerIDs,s=t.playerIDs,a=t.id,u=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return E.int(i||r||s)?this._summonerRequest({endUrl:""+(i||r||s).join(","),region:n},d):Number.isInteger(i||a||r||u||s||m)?this._summonerRequest({endUrl:""+(i||a||r||u||s||m),region:n},d):E.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:n},d):"object"!==l(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getSummoners.name,"required params "+o.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`names` ([str]/str)")+", or "+o.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||h),region:n},d)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,r=e.playerID,s=e.name,a=arguments[1];return Number.isInteger(n||i||r)?this.getSummoners({region:t,ids:[n||i||r]},a):"object"===l(arguments[0])&&"string"==typeof s?this.getSummoners({region:t,names:[s]},a):this._logError(this.getSummoner.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getSummonerNames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.ids,i=e.summonerIDs,r=e.playerIDs,s=e.id,a=e.summonerID,u=e.playerID,l=arguments[1];return E.int(n||i||r)?this._summonerRequest({endUrl:(n||i||r).join(",")+"/name",region:t},l):Number.isInteger(n||s||i||a||r||u)?this._summonerRequest({endUrl:(n||s||i||a||r||u)+"/name",region:t},l):void this._logError(this.getSummonerNames.name,"required params "+o.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+o.yellow("`id/summonerID/playerID` (int)")+" not passed in")}},{key:"getSummonerName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,r=e.playerID,s=arguments[1];if(Number.isInteger(n))return this.getSummonerNames({region:t,id:n||i||r},s);this._logError(this.getSummonerName.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),k={Kindred:C,REGIONS:f,LIMITS:y,TIME_CONSTANTS:c,CACHE_TYPES:I};e.exports=k});
{
"name": "kindred-api",
"version": "1.3.5",
"version": "1.3.6",
"description": "Kindred is a thin Node.js wrapper on top of Riot Games API for League of Legends",

@@ -31,3 +31,4 @@ "main": "index.js",

"league of legends",
"riot api wrapper"
"riot api wrapper",
"node.js riot api wrapper"
],

@@ -34,0 +35,0 @@ "devDependencies": {

@@ -384,4 +384,4 @@ # Kindred

All the namespaces are named after the official names Riot have given them (there
aee shorthand ones too).
All the namespaces are named after the official endpoint names (there
are shorthand ones too).
*/

@@ -553,8 +553,15 @@ k.League.getChallengers(rprint)

According to Riot API, query parameters that can accept multiple values
must be a comma separated list (or a single value), which is why I do the below 'join'.
must be a comma separated list (or a single value), which is why one can do the below join.
You can also simply do 'RANKED_SOLO_5x5,RANKED_FLEX_SR'.
However, both these options are inconvenient, and so I check if you pass in array values
for every option parameter, and manually join it for you. You can still pass in string values
if you want though.
Note, for arrays of values that are conceptually integers,
both strings and integers work because they're joined together as a string anyways.
*/
rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'].join(','),
championIds: '67' // '267,67' or ['267', '67'].join(',')
// rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'].join(','), STILL VALID
// championIds: '67' // '267,67' or ['267', '67'].join(',') STILL VALID
rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'], // valid
championIDs: [67, 62, '61'] // valid
} }, rprint)

@@ -583,6 +590,6 @@ }

k.getMastery({ id: furyMasteryId }, rprint)
k.Static.getMastery({ id: furyMasteryId }, rprint)
k.Static.mastery({ id: furyMasteryId }, rprint)
var msRuneId = 10002
k.Static.getRune({ id: msRuneId }, rprint)
k.Static.rune({ id: msRuneId }, rprint)
```

@@ -589,0 +596,0 @@

@@ -1,2 +0,2 @@

var redis = require('redis')
const redis = require('redis')

@@ -3,0 +3,0 @@ class RedisCache {

import responseCodes from '../constants/response-codes'
const getResponseMessage = (code) => {
const getResponseMessage = code => {
const message = responseCodes[code]

@@ -5,0 +5,0 @@ if (!message) return

const request = require('request')
const chalk = require('chalk')
const XRegExp = require('xregexp')
const queryString = require('query-string')

@@ -24,4 +23,5 @@

import checkValidRegion from './helpers/check-valid-region'
import getResponseMessage from './helpers/get-response-message'
import colorizeStatusMessage from './helpers/colorize-status-message'
import invalidLimits from './helpers/limits-checker'
import printResponseDebug from './helpers/print-response-debug'

@@ -49,3 +49,3 @@ class Kindred {

get: (args, cb) => cb(null, null),
set: (args, value) => { }
set: (args, value) => {}
}

@@ -55,3 +55,3 @@ } else {

this.cache = new IMC()
else if (cacheOptions === CACHE_TYPES[1])
else if (cacheOptions === CACHE_TYPES[1])
this.cache = new RC()

@@ -311,4 +311,11 @@ else

const proxy = staticReq ? 'global' : region
const stringified = queryString.stringify(options)
const postfix = stringified ? '?' + stringified : ''
for (const key of Object.keys(options)) {
if (Array.isArray(options[key])) {
options[key] = options[key].join(',')
}
}
const stringifiedOpts = queryString.stringify(options)
const postfix = stringifiedOpts ? '?' + stringifiedOpts : ''
const reqUrl = this._makeUrl(endUrl + postfix, proxy, staticReq, status, observerMode, championMastery)

@@ -335,23 +342,7 @@ const fullUrl = reqUrl + (reqUrl.lastIndexOf('?') === -1 ? '?' : '&') + `api_key=${this.key}`

if (response && body) {
let statusMessage
const { statusCode } = response
const statusMessage = colorizeStatusMessage(statusCode)
if (statusCode >= 200 && statusCode < 300)
statusMessage = chalk.green(statusCode)
else if (statusCode >= 400 && statusCode < 500)
statusMessage = chalk.red(`${statusCode} ${getResponseMessage(statusCode)}`)
else if (statusCode >= 500)
statusMessage = chalk.bold.red(`${statusCode} ${getResponseMessage(statusCode)}`)
if (self.debug) printResponseDebug(response, statusMessage, fullUrl)
if (self.debug) {
console.log(statusMessage, fullUrl)
console.log({
'x-app-rate-limit-count': response.headers['x-app-rate-limit-count'],
'x-method-rate-limit-count': response.headers['x-method-rate-limit-count'],
'x-rate-limit-count': response.headers['x-rate-limit-count'],
'retry-after': response.headers['retry-after']
})
console.log()
}
if (typeof callback === 'function') {

@@ -370,4 +361,5 @@ if (statusCode >= 500) {

if (statusCode >= 400) return callback(statusMessage + ' : ' + chalk.yellow(reqUrl))
else {
if (statusCode >= 400) {
return callback(statusMessage + ' : ' + chalk.yellow(reqUrl))
} else {
if (Number.isInteger(cacheParams.ttl) && cacheParams.ttl > 0)

@@ -403,31 +395,17 @@ self.cache.set({ key: reqUrl, ttl: cacheParams.ttl }, body)

if (response) {
let statusMessage
const { statusCode } = response
const statusMessage = colorizeStatusMessage(statusCode)
if (statusCode >= 200 && statusCode < 300)
statusMessage = chalk.green(statusCode)
else if (statusCode >= 400 && statusCode < 500)
statusMessage = chalk.red(`${statusCode} ${getResponseMessage(statusCode)}`)
else if (statusCode >= 500)
statusMessage = chalk.bold.red(`${statusCode} ${getResponseMessage(statusCode)}`)
if (self.debug) printResponseDebug(response, statusMessage, fullUrl)
if (this.debug) {
console.log(response && statusMessage, reqUrl)
console.log({
'x-app-rate-limit-count': response.headers['x-app-rate-limit-count'],
'x-method-rate-limit-count': response.headers['x-method-rate-limit-count'],
'x-rate-limit-count': response.headers['x-rate-limit-count'],
'retry-after': response.headers['retry-after']
})
}
if (typeof cb === 'function') {
if (statusCode >= 400) return cb(statusMessage + ' : ' + chalk.yellow(reqUrl))
else return cb(error, JSON.parse(body))
if (statusCode >= 400)
return cb(statusMessage + ' : ' + chalk.yellow(reqUrl))
else
return cb(error, JSON.parse(body))
} else {
if (error) {
if (error)
return reject('err:', error)
} else {
else
return resolve(JSON.parse(body))
}
}

@@ -444,4 +422,7 @@ } else {

if (!cb) return tryRequest().catch(tryRequest).catch(tryRequest).catch(tryRequest).then(data => data)
else return tryRequest()
if (!cb) return tryRequest()
.catch(tryRequest).catch(tryRequest).catch(tryRequest)
.then(data => data)
return tryRequest()
}

@@ -591,3 +572,7 @@

setRegion(region) {
this.defaultRegion = region
this.defaultRegion = checkValidRegion(region) ? region : undefined
console.log(`${chalk.red(`setRegion() by Kindred failed: ${chalk.yellow(region)} is an invalid region.`)}`)
console.log(`${(chalk.red(`Try importing ${chalk.yellow("require('./dist/kindred-api').REGIONS")} and using one of those values instead.`))}`)
process.exit(1)
}

@@ -639,3 +624,8 @@

getChampMasteries({ region = this.defaultRegion, id, summonerID, playerID, name, options } = {}, cb) {
getChampMasteries({
region = this.defaultRegion,
id, summonerID, playerID,
name,
options
} = {}, cb) {
if (Number.isInteger(id || summonerID || playerID)) {

@@ -820,9 +810,8 @@ const location = PLATFORM_IDS[REGIONS_BACK[region]]

if (err) { cb ? cb(err) : reject(err); return }
const ids = names.map(name => data[this._sanitizeName(name)].id)
let args = []
for (let name of names)
args.push(data[this._sanitizeName(name)].id)
return resolve(this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}`, region, options }, cb))
return resolve(this._leagueRequest({
endUrl: `by-summoner/${ids.join(',')}`,
region, options
}, cb))
})

@@ -869,9 +858,8 @@ })

if (err) { cb ? cb(err) : reject(err); return }
const ids = names.map(name => data[this._sanitizeName(name)].id)
let args = []
for (let name of names)
args.push(data[this._sanitizeName(name)].id)
return resolve(this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}/entry`, region }, cb))
return resolve(this._leagueRequest({
endUrl: `by-summoner/${ids.join(',')}/entry`,
region
}, cb))
})

@@ -1114,10 +1102,6 @@ })

if (err) { cb ? cb(err) : reject(err); return }
const ids = names.map(name => data[this._sanitizeName(name)].id)
let args = []
for (let name of names)
args.push(data[this._sanitizeName(name)].id)
return resolve(this._runesMasteriesRequest({
endUrl: `${args.join(',')}/runes`,
endUrl: `${ids.join(',')}/runes`,
region

@@ -1166,10 +1150,6 @@ }, cb))

if (err) { cb ? cb(err) : reject(err); return }
const ids = names.map(name => data[this._sanitizeName(name)].id)
let args = []
for (let name of names)
args.push(data[this._sanitizeName(name)].id)
return resolve(this._runesMasteriesRequest({
endUrl: `${args.join(',')}/masteries`,
endUrl: `${ids.join(',')}/masteries`,
region

@@ -1333,3 +1313,4 @@ }, cb))

getSummonerName({
region, id, summonerID, playerID
region,
id, summonerID, playerID
} = {}, cb) {

@@ -1336,0 +1317,0 @@ if (Number.isInteger(id)) {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc