From bdf1756baa223c89587abaa239001222263b665f Mon Sep 17 00:00:00 2001 From: TheMas3212 Date: Thu, 21 Sep 2023 11:21:30 +1000 Subject: rename README --- README | 64 ------------------------------------------------------------ README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 3 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 2a2272e..0000000 --- a/README +++ /dev/null @@ -1,64 +0,0 @@ -# @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 - -# 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); -``` diff --git a/README.md b/README.md new file mode 100644 index 0000000..2a2272e --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# @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 + +# 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); +``` diff --git a/package.json b/package.json index 8d96b92..99c59d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@themas3212/tasd", - "version": "0.0.1", + "version": "0.0.2", "description": "library for working with TASD files", "private": false, "main": "dist/lib.js", -- cgit v1.2.3