forked from seishun/node-steam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVDF.js
50 lines (40 loc) · 878 Bytes
/
VDF.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
var Type = {
None: 0,
String: 1,
Int32: 2,
Float32: 3,
Pointer: 4,
WideString: 5,
Color: 6,
UInt64: 7,
End: 8,
};
exports.decode = function(buffer) {
var object = {};
while (true) {
var type = buffer.readUint8();
if (type == Type.End)
break;
var name = buffer.readCString();
switch (type) {
case Type.None:
object[name] = exports.decode(buffer);
break;
case Type.String:
object[name] = buffer.readCString();
break;
case Type.Int32:
case Type.Color:
case Type.Pointer:
object[name] = buffer.readInt32();
break;
case Type.UInt64:
object[name] = buffer.readUint64();
break;
case Type.Float32:
object[name] = buffer.readFloat();
break;
}
}
return object;
};