transformice.js
Version:
Node.js client for Transformice with full Typescript support.
116 lines (115 loc) • 3.12 kB
TypeScript
/// <reference types="node" />
/**
* @hidden
*/
export default class ByteArray {
buffer: Buffer;
writePosition: number;
readPosition: number;
/**
* Constructor.
*
* @example
* ```js
* const packet = new ByteArray();
* ```
*/
constructor(buff?: Buffer | number[]);
get length(): number;
get [Symbol.toStringTag](): string;
get bytesAvailable(): number;
/**
* Expands the buffer
*/
expand(value: number): void;
/**
* Adds data to the buffer.
*/
write(data: Buffer | string | SharedArrayBuffer | ByteArray): this;
/**
* Clears the contents of the bytearray and resets the length and positions properties to 0.
*/
clear(): void;
/**
* Reads a Boolean value from the byte stream.
*/
readBoolean(): boolean;
/**
* Reads a signed byte from the byte stream.
*/
readByte(): number;
/**
* Reads a signed 32-bit integer from the byte stream.
*/
readInt(): number;
/**
* Reads a signed 16-bit integer from the byte stream.
*/
readShort(): number;
/**
* Reads an unsigned byte from the byte stream.
*/
readUnsignedByte(): number;
/**
* Reads an unsigned 32-bit integer from the byte stream.
*/
readUnsignedInt(): number;
/**
* Reads an unsigned 16-bit integer from the byte stream.
*/
readUnsignedShort(): number;
/**
* Reads a UTF-8 string from the byte stream.
*/
readUTF(): string;
toJSON(): number[];
/**
* Converts the byte array to a string.
*/
toString(): string;
/**
* Writes a Boolean value.
*/
writeBoolean(value: boolean): this;
/**
* Writes a byte to the byte stream.
*/
writeByte(value: number): this;
/**
* Writes a sequence of length bytes from the specified byte array, bytes, starting offset bytes into the byte stream.
*/
writeBytes(bytes: ByteArray, offset?: number, length?: number): this;
/**
* Writes a 32-bit signed integer to the byte stream.
*/
writeInt(value: number): this;
/**
* Writes a 16-bit integer to the byte stream.
*/
writeShort(value: number): this;
/**
* Writes a unsigned byte to the byte stream.
*/
writeUnsignedByte(value: number): this;
/**
* Writes a 32-bit unsigned integer to the byte stream.
*/
writeUnsignedInt(value: number): this;
/**
* Writes a 16-bit unsigned integer to the byte stream.
*/
writeUnsignedShort(value: number): this;
/**
* Writes a UTF-8 string to the byte stream.
*/
writeUTF(value: string): this;
XXTEA(v: number[], n: number, k: number[]): number[];
/**
* Cipher the packet with the XXTEA algorithm.
*/
blockCipher(keys: number[]): ByteArray;
/**
* Cipher the packet with the XOR algorithm.
*/
xorCipher(keys: number[], fingerprint: number): ByteArray;
}