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 2.0.11 to 2.0.12

2

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","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")}function l(e,t,n){return new O({key:e,defaultRegion:t,debug:n,limits:v.DEV,cacheOptions:_[0]})}function g(e,t){e?console.log(e):console.log(t)}var h="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}}(),c=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}(),d=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,t){this.client.setex(this.prefix+e.key,e.ttl,t)}}]),e}(),p=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}(),y={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:null,STATUS:"status",MASTERIES:"platform",MATCH:"match",MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner"},I={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},R={CHAMPION:I.MONTH,CHAMPION_MASTERY:I.SIX_HOURS,CURRENT_GAME:I.NONE,FEATURED_GAMES:I.NONE,GAME:I.HOUR,LEAGUE:I.SIX_HOURS,STATIC:I.MONTH,STATUS:I.NONE,MATCH:I.MONTH,MATCH_LIST:I.ONE_HOUR,RUNES_MASTERIES:I.WEEK,SPECTATOR:I.NONE,STATS:I.HOUR,SUMMONER:I.DAY},v={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},f={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"},S={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"},b={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"},E={CHAMPION:3,CHAMPION_MASTERY:3,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:3,STATUS:3,MATCH:3,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3},_=["in-memory-cache","redis"],M=i("^[0-9\\p{L} _\\.]+$"),A={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},D={int:function(e){return e&&Array.isArray(e)&&A.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&A.string(e)&&e.length>0}},T=function(e){var t=!0,n=!1,i=void 0;try{for(var r,s=Object.keys(S)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(S[o]===e)return!0}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}return!1},U={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},q=function(e){var t=U[e];if(t)return t},C=[200,400,500],N=function(e){return e>=C[0]&&e<C[1]?r.green(e):e>=C[1]&&e<C[2]?r.red(e+" "+q(e)):r.bold.red(e+" "+q(e))},k=function(e){return(Array.isArray(e)&&2!==e.length||!D.int(e[0])||2!==e[0].length||!D.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},w=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()},O=function(){function e(t){var n=t.key,i=t.defaultRegion,r=void 0===i?S.NORTH_AMERICA:i,s=t.debug,a=void 0!==s&&s,l=t.limits,g=t.cacheOptions,h=t.cacheTTL;if(u(this,e),this.key=n,this.defaultRegion=T(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,g?(g===_[0]?this.cache=new c:g===_[1]?this.cache=new d:this.cache=g,this.CACHE_TIMERS=h?h:R):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){k(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=v.DEV),"prod"===l&&(l=v.PROD);var m=!0,y=!1,I=void 0;try{for(var f,b=Object.keys(S)[Symbol.iterator]();!(m=(f=b.next()).done);m=!0){var E=f.value;this.limits[S[E]]=[new p(l[0][0],l[0][1]),new p(l[1][0],l[1][1])]}}catch(e){y=!0,I=e}finally{try{!m&&b.return&&b.return()}finally{if(y)throw I}}}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),score:this.getTotalChampMasteryScore.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),getAll:this.getLeagueEntries.bind(this),all: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),getMapData:this.getMapData.bind(this),mapData:this.getMapData.bind(this),map:this.getMapData.bind(this),maps:this.getMapData.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getProfileIcons:this.getProfileIcons.bind(this),profileIcons:this.getProfileIcons.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)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this),getMatchTimeline:this.getMatchTimeline.bind(this),getTimeline:this.getMatchTimeline.bind(this),timeline:this.getMatchTimeline.bind(this)},this.Matchlist={getMatchlist:this.getMatchlist.bind(this),get:this.getMatchlist.bind(this),getRecentMatchlist:this.getRecentMatchlist.bind(this),recent:this.getRecentMatchlist.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={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.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 M.test(e)}},{key:"_makeUrl",value:function(e,t,n,i,r,s){var o=n?"":t+"/",a=i||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),l="https://"+f[b[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return l.lastIndexOf("v3")==-1?u:l}},{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,g=void 0!==l&&l,h=e.observerMode,m=void 0!==h&&h,c=e.staticReq,d=void 0!==c&&c,p=e.championMastery,y=void 0!==p&&p,I=e.options,R=void 0===I?{}:I,v=e.cacheParams,f=void 0===v?{}:v,S=function(){return new Promise(function(e,r){var l=!0,h=!1,c=void 0;try{for(var p,I=Object.keys(R)[Symbol.iterator]();!(l=(p=I.next()).done);l=!0){var v=p.value;Array.isArray(R[v])&&(R[v]=R[v].join(","))}}catch(e){h=!0,c=e}finally{try{!l&&I.return&&I.return()}finally{if(h)throw c}}var S=a.stringify(R).replace(/%2C/,","),b=S?"?"+S:"",E=n._makeUrl(i+b,u,d,g,m,y),_=E+(E.lastIndexOf("?")===-1?"?":"&")+"api_key="+n.key;n.cache.get({key:E},function(i,a){if(a){n.debug&&console.log(o.green("CACHE HIT")+" "+_);var l=JSON.parse(a);return t?t(i,l):e(l)}if(n.limits){var g=n;!function t(n){g.canMakeRequest(u)?(d||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),s({url:_},function(i,s,a){if(s&&a){var u=s.statusCode,l=N(u);if(g.debug&&w(s,l,_),"function"==typeof n)return u>=500&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(n)},1e3)),429===u&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(n)},1e3*s.headers["retry-after"]+50)),u>=400?n(l+" : "+o.yellow(E)):(Number.isInteger(f.ttl)&&f.ttl>0&&g.cache.set({key:E,ttl:f.ttl},a),n(i,JSON.parse(a)));if(500===u)g.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(f.ttl)&&f.ttl>0&&g.cache.set({key:E,ttl:f.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(i,_)})):setTimeout(function(){t.bind(g)(n)},1e3)}(t)}else s({url:_},function(n,i,s){if(i){var a=i.statusCode,u=N(a);return g.debug&&w(i,u,_),"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?S():S().catch(S).catch(S).catch(S).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION_MASTERY+"/v"+E.CHAMPION+"/"+n,region:i,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION+"/v"+E.CHAMPION+"/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:y.SPECTATOR+"/v"+E.SPECTATOR+"/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.SPECTATOR}},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:y.STATIC_DATA+"/v"+E.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:y.STATUS+"/v"+E.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"+E.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"+E.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:y.MATCH+"/v"+E.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"+E.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._baseRequest({endUrl:y.RUNES_MASTERIES+"/v"+E.RUNES_MASTERIES+"/"+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"+E.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:y.SUMMONER+"/v"+E.SUMMONER+"/summoners/"+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=T(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:"champions",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:"champions/"+(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];return Number.isInteger(i)&&Number.isInteger(r)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+i+"/by-champion/"+r,region:n,options:s},a):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.accountID,s=t.accID,a=t.id,u=t.summonerID,l=t.playerID,g=t.name,m=t.options,c=arguments[1];return Number.isInteger(r||s)?new Promise(function(t,n){return e.getSummoner({accID:r||s,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:i},c))})}):Number.isInteger(a||u||l)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(a||u||l),region:i,options:m},c):"object"===h(arguments[0])&&"string"==typeof g?new Promise(function(t,n){return e.getSummoner({name:g,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:i},c))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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.accountID,s=t.accID,a=t.id,u=t.summonerID,l=t.playerID,g=t.name,m=t.options,c=arguments[1];return Number.isInteger(r||s)?new Promise(function(t,n){return e.getSummoner({accID:r||s,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:i},c))})}):Number.isInteger(a||u||l)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(a||u||l),region:i,options:m},c):"object"===h(arguments[0])&&"string"==typeof g?new Promise(function(t,n){return e.getSummoner({name:g,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:i},c))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.region,r=void 0===i?this.defaultRegion:i,s=n.accountID,a=n.accID,u=n.id,l=n.summonerID,g=n.playerID,m=n.name,c=arguments[1];return Number.isInteger(s||a)?new Promise(function(n,i){return e.getSummoner({accID:s||a,region:r},function(s,o){return s?void(c?c(s):i(s)):n(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},c=r?c:t[0]))})}):Number.isInteger(u||l||g)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(u||l||g),region:r},c=r?c:arguments[0]):"object"===h(arguments[0])&&"string"==typeof m?new Promise(function(n,i){return e.getSummoner({name:m,region:r},function(s,o){return s?void(c?c(s):i(s)):n(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},c=r?c:t[0]))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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._spectatorRequest({endUrl:"featured-games",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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._gameRequest({endUrl:"by-summoner/"+r.id+"/recent",region:n},g))})}):Number.isInteger(s||a||u)?this._gameRequest({endUrl:"by-summoner/"+(s||a||u)+"/recent",region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:n},g))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(m?m(i):s(i)):t(e._leagueRequest({endUrl:"by-summoner/"+r.id,region:n,options:g},m))})}):Number.isInteger(s||a||u)?this._leagueRequest({endUrl:"by-summoner/"+(s||a||u),region:n,options:g},m):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id,region:n,options:g},m))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._leagueRequest({endUrl:"by-summoner/"+r.id+"/entry",region:n},g))})}):Number.isInteger(s||a||u)?this._leagueRequest({endUrl:"by-summoner/"+(s||a||u)+"/entry",region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id+"/entry",region:n},g))})}):void this._logError(this.getLeagueEntries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{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:"champions",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:"champions/"+(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:"items",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:"items/"+(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:"getMapData",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:"maps",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:"masteries",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:"masteries/"+(n||i),region:t,options:r},s):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getProfileIcons",value:function(e,t){var n=e.region,i=e.options;return this._staticRequest({endUrl:"profile-icons",region:n,options:i},t=2===arguments.length?t:arguments[0])}},{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:"realms",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:"runes",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:"runes/"+(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-spells",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-spells/"+(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-data",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=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:"matches/"+(n||i),region:t,options:r},s):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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=void 0===g?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:g,c=arguments[1];return Number.isInteger(i||r)?this._matchRequest({endUrl:"matchlists/by-account/"+(i||r),region:n,options:m},c):Number.isInteger(s||a||u)?new Promise(function(t,i){return e.getSummoner({id:s,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId,region:n,options:m},c))})}):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId,region:n,options:m},c))})}):this._logError(this.getMatchlist.name,"required params "+o.yellow("`accountID/accID` (int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRecentMatchlist",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?this._matchRequest({endUrl:"matchlists/by-account/"+(i||r)+"/recent",region:n},g):Number.isInteger(s||a||u)?new Promise(function(t,i){return e.getSummoner({id:s,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId+"/recent",region:n},g))})}):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId+"/recent",region:n},g))})}):this._logError(this.getRecentMatchlist.name,"required params "+o.yellow("`accountID/accID` (int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getMatchTimeline",value:function(){
!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")}function l(e,t,n){return new O({key:e,defaultRegion:t,debug:n,limits:v.DEV,cacheOptions:_[0]})}function g(e,t){e?console.log(e):console.log(t)}var h="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}}(),c=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}(),d=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,t){this.client.setex(this.prefix+e.key,e.ttl,t)}}]),e}(),p=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}(),y={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:null,STATUS:"status",MASTERIES:"platform",MATCH:"match",MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner"},I={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},R={CHAMPION:I.MONTH,CHAMPION_MASTERY:I.SIX_HOURS,CURRENT_GAME:I.NONE,FEATURED_GAMES:I.NONE,GAME:I.HOUR,LEAGUE:I.SIX_HOURS,STATIC:I.MONTH,STATUS:I.NONE,MATCH:I.MONTH,MATCH_LIST:I.ONE_HOUR,RUNES_MASTERIES:I.WEEK,SPECTATOR:I.NONE,STATS:I.HOUR,SUMMONER:I.DAY},v={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},f={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"},S={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"},b={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"},E={CHAMPION:3,CHAMPION_MASTERY:3,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:3,STATUS:3,MATCH:3,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3},_=["in-memory-cache","redis"],M=i("^[0-9\\p{L} _\\.]+$"),A={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},D={int:function(e){return e&&Array.isArray(e)&&A.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&A.string(e)&&e.length>0}},T=function(e){var t=!0,n=!1,i=void 0;try{for(var r,s=Object.keys(S)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(S[o]===e)return!0}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}return!1},U={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},q=function(e){var t=U[e];if(t)return t},C=[200,400,500],N=function(e){return e>=C[0]&&e<C[1]?r.green(e):e>=C[1]&&e<C[2]?r.red(e+" "+q(e)):r.bold.red(e+" "+q(e))},k=function(e){return(Array.isArray(e)&&2!==e.length||!D.int(e[0])||2!==e[0].length||!D.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},w=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()},O=function(){function e(t){var n=t.key,i=t.defaultRegion,r=void 0===i?S.NORTH_AMERICA:i,s=t.debug,a=void 0!==s&&s,l=t.limits,g=t.cacheOptions,h=t.cacheTTL;if(u(this,e),this.key=n,this.defaultRegion=T(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,g?(g===_[0]?this.cache=new c:g===_[1]?this.cache=new d:this.cache=g,this.CACHE_TIMERS=h?h:R):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){k(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=v.DEV),"prod"===l&&(l=v.PROD);var m=!0,y=!1,I=void 0;try{for(var f,b=Object.keys(S)[Symbol.iterator]();!(m=(f=b.next()).done);m=!0){var E=f.value;this.limits[S[E]]=[new p(l[0][0],l[0][1]),new p(l[1][0],l[1][1])]}}catch(e){y=!0,I=e}finally{try{!m&&b.return&&b.return()}finally{if(y)throw I}}}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),score:this.getTotalChampMasteryScore.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),recent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),leagues: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),getMapData:this.getMapData.bind(this),mapData:this.getMapData.bind(this),map:this.getMapData.bind(this),maps:this.getMapData.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getProfileIcons:this.getProfileIcons.bind(this),profileIcons:this.getProfileIcons.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)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this),getMatchTimeline:this.getMatchTimeline.bind(this),getTimeline:this.getMatchTimeline.bind(this),timeline:this.getMatchTimeline.bind(this)},this.Matchlist={getMatchlist:this.getMatchlist.bind(this),get:this.getMatchlist.bind(this),getRecentMatchlist:this.getRecentMatchlist.bind(this),recent:this.getRecentMatchlist.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={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.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 M.test(e)}},{key:"_makeUrl",value:function(e,t,n,i,r,s){var o=n?"":t+"/",a=i||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),l="https://"+f[b[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return l.lastIndexOf("v3")==-1?u:l}},{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,g=void 0!==l&&l,h=e.observerMode,m=void 0!==h&&h,c=e.staticReq,d=void 0!==c&&c,p=e.championMastery,y=void 0!==p&&p,I=e.options,R=void 0===I?{}:I,v=e.cacheParams,f=void 0===v?{}:v,S=function(){return new Promise(function(e,r){var l=!0,h=!1,c=void 0;try{for(var p,I=Object.keys(R)[Symbol.iterator]();!(l=(p=I.next()).done);l=!0){var v=p.value;Array.isArray(R[v])&&(R[v]=R[v].join(","))}}catch(e){h=!0,c=e}finally{try{!l&&I.return&&I.return()}finally{if(h)throw c}}var S=a.stringify(R).replace(/%2C/,","),b=S?"?"+S:"",E=n._makeUrl(i+b,u,d,g,m,y),_=E+(E.lastIndexOf("?")===-1?"?":"&")+"api_key="+n.key;n.cache.get({key:E},function(i,a){if(a){n.debug&&console.log(o.green("CACHE HIT")+" "+_);var l=JSON.parse(a);return t?t(i,l):e(l)}if(n.limits){var g=n;!function t(n){g.canMakeRequest(u)?(d||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),s({url:_},function(i,s,a){if(s&&a){var u=s.statusCode,l=N(u);if(g.debug&&w(s,l,_),"function"==typeof n)return u>=500&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(n)},1e3)),429===u&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(n)},1e3*s.headers["retry-after"]+50)),u>=400?n(l+" : "+o.yellow(E)):(Number.isInteger(f.ttl)&&f.ttl>0&&g.cache.set({key:E,ttl:f.ttl},a),n(i,JSON.parse(a)));if(500===u)g.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(f.ttl)&&f.ttl>0&&g.cache.set({key:E,ttl:f.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(i,_)})):setTimeout(function(){t.bind(g)(n)},1e3)}(t)}else s({url:_},function(n,i,s){if(i){var a=i.statusCode,u=N(a);return g.debug&&w(i,u,_),"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?S():S().catch(S).catch(S).catch(S).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION_MASTERY+"/v"+E.CHAMPION+"/"+n,region:i,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION+"/v"+E.CHAMPION+"/"+n,region:i,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:y.SPECTATOR+"/v"+E.SPECTATOR+"/"+n,region:i,cacheParams:{ttl:this.CACHE_TIMERS.SPECTATOR}},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:y.STATIC_DATA+"/v"+E.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:y.STATUS+"/v"+E.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"+E.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"+E.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:y.MATCH+"/v"+E.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"+E.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._baseRequest({endUrl:y.RUNES_MASTERIES+"/v"+E.RUNES_MASTERIES+"/"+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"+E.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:y.SUMMONER+"/v"+E.SUMMONER+"/summoners/"+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=T(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:"champions",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:"champions/"+(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];return Number.isInteger(i)&&Number.isInteger(r)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+i+"/by-champion/"+r,region:n,options:s},a):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.accountID,s=t.accID,a=t.id,u=t.summonerID,l=t.playerID,g=t.name,m=t.options,c=arguments[1];return Number.isInteger(r||s)?new Promise(function(t,n){return e.getSummoner({accID:r||s,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:i},c))})}):Number.isInteger(a||u||l)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(a||u||l),region:i,options:m},c):"object"===h(arguments[0])&&"string"==typeof g?new Promise(function(t,n){return e.getSummoner({name:g,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:i},c))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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.accountID,s=t.accID,a=t.id,u=t.summonerID,l=t.playerID,g=t.name,m=t.options,c=arguments[1];return Number.isInteger(r||s)?new Promise(function(t,n){return e.getSummoner({accID:r||s,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:i},c))})}):Number.isInteger(a||u||l)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(a||u||l),region:i,options:m},c):"object"===h(arguments[0])&&"string"==typeof g?new Promise(function(t,n){return e.getSummoner({name:g,region:i},function(r,s){return r?void(c?c(r):n(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:i},c))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=n.region,r=void 0===i?this.defaultRegion:i,s=n.accountID,a=n.accID,u=n.id,l=n.summonerID,g=n.playerID,m=n.name,c=arguments[1];return Number.isInteger(s||a)?new Promise(function(n,i){return e.getSummoner({accID:s||a,region:r},function(s,o){return s?void(c?c(s):i(s)):n(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},c=r?c:t[0]))})}):Number.isInteger(u||l||g)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(u||l||g),region:r},c=r?c:arguments[0]):"object"===h(arguments[0])&&"string"==typeof m?new Promise(function(n,i){return e.getSummoner({name:m,region:r},function(s,o){return s?void(c?c(s):i(s)):n(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},c=r?c:t[0]))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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._spectatorRequest({endUrl:"featured-games",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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._gameRequest({endUrl:"by-summoner/"+r.id+"/recent",region:n},g))})}):Number.isInteger(s||a||u)?this._gameRequest({endUrl:"by-summoner/"+(s||a||u)+"/recent",region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:n},g))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(m?m(i):s(i)):t(e._leagueRequest({endUrl:"by-summoner/"+r.id,region:n,options:g},m))})}):Number.isInteger(s||a||u)?this._leagueRequest({endUrl:"by-summoner/"+(s||a||u),region:n,options:g},m):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id,region:n,options:g},m))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._leagueRequest({endUrl:"by-summoner/"+r.id+"/entry",region:n},g))})}):Number.isInteger(s||a||u)?this._leagueRequest({endUrl:"by-summoner/"+(s||a||u)+"/entry",region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id+"/entry",region:n},g))})}):void this._logError(this.getLeagueEntries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{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:"champions",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:"champions/"+(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:"items",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:"items/"+(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:"getMapData",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:"maps",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:"masteries",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:"masteries/"+(n||i),region:t,options:r},s):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getProfileIcons",value:function(e,t){var n=e.region,i=e.options;return this._staticRequest({endUrl:"profile-icons",region:n,options:i},t=2===arguments.length?t:arguments[0])}},{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:"realms",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:"runes",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:"runes/"+(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-spells",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-spells/"+(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-data",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=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:"matches/"+(n||i),region:t,options:r},s):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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=void 0===g?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:g,c=arguments[1];return Number.isInteger(i||r)?this._matchRequest({endUrl:"matchlists/by-account/"+(i||r),region:n,options:m},c):Number.isInteger(s||a||u)?new Promise(function(t,i){return e.getSummoner({id:s,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId,region:n,options:m},c))})}):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(c?c(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId,region:n,options:m},c))})}):this._logError(this.getMatchlist.name,"required params "+o.yellow("`accountID/accID` (int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRecentMatchlist",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?this._matchRequest({endUrl:"matchlists/by-account/"+(i||r)+"/recent",region:n},g):Number.isInteger(s||a||u)?new Promise(function(t,i){return e.getSummoner({id:s,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId+"/recent",region:n},g))})}):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchRequest({endUrl:"matchlists/by-account/"+s.accountId+"/recent",region:n},g))})}):this._logError(this.getRecentMatchlist.name,"required params "+o.yellow("`accountID/accID` (int)")+", "+o.yellow("`id/summonerID/playerID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getMatchTimeline",value:function(){
var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.matchID,r=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:"timelines/by-match/"+(n||i),region:t},r):this._logError(this.getMatchTimeline.name,"required params "+o.yellow("`id/matchID` (int)")+" 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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+r.id,region:n},g))})}):Number.isInteger(s||a||u)?this._runesMasteriesRequest({endUrl:"runes/by-summoner/"+(s||a||u),region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getRunes.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(g?g(i):s(i)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+r.id,region:n},g))})}):Number.isInteger(s||a||u)?this._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+(s||a||u),region:n},g):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(m?m(i):s(i)):t(e._statsRequest({endUrl:r.id+"/ranked",region:n,options:g},m))})}):Number.isInteger(s||a||u)?this._statsRequest({endUrl:(s||a||u)+"/ranked",region:n,options:g},m):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s.id+"/ranked",region:n,options:g},m))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (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.accountID,r=t.accID,s=t.id,a=t.summonerID,u=t.playerID,l=t.name,g=t.options,m=arguments[1];return Number.isInteger(i||r)?new Promise(function(t,s){return e.getSummoner({accID:i||r,region:n},function(i,r){return i?void(m?m(i):s(i)):t(e._statsRequest({endUrl:r.id+"/summary",region:n,options:g},m))})}):Number.isInteger(s||a||u)?this._statsRequest({endUrl:(s||a||u)+"/summary",region:n,options:g},m):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(t,i){return e.getSummoner({name:l,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s.id+"/summary",region:n,options:g},m))})}):void this._logError(this.getStatsSummary.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{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.accountID,a=e.accID,u=e.name,l=arguments[1];return Number.isInteger(n||i||r)?this._summonerRequest({endUrl:""+(n||i||r),region:t},l):"object"===h(arguments[0])&&"string"==typeof u?this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(u),region:t},l):Number.isInteger(s||a)?this._summonerRequest({endUrl:"by-account/"+(s||a),region:t},l):this._logError(this.getSummoner.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID/accID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}}]),e}(),P={Kindred:O,REGIONS:S,LIMITS:v,TIME_CONSTANTS:I,CACHE_TYPES:_,QuickStart:l,print:g};e.exports=P});
{
"name": "kindred-api",
"version": "2.0.11",
"version": "2.0.12",
"description": "Kindred is a thin Node.js wrapper on top of Riot Games API for League of Legends",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -98,4 +98,5 @@ # Kindred

* getRecentGames({ region, accountID/accID (int), id/summonerID/playerID (int), name (str) }, cb)
* Namespaced Functions: *Game.getRecentGames, Game.getRecent, Game.get*
* Namespaced Functions: *Game.getRecentGames, Game.getRecent, Game.recent, Game.get*
* Example 1: ```k.Game.get({ summonerID: 20026563 }, KindredAPI.print)```
* Example 2: ```k.Game.recent({ id: 20026563 }, KindredAPI.print)```

@@ -108,3 +109,3 @@ ### League

* getLeagues({ region, accountID/accID (int), id/summonerID/player/ID (int), name (str) }, cb)
* Namespaced Functions: *League.getLeagues, League.get*
* Namespaced Functions: *League.getLeagues, League.leagues, League.get*
* Example 1: ```k.League.getLeagues({ summonerID: 20026563 }, KindredAPI.print)```

@@ -115,3 +116,3 @@ * Example 2: ```k.League.get({ summonerID: 20026563 }, KindredAPI.print)```

* getLeagueEntries({ region, accountID/accID (int), id/summonerID/playerID (int), name (str) }, cb)
* Namespaced Functions: *League.getLeagueEntries, League.getEntries, League.entries, League.getAll, League.all*
* Namespaced Functions: *League.getLeagueEntries, League.getEntries, League.entries*
* Example 1: ```k.League.entries({ summonerID: 20026563 }, KindredAPI.print)```

@@ -151,3 +152,3 @@ 3. **/api/lol/{region}/v2.5/league/challenger**

Note that this endpoint has two different namespaces (Match and Matchlist).
Note that this section has two different namespaces (Match and Matchlist).
`id` parameter still refers to summonerID (not accountID).

@@ -242,3 +243,3 @@

* Namespaced Functions: *Static.getLanguages, Static.languages*
* Example 1: ```k.Static.languages().then(data => console.log(data)).catch(err => console.log(err))```
* Example 1: ```k.Static.languages().then(data => console.log(data)).catch(err => console.error(err))```
7. **/lol/static-data/v3/maps**

@@ -367,3 +368,3 @@ * Retrieve map data. (REST)

.then(data => console.log(data))
.catch(err => console.err(error))
.catch(err => console.error(err))

@@ -373,4 +374,4 @@ /*

k.Matchlist.get with the `name` param or the `id` (summonerID) param.
Any function that targets just id or accountID's can use all three
different type of params (summonerID, accountID, name(.))
Any function that targets just IDs or accountIDs can use all three
different type of params (summonerID, accountID, name).
*/

@@ -382,7 +383,2 @@ k.Matchlist

/*
Pretty much all the functions when applicable can take in
either an `accountID`, `id` (summoner), or `name`.
*/
var accID = 47776491

@@ -500,3 +496,3 @@ var id = 32932398 // summonerID

.then(json => console.log(json))
.catch(err => console.log(err))
.catch(err => console.error(err))

@@ -549,3 +545,3 @@ k.Match.get({ id: 2459973154 }, rprint)

if (data) k.Runes.get({ id: data.id }, rprint)
else console.err(err)
else console.error(err)
})

@@ -558,3 +554,3 @@

.then(data => console.log(data))
.catch(err => console.log(err))
.catch(err => console.error(err))

@@ -633,3 +629,3 @@ /* I find that inconvenient, and so I just chain it for you in my code. */

.then(data => console.log(data))
.catch(err => console.err(error))
.catch(err => console.error(err))

@@ -636,0 +632,0 @@ var furyMasteryId = 6111

@@ -136,2 +136,3 @@ const request = require('request')

getRecent: this.getRecentGames.bind(this),
recent: this.getRecentGames.bind(this),
get: this.getRecentGames.bind(this)

@@ -142,2 +143,3 @@ }

getLeagues: this.getLeagues.bind(this),
leagues: this.getLeagues.bind(this),
get: this.getLeagues.bind(this),

@@ -148,4 +150,2 @@

entries: this.getLeagueEntries.bind(this),
getAll: this.getLeagueEntries.bind(this),
all: this.getLeagueEntries.bind(this),

@@ -152,0 +152,0 @@ getChallengers: this.getChallengers.bind(this),

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