@wise-old-man/utils 2.0.0-beta.2 → 2.0.0-beta.3

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/dist/index.d.ts CHANGED
@@ -527,11 +527,11 @@ declare const Boss: {
527
527
  readonly ZULRAH: "zulrah";
528
528
  };
529
529
  declare type Boss = typeof Boss[keyof typeof Boss];
530
- declare const Virtual: {
530
+ declare const ComputedMetric: {
531
531
  readonly EHP: "ehp";
532
532
  readonly EHB: "ehb";
533
533
  };
534
- declare type Virtual = typeof Virtual[keyof typeof Virtual];
534
+ declare type ComputedMetric = typeof ComputedMetric[keyof typeof ComputedMetric];
535
535
  declare const Metric: {
536
536
  readonly EHP: "ehp";
537
537
  readonly EHB: "ehb";
@@ -1205,8 +1205,8 @@ declare const CompetitionTypeProps: CompetitionTypePropsMap;
1205
1205
  declare const CompetitionStatusProps: CompetitionStatusPropsMap;
1206
1206
  declare const COMPETITION_TYPES: ("classic" | "team")[];
1207
1207
  declare const COMPETITION_STATUSES: CompetitionStatus[];
1208
- declare function findCompetitionType(typeName: string): CompetitionType | null;
1209
- declare function findCompetitionStatus(statusName: string): CompetitionStatus | null;
1208
+ declare function isCompetitionType(typeString: string): typeString is CompetitionType;
1209
+ declare function isCompetitionStatus(statusString: string): statusString is CompetitionStatus;
1210
1210
 
1211
1211
  interface CountryDetails {
1212
1212
  code: Country;
@@ -1217,6 +1217,7 @@ declare type CountryPropsMap = {
1217
1217
  };
1218
1218
  declare const CountryProps: CountryPropsMap;
1219
1219
  declare const COUNTRY_CODES: ("AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW")[];
1220
+ declare function isCountry(countryCodeString: string): countryCodeString is Country;
1220
1221
  declare function findCountry(countryIdentifier: string): CountryDetails | undefined;
1221
1222
  declare function findCountryByName(countryName: string): CountryDetails | undefined;
1222
1223
  declare function findCountryByCode(countryCode: string): CountryDetails | undefined;
@@ -1240,12 +1241,13 @@ declare type GroupRolePropsMap = {
1240
1241
  };
1241
1242
  declare const GroupRoleProps: GroupRolePropsMap;
1242
1243
  declare function findGroupRole(roleName: string): GroupRole | null;
1244
+ declare function isGroupRole(roleString: string): roleString is GroupRole;
1243
1245
 
1244
1246
  declare enum MetricType {
1245
1247
  SKILL = "skill",
1246
1248
  BOSS = "boss",
1247
1249
  ACTIVITY = "activity",
1248
- VIRTUAL = "virtual"
1250
+ COMPUTED = "computed"
1249
1251
  }
1250
1252
  declare enum MetricMeasure {
1251
1253
  EXPERIENCE = "experience",
@@ -1267,14 +1269,14 @@ interface BossProperties {
1267
1269
  type: MetricType;
1268
1270
  measure: MetricMeasure;
1269
1271
  }
1270
- interface VirtualProperties {
1272
+ interface ComputedMetricProperties {
1271
1273
  name: string;
1272
1274
  type: MetricType;
1273
1275
  measure: MetricMeasure;
1274
1276
  }
1275
1277
  declare const MetricProps: {
1276
- ehp: VirtualProperties;
1277
- ehb: VirtualProperties;
1278
+ ehp: ComputedMetricProperties;
1279
+ ehb: ComputedMetricProperties;
1278
1280
  abyssal_sire: BossProperties;
1279
1281
  alchemical_hydra: BossProperties;
1280
1282
  barrows_chests: BossProperties;
@@ -1354,22 +1356,23 @@ declare const METRICS: string[];
1354
1356
  declare const SKILLS: ("overall" | "attack" | "defence" | "strength" | "hitpoints" | "ranged" | "prayer" | "magic" | "cooking" | "woodcutting" | "fletching" | "fishing" | "firemaking" | "crafting" | "smithing" | "mining" | "herblore" | "agility" | "thieving" | "slayer" | "farming" | "runecrafting" | "hunter" | "construction")[];
1355
1357
  declare const BOSSES: ("abyssal_sire" | "alchemical_hydra" | "barrows_chests" | "bryophyta" | "callisto" | "cerberus" | "chambers_of_xeric" | "chambers_of_xeric_challenge_mode" | "chaos_elemental" | "chaos_fanatic" | "commander_zilyana" | "corporeal_beast" | "crazy_archaeologist" | "dagannoth_prime" | "dagannoth_rex" | "dagannoth_supreme" | "deranged_archaeologist" | "general_graardor" | "giant_mole" | "grotesque_guardians" | "hespori" | "kalphite_queen" | "king_black_dragon" | "kraken" | "kreearra" | "kril_tsutsaroth" | "mimic" | "nex" | "nightmare" | "phosanis_nightmare" | "obor" | "sarachnis" | "scorpia" | "skotizo" | "tempoross" | "the_gauntlet" | "the_corrupted_gauntlet" | "theatre_of_blood" | "theatre_of_blood_hard_mode" | "thermonuclear_smoke_devil" | "tombs_of_amascut" | "tombs_of_amascut_expert" | "tzkal_zuk" | "tztok_jad" | "venenatis" | "vetion" | "vorkath" | "wintertodt" | "zalcano" | "zulrah")[];
1356
1358
  declare const ACTIVITIES: string[];
1357
- declare const VIRTUALS: ("ehp" | "ehb")[];
1359
+ declare const COMPUTED_METRICS: ("ehp" | "ehb")[];
1358
1360
  declare const REAL_SKILLS: ("overall" | "attack" | "defence" | "strength" | "hitpoints" | "ranged" | "prayer" | "magic" | "cooking" | "woodcutting" | "fletching" | "fishing" | "firemaking" | "crafting" | "smithing" | "mining" | "herblore" | "agility" | "thieving" | "slayer" | "farming" | "runecrafting" | "hunter" | "construction")[];
1359
1361
  declare const F2P_BOSSES: ("abyssal_sire" | "alchemical_hydra" | "barrows_chests" | "bryophyta" | "callisto" | "cerberus" | "chambers_of_xeric" | "chambers_of_xeric_challenge_mode" | "chaos_elemental" | "chaos_fanatic" | "commander_zilyana" | "corporeal_beast" | "crazy_archaeologist" | "dagannoth_prime" | "dagannoth_rex" | "dagannoth_supreme" | "deranged_archaeologist" | "general_graardor" | "giant_mole" | "grotesque_guardians" | "hespori" | "kalphite_queen" | "king_black_dragon" | "kraken" | "kreearra" | "kril_tsutsaroth" | "mimic" | "nex" | "nightmare" | "phosanis_nightmare" | "obor" | "sarachnis" | "scorpia" | "skotizo" | "tempoross" | "the_gauntlet" | "the_corrupted_gauntlet" | "theatre_of_blood" | "theatre_of_blood_hard_mode" | "thermonuclear_smoke_devil" | "tombs_of_amascut" | "tombs_of_amascut_expert" | "tzkal_zuk" | "tztok_jad" | "venenatis" | "vetion" | "vorkath" | "wintertodt" | "zalcano" | "zulrah")[];
1360
1362
  declare const MEMBER_SKILLS: ("overall" | "attack" | "defence" | "strength" | "hitpoints" | "ranged" | "prayer" | "magic" | "cooking" | "woodcutting" | "fletching" | "fishing" | "firemaking" | "crafting" | "smithing" | "mining" | "herblore" | "agility" | "thieving" | "slayer" | "farming" | "runecrafting" | "hunter" | "construction")[];
1361
1363
  declare const COMBAT_SKILLS: ("overall" | "attack" | "defence" | "strength" | "hitpoints" | "ranged" | "prayer" | "magic" | "cooking" | "woodcutting" | "fletching" | "fishing" | "firemaking" | "crafting" | "smithing" | "mining" | "herblore" | "agility" | "thieving" | "slayer" | "farming" | "runecrafting" | "hunter" | "construction")[];
1362
1364
  declare function findMetric(metricName: string): Metric | null;
1363
- declare function isSkill(metric: Metric): boolean;
1364
- declare function isActivity(metric: Metric): boolean;
1365
- declare function isBoss(metric: Metric): boolean;
1366
- declare function isVirtualMetric(metric: Metric): boolean;
1365
+ declare function isMetric(metricString: string): metricString is Metric;
1366
+ declare function isSkill(metric: Metric | string): metric is Skill;
1367
+ declare function isActivity(metric: Metric | string): metric is Activity;
1368
+ declare function isBoss(metric: Metric | string): metric is Boss;
1369
+ declare function isComputedMetric(metric: Metric | string): metric is ComputedMetric;
1367
1370
  declare function getMetricRankKey(metric: Metric): string;
1368
1371
  declare function getMetricValueKey(metric: Metric): string;
1369
1372
  declare function getMetricMeasure(metric: Metric): any;
1370
1373
  declare function getMetricName(metric: Metric): any;
1371
1374
  declare function getMinimumBossKc(metric: Metric): number;
1372
- declare function getParentVirtualMetric(metric: Metric): "ehp" | "ehb";
1375
+ declare function getParentEfficiencyMetric(metric: Metric): "ehp" | "ehb";
1373
1376
  declare function parseMetricAbbreviation(abbreviation: string): string | null;
1374
1377
 
1375
1378
  declare type PeriodPropsMap = {
@@ -1381,6 +1384,7 @@ declare type PeriodPropsMap = {
1381
1384
  declare const PeriodProps: PeriodPropsMap;
1382
1385
  declare const PERIODS: ("five_min" | "day" | "week" | "month" | "year")[];
1383
1386
  declare function findPeriod(periodName: string): Period | null;
1387
+ declare function isPeriod(periodString: string): periodString is Period;
1384
1388
  declare function parsePeriodExpression(periodExpression: string): {
1385
1389
  expression: string;
1386
1390
  durationMs: number;
@@ -1400,6 +1404,8 @@ declare const PlayerTypeProps: PlayerTypePropsMap;
1400
1404
  declare const PlayerBuildProps: PlayerBuildPropsMap;
1401
1405
  declare const PLAYER_TYPES: ("unknown" | "regular" | "ironman" | "hardcore" | "ultimate")[];
1402
1406
  declare const PLAYER_BUILDS: ("main" | "f2p" | "lvl3" | "zerker" | "def1" | "hp10")[];
1407
+ declare function isPlayerType(typeString: string): typeString is PlayerType;
1408
+ declare function isPlayerBuild(buildString: string): buildString is PlayerBuild;
1403
1409
  declare function findPlayerType(typeName: string): PlayerType | null;
1404
1410
  declare function findPlayerBuild(buildName: string): PlayerBuild | null;
1405
1411
 
@@ -1467,8 +1473,8 @@ interface ActivityDelta {
1467
1473
  rank: MeasuredDeltaProgress;
1468
1474
  score: MeasuredDeltaProgress;
1469
1475
  }
1470
- interface VirtualDelta {
1471
- metric: Virtual;
1476
+ interface ComputedMetricDelta {
1477
+ metric: ComputedMetric;
1472
1478
  rank: MeasuredDeltaProgress;
1473
1479
  value: MeasuredDeltaProgress;
1474
1480
  }
@@ -1476,7 +1482,7 @@ interface PlayerDeltasArray {
1476
1482
  skills: Array<SkillDelta>;
1477
1483
  bosses: Array<BossDelta>;
1478
1484
  activities: Array<ActivityDelta>;
1479
- virtuals: Array<VirtualDelta>;
1485
+ computed: Array<ComputedMetricDelta>;
1480
1486
  }
1481
1487
  interface PlayerDeltasMap {
1482
1488
  skills: {
@@ -1488,8 +1494,8 @@ interface PlayerDeltasMap {
1488
1494
  activities: {
1489
1495
  [activity in Activity]?: ActivityDelta;
1490
1496
  };
1491
- virtuals: {
1492
- [virtual in Virtual]?: VirtualDelta;
1497
+ computed: {
1498
+ [computedMetric in ComputedMetric]?: ComputedMetricDelta;
1493
1499
  };
1494
1500
  }
1495
1501
  interface DeltaLeaderboardEntry {
@@ -1523,8 +1529,8 @@ interface ActivityValue {
1523
1529
  rank: number;
1524
1530
  score: number;
1525
1531
  }
1526
- interface VirtualValue {
1527
- metric: Virtual;
1532
+ interface ComputedMetricValue {
1533
+ metric: ComputedMetric;
1528
1534
  rank: number;
1529
1535
  value: number;
1530
1536
  }
@@ -1543,8 +1549,8 @@ interface FormattedSnapshot {
1543
1549
  activities: {
1544
1550
  [activity in Activity]?: ActivityValue;
1545
1551
  };
1546
- virtuals: {
1547
- [virtual in Virtual]?: VirtualValue;
1552
+ computed: {
1553
+ [computed in ComputedMetric]?: ComputedMetric;
1548
1554
  };
1549
1555
  };
1550
1556
  }
@@ -1565,26 +1571,26 @@ interface MemberInput {
1565
1571
  username: string;
1566
1572
  role: string | GroupRole;
1567
1573
  }
1568
- interface SkillHiscoresItem {
1574
+ interface GroupHiscoresSkillItem {
1569
1575
  rank: number;
1570
1576
  level: number;
1571
1577
  experience: number;
1572
1578
  }
1573
- interface BossHiscoresItem {
1579
+ interface GroupHiscoresBossItem {
1574
1580
  rank: number;
1575
1581
  kills: number;
1576
1582
  }
1577
- interface ActivityHiscoresItem {
1583
+ interface GroupHiscoresActivityItem {
1578
1584
  rank: number;
1579
1585
  score: number;
1580
1586
  }
1581
- interface VirtualHiscoresItem {
1587
+ interface GroupHiscoresComputedMetricItem {
1582
1588
  rank: number;
1583
1589
  value: number;
1584
1590
  }
1585
1591
  interface GroupHiscoresEntry {
1586
1592
  player: Player;
1587
- data: SkillHiscoresItem | BossHiscoresItem | ActivityHiscoresItem | VirtualHiscoresItem;
1593
+ data: GroupHiscoresSkillItem | GroupHiscoresBossItem | GroupHiscoresActivityItem | GroupHiscoresComputedMetricItem;
1588
1594
  }
1589
1595
  interface GroupStatistics {
1590
1596
  maxedCombatCount: number;
@@ -2028,7 +2034,7 @@ declare class RecordsClient {
2028
2034
 
2029
2035
  declare class EfficiencyClient {
2030
2036
  /**
2031
- * Fetches the current efficiency leaderboard for a specific virtual metric, playerType, playerBuild and country.
2037
+ * Fetches the current efficiency leaderboard for a specific efficiency metric, playerType, playerBuild and country.
2032
2038
  * @returns A list of players.
2033
2039
  */
2034
2040
  getEfficiencyLeaderboards(filter: EfficiencyLeaderboardsFilter, pagination?: PaginationOptions): Promise<Player[]>;
@@ -2132,4 +2138,4 @@ declare class WOMClient {
2132
2138
  constructor();
2133
2139
  }
2134
2140
 
2135
- export { ACTIVITIES, Achievement, AchievementDefinition, AchievementProgress, AchievementTemplate, Activity, ActivityDelta, ActivityValue, AlgorithmCache, AssertPlayerTypeResponse, BOSSES, Bonus, BonusType, Boss, BossDelta, BossMetaConfig, BossValue, CAPPED_MAX_TOTAL_XP, CMLGroupData, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COUNTRY_CODES, ChangeMemberRolePayload, CompetitionDetails, CompetitionListItem, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, CompetitionWithParticipations, CompetitionsSearchFilter, Country, CountryDetails, CountryProps, CreateCompetitionPayload, CreateCompetitionResponse, CreateGroupPayload, CreateGroupResponse, DeltaLeaderboardEntry, DeltaLeaderboardFilter, EditCompetitionPayload, EditGroupPayload, EfficiencyAlgorithm, EfficiencyAlgorithmType, EfficiencyAlgorithmTypeUnion, EfficiencyLeaderboardsFilter, EfficiencyMap, ExperienceMap, ExtendedAchievement, F2P_BOSSES, FormattedSnapshot, GROUP_ROLES, GenericCountMessageResponse, GenericMessageResponse, GetGroupGainsFilter, GetPlayerGainsResponse, GroupHiscoresEntry, GroupListItem, GroupMemberFragment, GroupRecordsFilter, GroupRole, GroupRoleProps, GroupStatistics, GroupWithMemberships, KillcountMap, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MeasuredDeltaProgress, MemberInput, MembershipWithGroup, MembershipWithPlayer, Metric, MetricMeasure, MetricProps, MetricType, MigrationDataSource, NameChangeDetails, NameChangeStatus, NameChangesSearchFilter, PERIODS, PLAYER_BUILDS, PLAYER_TYPES, PRIVELEGED_GROUP_ROLES, ParticipationWithCompetition, ParticipationWithPlayer, ParticipationWithPlayerAndProgress, Period, PeriodProps, Player, PlayerBuild, PlayerBuildProps, PlayerDeltasArray, PlayerDeltasMap, PlayerDetails, PlayerRecordsFilter, PlayerResolvable, PlayerType, PlayerTypeProps, REAL_SKILLS, Record, RecordLeaderboardEntry, RecordLeaderboardFilter, SKILLS, SKILL_EXP_AT_99, Skill, SkillDelta, SkillMetaConfig, SkillValue, Snapshot, SnapshotDataSource, SnapshotFragment, Team, TempleGroupData, TimeRangeFilter, Top5ProgressResult, VIRTUALS, Virtual, VirtualDelta, VirtualValue, WOMClient, findCompetitionStatus, findCompetitionType, findCountry, findCountryByCode, findCountryByName, findGroupRole, findMetric, findPeriod, findPlayerBuild, findPlayerType, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMetricMeasure, getMetricName, getMetricRankKey, getMetricValueKey, getMinimumBossKc, getParentVirtualMetric, isActivity, isBoss, isSkill, isVirtualMetric, padNumber, parseMetricAbbreviation, parsePeriodExpression, round };
2141
+ export { ACTIVITIES, Achievement, AchievementDefinition, AchievementProgress, AchievementTemplate, Activity, ActivityDelta, ActivityValue, AlgorithmCache, AssertPlayerTypeResponse, BOSSES, Bonus, BonusType, Boss, BossDelta, BossMetaConfig, BossValue, CAPPED_MAX_TOTAL_XP, CMLGroupData, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, ChangeMemberRolePayload, CompetitionDetails, CompetitionListItem, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, CompetitionWithParticipations, CompetitionsSearchFilter, ComputedMetric, ComputedMetricDelta, ComputedMetricValue, Country, CountryDetails, CountryProps, CreateCompetitionPayload, CreateCompetitionResponse, CreateGroupPayload, CreateGroupResponse, DeltaLeaderboardEntry, DeltaLeaderboardFilter, EditCompetitionPayload, EditGroupPayload, EfficiencyAlgorithm, EfficiencyAlgorithmType, EfficiencyAlgorithmTypeUnion, EfficiencyLeaderboardsFilter, EfficiencyMap, ExperienceMap, ExtendedAchievement, F2P_BOSSES, FormattedSnapshot, GROUP_ROLES, GenericCountMessageResponse, GenericMessageResponse, GetGroupGainsFilter, GetPlayerGainsResponse, GroupHiscoresActivityItem, GroupHiscoresBossItem, GroupHiscoresComputedMetricItem, GroupHiscoresEntry, GroupHiscoresSkillItem, GroupListItem, GroupMemberFragment, GroupRecordsFilter, GroupRole, GroupRoleProps, GroupStatistics, GroupWithMemberships, KillcountMap, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MeasuredDeltaProgress, MemberInput, MembershipWithGroup, MembershipWithPlayer, Metric, MetricMeasure, MetricProps, MetricType, MigrationDataSource, NameChangeDetails, NameChangeStatus, NameChangesSearchFilter, PERIODS, PLAYER_BUILDS, PLAYER_TYPES, PRIVELEGED_GROUP_ROLES, ParticipationWithCompetition, ParticipationWithPlayer, ParticipationWithPlayerAndProgress, Period, PeriodProps, Player, PlayerBuild, PlayerBuildProps, PlayerDeltasArray, PlayerDeltasMap, PlayerDetails, PlayerRecordsFilter, PlayerResolvable, PlayerType, PlayerTypeProps, REAL_SKILLS, Record, RecordLeaderboardEntry, RecordLeaderboardFilter, SKILLS, SKILL_EXP_AT_99, Skill, SkillDelta, SkillMetaConfig, SkillValue, Snapshot, SnapshotDataSource, SnapshotFragment, Team, TempleGroupData, TimeRangeFilter, Top5ProgressResult, WOMClient, findCountry, findCountryByCode, findCountryByName, findGroupRole, findMetric, findPeriod, findPlayerBuild, findPlayerType, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMetricMeasure, getMetricName, getMetricRankKey, getMetricValueKey, getMinimumBossKc, getParentEfficiencyMetric, isActivity, isBoss, isCompetitionStatus, isCompetitionType, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerType, isSkill, padNumber, parseMetricAbbreviation, parsePeriodExpression, round };
package/dist/index.js CHANGED
@@ -569,11 +569,11 @@ const Boss = {
569
569
  ZALCANO: 'zalcano',
570
570
  ZULRAH: 'zulrah'
571
571
  };
572
- const Virtual = {
572
+ const ComputedMetric = {
573
573
  EHP: 'ehp',
574
574
  EHB: 'ehb'
575
575
  };
576
- const Metric = Object.assign(Object.assign(Object.assign(Object.assign({}, Skill), Activity), Boss), Virtual);
576
+ const Metric = Object.assign(Object.assign(Object.assign(Object.assign({}, Skill), Activity), Boss), ComputedMetric);
577
577
  const NameChangeStatus = {
578
578
  PENDING: 'pending',
579
579
  DENIED: 'denied',
@@ -1145,19 +1145,11 @@ const CompetitionStatusProps = {
1145
1145
  };
1146
1146
  const COMPETITION_TYPES = Object.values(CompetitionType);
1147
1147
  const COMPETITION_STATUSES = Object.values(exports.CompetitionStatus);
1148
- function findCompetitionType(typeName) {
1149
- for (const [key, value] of Object.entries(CompetitionTypeProps)) {
1150
- if (value.name === typeName)
1151
- return key;
1152
- }
1153
- return null;
1148
+ function isCompetitionType(typeString) {
1149
+ return typeString in CompetitionTypeProps;
1154
1150
  }
1155
- function findCompetitionStatus(statusName) {
1156
- for (const [key, value] of Object.entries(CompetitionStatusProps)) {
1157
- if (value.name === statusName)
1158
- return key;
1159
- }
1160
- return null;
1151
+ function isCompetitionStatus(statusString) {
1152
+ return statusString in CompetitionStatusProps;
1161
1153
  }
1162
1154
 
1163
1155
  const CountryProps = {
@@ -1416,6 +1408,9 @@ const COMMON_ALIASES = [
1416
1408
  { commonIdentifier: 'UK', trueIdentifier: 'GB' },
1417
1409
  { commonIdentifier: 'USA', trueIdentifier: 'US' }
1418
1410
  ];
1411
+ function isCountry(countryCodeString) {
1412
+ return countryCodeString in CountryProps;
1413
+ }
1419
1414
  function findCountry(countryIdentifier) {
1420
1415
  return findCountryByCode(countryIdentifier) || findCountryByName(countryIdentifier);
1421
1416
  }
@@ -1776,13 +1771,16 @@ function findGroupRole(roleName) {
1776
1771
  }
1777
1772
  return null;
1778
1773
  }
1774
+ function isGroupRole(roleString) {
1775
+ return roleString in GroupRoleProps;
1776
+ }
1779
1777
 
1780
1778
  exports.MetricType = void 0;
1781
1779
  (function (MetricType) {
1782
1780
  MetricType["SKILL"] = "skill";
1783
1781
  MetricType["BOSS"] = "boss";
1784
1782
  MetricType["ACTIVITY"] = "activity";
1785
- MetricType["VIRTUAL"] = "virtual";
1783
+ MetricType["COMPUTED"] = "computed";
1786
1784
  })(exports.MetricType || (exports.MetricType = {}));
1787
1785
  exports.MetricMeasure = void 0;
1788
1786
  (function (MetricMeasure) {
@@ -1889,16 +1887,16 @@ const ActivityProps = lodash.mapValues({
1889
1887
  [Activity.SOUL_WARS_ZEAL]: { name: 'Soul Wars Zeal' },
1890
1888
  [Activity.GUARDIANS_OF_THE_RIFT]: { name: 'Guardians of the Rift' }
1891
1889
  }, props => (Object.assign(Object.assign({}, props), { type: exports.MetricType.ACTIVITY, measure: exports.MetricMeasure.SCORE })));
1892
- const VirtualProps = lodash.mapValues({
1893
- [Virtual.EHP]: { name: 'EHP' },
1894
- [Virtual.EHB]: { name: 'EHB' }
1895
- }, props => (Object.assign(Object.assign({}, props), { type: exports.MetricType.VIRTUAL, measure: exports.MetricMeasure.VALUE })));
1896
- const MetricProps = Object.assign(Object.assign(Object.assign(Object.assign({}, SkillProps), BossProps), ActivityProps), VirtualProps);
1890
+ const ComputedMetricProps = lodash.mapValues({
1891
+ [ComputedMetric.EHP]: { name: 'EHP' },
1892
+ [ComputedMetric.EHB]: { name: 'EHB' }
1893
+ }, props => (Object.assign(Object.assign({}, props), { type: exports.MetricType.COMPUTED, measure: exports.MetricMeasure.VALUE })));
1894
+ const MetricProps = Object.assign(Object.assign(Object.assign(Object.assign({}, SkillProps), BossProps), ActivityProps), ComputedMetricProps);
1897
1895
  const METRICS = Object.values(Metric);
1898
1896
  const SKILLS = Object.values(Skill);
1899
1897
  const BOSSES = Object.values(Boss);
1900
1898
  const ACTIVITIES = Object.values(Activity);
1901
- const VIRTUALS = Object.values(Virtual);
1899
+ const COMPUTED_METRICS = Object.values(ComputedMetric);
1902
1900
  const REAL_SKILLS = SKILLS.filter(s => s !== Skill.OVERALL);
1903
1901
  const F2P_BOSSES = BOSSES.filter(b => !MetricProps[b].isMembers);
1904
1902
  const MEMBER_SKILLS = SKILLS.filter(s => MetricProps[s].isMembers);
@@ -1910,6 +1908,9 @@ function findMetric(metricName) {
1910
1908
  }
1911
1909
  return null;
1912
1910
  }
1911
+ function isMetric(metricString) {
1912
+ return metricString in MetricProps;
1913
+ }
1913
1914
  function isSkill(metric) {
1914
1915
  return metric in SkillProps;
1915
1916
  }
@@ -1919,8 +1920,8 @@ function isActivity(metric) {
1919
1920
  function isBoss(metric) {
1920
1921
  return metric in BossProps;
1921
1922
  }
1922
- function isVirtualMetric(metric) {
1923
- return metric in VirtualProps;
1923
+ function isComputedMetric(metric) {
1924
+ return metric in ComputedMetricProps;
1924
1925
  }
1925
1926
  function getMetricRankKey(metric) {
1926
1927
  return `${metric}Rank`;
@@ -1937,7 +1938,7 @@ function getMetricName(metric) {
1937
1938
  function getMinimumBossKc(metric) {
1938
1939
  return isBoss(metric) ? MetricProps[metric].minimumKc : 0;
1939
1940
  }
1940
- function getParentVirtualMetric(metric) {
1941
+ function getParentEfficiencyMetric(metric) {
1941
1942
  if (isBoss(metric))
1942
1943
  return Metric.EHB;
1943
1944
  if (isSkill(metric))
@@ -2200,9 +2201,12 @@ function findPeriod(periodName) {
2200
2201
  }
2201
2202
  return null;
2202
2203
  }
2204
+ function isPeriod(periodString) {
2205
+ return periodString in PeriodProps;
2206
+ }
2203
2207
  function parsePeriodExpression(periodExpression) {
2204
2208
  const fixed = periodExpression.toLowerCase();
2205
- if (PERIODS.includes(fixed)) {
2209
+ if (isPeriod(fixed)) {
2206
2210
  return {
2207
2211
  expression: fixed,
2208
2212
  durationMs: PeriodProps[fixed].milliseconds
@@ -2245,6 +2249,12 @@ const PlayerBuildProps = {
2245
2249
  };
2246
2250
  const PLAYER_TYPES = Object.values(PlayerType);
2247
2251
  const PLAYER_BUILDS = Object.values(PlayerBuild);
2252
+ function isPlayerType(typeString) {
2253
+ return typeString in PlayerTypeProps;
2254
+ }
2255
+ function isPlayerBuild(buildString) {
2256
+ return buildString in PlayerBuildProps;
2257
+ }
2248
2258
  function findPlayerType(typeName) {
2249
2259
  for (const [key, value] of Object.entries(PlayerTypeProps)) {
2250
2260
  if (value.name.toUpperCase() === typeName.toUpperCase())
@@ -2316,7 +2326,7 @@ exports.SnapshotDataSource = void 0;
2316
2326
 
2317
2327
  class EfficiencyClient {
2318
2328
  /**
2319
- * Fetches the current efficiency leaderboard for a specific virtual metric, playerType, playerBuild and country.
2329
+ * Fetches the current efficiency leaderboard for a specific efficiency metric, playerType, playerBuild and country.
2320
2330
  * @returns A list of players.
2321
2331
  */
2322
2332
  getEfficiencyLeaderboards(filter, pagination) {
@@ -2479,10 +2489,12 @@ exports.CAPPED_MAX_TOTAL_XP = CAPPED_MAX_TOTAL_XP;
2479
2489
  exports.COMBAT_SKILLS = COMBAT_SKILLS;
2480
2490
  exports.COMPETITION_STATUSES = COMPETITION_STATUSES;
2481
2491
  exports.COMPETITION_TYPES = COMPETITION_TYPES;
2492
+ exports.COMPUTED_METRICS = COMPUTED_METRICS;
2482
2493
  exports.COUNTRY_CODES = COUNTRY_CODES;
2483
2494
  exports.CompetitionStatusProps = CompetitionStatusProps;
2484
2495
  exports.CompetitionType = CompetitionType;
2485
2496
  exports.CompetitionTypeProps = CompetitionTypeProps;
2497
+ exports.ComputedMetric = ComputedMetric;
2486
2498
  exports.Country = Country;
2487
2499
  exports.CountryProps = CountryProps;
2488
2500
  exports.F2P_BOSSES = F2P_BOSSES;
@@ -2511,11 +2523,7 @@ exports.REAL_SKILLS = REAL_SKILLS;
2511
2523
  exports.SKILLS = SKILLS;
2512
2524
  exports.SKILL_EXP_AT_99 = SKILL_EXP_AT_99;
2513
2525
  exports.Skill = Skill;
2514
- exports.VIRTUALS = VIRTUALS;
2515
- exports.Virtual = Virtual;
2516
2526
  exports.WOMClient = WOMClient;
2517
- exports.findCompetitionStatus = findCompetitionStatus;
2518
- exports.findCompetitionType = findCompetitionType;
2519
2527
  exports.findCountry = findCountry;
2520
2528
  exports.findCountryByCode = findCountryByCode;
2521
2529
  exports.findCountryByName = findCountryByName;
@@ -2533,11 +2541,19 @@ exports.getMetricName = getMetricName;
2533
2541
  exports.getMetricRankKey = getMetricRankKey;
2534
2542
  exports.getMetricValueKey = getMetricValueKey;
2535
2543
  exports.getMinimumBossKc = getMinimumBossKc;
2536
- exports.getParentVirtualMetric = getParentVirtualMetric;
2544
+ exports.getParentEfficiencyMetric = getParentEfficiencyMetric;
2537
2545
  exports.isActivity = isActivity;
2538
2546
  exports.isBoss = isBoss;
2547
+ exports.isCompetitionStatus = isCompetitionStatus;
2548
+ exports.isCompetitionType = isCompetitionType;
2549
+ exports.isComputedMetric = isComputedMetric;
2550
+ exports.isCountry = isCountry;
2551
+ exports.isGroupRole = isGroupRole;
2552
+ exports.isMetric = isMetric;
2553
+ exports.isPeriod = isPeriod;
2554
+ exports.isPlayerBuild = isPlayerBuild;
2555
+ exports.isPlayerType = isPlayerType;
2539
2556
  exports.isSkill = isSkill;
2540
- exports.isVirtualMetric = isVirtualMetric;
2541
2557
  exports.padNumber = padNumber;
2542
2558
  exports.parseMetricAbbreviation = parseMetricAbbreviation;
2543
2559
  exports.parsePeriodExpression = parsePeriodExpression;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise-old-man/utils",
3
- "version": "2.0.0-beta.2",
3
+ "version": "2.0.0-beta.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",