mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-08-27 09:59:13 +00:00
remove string manipulation for chunk header
This commit is contained in:
@@ -5,9 +5,8 @@ module.exports = (id, chunkData, hasSubchunks) => {
|
|||||||
|
|
||||||
const header = Buffer.alloc(4);
|
const header = Buffer.alloc(4);
|
||||||
header.writeUInt16LE(id);
|
header.writeUInt16LE(id);
|
||||||
const chunkLengthBinaryString = chunkData.length.toString(2).padStart(15, '0');
|
const hasSubChunksBit = (hasSubchunks ? 1 : 0) << 15;
|
||||||
const secondByteBinary = `${hasSubchunks ? '1' : '0'}${chunkLengthBinaryString}`;
|
header.writeUInt16LE(hasSubChunksBit + chunkData.length, 2);
|
||||||
header.writeUInt16LE(parseInt(secondByteBinary, 2), 2);
|
|
||||||
|
|
||||||
return Buffer.concat([header, chunkData]);
|
return Buffer.concat([header, chunkData]);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user