0.0.13 • Published 6 months ago

@themas3212/tasd v0.0.13

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@themas3212/tasd

Javascript/Typescript library for parsing TASD files https://github.com/bigbass1997/TASD-Spec

This library is designed to work in both broswers and nodejs

This Library is still in flux much like the spec it is for

Anything could change between versions until a stable 1.0.0 is released

Usage

static TASD.parseFile(buffer: Uint8Array) Try to parses a file from a Uint8Array

TASD.pprint() Print a description of the contents of the file

TASD.toBuffer() Convert a file back into a Uint8Array

TASD.compactInputs() Attempt to compact Input Data into a single chunk for each port

const PACKET_TYPES and packetName(key: number) Provides mapping between numerical packet types and names

Some additional utility functions are also provided for working with tasd files writeUint8(uint: number, buffer: Uint8Array, index: number) writeUint16(uint: number, buffer: Uint8Array, index: number) writeUint24(uint: number, buffer: Uint8Array, index: number) writeUint32(uint: number, buffer: Uint8Array, index: number) writeUintN(uint: number, buffer: Uint8Array, index: number, size: number) Write a Unsigned Int of a given size into a Uint8Array at a given offset

readUint8(buffer: Uint8Array, index: number) readUint16(buffer: Uint8Array, index: number) readUint24(buffer: Uint8Array, index: number) readUint32(buffer: Uint8Array, index: number) readUintN(buffer: Uint8Array, index: number, n: number) Read a Unsigned Int of a given size from a Uint8Array at a given offset

minUint(uint: number) Calculate the minimum size needed to store a value in a Unsigned Int

concatUint8Array(arrays: Uint8Array[]) Concatenates an array of Uint8Arrays into a single Uint8Array

Example

Simple code to read a tasd file in nodejs and print information about it

import { TASD } from '@themas3212/tasd';
import { readFileSync } from 'node:fs';
const buffer = readFileSync('./inputfile.tasd');
const file = TASD.parseFile(buffer);
file.pprint();

Simple code to read tasd file, compact the inputs and write it back out to a new file

import { TASD } from '@themas3212/tasd';
import { readFileSync, writeFileSync } from 'node:fs';
const buffer = readFileSync('./inputfile.tasd');
const file = TASD.parseFile(buffer);
file.compactInputs();
const buffer2 = file.toBuffer();
writeFileSync('./compact.tasd', buffer2);
0.0.13

6 months ago

0.0.12

7 months ago

0.0.11

7 months ago

0.0.10

7 months ago

0.0.8

8 months ago

0.0.7

8 months ago

0.0.6

8 months ago

0.0.5

8 months ago

0.0.4

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

8 months ago