@wise-old-man/utils 4.0.2 → 4.0.4
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/cjs/index.cjs +77 -0
- package/dist/es/index.js +74 -1
- package/dist/es/index.mjs +74 -1
- package/dist/index.d.ts +36 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
@@ -1733,6 +1733,30 @@ type MemberActivityResponse = MemberActivity;
|
|
|
1733
1733
|
|
|
1734
1734
|
type NameChangeResponse = NameChange;
|
|
1735
1735
|
|
|
1736
|
+
/**
|
|
1737
|
+
* Response types are used to format the data returned by the API.
|
|
1738
|
+
*
|
|
1739
|
+
* Although sometimes very similar to our database models,
|
|
1740
|
+
* they often include transformations, additional properties or sensitive field omissions.
|
|
1741
|
+
*/
|
|
1742
|
+
|
|
1743
|
+
interface NameChangeDetailsResponse {
|
|
1744
|
+
nameChange: NameChangeResponse;
|
|
1745
|
+
data?: {
|
|
1746
|
+
isNewOnHiscores: boolean;
|
|
1747
|
+
isOldOnHiscores: boolean;
|
|
1748
|
+
isNewTracked: boolean;
|
|
1749
|
+
hasNegativeGains: boolean;
|
|
1750
|
+
negativeGains: Record<Metric, number> | null;
|
|
1751
|
+
timeDiff: number;
|
|
1752
|
+
hoursDiff: number;
|
|
1753
|
+
ehpDiff: number;
|
|
1754
|
+
ehbDiff: number;
|
|
1755
|
+
oldStats: SnapshotResponse;
|
|
1756
|
+
newStats: SnapshotResponse | null;
|
|
1757
|
+
};
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1736
1760
|
/**
|
|
1737
1761
|
* Response types are used to format the data returned by the API.
|
|
1738
1762
|
*
|
|
@@ -2312,6 +2336,8 @@ declare function getExpForLevel(level: number): number;
|
|
|
2312
2336
|
declare function getLevel(exp: number, virtual?: boolean): number;
|
|
2313
2337
|
declare function getCombatLevel(attack: number, strength: number, defence: number, ranged: number, magic: number, hitpoints: number, prayer: number): number;
|
|
2314
2338
|
|
|
2339
|
+
declare function formatNumber(num: number, withLetters?: boolean, decimalPrecision?: number): string | -1;
|
|
2340
|
+
|
|
2315
2341
|
declare const GroupRoleProps: {
|
|
2316
2342
|
achiever: {
|
|
2317
2343
|
name: string;
|
|
@@ -3907,6 +3933,13 @@ declare function isComputedMetric(metric: Metric | string): metric is ComputedMe
|
|
|
3907
3933
|
declare function getMinimumValue(metric: Metric): number;
|
|
3908
3934
|
declare function getParentEfficiencyMetric(metric: Metric): "ehp" | "ehb";
|
|
3909
3935
|
|
|
3936
|
+
declare function padNumber(value: number): string;
|
|
3937
|
+
|
|
3938
|
+
declare function parsePeriodExpression(periodExpression: string): {
|
|
3939
|
+
expression: string;
|
|
3940
|
+
durationMs: number;
|
|
3941
|
+
};
|
|
3942
|
+
|
|
3910
3943
|
declare const PeriodProps: Record<Period, {
|
|
3911
3944
|
name: string;
|
|
3912
3945
|
milliseconds: number;
|
|
@@ -3928,4 +3961,6 @@ declare const PlayerTypeProps: Record<PlayerType, {
|
|
|
3928
3961
|
}>;
|
|
3929
3962
|
declare function isPlayerType(typeString: string): typeString is PlayerType;
|
|
3930
3963
|
|
|
3931
|
-
|
|
3964
|
+
declare function roundNumber(num: number, cases: number): number;
|
|
3965
|
+
|
|
3966
|
+
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, 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
|
+
"version": "4.0.4",
|
|
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",
|