mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-09-11 00:59:41 +00:00
align structure more with underlying chunk layout
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import { Decoders } from '..';
|
||||
import { InfoTrackerNameChunk } from '../../models/info/info-tracker-name-chunk';
|
||||
import { InfoTrackerNameChunk, InfoTrackerNameChunkData } from '../../models/info/info-tracker-name-chunk';
|
||||
|
||||
function decodeTrackerNameChunk(trackerNameChunk: InfoTrackerNameChunk) {
|
||||
if (trackerNameChunk.chunk_data !== undefined && trackerNameChunk.data_len !== undefined) {
|
||||
trackerNameChunk.tracker_name = new TextDecoder().decode(
|
||||
trackerNameChunk.chunk_data.slice(0, trackerNameChunk.data_len)
|
||||
);
|
||||
}
|
||||
}
|
||||
export default (buffer: Uint8Array): InfoTrackerNameChunk =>
|
||||
Decoders.Chunk(buffer, decodeTrackerNameChunk) as InfoTrackerNameChunk;
|
||||
export default (buffer: Uint8Array): InfoTrackerNameChunk => {
|
||||
const chunk = Decoders.Chunk(buffer);
|
||||
|
||||
const data: InfoTrackerNameChunkData = {
|
||||
trackerName: new TextDecoder().decode(chunk.chunkData.subarray(0, chunk.header.dataLen)),
|
||||
};
|
||||
|
||||
return {
|
||||
chunk,
|
||||
data,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user