From 754442f83bbce82699ff01c062f3eaa0eee96b16 Mon Sep 17 00:00:00 2001 From: Miroslav Blasko Date: Thu, 21 Mar 2024 23:51:20 +0100 Subject: [PATCH] [Upd] Remove unused methods --- src/utils/Utils.js | 56 ---------------------------------------------- 1 file changed, 56 deletions(-) diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 14a49f96..7ff4bb75 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -450,59 +450,3 @@ export function dfsTraverseQuestionTree(questions, func) { recursiveTraverse(q); }); } - -/** - * Filters an array of objects based on a key-value pair. - * @param {Array} array - The array of objects to filter. - * @param {string} key - The key to filter the objects by. - * @param {*} value - The value to match against the key. - * @param {boolean} [keyMustExist=true] - Indicates whether the key must exist in the objects. Defaults to true. - * @returns {Array} An array containing objects that match the given key-value pair. - */ -export function filterObjectsByKeyValuePair(array, key, value, keyMustExist = true) { - const matchingObjects = []; - - if (!array || array.length === 0) { - return matchingObjects; - } - for (let obj of array) { - if (obj) { - if ((keyMustExist && obj.hasOwnProperty(key)) || !keyMustExist) { - if (!keyMustExist || obj[key] === value) { - matchingObjects.push(obj); - } - } - } - } - - return matchingObjects; -} - -/** - * Filters an array of objects based on a key-value pair within subquestions. - * @param {Array} array - The array of objects containing subquestions. - * @param {string} key - The key to filter the subquestions by. - * @param {*} value - The value to match against the key. - * @param {boolean} [keyMustExist=true] - Indicates whether the key must exist in the subquestions. Defaults to true. - * @returns {Array} An array containing subquestions that match the given key-value pair. - */ -export function filterSubquestionsByKeyValuePair(array, key, value, keyMustExist = true) { - const matchingSubquestions = []; - - if (!array || array.length === 0) { - return matchingSubquestions; - } - for (let obj of array) { - if (obj && obj[SConstants.HAS_SUBQUESTION]) { - for (let subQuestion of obj[SConstants.HAS_SUBQUESTION]) { - if ((keyMustExist && subQuestion.hasOwnProperty(key)) || !keyMustExist) { - if (!keyMustExist || subQuestion[key] === value) { - matchingSubquestions.push(subQuestion); - } - } - } - } - } - - return matchingSubquestions; -}