refactor(read-tree): Idiomatic 'attrsToList' instead of weird hack
This commit is contained in:
parent
f1655c5cbb
commit
48ed487bdd
1 changed files with 4 additions and 11 deletions
|
@ -3,7 +3,6 @@ path: { pkgs, ... } @ args:
|
||||||
let
|
let
|
||||||
inherit (builtins)
|
inherit (builtins)
|
||||||
attrNames
|
attrNames
|
||||||
attrValues
|
|
||||||
filter
|
filter
|
||||||
head
|
head
|
||||||
isString
|
isString
|
||||||
|
@ -11,19 +10,13 @@ let
|
||||||
map
|
map
|
||||||
match
|
match
|
||||||
readDir
|
readDir
|
||||||
tail
|
|
||||||
toPath
|
toPath
|
||||||
toString;
|
toString;
|
||||||
|
|
||||||
zipAttrs = names: values:
|
attrsToList = attrs: map (name: {
|
||||||
if (names == []) || (values == [])
|
inherit name;
|
||||||
then []
|
value = attrs."${name}";
|
||||||
else [{
|
}) (attrNames attrs);
|
||||||
name = head names;
|
|
||||||
value = head values;
|
|
||||||
}] ++ zipAttrs (tail names) (tail values);
|
|
||||||
|
|
||||||
attrsToList = attrs: zipAttrs (attrNames attrs) (attrValues attrs);
|
|
||||||
|
|
||||||
isFile = s: s == "regular";
|
isFile = s: s == "regular";
|
||||||
isDir = s: s == "directory";
|
isDir = s: s == "directory";
|
||||||
|
|
Loading…
Reference in a new issue