mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 09:04:13 +02:00
fix some typings
This commit is contained in:
parent
48b376fa2e
commit
ba7ce734e3
7 changed files with 146 additions and 95 deletions
|
|
@ -1,11 +1,12 @@
|
|||
import {Parser} from './Parser';
|
||||
import {Packet} from "../../Data/Packet";
|
||||
|
||||
export function make(name: string, definition: string): Parser {
|
||||
const parts = definition.substr(0, definition.length - 1).split('}');//remove leading } to prevent empty part
|
||||
const items = parts.map(function (part) {
|
||||
return part.split('{');
|
||||
});
|
||||
return function (stream) {
|
||||
return function (stream):Packet {
|
||||
let result = {
|
||||
'packetType': name
|
||||
};
|
||||
|
|
@ -19,7 +20,7 @@ export function make(name: string, definition: string): Parser {
|
|||
} catch (e) {
|
||||
throw new Error('Failed reading pattern ' + definition + '. ' + e);
|
||||
}
|
||||
return result;
|
||||
return <Packet>result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ export function UserMessage(stream: BitStream): UserMessagePacket { // 23: user
|
|||
result = {
|
||||
packetType: 'unknownUserMessage',
|
||||
type: type
|
||||
}
|
||||
};
|
||||
}
|
||||
stream.index = pos + length;
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue