Possibility to get undefined values in objects using wildcard path
Hey,
Here is an example:
import * as dot from 'dot-wild-tiny'
const data = {
pets: [
{},
{ name: 'Rex' },
'Sam',
3,
null
]
}
dot.forEach(data, 'pets.*.name', (value, _, __, path) => {
console.log(`${path} - ${value}`)
})
This will return pets.1.name - Rex. However, there is another object, string, number and null in this path which doesn't have name property and I can't get it as undefined. I would like the result to be:
pets.0.name - undefined
pets.1.name - Rex
pets.2.name - undefined
pets.3.name - undefined
pets.4.name - undefined
Same goes for map function, it would be great to have the same result.
Is it somehow possible to achieve? I'm using dot-wild-tiny, but opened issue here as it's more feature rich.
Hi @VladShcherbin, Thank you for Issues. And sorry late response :sob:
I am busy recently and I can not secure enough time for work. Therefore, it may take some time to respond to the problem...
If you can fix it, it will be a great help if you send me a PR :smiley:
I'm in agreement to fix this problem :+1:
@tsuyoshiwada I kinda tried to fix it today but unfortunately this deep object enumeration operations are a bit hard for me 😢 This is actually why I decided to use external package instead of my own implementation.
Since you are busy now, I'll add skip to nested tests for now and wait for this feature to be added. Will be happy to test any alpha/beta version when you'll have time ❤️
@VladShcherbin Thanks ... :sob: !!!! We are sorry for the inconvenience, but please wait for the fix version :bow: