Latest packet handling, parsing, enums, generators, etc..

This commit is contained in:
Casper Warden
2017-11-24 17:45:34 +00:00
parent ec300e33ac
commit 261f28698a
496 changed files with 30448 additions and 57 deletions

View File

@@ -1,4 +1,5 @@
import * as validator from 'validator';
const uuid = require('uuid');
export class UUID
{
@@ -9,11 +10,18 @@ export class UUID
return new UUID();
}
constructor(val?: string)
constructor(buf?: Buffer | string, pos?: number)
{
if (val !== undefined)
if (buf !== undefined)
{
this.setUUID(val);
if (typeof buf === 'string')
{
this.setUUID(buf);
}
else if (pos !== undefined)
{
this.mUUID = uuid.unparse(buf, pos);
}
}
}
@@ -30,5 +38,10 @@ export class UUID
public toString = (): string =>
{
return this.mUUID;
};
writeToBuffer(buf: Buffer, pos: number)
{
uuid.parse(this.mUUID, buf, pos);
}
}