/**
* equipment utility module
* @module
*/
/**
* Loop through the mf groups and items matching against the packed item name
* @param {string} str_packed_name Name of equipment packed to vehicle
* @returns {array} Array of equipment
*/
const getMatchingEquipment = (str_packed_name, skv_options_and_standards) => {
const arr_return = [];
const types = ['options', 'standards'];
// options / standards
types.forEach((str_type) => {
// loop through groups
skv_options_and_standards[str_type].forEach((skv_group) => {
// loop through equipment
skv_group.items.forEach((skv_equipment) => {
if (skv_equipment.name === str_packed_name) {
arr_return.push(skv_equipment);
}
});
});
});
return arr_return;
};
/**
* Description
* @param {string} derivative_extra
* @param {struct} equipment Struct From vehicle pluto api call
* @returns {array} Array of matching equipment structs
*/
const getMatchingEquipmentFromDerivativeExtra = (derivative_extra, equipment) => {
let arr_return = [];
const _derivative_extra = derivative_extra.replace(', ', ',');
const arr_derivative_extra = _derivative_extra.split(',');
if (
arr_derivative_extra.length === 1
&& arr_derivative_extra[0] === ''
) {
return arr_return;
}
arr_derivative_extra.forEach((str_packed_name) => {
const arr_equipment = getMatchingEquipment(str_packed_name, equipment);
// combine arrays
arr_return = [...arr_return, ...arr_equipment];
});
return arr_return;
};
export {
getMatchingEquipmentFromDerivativeExtra,
};