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
|
attrNames
|
||||||
elemAt
|
elemAt
|
||||||
filter
|
filter
|
||||||
|
getAttr
|
||||||
hasAttr
|
hasAttr
|
||||||
isAttrs
|
isAttrs
|
||||||
length
|
length
|
||||||
|
|
@ -30,6 +31,11 @@ in rec {
|
||||||
|
|
||||||
hasAttrs = list: xs: all (x: hasAttr x xs) list;
|
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.
|
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`.
|
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