mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-08-20 22:49:23 +00:00
ENCODING!! and lots of organization
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const Parser = require('binary-parser').Parser;
|
||||
|
||||
module.exports = new Parser()
|
||||
.uint16le('id')
|
||||
.uint16le('data_len', {
|
||||
formatter: (item) => {
|
||||
const binary = item.toString(2).padStart(16, '0');
|
||||
return Number.parseInt(binary.substring(1), 2);
|
||||
},
|
||||
})
|
||||
.seek(-2)
|
||||
.uint16le('has_subchunks', {
|
||||
formatter: (item) => {
|
||||
const binary = item.toString(2).padStart(16, '0');
|
||||
return binary.charAt(0) === '1';
|
||||
},
|
||||
})
|
||||
.buffer('chunk_data', { readUntil: 'eof' });
|
||||
Reference in New Issue
Block a user