-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcheck_exceptions.js
More file actions
37 lines (31 loc) · 839 Bytes
/
check_exceptions.js
File metadata and controls
37 lines (31 loc) · 839 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
32
33
34
35
36
37
function match(value, exception) {
return value === exception;
}
function checkExceptions(node, exceptions) {
if (!exceptions || !exceptions.length) {
return false;
}
var object = node.left.object.name;
var property = node.left.property.name;
for (var i = 0, length = exceptions.length; i < length; i += 1) {
var exception = exceptions[i];
var objectMatch = match(object, exception.object);
var propertyMatch = match(property, exception.property);
if (exception.object && exception.property) {
if (objectMatch && propertyMatch) {
return true;
}
}
else if (exception.object) {
if (objectMatch) {
return true;
}
}
else if (exception.property) {
if (propertyMatch) {
return true;
}
}
}
}
module.exports = checkExceptions;