mirror of
https://github.com/jwetzell/psn-js.git
synced 2026-09-10 16:49:46 +00:00
organize models and new modules
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { Decoders } from '..';
|
||||
import { Constants } from '../../constants';
|
||||
import chunk, { Chunk } from '../chunk';
|
||||
import infoTrackerNameChunk, { InfoTrackerNameChunk } from './info-tracker-name-chunk';
|
||||
|
||||
export interface InfoTrackerChunk extends Chunk {
|
||||
tracker_name?: InfoTrackerNameChunk;
|
||||
}
|
||||
import { InfoTrackerChunk } from '../../models/info/info-tracker-chunk';
|
||||
|
||||
function decodeInfoTrackerChunk(infoTrackerChunk: InfoTrackerChunk) {
|
||||
if (infoTrackerChunk.has_subchunks && infoTrackerChunk.chunk_data && infoTrackerChunk.data_len) {
|
||||
@@ -13,7 +9,7 @@ function decodeInfoTrackerChunk(infoTrackerChunk: InfoTrackerChunk) {
|
||||
const chunkId = infoTrackerChunk.chunk_data.readUInt16LE(offset);
|
||||
switch (chunkId) {
|
||||
case 0x0000:
|
||||
infoTrackerChunk.tracker_name = infoTrackerNameChunk(infoTrackerChunk.chunk_data.subarray(offset));
|
||||
infoTrackerChunk.tracker_name = Decoders.InfoTrackerNameChunk(infoTrackerChunk.chunk_data.subarray(offset));
|
||||
offset += Constants.CHUNK_HEADER_SIZE;
|
||||
if (infoTrackerChunk.tracker_name?.data_len) {
|
||||
offset += infoTrackerChunk?.tracker_name?.data_len;
|
||||
@@ -27,4 +23,4 @@ function decodeInfoTrackerChunk(infoTrackerChunk: InfoTrackerChunk) {
|
||||
}
|
||||
}
|
||||
|
||||
export default (buffer: Buffer): InfoTrackerChunk => chunk(buffer, decodeInfoTrackerChunk);
|
||||
export default (buffer: Buffer): InfoTrackerChunk => Decoders.Chunk(buffer, decodeInfoTrackerChunk);
|
||||
|
||||
Reference in New Issue
Block a user