lol-constants 2.18.0 → 2.19.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ export declare function isRiotId(riotId: any,
2
+ /** @default '#' */
3
+ splitChar?: string): riotId is string;
4
+ export declare const maxRiotIdNameCharCount: 16;
5
+ export declare const maxRiotIdTagCharCount: 5;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maxRiotIdTagCharCount = exports.maxRiotIdNameCharCount = exports.isRiotId = void 0;
4
+ const splitRiotId_1 = require("./splitRiotId");
5
+ function isRiotId(riotId,
6
+ /** @default '#' */
7
+ splitChar = '#') {
8
+ if (typeof riotId != 'string')
9
+ return false;
10
+ const id = (0, splitRiotId_1.splitRiotId)(riotId, splitChar);
11
+ if (id.name == '' || id.name.length > exports.maxRiotIdNameCharCount)
12
+ return false;
13
+ if (id.tag == '' || id.tag.length > exports.maxRiotIdTagCharCount)
14
+ return false;
15
+ return true;
16
+ }
17
+ exports.isRiotId = isRiotId;
18
+ exports.maxRiotIdNameCharCount = 16;
19
+ exports.maxRiotIdTagCharCount = 5;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `name#tag` => `{name, tag}`
3
+ */
4
+ export declare function splitRiotId(riotId: string,
5
+ /** @default '#' */
6
+ splitChar?: string): SplitRiotId;
7
+ export type SplitRiotId = {
8
+ name: string;
9
+ tag: string;
10
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitRiotId = void 0;
4
+ /**
5
+ * `name#tag` => `{name, tag}`
6
+ */
7
+ function splitRiotId(riotId,
8
+ /** @default '#' */
9
+ splitChar = '#') {
10
+ const split = riotId.split(splitChar);
11
+ let name = split[0] ?? '';
12
+ let tag = split[1] ?? '';
13
+ if (tag.includes(splitChar))
14
+ tag = '';
15
+ return {
16
+ name,
17
+ tag,
18
+ };
19
+ }
20
+ exports.splitRiotId = splitRiotId;
package/core/index.d.ts CHANGED
@@ -69,6 +69,8 @@ export * from './constants/Spells/SpellKeys';
69
69
  export * from './constants/Spells/SpellKeysNum';
70
70
  export * from './constants/Spells/SpellNames';
71
71
  export * from './helpers/getPositionImageUrl';
72
+ export * from './helpers/isRiotId';
73
+ export * from './helpers/splitRiotId';
72
74
  export * from './helpers/Champions/getChampionIdByKey';
73
75
  export * from './helpers/Champions/getChampionIdByName';
74
76
  export * from './helpers/Champions/getChampionKeyById';
package/core/index.js CHANGED
@@ -91,6 +91,8 @@ __exportStar(require("./constants/Spells/SpellKeysNum"), exports);
91
91
  __exportStar(require("./constants/Spells/SpellNames"), exports);
92
92
  // # helpers
93
93
  __exportStar(require("./helpers/getPositionImageUrl"), exports);
94
+ __exportStar(require("./helpers/isRiotId"), exports);
95
+ __exportStar(require("./helpers/splitRiotId"), exports);
94
96
  // ## Champions
95
97
  __exportStar(require("./helpers/Champions/getChampionIdByKey"), exports);
96
98
  __exportStar(require("./helpers/Champions/getChampionIdByName"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lol-constants",
3
- "version": "2.18.0",
3
+ "version": "2.19.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",