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

dota-wiki-api

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dota-wiki-api - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/modules/players.d.ts

2

dist/demo.js

@@ -8,3 +8,3 @@ "use strict";

const myDotaWikiApi = new index_1.DotaWikiApi(myConfig);
myDotaWikiApi.getAllRanks()
myDotaWikiApi.getTeam('VGJ.Storm')
.then((res) => {

@@ -11,0 +11,0 @@ console.log(res);

import { IRank, IRankKey } from './modules/dpc-rankings';
export { IRank, IRankKey };
export interface IDotaWikiConfig {
userAgentValue: string;
}
import { IPlayer } from './modules/players';
import { ITeam } from './modules/teams';
import { IDotaWikiConfig } from './utils/base';
export { IDotaWikiConfig, IPlayer, IRank, IRankKey, ITeam };
export declare class DotaWikiApi {
private dpc;
private config;
private dTeam;
constructor(config: IDotaWikiConfig);
getTeamByStanding(rank: number): Promise<IRank>;
getRankByTeamname(teamName: string): Promise<IRank>;
getAllRanks(): Promise<Map<IRankKey, IRank> | string>;
getAllRanks(): Promise<Map<IRankKey, IRank>>;
getTeam(teamName: string): Promise<ITeam>;
}
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const dpc_rankings_1 = require("./modules/dpc-rankings");
const teams_1 = require("./modules/teams");
class DotaWikiApi {
constructor(config) {
this.dpc = new dpc_rankings_1.DPCRankings(this.config.userAgentValue);
this.dpc = new dpc_rankings_1.DPCRankings(config);
this.dTeam = new teams_1.DotaTeams(config);
}
getTeamByStanding(rank) {
return new Promise((resolve, reject) => {
const stringRank = rank.toString();
this.dpc.getRankByStanding(stringRank)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
return __awaiter(this, void 0, void 0, function* () {
return this.dpc.getRankByStanding(rank.toString());
});
}
getRankByTeamname(teamName) {
return new Promise((resolve, reject) => {
this.dpc.getRankByTeam(teamName)
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
return __awaiter(this, void 0, void 0, function* () {
return this.dpc.getRankByTeam(teamName);
});
}
getAllRanks() {
return new Promise((resolve, reject) => {
this.dpc.getRankings()
.then((res) => {
resolve(res);
})
.catch((err) => {
reject(err);
});
return __awaiter(this, void 0, void 0, function* () {
return this.dpc.getRankings();
});
}
getTeam(teamName) {
return __awaiter(this, void 0, void 0, function* () {
return this.dTeam.getTeamInfo(teamName);
});
}
}
exports.DotaWikiApi = DotaWikiApi;

@@ -12,3 +12,4 @@ "use strict";

return new Promise((resolve, reject) => {
if (this._canFetchNew(new Date())) {
this._canFetchNew(new Date())
.then(() => {
node_fetch_1.default(url, init)

@@ -24,11 +25,3 @@ .then((res) => {

});
}
else {
if (this.apiCache[url.toString()]) {
resolve(this.apiCache[url.toString()]);
}
else {
reject();
}
}
});
});

@@ -42,8 +35,15 @@ }

_canFetchNew(currentTime) {
if (currentTime.getTime() - this.lastFetch.getTime() >= 3000) {
return true;
}
return false;
return new Promise((resolve) => {
const waitTime = (currentTime.getTime() - this.lastFetch.getTime());
if (currentTime.getTime() - this.lastFetch.getTime() >= 3000) {
resolve();
}
else {
setTimeout(() => {
resolve();
}, (3000 - waitTime));
}
});
}
}
exports.CacheFetch = CacheFetch;

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

import { Base, IDotaWikiConfig } from '../utils/base';
export interface IRankKey {

@@ -14,10 +15,8 @@ rank?: string;

}
export declare class DPCRankings {
private cacheFetch;
private userAgentValue;
constructor(userAgentValue: string);
export declare class DPCRankings extends Base {
constructor(config: IDotaWikiConfig);
getRankByStanding(rank: string): Promise<IRank>;
getRankByTeam(team: string): Promise<IRank>;
getRankings(): Promise<Map<IRankKey, IRank> | string>;
getRankings(): Promise<Map<IRankKey, IRank>>;
private _parseRanks(tableHtml);
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cheerio = require("cheerio");
const cachefetch_1 = require("./cachefetch");
class DPCRankings {
constructor(userAgentValue) {
this.cacheFetch = new cachefetch_1.CacheFetch();
this.userAgentValue = userAgentValue;
const base_1 = require("../utils/base");
class DPCRankings extends base_1.Base {
constructor(config) {
super(config);
}

@@ -10,0 +9,0 @@ getRankByStanding(rank) {

{
"name": "dota-wiki-api",
"version": "0.1.1",
"version": "0.2.0",
"description": "A module to communicate with Liquipedia's Dota 2 Wiki to fetch Team Info, DPC Rankings, Dota Game Schedules, and more!",

@@ -31,3 +31,4 @@ "license": "MIT",

"watch:test": "npm run test -- --watch",
"start": "node dist/demo.js"
"start": "node dist/demo.js",
"demo": "npm run build && node dist/demo.js"
},

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

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