-
Notifications
You must be signed in to change notification settings - Fork 1
/
matcher.js
43 lines (41 loc) · 1.29 KB
/
matcher.js
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
38
39
40
41
42
43
const csv = require("fast-csv");
require('enum').register();
const accessibilityState = new Enum(["Accessible", "AccessibleWithHelp", "NotAccessible", "Unknown"]);
module.exports = function (params) {
return new Promise((resolve, reject) => {
let accessiblityData = [];
csv
.fromPath("./toevla.csv", {
headers: true
})
.on("data", function (d) {
let result = matchingAddress(d, params);
if(result != accessibilityState.Unknown) {
accessiblityData.push(result);
}
})
.on("end", function () {
resolve(accessiblityData);
})
.on("error", function (error) {
reject(error);
});
})
}
function matchingAddress(row, params) {
if(params.straat.toLowerCase().trim() === row.AccommodatieStraat.toLowerCase().trim() && params.huisnummer == row.AccommodatieNummer && params.postcode == row.AccommodatiePostCode) {
console.log("MATCH: " + row.HO_INK_Inkom_);
console.log(row.AccommodatieStraat + " " + row.AccommodatieNummer + " " + row.AccommodatiePostCode);
switch (row.HO_INK_Inkom_) {
case "PLUS":
return accessibilityState.Accessible;
case "PLMN":
return accessibilityState.AccessibleWithHelp;
case "MIN":
return accessibilityState.NotAccessible;
default:
return accessibilityState.Unknown;
}
}
return accessibilityState.Unknown;
}