Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
35 lines
948 B
Plaintext
35 lines
948 B
Plaintext
/**
|
|
* Extracts the value from an option-like object or string.
|
|
*/ const getOptionValue = (option)=>{
|
|
if (typeof option === 'string') {
|
|
return option;
|
|
}
|
|
return option.value;
|
|
};
|
|
/**
|
|
* Compares two arrays of options by their values.
|
|
* Returns true if both arrays contain the same values (order-independent).
|
|
*/ export const optionsAreEqual = (options1, options2)=>{
|
|
if (!options1 && !options2) {
|
|
return true;
|
|
}
|
|
if (!options1 || !options2) {
|
|
return false;
|
|
}
|
|
if (options1.length !== options2.length) {
|
|
return false;
|
|
}
|
|
const values1 = new Set(options1.map(getOptionValue));
|
|
const values2 = new Set(options2.map(getOptionValue));
|
|
if (values1.size !== values2.size) {
|
|
return false;
|
|
}
|
|
for (const value of values1){
|
|
if (!values2.has(value)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
|
|
//# sourceMappingURL=optionsAreEqual.js.map |