-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.js
More file actions
31 lines (26 loc) · 942 Bytes
/
util.js
File metadata and controls
31 lines (26 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function comparePropertyValue(propertyNames, instA, instB, resultString){
if(!instA || !instB){
throw new Error('입력한 instance가 유효하지 않습니다.');
}
if(!Array.isArray(propertyNames)){
throw new Error('propertyNames parameter is not array');
}
let consider = [];
for(let property of propertyNames){
if(!instA.hasOwnProperty(property) || !instB.hasOwnProperty(property)){
console.log('wtf', property);
throw new Error('해당 property가 없습니다.');
}
if(Array.isArray(instA[property])){
consider.push(instA[property].equals(instB[property]));
} else {
consider.push(instA[property] === instB[property]);
}
}
if( consider.every((v) => { return v; }) ) {
return resultString;
} else {
return false;
}
}
module.exports = { comparePropertyValue };