linkstate icon indicating copy to clipboard operation
linkstate copied to clipboard

Add support for array indices in key path

Open hpneo opened this issue 5 years ago • 4 comments

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 avatar Jun 21 '19 03:06 hpneo

Hi @developit what do you think about this PR?

hpneo avatar Jun 29 '20 19:06 hpneo

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.

developit avatar Nov 11 '20 15:11 developit

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

hpneo avatar Nov 11 '20 18:11 hpneo

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

developit avatar Dec 02 '20 03:12 developit