mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-08-20 22:49:23 +00:00
remove binary-parsser lib dependency
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
const chunk = require('../chunk');
|
||||
|
||||
module.exports = (trackerId, fieldChunks) => chunk(trackerId, Buffer.concat(fieldChunks), true);
|
||||
module.exports = (trackerId, fieldChunks) => chunk(trackerId, Buffer.concat(fieldChunks), fieldChunks.length > 0);
|
||||
|
||||
@@ -2,9 +2,6 @@ const chunk = require('../chunk');
|
||||
|
||||
module.exports = (timestamp) => {
|
||||
const buf = Buffer.alloc(8);
|
||||
const timestampHigh = timestamp.toString(2).padStart(64, '0').substring(0, 32);
|
||||
const timestampLow = timestamp.toString(2).padStart(64, '0').substring(32);
|
||||
buf.writeUInt32LE(parseInt(timestampLow, 2));
|
||||
buf.writeUInt32LE(parseInt(timestampHigh, 2), 4);
|
||||
buf.writeBigUInt64LE(BigInt(timestamp));
|
||||
return chunk(0x0006, buf, false);
|
||||
};
|
||||
|
||||
@@ -5,11 +5,7 @@ module.exports = (timestamp, versionHigh, versionLow, frameId, framePacketCount)
|
||||
throw new Error('frame id must be >= 0 and <= 255');
|
||||
}
|
||||
const packetHeader = Buffer.alloc(12);
|
||||
const timestampHigh = timestamp.toString(2).padStart(64, '0').substring(0, 32);
|
||||
const timestampLow = timestamp.toString(2).padStart(64, '0').substring(32);
|
||||
packetHeader.writeUInt32LE(parseInt(timestampLow, 2));
|
||||
packetHeader.writeUInt32LE(parseInt(timestampHigh, 2), 4);
|
||||
|
||||
packetHeader.writeBigUInt64LE(BigInt(timestamp));
|
||||
packetHeader.writeUint8(versionHigh, 8);
|
||||
packetHeader.writeUint8(versionLow, 9);
|
||||
packetHeader.writeUint8(frameId, 10);
|
||||
|
||||
Reference in New Issue
Block a user