Skip to content

Access prior parsed values in Array formatter #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dsshap opened this issue Mar 10, 2016 · 2 comments
Closed

Access prior parsed values in Array formatter #30

dsshap opened this issue Mar 10, 2016 · 2 comments

Comments

@dsshap
Copy link

dsshap commented Mar 10, 2016

I have this example:

var payload = Parser.start()
        .uint8('data_type')
        .uint8('data_length')
        .array('data', {
          type: 'uint8',
          length: 'data_length',
          formatter: function(array){
            // ACCESS 'data_type' HERE!!
            return array
          }
        })

I want to be able to access data_type inside formatter of array.

I inspected this, but it wasn't clear how to get to this value.
The scope is available in `length'.

Is this possible? If yes, how?

@dsshap dsshap changed the title Access prior parsed values in formatter Access prior parsed values in Array formatter Mar 10, 2016
@p0358
Copy link

p0358 commented Dec 12, 2019

In case it helps someone coming here from a search, look in #75 comments

@keichi
Copy link
Owner

keichi commented Jun 10, 2021

Please try using $parent and $root introduced in #166.

@keichi keichi closed this as completed Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants