question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`get` does not deep pick. Syntactically pleasing workaround?

See original GitHub issue

Allow me to speak in code:

var obj = {
    family: 'Fosters',
    person : {
        name : 'Hank',
        data : {
            id : 2,
            checked : false
        }
    }
};

var amend = {
    person : {
        data : {
            checked : true
        }
    }
};

var fam = Lazy(obj).assign(amend);

fam.get('family');
// 'Fosters'

fam.get('family.person.data.checked');
// undefined
// EXPECTED: true

Can I do this in a syntactically pleasant way?

Perhaps get should be extended so we can do something like: fam.get(['family', 'person', 'data', 'checked'])

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dtaocommented, Feb 7, 2018

I’m on the fence on this one. On the one hand, I’m not sure deep-picking really falls under the purview of this library. Lazy.js is about dealing with sequences; I never envisioned it as a do-everything utility belt. On the other hand, I have historically compared it directly to Underscore and Lodash, which describe themselves as utility libraries. So maybe it’s only fair to expect this.

I’ll have a think on it.

0reactions
Nepoxxcommented, Jun 16, 2016

@nicemaker That’s be nice considering that is how Lodash does it (so newcomers (like me!) would feel right at home), however I second @Redsandro that an array would be faster than parsing/splitting a string.

I was under the impression that the following would work, but it doesn’t and I’m not sure why:

fam.pick('family').pick('person').pick('data').pick('checked')
Read more comments on GitHub >

github_iconTop Results From Across the Web

rust-rfcs/0243-trait-based-exception-handling.md at master · nox/rust ...
This solution is simple, well-behaved, and easy to understand, ... operator itself is suggestive, syntactically lightweight enough to not be bothersome, ...
Read more >
rhetorical strategies: any device used to analyze the interplay
Anticipating and addressing counter-arguments: When making the argument, the author, aware of what points his or her opponents will likely take exception to, ......
Read more >
Rhetorical Devices Quiz Flashcards - Quizlet
Study with Quizlet and memorize flashcards containing terms like Alliteration, Antithesis, Climax and more.
Read more >
Regional Multi-scale Approach for Visually Pleasing Explanations of ...
Thus, this paper proposes a region-based approach that estimates feature importance in terms of appropriately segmented regions. By fusing the saliency maps ...
Read more >
Thematic Proto-Roles and Argument Selection - JSTOR
As a novel attack on the perennially vexing questions of the theoretical status of thematic roles and the inventory of possible roles, this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found