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

exists with wildcards #18

Open
pocesar opened this issue Jul 21, 2014 · 2 comments
Open

exists with wildcards #18

pocesar opened this issue Jul 21, 2014 · 2 comments
Labels
Milestone

Comments

@pocesar
Copy link
Collaborator

pocesar commented Jul 21, 2014

So, I was checking for a cache entry, and the cache keys are completly random, but I knew the id of the cache item, basically it was like this:

cache = {
 activities: {
   'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad': [
    {'id': 1 /*...*/},
    {'id': 9 /*...*/},
    /* ...etc */
  ]
 }
};

I could just iterate through all activities, and check each one of the ids, but then I realized that I could use an 'exists' function that could 'ignore' parts of the path (using a * and check for the existance of the deep path).
So, for that cache I'd do objectPath.exists(cache, 'activities.*.*.id', 1) the last value is a comparision. If omitted, it just check of the path !== undefined. It's a nice addition to the library, what do you think @mariocasciaro ?

@mariocasciaro
Copy link
Owner

Yes, the idea looks great. I'm just thinking if the API should be called something else. find or search perhaps.

@pocesar
Copy link
Collaborator Author

pocesar commented Jul 21, 2014

ok, i will fix something ;)

PS: harder than it looks lol

@pocesar pocesar modified the milestone: 1.0.0 May 12, 2015
@pocesar pocesar added the plugin label May 12, 2015
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