organize models and new modules

This commit is contained in:
2023-09-16 14:27:05 -05:00
parent 489d32ae78
commit 64a3709cac
29 changed files with 240 additions and 120 deletions
+4 -8
View File
@@ -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);