`function isFullCombination(datas) {
if (datas.length === 0) {
return false;
}
const keys = Object.keys(datas[0]);
const entries = keys.map((k) => [k, new Set()]);
const fieldMap = new Map(entries);
//Map(3) { '字段1' => Set(0) {}, '字段2' => Set(0) {}, '字段3' => Set(0) {} }
const serializedSet = new Set();
for (const data of datas) {
const serialized = JSON.stringify(data)
if(serializedSet.has(serialized)){
return false
}
serializedSet.add(serialized)
for (const key of keys) {
const value = data[key]
fieldMap.get(key).add(value);
}
}
// console.log(fieldMap.values());
const n1 = [...fieldMap.values()].reduce((a,b)=>a*b.size,1)
const n2 = datas.length
return n2 === n1
}
const inputData = [
{ 字段1: "甲", 字段2: "a", 字段3: 1 },
{ 字段1: "甲", 字段2: "a", 字段3: 2 },
{ 字段1: "甲", 字段2: "a", 字段3: 3 },
{ 字段1: "甲", 字段2: "b", 字段3: 1 },
{ 字段1: "甲", 字段2: "b", 字段3: 2 },
{ 字段1: "甲", 字段2: "b", 字段3: 3 },
{ 字段1: "乙", 字段2: "a", 字段3: 1 },
{ 字段1: "乙", 字段2: "a", 字段3: 2 },
{ 字段1: "乙", 字段2: "a", 字段3: 3 },
{ 字段1: "乙", 字段2: "b", 字段3: 1 },
{ 字段1: "乙", 字段2: "b", 字段3: 2 },
{ 字段1: "乙", 字段2: "b", 字段3: 3 },
];
console.log(isFullCombination(inputData));
`