tods-competition-factory 1.9.0 → 1.9.1
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/forge/generate.mjs +19 -5
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +9 -6
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +12 -13
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs +6 -3
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +29 -19
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +38 -23
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +4 -4
package/dist/forge/generate.mjs
CHANGED
|
@@ -1221,6 +1221,11 @@ const extractAttributes = (accessor) => (element) => !accessor || typeof element
|
|
|
1221
1221
|
})) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
|
|
1222
1222
|
[key]: getAccessorValue({ element, accessor: key })?.value
|
|
1223
1223
|
})) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
|
|
1224
|
+
function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
|
|
1225
|
+
return Object.keys(obj).filter(
|
|
1226
|
+
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1224
1229
|
function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
1225
1230
|
if (typeof obj !== "object" || obj === null)
|
|
1226
1231
|
return obj;
|
|
@@ -1230,9 +1235,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
|
|
|
1230
1235
|
const ignoreValues = ["", void 0, null];
|
|
1231
1236
|
if (ignoreFalse)
|
|
1232
1237
|
ignoreValues.push(false);
|
|
1233
|
-
const definedKeys =
|
|
1234
|
-
(key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
|
|
1235
|
-
);
|
|
1238
|
+
const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
|
|
1236
1239
|
return Object.assign(
|
|
1237
1240
|
{},
|
|
1238
1241
|
...definedKeys.map((key) => {
|
|
@@ -20922,10 +20925,11 @@ function generateQualifyingStructures({
|
|
|
20922
20925
|
for (const structureProfile of (structureProfiles || []).sort(
|
|
20923
20926
|
sequenceSort
|
|
20924
20927
|
)) {
|
|
20925
|
-
let drawSize =
|
|
20928
|
+
let drawSize = coerceEven(
|
|
20929
|
+
structureProfile.drawSize || structureProfile.participantsCount
|
|
20930
|
+
);
|
|
20926
20931
|
const {
|
|
20927
20932
|
qualifyingRoundNumber,
|
|
20928
|
-
qualifyingPositions,
|
|
20929
20933
|
structureOptions,
|
|
20930
20934
|
matchUpFormat,
|
|
20931
20935
|
structureName,
|
|
@@ -20933,6 +20937,7 @@ function generateQualifyingStructures({
|
|
|
20933
20937
|
drawType
|
|
20934
20938
|
} = structureProfile;
|
|
20935
20939
|
const matchUpType = structureProfile.matchUpType;
|
|
20940
|
+
const qualifyingPositions = structureProfile.qualifyingPositions || deriveQualifyingPositions({ drawSize, qualifyingRoundNumber });
|
|
20936
20941
|
let roundLimit, structure, matchUps;
|
|
20937
20942
|
if (!isConvertableInteger(drawSize)) {
|
|
20938
20943
|
return decorateResult({
|
|
@@ -21039,6 +21044,15 @@ function generateQualifyingStructures({
|
|
|
21039
21044
|
links
|
|
21040
21045
|
};
|
|
21041
21046
|
}
|
|
21047
|
+
function deriveQualifyingPositions({ drawSize, qualifyingRoundNumber }) {
|
|
21048
|
+
let qualifyingPositions = drawSize;
|
|
21049
|
+
let divisionsCount = 0;
|
|
21050
|
+
while (divisionsCount < qualifyingRoundNumber) {
|
|
21051
|
+
qualifyingPositions = Math.floor(qualifyingPositions / 2);
|
|
21052
|
+
divisionsCount += 1;
|
|
21053
|
+
}
|
|
21054
|
+
return qualifyingPositions;
|
|
21055
|
+
}
|
|
21042
21056
|
|
|
21043
21057
|
function generateDrawStructuresAndLinks(params) {
|
|
21044
21058
|
const {
|