Skip to content
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

Support for Map #302

Open
nlepage opened this issue Jun 5, 2018 · 2 comments
Open

Support for Map #302

nlepage opened this issue Jun 5, 2018 · 2 comments
Milestone

Comments

@nlepage
Copy link
Member

nlepage commented Jun 5, 2018

Description

Add support for JavaScript Map

Access to map keys via prop notation and bracket notation

const obj = { nested: { map: new Map() } }
const newObj = set(obj, 'nested.map.foo', 'bar')
get(newObj, 'nested.map["foo"]') // bar

Iterate over map values

const obj = { nested: { map: new Map([['foo', { val: 'bar' }], ['aze', { val: 'rty' }]]) } }
get(obj, 'nested.map[:].val') // ['bar', 'rty']

In addition it would be nice to support more literals in bracket notation, since map keys might be of any type !

@nlepage nlepage added this to the 2.0 milestone Jun 5, 2018
@EmrysMyrddin
Copy link
Contributor

How do you allow the user to put a key that is not a string or number ?

@nlepage
Copy link
Member Author

nlepage commented Jun 5, 2018

For now I have only these examples in mind:

get(obj, 'nested.map[true].val') // boolean
get(obj, 'nested.map[6.66].val') // floating number
get(obj, 'nested.map[null].val') // null

but if we allow path to be an array, we might accept any value

@nlepage nlepage modified the milestones: 2.0, Future Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants