lol-constants 2.18.0 → 2.19.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/core/helpers/isRiotId.d.ts +5 -0
 - package/core/helpers/isRiotId.js +19 -0
 - package/core/helpers/splitRiotId.d.ts +10 -0
 - package/core/helpers/splitRiotId.js +20 -0
 - package/core/index.d.ts +2 -0
 - package/core/index.js +2 -0
 - package/package.json +1 -1
 
| 
         @@ -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,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