blob: 5cc985e0f1b3853fa655f39738a6be40347cd55e (
plain)
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
|
function fromPronote({ N, L, G, ...obj } = {}, fn = null, gName = 'type') {
const result = {};
if (typeof fn === 'string') {
gName = fn;
fn = null;
}
if (N) {
result.id = N;
}
if (L) {
result.name = L;
}
if (G !== undefined && gName) {
result[gName] = G;
}
return {
...result,
...(fn ? fn(G && gName ? obj : { G, ...obj }) : {})
};
}
function toPronote({ id, name, type } = {}) {
const result = {};
if (id) {
result.N = id;
}
if (name) {
result.L = name;
}
if (type) {
result.G = type;
}
return result;
}
module.exports = {
fromPronote,
toPronote
};
|