[wp-trac] [WordPress Trac] #41111: WP-API JS Client: Add a helper to get model or collection by route
WordPress Trac
noreply at wordpress.org
Fri Aug 18 14:49:47 UTC 2017
#41111: WP-API JS Client: Add a helper to get model or collection by route
-------------------------------------------------+-------------------------
Reporter: adamsilverstein | Owner:
Type: enhancement | adamsilverstein
Priority: normal | Status: assigned
Component: REST API | Milestone: 4.9
Severity: normal | Version: 4.7
Keywords: good-first-bug has-patch has-unit- | Resolution:
tests commit | Focuses: javascript
-------------------------------------------------+-------------------------
Changes (by adamsilverstein):
* keywords: good-first-bug has-patch has-unit-tests reporter-feedback =>
good-first-bug has-patch has-unit-tests commit
Comment:
@rcutmore - nice work here!
In [attachment:41111.2.diff] I moved the code up a bit into the utility
section, ultimately we will probably split this file back up so wanted to
group the functions with the other helpers. Also, I clarified the return
value would be undefined if not matching item is found and I switched out
`_.first( _.filter(...` for `_.find(...` which should also return the
first item matching the predicate. This makes the code a little more
legible and all the unit tests continued to pass.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41111#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list