Parser

@perion/net. Parser

Parses binary packet Buffers in little endian

Constructor

new Parser(data)

Source:
Parameters:
Name Type Description
data Buffer

The input data Buffer

Methods

(static) from(data) → {Parser}

Source:

Static constructor

Parameters:
Name Type Description
data Buffer

The input data Buffer

Returns:
Type
Parser

ascii(length) → {Parser}

Source:

Reads an ASCII string

Parameters:
Name Type Description
length number

Length of the string

Returns:

Returns a reference to the current Parser

Type
Parser

bool() → {Parser}

Source:

Reads a boolean

Returns:

Returns a reference to the current Parser

Type
Parser

byte() → {Parser}

Source:

Reads a byte

Returns:

Returns a reference to the current Parser

Type
Parser

char() → {Parser}

Source:

Reads a character

Returns:

Returns a reference to the current Parser

Type
Parser

collect(fieldNames) → {Map.<string, any>}

Source:

Collects the parsed values and maps them to the input array strings Will clear the parsed values

Parameters:
Name Type Description
fieldNames Array.<string>

Names mapped to values

Returns:

The object with {name:value}

Type
Map.<string, any>

double() → {Parser}

Source:

Reads a double

Returns:

Returns a reference to the current Parser

Type
Parser

get(options) → {any}

Source:

Gets the last parsed value, removes it from the parsed list. Set the option flag removeParsed=false to override

Parameters:
Name Type Description
options Object

{removeParsed}

Returns:

Any piece of data

Type
any

int() → {Parser}

Source:

Reads an integer

Returns:

Returns a reference to the current Parser

Type
Parser

long() → {Parser}

Source:

Reads a long

Returns:

Returns a reference to the current Parser

Type
Parser

mapleascii() → {Parser}

Source:

Reads a MapleStory ASCII string

Returns:

Returns a reference to the current Parser

Type
Parser

nullascii() → {Parser}

Source:

Reads a null terminated ASCII string

Returns:

Returns a reference to the current Parser

Type
Parser

pos() → {Parser}

Source:

Reads a position (x, y)

Returns:

Returns a reference to the current Parser

Type
Parser

read(length) → {Parser}

Source:

Reads a specified length

Parameters:
Name Type Description
length number
Returns:

Returns a reference to the current Parser

Type
Parser

seek(offset) → {Parser}

Source:

Moves the cursor to a specified byte offset

Parameters:
Name Type Description
offset number
Returns:

Returns a reference to the current Parser

Type
Parser

short() → {Parser}

Source:

Reads a short

Returns:

Returns a reference to the current Parser

Type
Parser

skip(length) → {Parser}

Source:

Skips the cursor a specified length

Parameters:
Name Type Description
length number
Returns:

Returns a reference to the current Parser

Type
Parser

ubyte() → {Parser}

Source:

Reads an unsigned byte

Returns:

Returns a reference to the current Parser

Type
Parser

uint() → {Parser}

Source:

Reads an unsigned integer

Returns:

Returns a reference to the current Parser

Type
Parser

ulong() → {Parser}

Source:

Reads an unsigned long

Returns:

Returns a reference to the current Parser

Type
Parser

ushort() → {Parser}

Source:

Reads an unsigned short

Returns:

Returns a reference to the current Parser

Type
Parser