-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (27 loc) · 844 Bytes
/
index.js
File metadata and controls
31 lines (27 loc) · 844 Bytes
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
var native = require('./build/Release/ebml.node');
exports = module.exports = native.writeEBML;
var tag = exports.tag = function(id, type) {
var b = new Buffer(4);
b.writeUInt32BE(id, 0);
if (id <= 0xFF)
b = b.slice(3, 4);
else if (id <= 0xFFFF)
b = b.slice(2, 4);
else if (id <= 0xFFFFFF)
b = b.slice(1, 4);
else if (id > 0xFFFFFFFF)
throw new Error('Invalid ID');
return function(val, sizeUnknown) {
return [b, type, val, sizeUnknown];
};
};
exports.standardTags = {
EBML: tag(0x1A45DFA3, 'm'),
EBMLVersion: tag(0x4286, 'u'),
EBMLReadVersion: tag(0x42F7, 'u'),
EBMLMaxIDLength: tag(0x42F2, 'u'),
EBMLMaxSizeLength: tag(0x42F3, 'u'),
DocType: tag(0x4282, 's'),
DocTypeVersion: tag(0x4287, 'u'),
DocTypeReadVersion: tag(0x4285, 'u')
};