1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# @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);
```
|