Support for Map
nlepage opened this issue · comments
Nicolas Lepage commented
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 !
Valentin Cocaud commented
How do you allow the user to put a key that is not a string or number ?
Nicolas Lepage commented
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