mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-09-10 08:39:39 +00:00
replace NodeJS buffer with Uint8Array
This commit is contained in:
@@ -6,10 +6,15 @@ function decodeInfoTrackerChunk(infoTrackerChunk: InfoTrackerChunk) {
|
||||
if (infoTrackerChunk.has_subchunks && infoTrackerChunk.chunk_data && infoTrackerChunk.data_len) {
|
||||
let offset = 0;
|
||||
while (offset < infoTrackerChunk.data_len) {
|
||||
const chunkId = infoTrackerChunk.chunk_data.readUInt16LE(offset);
|
||||
const view = new DataView(
|
||||
infoTrackerChunk.chunk_data.buffer,
|
||||
infoTrackerChunk.chunk_data.byteOffset,
|
||||
infoTrackerChunk.chunk_data.byteLength
|
||||
);
|
||||
const chunkId = view.getUint16(offset, true);
|
||||
switch (chunkId) {
|
||||
case 0x0000:
|
||||
infoTrackerChunk.tracker_name = Decoders.InfoTrackerNameChunk(infoTrackerChunk.chunk_data.subarray(offset));
|
||||
infoTrackerChunk.tracker_name = Decoders.InfoTrackerNameChunk(infoTrackerChunk.chunk_data.slice(offset));
|
||||
offset += Constants.CHUNK_HEADER_SIZE;
|
||||
if (infoTrackerChunk.tracker_name?.data_len) {
|
||||
offset += infoTrackerChunk?.tracker_name?.data_len;
|
||||
@@ -23,4 +28,4 @@ function decodeInfoTrackerChunk(infoTrackerChunk: InfoTrackerChunk) {
|
||||
}
|
||||
}
|
||||
|
||||
export default (buffer: Buffer): InfoTrackerChunk => Decoders.Chunk(buffer, decodeInfoTrackerChunk);
|
||||
export default (buffer: Uint8Array): InfoTrackerChunk => Decoders.Chunk(buffer, decodeInfoTrackerChunk);
|
||||
|
||||
Reference in New Issue
Block a user