@wise-old-man/utils 4.0.3 → 4.0.5

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.
@@ -1743,6 +1743,40 @@ function getCombatLevel(attack, strength, defence, ranged, magic, hitpoints, pra
1743
1743
  return Math.floor(baseCombat + Math.max(meleeCombat, rangeCombat, mageCombat));
1744
1744
  }
1745
1745
 
1746
+ function formatNumber(num, withLetters = false, decimalPrecision = 2) {
1747
+ if (num === undefined || num === null)
1748
+ return -1;
1749
+ // If number is float
1750
+ if (num % 1 !== 0) {
1751
+ return (Math.round(num * 100) / 100).toLocaleString('en-US');
1752
+ }
1753
+ if ((num < 10000 && num > -10000) || !withLetters) {
1754
+ return num.toLocaleString('en-US');
1755
+ }
1756
+ // < 100k
1757
+ if (num < 100000 && num > -100000) {
1758
+ // If has no decimals, return as whole number instead (10.00k => 10k)
1759
+ if ((num / 1000) % 1 === 0)
1760
+ return `${num / 1000}k`;
1761
+ return `${(num / 1000).toFixed(decimalPrecision)}k`;
1762
+ }
1763
+ // < 10 million
1764
+ if (num < 10000000 && num > -10000000) {
1765
+ return `${Math.round(num / 1000)}k`;
1766
+ }
1767
+ // < 1 billion
1768
+ if (num < 1000000000 && num > -1000000000) {
1769
+ // If has no decimals, return as whole number instead (10.00m => 10m)
1770
+ if ((num / 1000000) % 1 === 0)
1771
+ return `${num / 1000000}m`;
1772
+ return `${(num / 1000000).toFixed(decimalPrecision)}m`;
1773
+ }
1774
+ // If has no decimals, return as whole number instead (10.00b => 10b)
1775
+ if ((num / 1000000000) % 1 === 0)
1776
+ return `${num / 1000000000}b`;
1777
+ return `${(num / 1000000000).toFixed(decimalPrecision)}b`;
1778
+ }
1779
+
1746
1780
  const GroupRoleProps = {
1747
1781
  [GroupRole.ACHIEVER]: { name: 'Achiever' },
1748
1782
  [GroupRole.ADAMANT]: { name: 'Adamant' },
@@ -2183,6 +2217,41 @@ function getParentEfficiencyMetric(metric) {
2183
2217
  return null;
2184
2218
  }
2185
2219
 
2220
+ function padNumber(value) {
2221
+ if (!value)
2222
+ return '00';
2223
+ return value < 10 ? `0${value}` : value.toString();
2224
+ }
2225
+
2226
+ const CUSTOM_PERIOD_REGEX = /(\d+y)?(\d+m)?(\d+w)?(\d+d)?(\d+h)?/;
2227
+ function parsePeriodExpression(periodExpression) {
2228
+ const fixed = periodExpression.toLowerCase();
2229
+ if (isPeriod(fixed)) {
2230
+ return {
2231
+ expression: fixed,
2232
+ durationMs: PeriodProps[fixed].milliseconds
2233
+ };
2234
+ }
2235
+ const result = fixed.match(CUSTOM_PERIOD_REGEX);
2236
+ if (!result || result.length === 0 || result[0] !== fixed)
2237
+ return null;
2238
+ const years = result[1] ? parseInt(result[1].replace(/\D/g, '')) : 0;
2239
+ const months = result[2] ? parseInt(result[2].replace(/\D/g, '')) : 0;
2240
+ const weeks = result[3] ? parseInt(result[3].replace(/\D/g, '')) : 0;
2241
+ const days = result[4] ? parseInt(result[4].replace(/\D/g, '')) : 0;
2242
+ const hours = result[5] ? parseInt(result[5].replace(/\D/g, '')) : 0;
2243
+ const yearsMs = years * PeriodProps[Period.YEAR].milliseconds;
2244
+ const monthsMs = months * PeriodProps[Period.MONTH].milliseconds;
2245
+ const weeksMs = weeks * PeriodProps[Period.WEEK].milliseconds;
2246
+ const daysMs = days * PeriodProps[Period.DAY].milliseconds;
2247
+ const hoursMs = hours * (PeriodProps[Period.DAY].milliseconds / 24);
2248
+ const totalMs = yearsMs + monthsMs + weeksMs + daysMs + hoursMs;
2249
+ return {
2250
+ expression: result[0],
2251
+ durationMs: totalMs
2252
+ };
2253
+ }
2254
+
2186
2255
  const PeriodProps = {
2187
2256
  [Period.FIVE_MIN]: { name: '5 Min', milliseconds: 300000 },
2188
2257
  [Period.DAY]: { name: 'Day', milliseconds: 86400000 },
@@ -2229,6 +2298,10 @@ function isPlayerType(typeString) {
2229
2298
  return typeString in PlayerTypeProps;
2230
2299
  }
2231
2300
 
2301
+ function roundNumber(num, cases) {
2302
+ return Math.round(num * Math.pow(10, cases)) / Math.pow(10, cases);
2303
+ }
2304
+
2232
2305
  exports.ACTIVITIES = ACTIVITIES;
2233
2306
  exports.Activity = Activity;
2234
2307
  exports.ActivityProps = ActivityProps;
@@ -2285,6 +2358,7 @@ exports.WOMClient = WOMClient;
2285
2358
  exports.findCountry = findCountry;
2286
2359
  exports.findCountryByCode = findCountryByCode;
2287
2360
  exports.findCountryByName = findCountryByName;
2361
+ exports.formatNumber = formatNumber;
2288
2362
  exports.getCombatLevel = getCombatLevel;
2289
2363
  exports.getExpForLevel = getExpForLevel;
2290
2364
  exports.getLevel = getLevel;
@@ -2301,3 +2375,6 @@ exports.isPlayerBuild = isPlayerBuild;
2301
2375
  exports.isPlayerStatus = isPlayerStatus;
2302
2376
  exports.isPlayerType = isPlayerType;
2303
2377
  exports.isSkill = isSkill;
2378
+ exports.padNumber = padNumber;
2379
+ exports.parsePeriodExpression = parsePeriodExpression;
2380
+ exports.roundNumber = roundNumber;
package/dist/es/index.js CHANGED
@@ -1741,6 +1741,40 @@ function getCombatLevel(attack, strength, defence, ranged, magic, hitpoints, pra
1741
1741
  return Math.floor(baseCombat + Math.max(meleeCombat, rangeCombat, mageCombat));
1742
1742
  }
1743
1743
 
1744
+ function formatNumber(num, withLetters = false, decimalPrecision = 2) {
1745
+ if (num === undefined || num === null)
1746
+ return -1;
1747
+ // If number is float
1748
+ if (num % 1 !== 0) {
1749
+ return (Math.round(num * 100) / 100).toLocaleString('en-US');
1750
+ }
1751
+ if ((num < 10000 && num > -10000) || !withLetters) {
1752
+ return num.toLocaleString('en-US');
1753
+ }
1754
+ // < 100k
1755
+ if (num < 100000 && num > -100000) {
1756
+ // If has no decimals, return as whole number instead (10.00k => 10k)
1757
+ if ((num / 1000) % 1 === 0)
1758
+ return `${num / 1000}k`;
1759
+ return `${(num / 1000).toFixed(decimalPrecision)}k`;
1760
+ }
1761
+ // < 10 million
1762
+ if (num < 10000000 && num > -10000000) {
1763
+ return `${Math.round(num / 1000)}k`;
1764
+ }
1765
+ // < 1 billion
1766
+ if (num < 1000000000 && num > -1000000000) {
1767
+ // If has no decimals, return as whole number instead (10.00m => 10m)
1768
+ if ((num / 1000000) % 1 === 0)
1769
+ return `${num / 1000000}m`;
1770
+ return `${(num / 1000000).toFixed(decimalPrecision)}m`;
1771
+ }
1772
+ // If has no decimals, return as whole number instead (10.00b => 10b)
1773
+ if ((num / 1000000000) % 1 === 0)
1774
+ return `${num / 1000000000}b`;
1775
+ return `${(num / 1000000000).toFixed(decimalPrecision)}b`;
1776
+ }
1777
+
1744
1778
  const GroupRoleProps = {
1745
1779
  [GroupRole.ACHIEVER]: { name: 'Achiever' },
1746
1780
  [GroupRole.ADAMANT]: { name: 'Adamant' },
@@ -2181,6 +2215,41 @@ function getParentEfficiencyMetric(metric) {
2181
2215
  return null;
2182
2216
  }
2183
2217
 
2218
+ function padNumber(value) {
2219
+ if (!value)
2220
+ return '00';
2221
+ return value < 10 ? `0${value}` : value.toString();
2222
+ }
2223
+
2224
+ const CUSTOM_PERIOD_REGEX = /(\d+y)?(\d+m)?(\d+w)?(\d+d)?(\d+h)?/;
2225
+ function parsePeriodExpression(periodExpression) {
2226
+ const fixed = periodExpression.toLowerCase();
2227
+ if (isPeriod(fixed)) {
2228
+ return {
2229
+ expression: fixed,
2230
+ durationMs: PeriodProps[fixed].milliseconds
2231
+ };
2232
+ }
2233
+ const result = fixed.match(CUSTOM_PERIOD_REGEX);
2234
+ if (!result || result.length === 0 || result[0] !== fixed)
2235
+ return null;
2236
+ const years = result[1] ? parseInt(result[1].replace(/\D/g, '')) : 0;
2237
+ const months = result[2] ? parseInt(result[2].replace(/\D/g, '')) : 0;
2238
+ const weeks = result[3] ? parseInt(result[3].replace(/\D/g, '')) : 0;
2239
+ const days = result[4] ? parseInt(result[4].replace(/\D/g, '')) : 0;
2240
+ const hours = result[5] ? parseInt(result[5].replace(/\D/g, '')) : 0;
2241
+ const yearsMs = years * PeriodProps[Period.YEAR].milliseconds;
2242
+ const monthsMs = months * PeriodProps[Period.MONTH].milliseconds;
2243
+ const weeksMs = weeks * PeriodProps[Period.WEEK].milliseconds;
2244
+ const daysMs = days * PeriodProps[Period.DAY].milliseconds;
2245
+ const hoursMs = hours * (PeriodProps[Period.DAY].milliseconds / 24);
2246
+ const totalMs = yearsMs + monthsMs + weeksMs + daysMs + hoursMs;
2247
+ return {
2248
+ expression: result[0],
2249
+ durationMs: totalMs
2250
+ };
2251
+ }
2252
+
2184
2253
  const PeriodProps = {
2185
2254
  [Period.FIVE_MIN]: { name: '5 Min', milliseconds: 300000 },
2186
2255
  [Period.DAY]: { name: 'Day', milliseconds: 86400000 },
@@ -2227,4 +2296,8 @@ function isPlayerType(typeString) {
2227
2296
  return typeString in PlayerTypeProps;
2228
2297
  }
2229
2298
 
2230
- export { ACTIVITIES, Activity, ActivityProps, BOSSES, Boss, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, CompetitionCSVTableType, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, GroupRole, GroupRoleProps, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MemberActivityType, Metric, MetricMeasure, MetricProps, MetricType, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, Period, PeriodProps, PlayerAnnotationType, PlayerBuild, PlayerBuildProps, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, SKILLS, SKILL_EXP_AT_99, Skill, SkillProps, WOMClient, findCountry, findCountryByCode, findCountryByName, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill };
2299
+ function roundNumber(num, cases) {
2300
+ return Math.round(num * Math.pow(10, cases)) / Math.pow(10, cases);
2301
+ }
2302
+
2303
+ export { ACTIVITIES, Activity, ActivityProps, BOSSES, Boss, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, CompetitionCSVTableType, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, GroupRole, GroupRoleProps, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MemberActivityType, Metric, MetricMeasure, MetricProps, MetricType, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, Period, PeriodProps, PlayerAnnotationType, PlayerBuild, PlayerBuildProps, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, SKILLS, SKILL_EXP_AT_99, Skill, SkillProps, WOMClient, findCountry, findCountryByCode, findCountryByName, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill, padNumber, parsePeriodExpression, roundNumber };
package/dist/es/index.mjs CHANGED
@@ -1741,6 +1741,40 @@ function getCombatLevel(attack, strength, defence, ranged, magic, hitpoints, pra
1741
1741
  return Math.floor(baseCombat + Math.max(meleeCombat, rangeCombat, mageCombat));
1742
1742
  }
1743
1743
 
1744
+ function formatNumber(num, withLetters = false, decimalPrecision = 2) {
1745
+ if (num === undefined || num === null)
1746
+ return -1;
1747
+ // If number is float
1748
+ if (num % 1 !== 0) {
1749
+ return (Math.round(num * 100) / 100).toLocaleString('en-US');
1750
+ }
1751
+ if ((num < 10000 && num > -10000) || !withLetters) {
1752
+ return num.toLocaleString('en-US');
1753
+ }
1754
+ // < 100k
1755
+ if (num < 100000 && num > -100000) {
1756
+ // If has no decimals, return as whole number instead (10.00k => 10k)
1757
+ if ((num / 1000) % 1 === 0)
1758
+ return `${num / 1000}k`;
1759
+ return `${(num / 1000).toFixed(decimalPrecision)}k`;
1760
+ }
1761
+ // < 10 million
1762
+ if (num < 10000000 && num > -10000000) {
1763
+ return `${Math.round(num / 1000)}k`;
1764
+ }
1765
+ // < 1 billion
1766
+ if (num < 1000000000 && num > -1000000000) {
1767
+ // If has no decimals, return as whole number instead (10.00m => 10m)
1768
+ if ((num / 1000000) % 1 === 0)
1769
+ return `${num / 1000000}m`;
1770
+ return `${(num / 1000000).toFixed(decimalPrecision)}m`;
1771
+ }
1772
+ // If has no decimals, return as whole number instead (10.00b => 10b)
1773
+ if ((num / 1000000000) % 1 === 0)
1774
+ return `${num / 1000000000}b`;
1775
+ return `${(num / 1000000000).toFixed(decimalPrecision)}b`;
1776
+ }
1777
+
1744
1778
  const GroupRoleProps = {
1745
1779
  [GroupRole.ACHIEVER]: { name: 'Achiever' },
1746
1780
  [GroupRole.ADAMANT]: { name: 'Adamant' },
@@ -2181,6 +2215,41 @@ function getParentEfficiencyMetric(metric) {
2181
2215
  return null;
2182
2216
  }
2183
2217
 
2218
+ function padNumber(value) {
2219
+ if (!value)
2220
+ return '00';
2221
+ return value < 10 ? `0${value}` : value.toString();
2222
+ }
2223
+
2224
+ const CUSTOM_PERIOD_REGEX = /(\d+y)?(\d+m)?(\d+w)?(\d+d)?(\d+h)?/;
2225
+ function parsePeriodExpression(periodExpression) {
2226
+ const fixed = periodExpression.toLowerCase();
2227
+ if (isPeriod(fixed)) {
2228
+ return {
2229
+ expression: fixed,
2230
+ durationMs: PeriodProps[fixed].milliseconds
2231
+ };
2232
+ }
2233
+ const result = fixed.match(CUSTOM_PERIOD_REGEX);
2234
+ if (!result || result.length === 0 || result[0] !== fixed)
2235
+ return null;
2236
+ const years = result[1] ? parseInt(result[1].replace(/\D/g, '')) : 0;
2237
+ const months = result[2] ? parseInt(result[2].replace(/\D/g, '')) : 0;
2238
+ const weeks = result[3] ? parseInt(result[3].replace(/\D/g, '')) : 0;
2239
+ const days = result[4] ? parseInt(result[4].replace(/\D/g, '')) : 0;
2240
+ const hours = result[5] ? parseInt(result[5].replace(/\D/g, '')) : 0;
2241
+ const yearsMs = years * PeriodProps[Period.YEAR].milliseconds;
2242
+ const monthsMs = months * PeriodProps[Period.MONTH].milliseconds;
2243
+ const weeksMs = weeks * PeriodProps[Period.WEEK].milliseconds;
2244
+ const daysMs = days * PeriodProps[Period.DAY].milliseconds;
2245
+ const hoursMs = hours * (PeriodProps[Period.DAY].milliseconds / 24);
2246
+ const totalMs = yearsMs + monthsMs + weeksMs + daysMs + hoursMs;
2247
+ return {
2248
+ expression: result[0],
2249
+ durationMs: totalMs
2250
+ };
2251
+ }
2252
+
2184
2253
  const PeriodProps = {
2185
2254
  [Period.FIVE_MIN]: { name: '5 Min', milliseconds: 300000 },
2186
2255
  [Period.DAY]: { name: 'Day', milliseconds: 86400000 },
@@ -2227,4 +2296,8 @@ function isPlayerType(typeString) {
2227
2296
  return typeString in PlayerTypeProps;
2228
2297
  }
2229
2298
 
2230
- export { ACTIVITIES, Activity, ActivityProps, BOSSES, Boss, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, CompetitionCSVTableType, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, GroupRole, GroupRoleProps, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MemberActivityType, Metric, MetricMeasure, MetricProps, MetricType, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, Period, PeriodProps, PlayerAnnotationType, PlayerBuild, PlayerBuildProps, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, SKILLS, SKILL_EXP_AT_99, Skill, SkillProps, WOMClient, findCountry, findCountryByCode, findCountryByName, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill };
2299
+ function roundNumber(num, cases) {
2300
+ return Math.round(num * Math.pow(10, cases)) / Math.pow(10, cases);
2301
+ }
2302
+
2303
+ export { ACTIVITIES, Activity, ActivityProps, BOSSES, Boss, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, CompetitionCSVTableType, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, GroupRole, GroupRoleProps, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, MemberActivityType, Metric, MetricMeasure, MetricProps, MetricType, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, Period, PeriodProps, PlayerAnnotationType, PlayerBuild, PlayerBuildProps, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, SKILLS, SKILL_EXP_AT_99, Skill, SkillProps, WOMClient, findCountry, findCountryByCode, findCountryByName, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill, padNumber, parsePeriodExpression, roundNumber };
package/dist/index.d.ts CHANGED
@@ -259,6 +259,7 @@ interface Snapshot {
259
259
  createdAt: Date;
260
260
  overallRank: number;
261
261
  overallExperience: number;
262
+ overallLevel: number;
262
263
  attackRank: number;
263
264
  attackExperience: number;
264
265
  defenceRank: number;
@@ -509,12 +510,39 @@ interface BossMetaConfig {
509
510
  rate: number;
510
511
  }
511
512
 
513
+ declare const Period: {
514
+ readonly FIVE_MIN: "five_min";
515
+ readonly DAY: "day";
516
+ readonly WEEK: "week";
517
+ readonly MONTH: "month";
518
+ readonly YEAR: "year";
519
+ };
520
+ type Period = (typeof Period)[keyof typeof Period];
521
+ declare const PERIODS: ("five_min" | "day" | "week" | "month" | "year")[];
522
+
523
+ interface CachedDelta {
524
+ playerId: number;
525
+ period: Period;
526
+ metric: Metric;
527
+ value: number;
528
+ startedAt: Date;
529
+ endedAt: Date;
530
+ updatedAt: Date;
531
+ }
532
+
512
533
  declare enum CompetitionCSVTableType {
513
534
  TEAM = "team",
514
535
  TEAMS = "teams",
515
536
  PARTICIPANTS = "participants"
516
537
  }
517
538
 
539
+ interface CompetitionMetric {
540
+ competitionId: number;
541
+ metric: Metric;
542
+ createdAt: Date;
543
+ deletedAt: Date | null;
544
+ }
545
+
518
546
  declare enum CompetitionStatus {
519
547
  UPCOMING = "upcoming",
520
548
  ONGOING = "ongoing",
@@ -537,7 +565,6 @@ declare const COMPETITION_TYPES: CompetitionType[];
537
565
  interface Competition {
538
566
  id: number;
539
567
  title: string;
540
- metric: Metric;
541
568
  type: CompetitionType;
542
569
  startsAt: Date;
543
570
  endsAt: Date;
@@ -807,16 +834,6 @@ declare const Country: {
807
834
  type Country = (typeof Country)[keyof typeof Country];
808
835
  declare const COUNTRY_CODES: Country[];
809
836
 
810
- declare const Period: {
811
- readonly FIVE_MIN: "five_min";
812
- readonly DAY: "day";
813
- readonly WEEK: "week";
814
- readonly MONTH: "month";
815
- readonly YEAR: "year";
816
- };
817
- type Period = (typeof Period)[keyof typeof Period];
818
- declare const PERIODS: ("five_min" | "day" | "week" | "month" | "year")[];
819
-
820
837
  interface Delta {
821
838
  playerId: number;
822
839
  period: Period;
@@ -1511,6 +1528,8 @@ interface GroupResponse extends Omit<Group, 'verificationHash' | 'creatorIpHash'
1511
1528
  */
1512
1529
 
1513
1530
  interface CompetitionResponse extends Omit<Competition, 'verificationHash' | 'creatorIpHash'> {
1531
+ metric: Metric;
1532
+ metrics: Metric[];
1514
1533
  participantCount: number;
1515
1534
  group?: GroupResponse;
1516
1535
  }
@@ -2336,6 +2355,8 @@ declare function getExpForLevel(level: number): number;
2336
2355
  declare function getLevel(exp: number, virtual?: boolean): number;
2337
2356
  declare function getCombatLevel(attack: number, strength: number, defence: number, ranged: number, magic: number, hitpoints: number, prayer: number): number;
2338
2357
 
2358
+ declare function formatNumber(num: number, withLetters?: boolean, decimalPrecision?: number): string | -1;
2359
+
2339
2360
  declare const GroupRoleProps: {
2340
2361
  achiever: {
2341
2362
  name: string;
@@ -3931,6 +3952,13 @@ declare function isComputedMetric(metric: Metric | string): metric is ComputedMe
3931
3952
  declare function getMinimumValue(metric: Metric): number;
3932
3953
  declare function getParentEfficiencyMetric(metric: Metric): "ehp" | "ehb";
3933
3954
 
3955
+ declare function padNumber(value: number): string;
3956
+
3957
+ declare function parsePeriodExpression(periodExpression: string): {
3958
+ expression: string;
3959
+ durationMs: number;
3960
+ };
3961
+
3934
3962
  declare const PeriodProps: Record<Period, {
3935
3963
  name: string;
3936
3964
  milliseconds: number;
@@ -3952,4 +3980,6 @@ declare const PlayerTypeProps: Record<PlayerType, {
3952
3980
  }>;
3953
3981
  declare function isPlayerType(typeString: string): typeString is PlayerType;
3954
3982
 
3955
- export { ACTIVITIES, type Achievement, type AchievementDefinition, type AchievementMeasure, type AchievementProgressResponse, type AchievementResponse, Activity, ActivityProps, BOSSES, Boss, type BossMetaConfig, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, type Competition, CompetitionCSVTableType, type CompetitionDetailsResponse, type CompetitionResponse, CompetitionStatus, CompetitionStatusProps, type CompetitionTeam, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, type CreateCompetitionPayload, type CreateGroupPayload, type Delta, type EditCompetitionPayload, type EditGroupPayload, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, type GenericCountMessageResponse, type GenericMessageResponse, type Group, type GroupDetailsResponse, type GroupHiscoresEntryResponse, type GroupResponse, GroupRole, type GroupRoleOrder, GroupRoleProps, type GroupSocialLinks, type GroupStatisticsResponse, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, type MemberActivity, type MemberActivityResponse, MemberActivityType, type Membership, type MembershipResponse, Metric, type MetricDelta, MetricMeasure, MetricProps, MetricType, type NameChange, type NameChangeDenyContext, type NameChangeDetailsResponse, type NameChangeResponse, type NameChangeReviewContext, type NameChangeSkipContext, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, type ParticipantHistoryResponse, type Participation, type ParticipationResponse, type Patron, Period, PeriodProps, type Player, type PlayerAnnotation, PlayerAnnotationType, type PlayerArchive, type PlayerArchiveResponse, PlayerBuild, PlayerBuildProps, type PlayerCompetitionStandingResponse, type PlayerDeltasMapResponse, type PlayerDetailsResponse, type PlayerResponse, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, type Record$1 as Record, type RecordResponse, SKILLS, SKILL_EXP_AT_99, Skill, type SkillMetaBonus, type SkillMetaConfig, type SkillMetaMethod, SkillProps, type Snapshot, type SnapshotResponse, type TimeRangeFilter, WOMClient, findCountry, findCountryByCode, findCountryByName, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill };
3983
+ declare function roundNumber(num: number, cases: number): number;
3984
+
3985
+ export { ACTIVITIES, type Achievement, type AchievementDefinition, type AchievementMeasure, type AchievementProgressResponse, type AchievementResponse, Activity, ActivityProps, BOSSES, Boss, type BossMetaConfig, BossProps, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, type CachedDelta, type Competition, CompetitionCSVTableType, type CompetitionDetailsResponse, type CompetitionMetric, type CompetitionResponse, CompetitionStatus, CompetitionStatusProps, type CompetitionTeam, CompetitionType, CompetitionTypeProps, ComputedMetric, ComputedMetricProps, Country, CountryProps, type CreateCompetitionPayload, type CreateGroupPayload, type Delta, type EditCompetitionPayload, type EditGroupPayload, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, type GenericCountMessageResponse, type GenericMessageResponse, type Group, type GroupDetailsResponse, type GroupHiscoresEntryResponse, type GroupResponse, GroupRole, type GroupRoleOrder, GroupRoleProps, type GroupSocialLinks, type GroupStatisticsResponse, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, type MemberActivity, type MemberActivityResponse, MemberActivityType, type Membership, type MembershipResponse, Metric, type MetricDelta, MetricMeasure, MetricProps, MetricType, type NameChange, type NameChangeDenyContext, type NameChangeDetailsResponse, type NameChangeResponse, type NameChangeReviewContext, type NameChangeSkipContext, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVILEGED_GROUP_ROLES, type ParticipantHistoryResponse, type Participation, type ParticipationResponse, type Patron, Period, PeriodProps, type Player, type PlayerAnnotation, PlayerAnnotationType, type PlayerArchive, type PlayerArchiveResponse, PlayerBuild, PlayerBuildProps, type PlayerCompetitionStandingResponse, type PlayerDeltasMapResponse, type PlayerDetailsResponse, type PlayerResponse, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, type Record$1 as Record, type RecordResponse, SKILLS, SKILL_EXP_AT_99, Skill, type SkillMetaBonus, type SkillMetaConfig, type SkillMetaMethod, SkillProps, type Snapshot, type SnapshotResponse, type TimeRangeFilter, WOMClient, findCountry, findCountryByCode, findCountryByName, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill, padNumber, parsePeriodExpression, roundNumber };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise-old-man/utils",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "A JavaScript/TypeScript client that interfaces and consumes the Wise Old Man API, an API that tracks and measures players' progress in Old School Runescape.",
5
5
  "keywords": [
6
6
  "wiseoldman",