add getAttrOr
This commit is contained in:
parent
fec4ecd556
commit
382ae56432
1 changed files with 6 additions and 0 deletions
|
|
@ -5,6 +5,7 @@
|
|||
attrNames
|
||||
elemAt
|
||||
filter
|
||||
getAttr
|
||||
hasAttr
|
||||
isAttrs
|
||||
length
|
||||
|
|
@ -30,6 +31,11 @@ in rec {
|
|||
|
||||
hasAttrs = list: xs: all (x: hasAttr x xs) list;
|
||||
|
||||
getAttrOr = name: xs: default:
|
||||
if hasAttr name xs
|
||||
then getAttr name xs
|
||||
else default;
|
||||
|
||||
/**
|
||||
Like `genAttrs`, but allows the name of each attribute to be specified in addition to the value.
|
||||
The applied function should return both the new name and value as a `nameValuePair`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue