@algoux/standard-ranklist-utils 0.2.2 → 0.2.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/README.md +1 -0
- package/dist/index.cjs +18 -4
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +18 -5
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -188,6 +188,13 @@ function resolveStyle(style) {
|
|
|
188
188
|
backgroundColor: backgroundThemeColor
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
|
+
function resolveUserMarkers(user, markersConfig) {
|
|
192
|
+
if (!user) {
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
const userMarkers = (Array.isArray(user.markers) ? user.markers : [user.marker]).filter(Boolean).map((marker) => (markersConfig || []).find((m) => m.id === marker)).filter(Boolean);
|
|
196
|
+
return userMarkers;
|
|
197
|
+
}
|
|
191
198
|
|
|
192
199
|
function canRegenerateRanklist(ranklist) {
|
|
193
200
|
var _a;
|
|
@@ -626,13 +633,15 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
626
633
|
});
|
|
627
634
|
return fns;
|
|
628
635
|
}
|
|
629
|
-
function genRowRanks(rows) {
|
|
636
|
+
function genRowRanks(rows, options = {}) {
|
|
630
637
|
const compareScoreEqual = (a, b) => {
|
|
631
638
|
if (a.value !== b.value) {
|
|
632
639
|
return false;
|
|
633
640
|
}
|
|
634
|
-
const
|
|
635
|
-
const
|
|
641
|
+
const rankingTimePrecision = options.rankingTimePrecision || "ms";
|
|
642
|
+
const rankingTimeRoundingFn = options.rankingTimeRounding === "ceil" ? Math.ceil : options.rankingTimeRounding === "round" ? Math.round : Math.floor;
|
|
643
|
+
const da = a.time ? formatTimeDuration(a.time, rankingTimePrecision, rankingTimeRoundingFn) : 0;
|
|
644
|
+
const db = b.time ? formatTimeDuration(b.time, rankingTimePrecision, rankingTimeRoundingFn) : 0;
|
|
636
645
|
return da === db;
|
|
637
646
|
};
|
|
638
647
|
const genRanks = (rows2) => {
|
|
@@ -669,11 +678,15 @@ function genRowRanks(rows) {
|
|
|
669
678
|
};
|
|
670
679
|
}
|
|
671
680
|
function convertToStaticRanklist(ranklist) {
|
|
681
|
+
var _a, _b, _c, _d;
|
|
672
682
|
if (!ranklist) {
|
|
673
683
|
return ranklist;
|
|
674
684
|
}
|
|
675
685
|
const { series, rows } = ranklist;
|
|
676
|
-
const rowRanks = genRowRanks(rows
|
|
686
|
+
const rowRanks = genRowRanks(rows, {
|
|
687
|
+
rankingTimePrecision: (_b = (_a = ranklist.sorter) == null ? void 0 : _a.config) == null ? void 0 : _b.rankingTimePrecision,
|
|
688
|
+
rankingTimeRounding: (_d = (_c = ranklist.sorter) == null ? void 0 : _c.config) == null ? void 0 : _d.rankingTimeRounding
|
|
689
|
+
});
|
|
677
690
|
const seriesCalcFns = genSeriesCalcFns(series, rows, rowRanks.ranks, rowRanks.officialRanks);
|
|
678
691
|
return {
|
|
679
692
|
...ranklist,
|
|
@@ -703,5 +716,6 @@ exports.resolveContributor = resolveContributor;
|
|
|
703
716
|
exports.resolveStyle = resolveStyle;
|
|
704
717
|
exports.resolveText = resolveText;
|
|
705
718
|
exports.resolveThemeColor = resolveThemeColor;
|
|
719
|
+
exports.resolveUserMarkers = resolveUserMarkers;
|
|
706
720
|
exports.secToTimeStr = secToTimeStr;
|
|
707
721
|
exports.sortRows = sortRows;
|
package/dist/index.d.cts
CHANGED
|
@@ -90,6 +90,7 @@ declare function resolveStyle(style: srk.Style): {
|
|
|
90
90
|
textColor: ThemeColor;
|
|
91
91
|
backgroundColor: ThemeColor;
|
|
92
92
|
};
|
|
93
|
+
declare function resolveUserMarkers(user: srk.User, markersConfig: srk.Marker[] | undefined): srk.Marker[];
|
|
93
94
|
|
|
94
95
|
declare function canRegenerateRanklist(ranklist: srk.Ranklist): boolean;
|
|
95
96
|
declare function getSortedCalculatedRawSolutions(rows: srk.RanklistRow[]): CalculatedSolutionTetrad[];
|
|
@@ -99,4 +100,4 @@ declare function regenerateRanklistBySolutions(originalRanklist: srk.Ranklist, s
|
|
|
99
100
|
declare function regenerateRowsByIncrementalSolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.RanklistRow[];
|
|
100
101
|
declare function convertToStaticRanklist(ranklist: srk.Ranklist): StaticRanklist;
|
|
101
102
|
|
|
102
|
-
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, secToTimeStr, sortRows };
|
|
103
|
+
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
package/dist/index.d.mts
CHANGED
|
@@ -90,6 +90,7 @@ declare function resolveStyle(style: srk.Style): {
|
|
|
90
90
|
textColor: ThemeColor;
|
|
91
91
|
backgroundColor: ThemeColor;
|
|
92
92
|
};
|
|
93
|
+
declare function resolveUserMarkers(user: srk.User, markersConfig: srk.Marker[] | undefined): srk.Marker[];
|
|
93
94
|
|
|
94
95
|
declare function canRegenerateRanklist(ranklist: srk.Ranklist): boolean;
|
|
95
96
|
declare function getSortedCalculatedRawSolutions(rows: srk.RanklistRow[]): CalculatedSolutionTetrad[];
|
|
@@ -99,4 +100,4 @@ declare function regenerateRanklistBySolutions(originalRanklist: srk.Ranklist, s
|
|
|
99
100
|
declare function regenerateRowsByIncrementalSolutions(originalRanklist: srk.Ranklist, solutions: CalculatedSolutionTetrad[]): srk.RanklistRow[];
|
|
100
101
|
declare function convertToStaticRanklist(ranklist: srk.Ranklist): StaticRanklist;
|
|
101
102
|
|
|
102
|
-
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, secToTimeStr, sortRows };
|
|
103
|
+
export { type CalculatedSolutionTetrad, EnumTheme, MIN_REGEN_SUPPORTED_VERSION, type RankValue, type StaticRanklist, type ThemeColor, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
package/dist/index.mjs
CHANGED
|
@@ -186,6 +186,13 @@ function resolveStyle(style) {
|
|
|
186
186
|
backgroundColor: backgroundThemeColor
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
|
+
function resolveUserMarkers(user, markersConfig) {
|
|
190
|
+
if (!user) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
const userMarkers = (Array.isArray(user.markers) ? user.markers : [user.marker]).filter(Boolean).map((marker) => (markersConfig || []).find((m) => m.id === marker)).filter(Boolean);
|
|
194
|
+
return userMarkers;
|
|
195
|
+
}
|
|
189
196
|
|
|
190
197
|
function canRegenerateRanklist(ranklist) {
|
|
191
198
|
var _a;
|
|
@@ -624,13 +631,15 @@ function genSeriesCalcFns(series, rows, ranks, officialRanks) {
|
|
|
624
631
|
});
|
|
625
632
|
return fns;
|
|
626
633
|
}
|
|
627
|
-
function genRowRanks(rows) {
|
|
634
|
+
function genRowRanks(rows, options = {}) {
|
|
628
635
|
const compareScoreEqual = (a, b) => {
|
|
629
636
|
if (a.value !== b.value) {
|
|
630
637
|
return false;
|
|
631
638
|
}
|
|
632
|
-
const
|
|
633
|
-
const
|
|
639
|
+
const rankingTimePrecision = options.rankingTimePrecision || "ms";
|
|
640
|
+
const rankingTimeRoundingFn = options.rankingTimeRounding === "ceil" ? Math.ceil : options.rankingTimeRounding === "round" ? Math.round : Math.floor;
|
|
641
|
+
const da = a.time ? formatTimeDuration(a.time, rankingTimePrecision, rankingTimeRoundingFn) : 0;
|
|
642
|
+
const db = b.time ? formatTimeDuration(b.time, rankingTimePrecision, rankingTimeRoundingFn) : 0;
|
|
634
643
|
return da === db;
|
|
635
644
|
};
|
|
636
645
|
const genRanks = (rows2) => {
|
|
@@ -667,11 +676,15 @@ function genRowRanks(rows) {
|
|
|
667
676
|
};
|
|
668
677
|
}
|
|
669
678
|
function convertToStaticRanklist(ranklist) {
|
|
679
|
+
var _a, _b, _c, _d;
|
|
670
680
|
if (!ranklist) {
|
|
671
681
|
return ranklist;
|
|
672
682
|
}
|
|
673
683
|
const { series, rows } = ranklist;
|
|
674
|
-
const rowRanks = genRowRanks(rows
|
|
684
|
+
const rowRanks = genRowRanks(rows, {
|
|
685
|
+
rankingTimePrecision: (_b = (_a = ranklist.sorter) == null ? void 0 : _a.config) == null ? void 0 : _b.rankingTimePrecision,
|
|
686
|
+
rankingTimeRounding: (_d = (_c = ranklist.sorter) == null ? void 0 : _c.config) == null ? void 0 : _d.rankingTimeRounding
|
|
687
|
+
});
|
|
675
688
|
const seriesCalcFns = genSeriesCalcFns(series, rows, rowRanks.ranks, rowRanks.officialRanks);
|
|
676
689
|
return {
|
|
677
690
|
...ranklist,
|
|
@@ -684,4 +697,4 @@ function convertToStaticRanklist(ranklist) {
|
|
|
684
697
|
};
|
|
685
698
|
}
|
|
686
699
|
|
|
687
|
-
export { EnumTheme, MIN_REGEN_SUPPORTED_VERSION, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, secToTimeStr, sortRows };
|
|
700
|
+
export { EnumTheme, MIN_REGEN_SUPPORTED_VERSION, alphabetToNumber, canRegenerateRanklist, convertToStaticRanklist, filterSolutionsUntil, formatTimeDuration, getSortedCalculatedRawSolutions, numberToAlphabet, preZeroFill, regenerateRanklistBySolutions, regenerateRowsByIncrementalSolutions, resolveColor, resolveContributor, resolveStyle, resolveText, resolveThemeColor, resolveUserMarkers, secToTimeStr, sortRows };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algoux/standard-ranklist-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"author": "bLue",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"standard ranklist",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"textcolor": "^1.0.2"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@algoux/standard-ranklist": "^0.3.
|
|
38
|
+
"@algoux/standard-ranklist": "^0.3.7",
|
|
39
39
|
"@types/node": "^16.18.38",
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
|
41
41
|
"@typescript-eslint/parser": "^5.61.0",
|