Skip to content

bytearray is undefined #5

@MattShawPhoto

Description

@MattShawPhoto

Expected Behavior

VMF.readData() should return message JSON for current instance of VMF

Current Behavior

An undefined exception is thrown: undefined is not an object (evaluating 'bytearray[readByte].toString')

Possible Solution

Ensure that VMF is reading its own binary member variable

Steps to Reproduce

  1. Create a message using a message object myMessageObject
  2. Set message on current VMF instance using .setMessage(myMessage)
  3. Write message binary on current instance using .writeMessageToBinary(myMessageObject)
  4. Attempt to read back binary as json using message type `.readMessage(myMessageObject)
  5. Observe error message in console at readData() vmf-parser.js:198

Context (Environment)

Per #3, it would be useful to have some additional exemplars of message objects. These seem straight forward but it would be useful to verify the correct json->binary conversion by converting back to JSON. It is when calling .readMessage(myMessageObject) to perform this verification that the error occurs.

Detailed Description

The fix is simple, the error does not occur in /dev/test.html because there is already an object called bytearray defined. The 'readData()' method in dist/vmf-parser.js needs to read its own .binary property which is already a bytearray

Possible Implementation

function readData(){
	var octet = selfBinary[readByte].toString(2)
    ...

At line 253:

    var selfBinary = this.binary;
	var message = read(messagetype.items);
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions