keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
857 stars 133 forks source link

Array containing arrays are not getting parsed #235

Closed Varisck closed 1 year ago

Varisck commented 1 year ago

Hi, I'm having trouble parsing array containing other arrays. The structure of the data i want to parse looks like this:

const someData = new Parser()
    .endianness('little')
    .array('array1', { length: 4, type: "floatle" })
    .array('array2', { length: 4, type: "uint8" })
    .array('array3', { length: 4, type: "uint8" })
    .uint8('someOtherData')
    ....

const allDataParser = new Parser()
    .endianness('little')
    .array('someDataArray', { length: 22, type: someData })    

what i end up getting if i console.log the result of parsing is something looking like this:

{
  [
     {
      array1: [Array],
      array2: [Array],
      array3: [Array],
      someOtherData: 0,
      ....
     } ...
  ]
}

Trying printing the array1 in the structure yields undefined. I have no problem when parsing array of data on their own with other binary structure, and printing them just fine on the console, the problem seem to arise when i need to parse array containing data including other arrays. I'm not sure if I'm doing something wrong. I hope you can help me with the problem! Tanks.

keichi commented 1 year ago

Please try console.dir(obj, {depth: null}) https://stackoverflow.com/questions/10729276/how-can-i-get-the-full-object-in-node-jss-console-log-rather-than-object

Varisck commented 1 year ago

Thank you so much for the quick response and the help.