diff --git a/nib/std/attrs.nix b/nib/std/attrs.nix index 984c81f..52ac329 100644 --- a/nib/std/attrs.nix +++ b/nib/std/attrs.nix @@ -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`.