Add _.withDefault combinator
@joshuacc is already working on this.
Since Jul 31, 2014.
Assessment
This issue has not been assessed yet.
Description
The _.withDefault function would accept a function as its argument, and returns a new function that transparently replaces null/undefined return values with a default value.
Example:
function getArrLength (arr) {
if (_.isArray(arr)) return arr.length;
}
getArrLengthOrZero = _.withDefault(getArrLength, 0);
getArrLengthOrZero({});
// => 0
May need a better name for the function, though.
- Dominant language
- JavaScript
- Stars
- 622
- Forks
- 114
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from documentcloud/underscore-contrib
-
Boolean helper Open
Difficulty 3/5 1-2 days Newbie friendliness 38/100
documentcloud/underscore-contrib#254 · 2 comments ·
-
breaking change bug
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
documentcloud/underscore-contrib#252 · 7 comments ·
-
after modules enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
after modules question
Difficulty 5/5 Over a week Newbie friendliness 25/100
documentcloud/underscore-contrib#234 · 1 comment ·
-
after modules docs enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
All issues in documentcloud/underscore-contrib
Similar issues
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
githubnext/gh-aw-workshop#3692 ·
-
agent/guide documentation hive/hosted-available-lke648397-260827-5n31
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
Add: BuyPass TV Openchannels:add check:passed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
S: triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·