Skip to content

Add support for array indices in key path #23

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hpneo
Copy link

@hpneo hpneo commented Jun 21, 2019

This PR adds support to generate an array when indices are used as part of the key path.

For example: 'nested.state.0.key' creates this state: {nested: {state: [{key: 'newValue'}]}}.

Old gzip size: 311B
New gzip size: 337B (+26B)

@hpneo
Copy link
Author

hpneo commented Jun 29, 2020

Hi @developit what do you think about this PR?

@developit
Copy link
Owner

Hiya! Sorry for the delay here - I'm actually not sure about this one, since numeric properties are supported on objects it feels a little unsafe to infer arrays.

@hpneo
Copy link
Author

hpneo commented Nov 11, 2020

Got it. How about nested.state.0.key for numeric properties and nested.state.[0].key for arrays?

@developit
Copy link
Owner

Arrays are just objects with numeric properties though - you can already use nested.state.0.key to access array indices.

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

Successfully merging this pull request may close these issues.

2 participants