This commit is contained in:
Viet An
2026-07-04 16:01:35 +07:00
parent 24bd08e719
commit 71e4494004
3 changed files with 38 additions and 2 deletions

View File

@@ -271,6 +271,11 @@ export default defineNuxtPlugin(() => {
};
const unique = function (arr, keyProps) {
// assume keyProps always has 1 element only
// assume all elements of arr have the same shape
// if keyProps[0] is not a key of arr[0], return []
if (!Object.keys(arr[0]).includes(keyProps[0])) return [];
const kvArray = arr.map((entry) => {
const key = keyProps.map((k) => entry[k]).join("|");
return [key, entry];