-
Notifications
You must be signed in to change notification settings - Fork 960
Expand file tree
/
Copy pathformat_schema.js
More file actions
77 lines (58 loc) · 1.39 KB
/
Copy pathformat_schema.js
File metadata and controls
77 lines (58 loc) · 1.39 KB
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
75
76
77
let json = require(__dirname + '/in/schema');
let top = {};
/* ['MTProto', 'API'].forEach(key => {
let schema = json[key];
let out = {constructors: {}, methods: {}};
['constructors', 'methods'].forEach(key => {
schema[key].forEach(smth => {
let id = smth.id;
if(id < 0) {
id = +id + 4294967296;
}
out[key][id] = smth;
delete smth.id;
});
});
top[key] = out;
//console.log(out);
//process.exit(0);
}); */
function uintToInt(val) {
if(val > 2147483647) {
val = val - 4294967296;
}
return val;
}
['MTProto', 'API'].forEach(key => {
let schema = json[key];
['constructors', 'methods'].forEach(key => {
schema[key].forEach(smth => {
/* if(+smth.id < 0) {
smth.id = +smth.id + 4294967296;
} */
smth.id = uintToInt(+smth.id);
});
});
//console.log(out);
//process.exit(0);
});
top = json;
/* ['API'].forEach(key => {
let schema = json[key];
let out = {constructors: {}, methods: {}};
['constructors', 'methods'].forEach(key => {
schema[key].forEach(smth => {
let id = smth.id;
if(id < 0) {
id = id + 4294967296;
}
out[key][id] = smth;
delete smth.id;
});
});
top[key] = out;
//console.log(out);
//process.exit(0);
}); */
//console.log(out);
require('fs').writeFileSync(__dirname + '/out/schema.json', JSON.stringify(top/* , null, '\t' */));