-
Notifications
You must be signed in to change notification settings - Fork 6
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
Any possibility for .map() or .forEach()? #2
Comments
Hi @fidian, Thanks for Issues. As you mentioned, |
Hi @fidian. I'm sorry I'm late. Please check when you have time 🙏 |
Unfortunately, the key is useless to me. It doesn't give me the path into the object and it doesn't give me the parent object as well. Your examples provide accurate values, but the key is just a string. I don't know what object contains that string and I can't modify that object directly. Consider an Array example:
Now let us use your
Having the key supplied does not appear to have any purpose. If you were to pass the parent object along or the full key, that would get us somewhere.
The |
@fidian Thanks for confirmation and reply. What do you think of the following ideas? dot.forEach(postData, 'data.posts.*.id', (value, key, path, data) => {
console.log(key); // => 'id'
console.log(path); // => 'data.posts.0.id'
}); We think that convenience will be improved by giving the full path that can access the most recent key and object. |
That looks good, especially if this is true:
|
@fidian It is reasonable to pass the original array to the variable I would like to implement it with the following contents if possible. dot.forEach(postData, 'data.posts.0.id', (value, key, path, data) => {
console.log(path); // => 'data.posts.0.id'
console.log(key); // => 'id'
console.log(value === postData.data.posts[0].id); // => true
console.log(dot.get(postData, path) === value); // => true
console.log(data); // => postData...
}); Thanks. |
That implementation would give me everything I need, so it certainly meets what I want. Also, I like maintaining an interface similar to |
Hi @fidian, Changed the specification of |
Why is the fourth parameter the same as the object going in? I hope I wasn't unclear earlier when I was trying to describe that I would really need access to the object that contains the value.
That would give me the object containing the Also, the documentation is a bit weird. I would expect the docs to say the following.
|
I am not good at English and may be misinterpreting.
I think that dot.forEach(postData, 'data.posts.*.id', (value, key, path, data) => {
assert.deepStrictEqual(postData, data);
}); The contents you want to realize can be realized with the following code. dot.forEach(postData, 'data.posts.*', (value, key, path, data) => {
console.log(value === postData.data.posts[0] || value === postData.data.posts[1]); // true
}); |
I'll try to word it a few different ways and we'll see what we come to. Topic 1:
|
Come to think about it, the
|
Hi @fidian, As you said, the following code may be more intuitive when simulating dot.forEach(data, pattern, (value, key, parentObject, fullPath, topLevelData) => {
// ...
}); I will implement it. Would you please check the function before it releases next time if possible? |
Would I check the feature? Certainly. I had missed your discussion point 13 days ago and thought it provided what I had expected, so I am sorry that happened. |
Hi @fidian, Thank you for your reply. I'm planning to complete the development within this week. I'm sorry, please wait for a while 🙏 |
Waiting is not a problem. I appreciate that you're looking into things.
…--
Tyler Akins
On Mon, Apr 24, 2017 at 10:36 AM, tsuyoshi wada ***@***.***> wrote:
Hi @fidian <https://github.com/fidian>, Thank you for your reply.
I'm planning to complete the development within this week.
I will inform you as soon as I can test it.
I'm sorry, please wait for a while 🙏
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAaJPCKRBSw8hZibJOlKD2RqRwX-_4glks5rzMFhgaJpZM4M2NAW>
.
|
Thank you for waiting. I changed the argument of the callback. The following is an example of setting {
"dependencies": {
"dot-wild": "tsuyoshiwada/dot-wild#develop"
}
} Please refer here for the document. |
Looks like a winner. I've just put it into my code and it's working splendidly. Thanks! |
Thank you for confirmation 👍 !! |
I really appreciate the effort you went though and the willingness you've shown to help me out even when I was giving you mixed messages. Thank you very much! |
I just published it to Thank you too ! |
I am parsing some search results for issues and I get back a structure like this:
The object content is the same content but are different objects. My code combines them so they point to the same object instance in memory. What I would love is a way to have code that does something like this:
Another possible solution, though less useful for my particular case
Currently I have a list of several wildcards and I'm splitting on ".", taking off the last chunk and using the rest.
As you can see, the above example would be a couple lines shorter with
.forEach()
and greatly simplified with support for.map
.The text was updated successfully, but these errors were encountered: