mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-08-16 04:43:40 +00:00
13 lines
392 B
JavaScript
13 lines
392 B
JavaScript
module.exports = (id, chunkData, hasSubchunks) => {
|
|
if (chunkData.length > 0x7fff) {
|
|
throw new Error('chunkData can not be greater than 32767 bytes');
|
|
}
|
|
|
|
const header = Buffer.alloc(4);
|
|
header.writeUInt16LE(id);
|
|
const hasSubChunksBit = (hasSubchunks ? 1 : 0) << 15;
|
|
header.writeUInt16LE(hasSubChunksBit + chunkData.length, 2);
|
|
|
|
return Buffer.concat([header, chunkData]);
|
|
};
|