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

Possibility to get undefined values in objects using wildcard path #13

Open
vladshcherbin opened this issue Feb 7, 2018 · 4 comments
Open
Labels

Comments

@vladshcherbin
Copy link

vladshcherbin commented Feb 7, 2018

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.

@wadackel
Copy link
Owner

wadackel commented Feb 8, 2018

Hi @vladshcherbin, Thank you for Issues. And sorry late response 😭

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 😃

@wadackel
Copy link
Owner

wadackel commented Feb 8, 2018

I'm in agreement to fix this problem 👍

@vladshcherbin
Copy link
Author

vladshcherbin commented Feb 8, 2018

@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 ❤️

@wadackel
Copy link
Owner

wadackel commented Feb 8, 2018

@vladshcherbin
Thanks ... 😭 !!!!
We are sorry for the inconvenience, but please wait for the fix version 🙇

@wadackel wadackel added the bug label Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants