-
Notifications
You must be signed in to change notification settings - Fork 9
/
maps.js
76 lines (63 loc) · 1.35 KB
/
maps.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************
* todo-mvc implementation based on ALPS doc
* mapping document (server)
* May 2015
* Mike Amundsen (@mamund)
* Soundtrack : Complete Collection : B.B. King (2008)
*******************************************************/
// hold mapping rules for interface v. stored data
// key = internal name
// value = interface name
function storeMap() {
var todo, rtn;
rtn = {};
todo = {};
todo.id = "id";
todo.completeFlag = "completed";
todo.title = "title";
rtn.todo = todo;
return rtn;
}
// run once at the start
var map = storeMap();
module.exports = main;
function main(object, property, action) {
var rtn = "";
switch (action) {
case "ex2in":
rtn = ex2in(object, property);
break;
case "in2ex":
rtn = in2ex(object, property);
break;
}
return rtn;
}
// convert interface name
// to internal name
function ex2in(object, property) {
var rtn;
if(map[object]) {
for(p in map[object]) {
if(map[object][p]===property) {
rtn = p;
break;
}
}
}
return rtn;
}
// convert internal name
// to interface name
function in2ex(object, property) {
var rtn;
if(map[object]) {
for(p in map[object]) {
if(p===property) {
rtn = map[object][property];
break;
}
}
}
return rtn;
}