Int32

Int32

Four bytes signed.

Constructor

new Int32()

Source:

Equivalent to using Buffer's [write|read]Int32LE.

Extends

Methods

compiledDecoder(target_var, tmp_var_alloc) → {String}

Source:
Overrides:

Generate code that decodes the local buffer variable at position. Save the decoded value to target_var variable. Refer to Compiler.js for usable local variables.

Parameters:
Name Type Description
target_var String

The variable name to save to.

tmp_var_alloc function

A function that allocates a unique temporary variable. Returns its name.

Returns:

JavaScript code

Type
String

compiledEncoder(source_var, tmp_var_alloc) → {String}

Source:
Overrides:

Generate code that encodes the value in variable of name source_var. The code is pasted with other generated code in a single function. Refer to Compiler.js for usable local variables.

Parameters:
Name Type Description
source_var String

The variable name to read from.

tmp_var_alloc function

A function that allocates a unique temporary variable. Returns its name.

Returns:

JavaScript code

Type
String

decode(buffer, offsetopt)

Source:
Overrides:

Decode an object from a binary representation.

Parameters:
Name Type Attributes Description
buffer Buffer

The buffer to read from.

offset Number <optional>

The offset in buffer to start reading.

encode(object, bufferopt, offsetopt) → {Buffer}

Source:
Overrides:

Encode an object into a binary representation.

Parameters:
Name Type Attributes Description
object *

The object/value to be encoded.

buffer Buffer <optional>

The buffer to write to. If the buffer is too small an exception will be thrown.

offset Number <optional>

The offset in buffer to write at.

Returns:

The buffer that contains the encoded data. If a new buffer is allocated then the data was written from the begining.

Type
Buffer