lol-constants 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
- Provides constants and types for League of Legends related stuff within the context of [Riot APIs](https://developer.riotgames.com/docs/lol). Types such as [`ChampionId`](src/core/constants/Champions/ChampionIds.ts), [`ChampionName`](src/core/constants/Champions/ChampionNames.ts), [`ItemKey`](src/core/constants/Items/ItemKeys.ts), [`RuneId`](src/core/constants/Runes/RuneSetsByRuneNames.ts#L55), [`SpellName`](src/core/constants/Spells/SpellNames.ts), [`Position`](src/core/constants/Positions.ts), [`QueueType`](src/core/constants/QueueTypes.ts), [`RankedTier`](src/core/constants/RankedTiers.ts), [`Region`](src/core/constants/Regions.ts) and more are provided. Certain URLs and URIs are available as constants as well in [`DataDragonUrls`](src/core/constants/DataDragonUrls.ts), [`PlatformApiUris`](src/core/constants/PlatformApiUris.ts), [`RegionalApiUris`](src/core/constants/RegionalApiUris.ts).
1
+ Provides constants and types for League of Legends related stuff within the context of [Riot APIs](https://developer.riotgames.com/docs/lol). Types such as [`ChampionId`](src/core/constants/Champions/ChampionIds.ts), [`ChampionName`](src/core/constants/Champions/ChampionNames.ts), [`ItemKey`](src/core/constants/Items/ItemKeys.ts), [`RuneId`](src/core/constants/Runes/RuneSetsByRuneNames.ts#L55), [`SpellName`](src/core/constants/Spells/SpellNames.ts), [`Position`](src/core/constants/Positions.ts), [`QueueType`](src/core/constants/QueueTypes.ts), [`RankedTier`](src/core/constants/RankedTiers.ts), [`Region`](src/core/constants/Regions.ts) and more are provided. Certain URLs and URIs are available as constants as well: [`DataDragonUrls`](src/core/constants/DataDragonUrls.ts), [`PlatformApiUris`](src/core/constants/PlatformApiUris.ts), [`RegionalApiUris`](src/core/constants/RegionalApiUris.ts).
2
2
 
3
3
  Advantages:
4
+ - Types
4
5
  - Four categories — champions, items, runes, summoner spells — are armed with getter functions that exchange between id–key–name such as [`getChampionNameByKey`](src/core/helpers/Champions/getChampionNameByKey.ts)–[`getChampionIdByName`](src/core/helpers/Champions/getChampionIdByName.ts)–[`getChampionKeyById`](src/core/helpers/Champions/getChampionKeyById.ts)
5
6
  - Types can be validated through type-validating functions such as [`isChampionName`](src/core/helpers/Champions/isChampionName.ts)
6
7
  - Type validation functions such as [`isChampionName`](src/core/helpers/Champions/isChampionName.ts) and getter functions such as [`getChampionNameByKey`](src/core/helpers/Champions/getChampionNameByKey.ts) are instantaneous $O(1)$ and do not iterate over many elements
@@ -8,8 +9,20 @@ Advantages:
8
9
  # Champions
9
10
  | constants | types | getters | type-validators
10
11
  | --- | --- | --- | --- |
11
- | `ChampionIds`, `ChampionIdsByName`, `ChampionKeys`, `ChampionKeysNum`, `ChampionNames` | `ChampionId`, `ChampionKey`, `ChampionKeyNum`, `ChampionName` | `getChampionIdByKey`, `getChampionIdByName`, `getChampionKeyById`, `getChampionKeyByName`, `getChampionNameById`, `getChampionNameByKey` | `isChampionId`, `isChampionKey`, `isChampionKeyNum`, `isChampionName`
12
+ `ChampionIds`, `ChampionIdsByName`, `ChampionKeys`, `ChampionKeysNum`, `ChampionNames` | `ChampionId`, `ChampionKey`, `ChampionKeyNum`, `ChampionName` | `getChampionIdByKey`, `getChampionIdByName`, `getChampionKeyById`, `getChampionKeyByName`, `getChampionNameById`, `getChampionNameByKey` | `isChampionId`, `isChampionKey`, `isChampionKeyNum`, `isChampionName`
12
13
  # Items
14
+ | constants | types | getters | type-validators
15
+ | --- | --- | --- | --- |
16
+ `BootsItemKeys`, `BootsItemKeysNum`, `BootsItemNames`, `ItemKeys`, `ItemKeysNum`, `ItemNames`, `ItemTypes`, `LegendaryItemKeys`, `LegendaryItemKeysNum`, `LegendaryItemNames`, `MythicItemKeys`, `MythicItemKeysNum`, `MythicItemNames`, `OrnnItemKeys`, `OrnnItemKeysNum`, `OrnnItemNames` | `BootsItemKey`, `BootsItemKeyNum`, `BootsItemName`, `ItemKey`, `ItemKeyNum`, `ItemName`, `ItemType`, `LegendaryItemKey`, `LegendaryItemKeyNum`, `LegendaryItemName`, `MythicItemKey`, `MythicItemKeyNum`, `MythicItemName`, `OrnnItemKey`, `OrnnItemKeyNum`, `OrnnItemName` | `getItemKeyByName`, `getItemNameByKey` | `isBootsItemKey`, `isBootsItemKeyNum`, `isBootsItemName`, `isItemKey`, `isItemKeyNum`, `isItemName`, `isItemType`, `isLegendaryItemKey`, `isLegendaryItemKeyNum`, `isLegendaryItemName`, `isMythicItemKey`, `isMythicItemKeyNum`, `isMythicItemName`, `isOrnnItemKey`, `isOrnnItemKeyNum`, `isOrnnItemName`
13
17
  # Runes
18
+ | constants | types | getters | type-validators
19
+ | --- | --- | --- | --- |
20
+ `KeystoneIds`, `KeystoneIdsNum`, `KeystoneNames`, `NonStatRuneIds`, `NonStatRuneIdsNum`, `NonStatRuneNames`, `PrimaryRuneTrees`, `PrimaryRuneTreesByRuneNames`, `PrimaryRuneTreesByRuneNamesNum`, `RuneHSets`, `RuneHSetsByRuneNames`, `RuneHSetsByRuneNamesNum`, `RuneIconFileNames`, `RuneIds`, `RuneIdsNum`, `RuneNames`, `RunePickingRelationships`, `RuneSets`, `RuneSetsByRuneNames`, `RuneSetsByRuneNamesNum`, `RuneTreeIds`, `RuneTreeIdsNum`, `RuneTreeNames`, `RuneTreeTypes`, `SecondaryRuneTrees`, `SecondaryRuneTreesByRuneNames`, `SecondaryRuneTreesByRuneNamesNum`, `StatRuneHSets`, `StatRuneHSetsByRuneNames`, `StatRuneHSetsByRuneNamesNum`, `StatRuneIds`, `StatRuneIdsNum`, `StatRuneNames` | `NonStatRuneId`, `NonStatRuneIdNum`, `NonStatRuneName`, `RuneIconFile`, `RuneId`, `RuneIdNum`, `RuneName`, `RuneTreeId`, `RuneTreeIdNum`, `RuneTreeName`, `RuneTreeType`, `StatRuneId`, `StatRuneIdNum`, `StatRuneName` | `getNonStatRuneIdByName`, `getNonStatRuneNameById`, `getRuneCategoryName`, `getRuneCdnUrl`, `getRuneIdByName`, `getRuneNameById`, `getRuneTreeIdByName`, `getRuneTreeIdNumByName`, `getRuneTreeNameById`, `getStatRuneIdByName`, `getStatRuneNameById` | `isDominationRuneId`, `isDominationRuneIdNum`, `isDominationRuneName`, `isInspirationRuneId`, `isInspirationRuneIdNum`, `isInspirationRuneName`, `isKeystoneRuneId`, `isKeystoneRuneIdNum`, `isKeystoneRuneName`, `isNonStatRuneId`, `isNonStatRuneIdNum`, `isNonStatRuneName`, `isPrecisionRuneId`, `isPrecisionRuneIdNum`, `isPrecisionRuneName`, `isResolveRuneId`, `isResolveRuneIdNum`, `isResolveRuneName`, `isRuneId`, `isRuneIdNum`, `isRuneName`, `isRuneTreeId`, `isRuneTreeIdNum`, `isRuneTreeName`, `isRuneTreeType`, `isSorceryRuneId`, `isSorceryRuneIdNum`, `isSorceryRuneName`, `isStatRuneId`, `isStatRuneIdNum`, `isStatRuneName`
14
21
  # Summoner spells
22
+ | constants | types | getters | type-validators
23
+ | --- | --- | --- | --- |
24
+ `SpellIds`, `SpellIdsByName`, `SpellKeys`, `SpellKeysNum`, `SpellNames` | `SpellId`, `SpellKey`, `SpellKeyNum`, `SpellName` | `getSpellIdByKey`, `getSpellIdByName`, `getSpellKeyById`, `getSpellKeyByName`, `getSpellNameById`, `getSpellNameByKey` | `isSpellId`, `isSpellKey`, `isSpellKeyNum`, `isSpellName`
15
25
  # Other
26
+ | constants | types | type-validators
27
+ | --- | --- | --- |
28
+ `BuildingTypes`, `Continents`, `DataDragonUrls`, `DragonTypes`, `GameModes`, `GameTypes`, `KillTypes`, `Lanes`, `LaneTypes`, `Levels`, `Locales`, `MapIds`, `MonsterTypes`, `ParticipantIds`, `PlatformApiUris`, `PlatformIds`, `Positions`, `QueueDescriptions:`, `QueueIds`, `QueueTypes`, `RankedRanks`, `RankedTiers`, `RegionalApiUris`, `Regions`, `RelativeTeams`, `Roles`, `Skills`, `SkillSlots`, `TeamIds`, `TowerTypes`, `WardTypes` | `BuildingType`, `Continent`, `DragonType`, `GameMode`, `GameType`, `KillType`, `Lane`, `LaneType`, `Level`, `Locale`, `MapId`, `MonsterType`, `ParticipantId`, `PlatformApiUri`, `PlatformId`, `Position`, `QueueId`, `QueueType`, `RankedRank`, `RankedTier`, `RegionalApiUri`, `Region`, `RelativeTeam`, `Role`, `Skill`, `SkillSlot`, `TeamId`, `TowerType`, `WardType` | `isBuildingType`, `isContinent`, `isDragonType`, `isGameMode`, `isGameType`, `isKillType`, `isLane`, `isLaneType`, `isLevel`, `isLocale`, `isMapId`, `isMonsterType`, `isParticipantId`, `isPlatformApiUri`, `isPlatformId`, `getPlatformIdByRegion`, `isPosition`, `isQueueId`, `isQueueType`, `isRankedRank`, `isRankedTier`, `isRegionalApiUri`, `isRegion`, `getRegionByPlatformId`, `isRelativeTeam`, `isRole`, `isSkill`, `isSkillSlot`, `isTeamId`, `isTowerType`, `isWardType`
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const promises_1 = require("fs/promises");
4
+ const folders1 = [
5
+ 'constants',
6
+ 'helpers',
7
+ ];
8
+ const folders2 = [
9
+ 'Champions',
10
+ 'Items',
11
+ 'Runes',
12
+ 'Spells',
13
+ ];
14
+ // TEMP
15
+ // async function getConstantNames() {
16
+ // const product: {
17
+ // [folder1: string]: {
18
+ // [folder2: string]: string
19
+ // }
20
+ // } = {}
21
+ // async function getFileNames(dir: string): Promise<string> {
22
+ // const fileNames = await readdir(dir)
23
+ // // Remove `.ts` extension
24
+ // const modifiedFileNames = fileNames
25
+ // .map(name => name.slice(0, name.indexOf('.ts')))
26
+ // .join('`, `')
27
+ // return '`' + modifiedFileNames + '`'
28
+ // }
29
+ // for (const folder1 of folders1) {
30
+ // if (product[folder1] == null) product[folder1] = {}
31
+ // for (const folder2 of folders2) {
32
+ // const fileNamesSt = await getFileNames(`src/core/${folder1}/${folder2}`)
33
+ // product[folder1]![folder2] = fileNamesSt
34
+ // }
35
+ // }
36
+ // return product
37
+ // }
38
+ function getVariableNamesFromFileContents(contents, exportStatement, endingCharacter) {
39
+ const typeNames = [];
40
+ let exportIndex = 0;
41
+ while ((exportIndex = contents.indexOf(exportStatement, exportIndex)) != -1) {
42
+ const typeNameIndex = exportIndex + (exportStatement + ' ').length;
43
+ const typeNameEndIndex = contents.indexOf(endingCharacter, typeNameIndex);
44
+ const typeName = contents.slice(typeNameIndex, typeNameEndIndex);
45
+ typeNames.push(typeName);
46
+ exportIndex = typeNameEndIndex;
47
+ }
48
+ return typeNames;
49
+ }
50
+ async function getVariableNames(exportStatement, endingCharacter) {
51
+ exportStatement = exportStatement.trim();
52
+ const workspace = {};
53
+ const product = {};
54
+ for (const folder1 of folders1) {
55
+ for (const folder2 of folders2) {
56
+ if (workspace[folder2] == null)
57
+ workspace[folder2] = [];
58
+ const base = `src/core/${folder1}/${folder2}`;
59
+ const fileNames = await (0, promises_1.readdir)(base);
60
+ for (const fileName of fileNames) {
61
+ const contents = await (0, promises_1.readFile)(`${base}/${fileName}`, { encoding: 'utf-8' });
62
+ workspace[folder2].push(...getVariableNamesFromFileContents(contents, exportStatement, endingCharacter));
63
+ }
64
+ }
65
+ }
66
+ // Finalize product
67
+ for (const folder2 in workspace) {
68
+ const variableNames = workspace[folder2];
69
+ variableNames.sort((a, b) => a.localeCompare(b));
70
+ product[folder2] = '`' + workspace[folder2].join('`, `') + '`';
71
+ }
72
+ return product;
73
+ }
74
+ function combineVariableGroupsForReadMeTable(obj) {
75
+ const product = {};
76
+ for (const folder2 of folders2) {
77
+ const groups = [];
78
+ for (let groupName in obj) {
79
+ groups.push(obj[groupName][folder2]);
80
+ }
81
+ product[folder2] = groups.join(' | ');
82
+ }
83
+ return product;
84
+ }
85
+ async function getOtherVariableInfo() {
86
+ const constants = [];
87
+ const types = [];
88
+ const functions = [];
89
+ const constantFileNames = (await (0, promises_1.readdir)('src/core/constants'))
90
+ .filter(fileName => fileName.includes('.ts'));
91
+ console.log('constantFileNames', constantFileNames); // TEMP
92
+ for (const fileName of constantFileNames) {
93
+ const contents = await (0, promises_1.readFile)(`src/core/constants/${fileName}`, { encoding: 'utf-8' });
94
+ constants.push(...getVariableNamesFromFileContents(contents, 'export const', ' '));
95
+ types.push(...getVariableNamesFromFileContents(contents, 'export type', ' '));
96
+ functions.push(...getVariableNamesFromFileContents(contents, 'export function', '('));
97
+ }
98
+ const constantsSt = '`' + constants.join('`, `') + '`';
99
+ const typesSt = '`' + types.join('`, `') + '`';
100
+ const functionsSt = '`' + functions.join('`, `') + '`';
101
+ return `${constantsSt} | ${typesSt} | ${functionsSt}`;
102
+ }
103
+ (async () => {
104
+ const constantNames = await getVariableNames('export const', ' ');
105
+ const typeNames = await getVariableNames('export type', ' ');
106
+ const functionNames = await getVariableNames('export function', '(');
107
+ const grouped = {
108
+ constants: constantNames,
109
+ types: typeNames,
110
+ functions: functionNames,
111
+ };
112
+ const product = combineVariableGroupsForReadMeTable(grouped);
113
+ console.log(product);
114
+ const otherVariableInfo = await getOtherVariableInfo();
115
+ console.log(otherVariableInfo);
116
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lol-constants",
3
- "version": "2.10.0",
3
+ "version": "2.11.0",
4
4
  "description": "League of Legends constants and data resources, such as champion, item, runes reforged, summoner spells.",
5
5
  "main": "core/index.js",
6
6
  "types": "core/index.d.ts",
@@ -12,6 +12,7 @@
12
12
  "scripts": {
13
13
  "build:clean": "rmdir /s /q core && rmdir /s /q assets && tsc",
14
14
  "generate": "node assets/scripts/generate-all",
15
+ "print-file-names": "node assets/scripts/print-file-names",
15
16
  "dev": "vite"
16
17
  },
17
18
  "devDependencies": {